| 80 | } |
| 81 | |
| 82 | int CManager::Initial(QString szFile) |
| 83 | { |
| 84 | bool check = false; |
| 85 | //#if defined (_DEBUG) || !defined(BUILD_SHARED_LIBS) |
| 86 | // Q_INIT_RESOURCE(translations_Plugin); |
| 87 | //#endif |
| 88 | |
| 89 | m_Translator = RabbitCommon::CTools::Instance()->InstallTranslator( |
| 90 | "Plugin", RabbitCommon::CTools::TranslationType::Library); |
| 91 | |
| 92 | m_szSettingsFile = szFile; |
| 93 | |
| 94 | CChannel::InitTranslation(); |
| 95 | |
| 96 | m_pParameterPlugin = new CParameterPlugin(); |
| 97 | if(m_pParameterPlugin) { |
| 98 | LoadSettings(m_szSettingsFile); |
| 99 | |
| 100 | // Initial database |
| 101 | auto pg = GetGlobalParameters(); |
| 102 | Q_ASSERT(pg); |
| 103 | QString szFile; |
| 104 | szFile = pg->m_Database.GetDatabaseName(); |
| 105 | bool bRet = pg->m_DatabaseLocal.OpenSQLiteDatabase(szFile, "Local_connect"); |
| 106 | if(!bRet) return -1; |
| 107 | bRet = pg->m_DatabaseRemote.OpenDatabase(&pg->m_Database, "Remote_connect"); |
| 108 | if(!bRet) return -1; |
| 109 | bRet = m_pParameterPlugin->m_WhiteList.InitDatabase(&pg->m_DatabaseLocal); |
| 110 | if(!bRet) return -1; |
| 111 | bRet = m_pParameterPlugin->m_BlackList.InitDatabase(&pg->m_DatabaseLocal); |
| 112 | if(!bRet) return -1; |
| 113 | |
| 114 | bool bReboot = true; |
| 115 | QString szSnap; |
| 116 | QString szFlatpak; |
| 117 | #if defined(Q_OS_ANDROID) |
| 118 | bReboot = false; |
| 119 | #endif |
| 120 | #if QT_VERSION > QT_VERSION_CHECK(6, 0, 0) && defined(Q_OS_WIN) |
| 121 | szSnap = qEnvironmentVariable("SNAP"); |
| 122 | szFlatpak = qEnvironmentVariable("FLATPAK_ID"); |
| 123 | #else |
| 124 | szSnap = QString::fromLocal8Bit(qgetenv("SNAP")); |
| 125 | szFlatpak = QString::fromLocal8Bit(qgetenv("FLATPAK_ID")); |
| 126 | #endif |
| 127 | if(!szSnap.isEmpty() || !szFlatpak.isEmpty()) |
| 128 | bReboot = false; |
| 129 | if(bReboot && !RabbitCommon::CTools::Instance()->HasAdministratorPrivilege() |
| 130 | && m_pParameterPlugin->GetPromptAdministratorPrivilege()) |
| 131 | { |
| 132 | int nRet = 0; |
| 133 | QString szMsg; |
| 134 | szMsg = tr("The programe is not administrator privilege.\n" |
| 135 | "Some features are limited.\n"); |
| 136 | #if defined(Q_OS_WIN) |
| 137 | szMsg += tr("Eg: Can not disable system shortcuts(eg: Ctrl+Alt+del).") + "\n"; |
| 138 | #else |
| 139 | szMsg += tr("Eg: Can not use the wake on LAN feature.") + "\n"; |
nothing calls this directly
no test coverage detected