StatusType iDroid::UpgradeApplication(int appID) { if (appID <= 0) return INVALID_INPUT; try { DataByID appByID(appID); Tree<DataByID>::Node* node = _appsByIDtree.find(appByID); CMP_DATA(node, appID); Version version(node->getData()._versionCode); List<Version>::Iterator it = _versions.find(version); if (++it == _versions.end()) { return FAILURE; } it = _versions.find(version); appByID = node->getData(); DataByDowns appByDowns(appByID); StatusType status = RemoveApplication(appID); if (status != SUCCESS) return status; status = AddApplication(appID, (++it)->_versionID, appByID._downloads); if (status != SUCCESS) return status; } catch (Tree<DataByID>::TreeIsEmpty& e) { return FAILURE; } catch (Tree<DataByDowns>::TreeIsEmpty& e) { return FAILURE; } return SUCCESS; }
SettingsDialog::SettingsDialog(ApplicationList *list, TranslationHandler *translator, QWidget *parent) : QDialog(parent), mApplications(list), mTempApplications(new ApplicationList(this)), mTranslator(translator) { mUI.setupUi(this); QSettings settings; mTempApplications->Copy(list); mUI.mJobs->setText(settings.value(SETTINGS_CHECK_THREADS, 1).toString()); mUI.mForce->setCheckState(BoolToCheckState(settings.value(SETTINGS_CHECK_FORCE, false).toBool())); mUI.mShowFullPath->setCheckState(BoolToCheckState(settings.value(SETTINGS_SHOW_FULL_PATH, false).toBool())); mUI.mShowNoErrorsMessage->setCheckState(BoolToCheckState(settings.value(SETTINGS_SHOW_NO_ERRORS, false).toBool())); mUI.mShowDebugWarnings->setCheckState(BoolToCheckState(settings.value(SETTINGS_SHOW_DEBUG_WARNINGS, false).toBool())); mUI.mSaveAllErrors->setCheckState(BoolToCheckState(settings.value(SETTINGS_SAVE_ALL_ERRORS, false).toBool())); mUI.mSaveFullPath->setCheckState(BoolToCheckState(settings.value(SETTINGS_SAVE_FULL_PATH, false).toBool())); mUI.mInlineSuppressions->setCheckState(BoolToCheckState(settings.value(SETTINGS_INLINE_SUPPRESSIONS, false).toBool())); mUI.mEnableInconclusive->setCheckState(BoolToCheckState(settings.value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool())); mUI.mShowErrorId->setCheckState(BoolToCheckState(settings.value(SETTINGS_SHOW_ERROR_ID, false).toBool())); connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(Ok())); connect(mUI.mButtons, SIGNAL(rejected()), this, SLOT(reject())); connect(mUI.mBtnAddApplication, SIGNAL(clicked()), this, SLOT(AddApplication())); connect(mUI.mBtnRemoveApplication, SIGNAL(clicked()), this, SLOT(RemoveApplication())); connect(mUI.mBtnEditApplication, SIGNAL(clicked()), this, SLOT(EditApplication())); connect(mUI.mBtnDefaultApplication, SIGNAL(clicked()), this, SLOT(DefaultApplication())); connect(mUI.mListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(EditApplication())); connect(mUI.mBtnAddIncludePath, SIGNAL(clicked()), this, SLOT(AddIncludePath())); connect(mUI.mBtnRemoveIncludePath, SIGNAL(clicked()), this, SLOT(RemoveIncludePath())); connect(mUI.mBtnEditIncludePath, SIGNAL(clicked()), this, SLOT(EditIncludePath())); mUI.mListWidget->setSortingEnabled(false); PopulateApplicationList(); const int count = QThread::idealThreadCount(); if (count != -1) mUI.mLblIdealThreads->setText(QString::number(count)); else mUI.mLblIdealThreads->setText(tr("N/A")); LoadSettings(); InitTranslationsList(); InitIncludepathsList(); }
void MimeTypeNode::SetDefault(ApplicationNode * app) { if(!app) return; // If the app is already in the applications list - remove it RemoveApplication(app); // If we have a default already - add it to the applications list if(m_default_app) AddApplication(m_default_app); // Set the default to be the new one m_default_app = app; }
StatusType iDroid::IncreaseDownloads(int appID, int downloadIncrease) { if (appID <= 0 || downloadIncrease <= 0) return INVALID_INPUT; try { DataByID appByID(appID); Tree<DataByID>::Node* node = _appsByIDtree.find(appByID); CMP_DATA(node, appID); appByID = node->getData(); StatusType status = RemoveApplication(appID); if (status != SUCCESS) return status; appByID._downloads += downloadIncrease; status = AddApplication(appID, appByID._versionCode, appByID._downloads); if (status != SUCCESS) return status; } catch (Tree<DataByID>::TreeIsEmpty& e) { return FAILURE; } catch (Tree<DataByDowns>::TreeIsEmpty& e) { return FAILURE; } return SUCCESS; }
int main(int argc, char *argv[]) { pargc = &argc; pargv = &argv; // Get current executable path char curExePath[MAXPATHLEN]; if (NS_FAILED(mozilla::BinaryPath::Get(argv[0], curExePath))) { ErrorDialog("Couldn't read current executable path"); return 255; } char curExeDir[MAXPATHLEN]; GetDirFromPath(curExeDir, curExePath); bool removeApp = false; for (int i = 1; i < argc; i++) { if (!strcmp(argv[i], "-profile")) { isProfileOverridden = true; } else if (!strcmp(argv[i], "-remove")) { removeApp = true; } } char firefoxDir[MAXPATHLEN]; // Check if Firefox is in the same directory as the webapp runtime. // This is the case for webapprt chrome and content tests. if (GRELoadAndLaunch(curExeDir, true)) { return 0; } // Set up webAppIniPath with path to webapp.ini char webAppIniPath[MAXPATHLEN]; snprintf(webAppIniPath, MAXPATHLEN, "%s/%s", curExeDir, kWEBAPP_INI); // Open webapp.ini as an INI file nsINIParser parser; if (NS_FAILED(parser.Init(webAppIniPath))) { ErrorDialog("Couldn't open webapp.ini"); return 255; } // Set up our environment to know where webapp.ini was loaded from if (setenv(kAPP_ENV_VAR, webAppIniPath, 1) == -1) { ErrorDialog("Couldn't set up app environment"); return 255; } // Get profile dir from webapp.ini if (NS_FAILED(parser.GetString("Webapp", "Profile", profile, MAXPATHLEN))) { ErrorDialog("Couldn't retrieve profile from web app INI file"); return 255; } if (removeApp) { RemoveApplication(parser, curExeDir, profile); return 0; } // Get the location of Firefox from our webapp.ini if (NS_FAILED(parser.GetString("WebappRT", "InstallDir", firefoxDir, MAXPATHLEN))) { ErrorDialog("Couldn't find your Firefox install directory."); return 255; } // Set up appIniPath with path to application.ini. // This is in the Firefox installation directory. char appIniPath[MAXPATHLEN]; snprintf(appIniPath, MAXPATHLEN, "%s/%s", firefoxDir, kAPP_INI); if (NS_FAILED(parser.Init(appIniPath))) { ErrorDialog("This app requires that Firefox version 16 or above is installed." " Firefox 16+ has not been detected."); return 255; } // Get buildid of Firefox we're trying to load (MAXPATHLEN only for convenience) char buildid[MAXPATHLEN]; if (NS_FAILED(parser.GetString("App", "BuildID", buildid, MAXPATHLEN))) { ErrorDialog("Couldn't read BuildID from Firefox application.ini"); return 255; } // If WebAppRT version == Firefox version, load XUL and execute the application if (!strcmp(buildid, NS_STRINGIFY(GRE_BUILDID))) { if (GRELoadAndLaunch(firefoxDir, false)) return 0; } // Else, copy WebAppRT from Firefox installation and re-execute the process else CopyAndRelaunch(firefoxDir, curExePath); return 255; }
HRESULT CpiConfigureApplications( LPWSTR* ppwzData, HANDLE hRollbackFile ) { HRESULT hr = S_OK; CPI_APPLICATION_ATTRIBUTES attrs; ::ZeroMemory(&attrs, sizeof(attrs)); // read action text hr = CpiActionStartMessage(ppwzData, FALSE); ExitOnFailure(hr, "Failed to send action start message"); // get count int iCnt = 0; hr = WcaReadIntegerFromCaData(ppwzData, &iCnt); ExitOnFailure(hr, "Failed to read count"); // write count to rollback file hr = CpiWriteIntegerToRollbackFile(hRollbackFile, iCnt); ExitOnFailure(hr, "Failed to write count to rollback file"); for (int i = 0; i < iCnt; i++) { // read attributes from CustomActionData hr = ReadApplicationAttributes(ppwzData, &attrs); ExitOnFailure(hr, "Failed to read attributes"); // progress message hr = CpiActionDataMessage(1, attrs.pwzName); ExitOnFailure(hr, "Failed to send progress messages"); if (S_FALSE == hr) ExitFunction(); // write key to rollback file hr = CpiWriteKeyToRollbackFile(hRollbackFile, attrs.pwzKey); ExitOnFailure(hr, "Failed to write key to rollback file"); // action switch (attrs.iActionType) { case atCreate: hr = CreateApplication(&attrs); ExitOnFailure1(hr, "Failed to create application, key: %S", attrs.pwzKey); break; case atRemove: hr = RemoveApplication(&attrs); ExitOnFailure1(hr, "Failed to remove application, key: %S", attrs.pwzKey); break; } // write completion status to rollback file hr = CpiWriteIntegerToRollbackFile(hRollbackFile, 1); ExitOnFailure(hr, "Failed to write completion status to rollback file"); // progress hr = WcaProgressMessage(attrs.iActionCost, FALSE); ExitOnFailure(hr, "Failed to update progress"); } hr = S_OK; LExit: // clean up FreeApplicationAttributes(&attrs); return hr; }
HRESULT CpiRollbackConfigureApplications( LPWSTR* ppwzData, CPI_ROLLBACK_DATA* pRollbackDataList ) { HRESULT hr = S_OK; int iRollbackStatus; CPI_APPLICATION_ATTRIBUTES attrs; ::ZeroMemory(&attrs, sizeof(attrs)); // read action text hr = CpiActionStartMessage(ppwzData, NULL == pRollbackDataList); ExitOnFailure(hr, "Failed to send action start message"); // get count int iCnt = 0; hr = WcaReadIntegerFromCaData(ppwzData, &iCnt); ExitOnFailure(hr, "Failed to read count"); for (int i = 0; i < iCnt; i++) { // read attributes from CustomActionData hr = ReadApplicationAttributes(ppwzData, &attrs); ExitOnFailure(hr, "Failed to read attributes"); // rollback status hr = CpiFindRollbackStatus(pRollbackDataList, attrs.pwzKey, &iRollbackStatus); if (S_FALSE == hr) continue; // not found, nothing to rollback // progress message hr = CpiActionDataMessage(1, attrs.pwzName); ExitOnFailure(hr, "Failed to send progress messages"); if (S_FALSE == hr) ExitFunction(); // action switch (attrs.iActionType) { case atCreate: hr = CreateApplication(&attrs); if (FAILED(hr)) WcaLog(LOGMSG_STANDARD, "Failed to create application, hr: 0x%x, key: %S", hr, attrs.pwzKey); break; case atRemove: hr = RemoveApplication(&attrs); if (FAILED(hr)) WcaLog(LOGMSG_STANDARD, "Failed to remove application, hr: 0x%x, key: %S", hr, attrs.pwzKey); break; } // check rollback status if (0 == iRollbackStatus) continue; // operation did not complete, skip progress // progress hr = WcaProgressMessage(attrs.iActionCost, FALSE); ExitOnFailure(hr, "Failed to update progress"); } hr = S_OK; LExit: // clean up FreeApplicationAttributes(&attrs); return hr; }