| 1 | /* |
| 2 | * Copyright (C) 2013 Canonical Ltd. |
| 3 | * |
| 4 | * Contact: Alberto Mardegan <[email protected]> |
| 5 | * |
| 6 | * This file is part of lomiri-online-accounts-service |
| 7 | * |
| 8 | * This program is free software: you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License version 3, as published |
| 10 | * by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 15 | * PURPOSE. See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include <online-accounts-common/debug.h>cxx . . $ `<file>/online-accounts-common/debug.h`/ |
| 22 | #include <online-accounts-common/globals.h>cxx . . $ `<file>/online-accounts-common/globals.h`/ |
| 23 | #include "inactivity-timer.h"cxx . . $ `<file>/online-accounts-service/src/inactivity-timer.h`/ |
| 24 | #include "indicator-service.h"cxx . . $ `<file>/online-accounts-service/src/indicator-service.h`/ |
| 25 | #include "libaccounts-service.h"cxx . . $ `<file>/online-accounts-service/src/libaccounts-service.h`/ |
| 26 | #include "request-manager.h"cxx . . $ `<file>/online-accounts-service/src/request-manager.h`/ |
| 27 | #include "service.h"cxx . . $ `<file>/online-accounts-service/src/service.h`/ |
| 28 | #include "signonui-service.h"cxx . . $ `<file>/online-accounts-service/src/signonui-service.h`/ |
| 29 | |
| 30 | #include <LomiriOnlineAccountsDaemon/Manager>cxx . . $ `<file>/online-accounts-daemon/lib/LomiriOnlineAccountsDaemon/Manager`/ |
| 31 | #include <LomiriOnlineAccountsDaemon/dbus_constants.h>cxx . . $ `<file>/online-accounts-daemon/lib/LomiriOnlineAccountsDaemon/dbus_constants.h`/ |
| 32 | |
| 33 | #include <QCoreApplication> |
| 34 | #include <QDBusConnection> |
| 35 | #include <QDBusMetaType> |
| 36 | #include <QProcessEnvironment> |
| 37 | #include <QSettings> |
| 38 | |
| 39 | using namespace OnlineAccountsUi; |
| 40 | |
| 41 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) |
| 42 | { |
| 43 | QCoreApplicationcxx . . $ QCoreApplication# appcxx . . $ QCoreApplication#QCoreApplication(6e9b1c7df49e191d).(argc, argv); |
| 44 | |
| 45 | QSettingscxx . . $ QSettings# settingscxx . . $ QSettings#QSettings(b05324713c9ab95e).("lomiri-online-accounts-service"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 46 | |
| 47 | /* read environment variables */ |
| 48 | QProcessEnvironmentcxx . . $ QProcessEnvironment# environment = QProcessEnvironmentcxx . . $ QProcessEnvironment#::systemEnvironmentcxx . . $ QProcessEnvironment#systemEnvironment(f0e8295e01d32d01).(); |
| 49 | if (environment.containscxx . . $ QProcessEnvironment#contains(f3b39adf77d9c36c).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("OAU_LOGGING_LEVEL"))) { |
| 50 | bool isOk; |
| 51 | int value = environment.valuecxx . . $ QProcessEnvironment#value(11b1083083847b8e).( |
| 52 | QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("OAU_LOGGING_LEVEL")).toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&isOk); |
| 53 | if (isOk) |
| 54 | setLoggingLevelcxx . . $ setLoggingLevel(d4f767463ce0a6b3).(value); |
| 55 | } else { |
| 56 | setLoggingLevelcxx . . $ setLoggingLevel(d4f767463ce0a6b3).(settings.valuecxx . . $ QSettings#value(12a1b1749da49362).("LoggingLevel"cxx . . $ QString#QString(85c52e162fed56f9)., 1cxx . . $ QVariant#QVariant(d4f767463ce0a6b3).).toIntcxx . . $ QVariant#toInt(5bd9a3493f6a7a21).()); |
| 57 | } |
| 58 | |
| 59 | /* default daemonTimeout to 5 seconds */ |
| 60 | int daemonTimeout = 5; |
| 61 | |
| 62 | /* override daemonTimeout if OAU_DAEMON_TIMEOUT is set */ |
| 63 | if (environment.containscxx . . $ QProcessEnvironment#contains(f3b39adf77d9c36c).(QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("OAU_DAEMON_TIMEOUT"))) { |
| 64 | bool isOk; |
| 65 | int value = environment.valuecxx . . $ QProcessEnvironment#value(11b1083083847b8e).( |
| 66 | QLatin1Stringcxx . . $ QString#QString(4641beeb24e75d60).("OAU_DAEMON_TIMEOUT")).toIntcxx . . $ QString#toInt(d7972accae11ee1f).(&isOk); |
| 67 | if (isOk) |
| 68 | daemonTimeout = value; |
| 69 | } else { |
| 70 | daemonTimeout = settings.valuecxx . . $ QSettings#value(12a1b1749da49362).("DaemonTimeout"cxx . . $ QString#QString(85c52e162fed56f9)., 5cxx . . $ QVariant#QVariant(d4f767463ce0a6b3).).toIntcxx . . $ QVariant#toInt(5bd9a3493f6a7a21).(); |
| 71 | } |
| 72 | |
| 73 | RequestManagercxx . . $ OnlineAccountsUi/RequestManager# *requestManager = new RequestManagercxx . . $ OnlineAccountsUi/RequestManager#(); |
| 74 | |
| 75 | qDBusRegisterMetaTypecxx . . $ qDBusRegisterMetaType(2f7c408e008fec29).<SignOnUicxx . . $ SignOnUi/::RawCookiescxx . . $ SignOnUi/RawCookies#>(); |
| 76 | |
| 77 | Servicecxx . . $ OnlineAccountsUi/Service# *service = new Servicecxx . . $ OnlineAccountsUi/Service#(); |
| 78 | QDBusConnectioncxx . . $ QDBusConnection# connection = QDBusConnectioncxx . . $ QDBusConnection#::sessionBuscxx . . $ QDBusConnection#sessionBus(45d475f1888103b2).(); |
| 79 | connection.registerObjectcxx . . $ QDBusConnection#registerObject(3ca2fdce2ef96dc8).(OAU_OBJECT_PATHcxx . . $ `online-accounts-common/globals.h:26:9`!, service); |
| 80 | connection.registerServicecxx . . $ QDBusConnection#registerService(e1defb592416720d).(OAU_SERVICE_NAMEcxx . . $ `online-accounts-common/globals.h:25:9`!); |
| 81 | |
| 82 | SignOnUicxx . . $ SignOnUi/::Servicecxx . . $ SignOnUi/Service# *signonuiService = new SignOnUicxx . . $ SignOnUi/::Servicecxx . . $ SignOnUi/Service#(); |
| 83 | connection.registerObjectcxx . . $ QDBusConnection#registerObject(3ca2fdce2ef96dc8).(SIGNONUI_OBJECT_PATHcxx . . $ `online-accounts-common/globals.h:52:9`!, signonuiService, |
| 84 | QDBusConnectioncxx . . $ QFlags#QFlags(93d577a3e9528307).::ExportAllContentscxx . . $ QDBusConnection#ExportAllContents.); |
| 85 | connection.registerServicecxx . . $ QDBusConnection#registerService(e1defb592416720d).(SIGNONUI_SERVICE_NAMEcxx . . $ `online-accounts-common/globals.h:51:9`!); |
| 86 | |
| 87 | SignOnUicxx . . $ SignOnUi/::IndicatorServicecxx . . $ SignOnUi/IndicatorService# *indicatorService = |
| 88 | new SignOnUicxx . . $ SignOnUi/::IndicatorServicecxx . . $ SignOnUi/IndicatorService#(); |
| 89 | connection.registerObjectcxx . . $ QDBusConnection#registerObject(3ca2fdce2ef96dc8).(WEBCREDENTIALS_OBJECT_PATHcxx . . $ `online-accounts-service/src/indicator-service.h:30:9`!, |
| 90 | indicatorService->serviceObjectcxx . . $ SignOnUi/IndicatorService#serviceObject(2dbb680a34285c44).()); |
| 91 | connection.registerServicecxx . . $ QDBusConnection#registerService(e1defb592416720d).(WEBCREDENTIALS_BUS_NAMEcxx . . $ `online-accounts-service/src/indicator-service.h:34:9`!); |
| 92 | |
| 93 | LibaccountsServicecxx . . $ OnlineAccountsUi/LibaccountsService# *libaccountsService = new LibaccountsServicecxx . . $ OnlineAccountsUi/LibaccountsService#(); |
| 94 | connection.registerObjectcxx . . $ QDBusConnection#registerObject(3ca2fdce2ef96dc8).(LIBACCOUNTS_OBJECT_PATHcxx . . $ `online-accounts-service/src/libaccounts-service.h:30:9`!, libaccountsService, |
| 95 | QDBusConnectioncxx . . $ QFlags#QFlags(93d577a3e9528307).::ExportAllContentscxx . . $ QDBusConnection#ExportAllContents.); |
| 96 | connection.registerServicecxx . . $ QDBusConnection#registerService(e1defb592416720d).(LIBACCOUNTS_BUS_NAMEcxx . . $ `online-accounts-service/src/libaccounts-service.h:32:9`!); |
| 97 | |
| 98 | // V2 API |
| 99 | OnlineAccountsDaemoncxx . . $ OnlineAccountsDaemon/::Managercxx . . $ OnlineAccountsDaemon/Manager# *v2api = |
| 100 | new OnlineAccountsDaemoncxx . . $ OnlineAccountsDaemon/::Managercxx . . $ OnlineAccountsDaemon/Manager#(); |
| 101 | connection.registerObjectcxx . . $ QDBusConnection#registerObject(3ca2fdce2ef96dc8).(ONLINE_ACCOUNTS_MANAGER_PATHcxx . . $ `online-accounts-daemon/lib/LomiriOnlineAccountsDaemon/dbus_constants.h:27:9`!, v2api); |
| 102 | connection.registerServicecxx . . $ QDBusConnection#registerService(e1defb592416720d).(ONLINE_ACCOUNTS_MANAGER_SERVICE_NAMEcxx . . $ `online-accounts-daemon/lib/LomiriOnlineAccountsDaemon/dbus_constants.h:25:9`!); |
| 103 | connection.connectcxx . . $ QDBusConnection#connect(a950c2c6143dd21d).(QStringcxx . . $ QString#QString(ced63f7c635d850d).(), |
| 104 | QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("/org/freedesktop/DBus/Local"), |
| 105 | QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("org.freedesktop.DBus.Local"), |
| 106 | QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!("Disconnected"), |
| 107 | v2api, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(onDisconnected())); |
| 108 | |
| 109 | InactivityTimercxx . . $ OnlineAccountsUi/InactivityTimer# *inactivityTimer = 0; |
| 110 | if (daemonTimeout > 0) { |
| 111 | inactivityTimer = new InactivityTimercxx . . $ OnlineAccountsUi/InactivityTimer#(daemonTimeout * 1000); |
| 112 | inactivityTimer->watchObjectcxx . . $ OnlineAccountsUi/InactivityTimer#watchObject(749de1b6ae65bddd).(v2api); |
| 113 | inactivityTimer->watchObjectcxx . . $ OnlineAccountsUi/InactivityTimer#watchObject(749de1b6ae65bddd).(requestManager); |
| 114 | inactivityTimer->watchObjectcxx . . $ OnlineAccountsUi/InactivityTimer#watchObject(749de1b6ae65bddd).(indicatorService); |
| 115 | QObjectcxx . . $ QObject#::connectcxx . . $ QObject#connect(158df1d9a01a3410).(inactivityTimer, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(timeout()), |
| 116 | &app, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(quit())); |
| 117 | } |
| 118 | |
| 119 | int ret = app.execcxx . . $ QCoreApplication#exec(b126dc7c1de90089).(); |
| 120 | |
| 121 | connection.unregisterServicecxx . . $ QDBusConnection#unregisterService(e1defb592416720d).(ONLINE_ACCOUNTS_MANAGER_SERVICE_NAMEcxx . . $ `online-accounts-daemon/lib/LomiriOnlineAccountsDaemon/dbus_constants.h:25:9`!); |
| 122 | connection.unregisterObjectcxx . . $ QDBusConnection#unregisterObject(1667c585e463f5a5).(ONLINE_ACCOUNTS_MANAGER_PATHcxx . . $ `online-accounts-daemon/lib/LomiriOnlineAccountsDaemon/dbus_constants.h:27:9`!); |
| 123 | delete v2api; |
| 124 | |
| 125 | connection.unregisterServicecxx . . $ QDBusConnection#unregisterService(e1defb592416720d).(LIBACCOUNTS_BUS_NAMEcxx . . $ `online-accounts-service/src/libaccounts-service.h:32:9`!); |
| 126 | connection.unregisterObjectcxx . . $ QDBusConnection#unregisterObject(1667c585e463f5a5).(LIBACCOUNTS_OBJECT_PATHcxx . . $ `online-accounts-service/src/libaccounts-service.h:30:9`!); |
| 127 | delete libaccountsService; |
| 128 | |
| 129 | connection.unregisterServicecxx . . $ QDBusConnection#unregisterService(e1defb592416720d).(WEBCREDENTIALS_BUS_NAMEcxx . . $ `online-accounts-service/src/indicator-service.h:34:9`!); |
| 130 | connection.unregisterObjectcxx . . $ QDBusConnection#unregisterObject(1667c585e463f5a5).(WEBCREDENTIALS_OBJECT_PATHcxx . . $ `online-accounts-service/src/indicator-service.h:30:9`!); |
| 131 | delete indicatorService; |
| 132 | |
| 133 | connection.unregisterServicecxx . . $ QDBusConnection#unregisterService(e1defb592416720d).(SIGNONUI_SERVICE_NAMEcxx . . $ `online-accounts-common/globals.h:51:9`!); |
| 134 | connection.unregisterObjectcxx . . $ QDBusConnection#unregisterObject(1667c585e463f5a5).(SIGNONUI_OBJECT_PATHcxx . . $ `online-accounts-common/globals.h:52:9`!); |
| 135 | delete signonuiService; |
| 136 | |
| 137 | connection.unregisterServicecxx . . $ QDBusConnection#unregisterService(e1defb592416720d).(OAU_SERVICE_NAMEcxx . . $ `online-accounts-common/globals.h:25:9`!); |
| 138 | connection.unregisterObjectcxx . . $ QDBusConnection#unregisterObject(1667c585e463f5a5).(OAU_OBJECT_PATHcxx . . $ `online-accounts-common/globals.h:26:9`!); |
| 139 | delete service; |
| 140 | |
| 141 | delete requestManager; |
| 142 | |
| 143 | delete inactivityTimer; |
| 144 | |
| 145 | return ret; |
| 146 | } |
| 147 |