#include <QInputDialog>
#include <QDir>
+#ifdef Q_OS_ANDROID
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <QQmlContext>
+
+#ifdef ENTERPRISE
+#include "enterprise-tray-ui-controller.h"
+#else
+#include "tray-ui-controller.h"
+#endif
+
+#include "resdetails-ui-controller.h"
+#include "respanel-ui-controller.h"
+#include "runjob-ui-controller.h"
+#include "restore-ui-controller.h"
+#include "fd-config-ui-controller.h"
+#include "android-fd-service.h"
+#include "app-boot-ui-controller.h"
+
+int64_t AndroidFD::logLevel;
+#endif
+
/* Static variables */
char *configfile = NULL;
static MONITOR *monitor = NULL;
"\n"), 2004, BDEMO, VERSION, BDATE, HOST_OS, DISTNAME, DISTVER);
}
+void terminate_tray_monitor(int /*sig*/)
+{
+#ifdef HAVE_WIN32
+ WSACleanup(); /* TODO: check when we have to call it */
+#endif
+ exit(0);
+}
+
void refresh_tray(TrayUI *t)
{
RESMON *r;
*
*/
int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
+{
int ch;
bool test_config = false, display_cfg = false;
+
+#ifdef Q_OS_ANDROID
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QGuiApplication app(argc, argv);
+ QQmlApplicationEngine engine;
+ AndroidFD::install();
+#ifdef ENTERPRISE
+ qmlRegisterType<EnterpriseTrayUiController>("io.qt.bmob.traycontroller", 1, 0, "TrayUiController");
+ engine.rootContext()->setContextProperty("IS_ENTERPRISE", QVariant(true));
+#else
+ qmlRegisterType<TrayUiController>("io.qt.bmob.traycontroller", 1, 0, "TrayUiController");
+ engine.rootContext()->setContextProperty("IS_ENTERPRISE", QVariant(false));
+#endif // ENTERPRISE
+ qmlRegisterType<RestoreUiController>("io.qt.bmob.restorejobcontroller", 1, 0, "RestoreUiController");
+ qmlRegisterType<RunJobUiController>("io.qt.bmob.runjobcontroller", 1, 0, "RunJobUiController");
+ qmlRegisterType<ResDetailsUiController>("io.qt.bmob.resdetailscontroller", 1, 0, "ResDetailsUiController");
+ qmlRegisterType<ResPanelUiController>("io.qt.bmob.respanelcontroller", 1, 0, "ResPanelUiController");
+ qmlRegisterType<FdConfigUiController>("io.qt.bmob.fdconfigcontroller", 1, 0, "FdConfigUiController");
+ qmlRegisterType<BootUiController>("io.qt.bmob.bootuicontroller", 1, 0, "BootUiController");
+#else
+ QApplication app(argc, argv);
TrayUI tray;
+#endif
+
TSched sched;
-
+
setlocale(LC_ALL, "");
bindtextdomain("bacula", LOCALEDIR);
textdomain("bacula");
my_name_is(argc, argv, "tray-monitor");
lmgr_init_thread();
init_msg(NULL, NULL, NULL);
-#ifdef HAVE_WIN32
+#if defined(HAVE_WIN32)
working_directory = getenv("TMP");
-#endif
+#elif defined(Q_OS_ANDROID)
+ debug_level = 0;
+ AndroidFD::logLevel = debug_level;
+ working_directory = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
+ .toLatin1()
+ .constData();
+ set_trace(true);
+#else
if (working_directory == NULL) {
working_directory = "/tmp";
}
+#endif
start_watchdog();
#ifndef HAVE_WIN32
configfile = bstrdup(optarg);
break;
+#ifndef Q_OS_ANDROID
case 'W':
tray.have_systray = (atoi(optarg) != 0);
break;
+#endif
case 'T':
set_trace(true);
argc -= optind;
//argv += optind;
+#ifndef Q_OS_ANDROID
+init_signals(terminate_tray_monitor);
+#endif
+
if (argc) {
usage();
exit(1);
configfile = bstrdup(CONFIG_FILE);
}
}
- Dmsg1(50, "configfile=%s\n", configfile);
+
+#ifndef Q_OS_ANDROID
+ Dmsg1(0, "configfile=%s\n", configfile);
+#else
+ Dmsg0(0, "Opening App...\n");
+#endif
// We need to initialize the scheduler before the reload() command
scheduler = &sched;
- OSDependentInit(); /* Initialize Windows path handling */
+ OSDependentInit(); /* Initialize Windows path handling */
(void)WSA_Init(); /* Initialize Windows sockets */
+ if (init_crypto() != 0) {
+ Emsg0(M_ERROR_TERM, 0, _("Cryptography library initialization failed.\n"));
+ }
+
+#ifdef Q_OS_ANDROID
+ ConfigStorage::init(configfile);
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+ if (engine.rootObjects().isEmpty())
+ return -1;
+#else
display_cfg = reload();
if (test_config) {
exit(0);
}
+
/* If we have a systray, we always keep the application*/
if (tray.have_systray) {
app.setQuitOnLastWindowClosed(false);
tray.setupUi(&tray, monitor);
refresh_tray(&tray);
mainwidget = &tray;
+
if (display_cfg) {
new Conf();
}
+#endif
+
app.exec();
sched.stop();
stop_watchdog();