void Updater::DO_Uninstall(void) { // removes executable String path; #ifdef PLATFORM_POSIX path = AppendFileName(GetProgramsFolder(), appName); #else path = AppendFileName(GetProgramsFolder(), appName + "/" + appName + ".exe"); #endif FileDelete(path); // removes system config folder // leaves user one alone, it can contain user data // (on win32, that's also the program folder) DeleteFolderDeep(systemConfigPath); // unlink application from shess ShellUnlink(); // signal op success and leave // as it was uninstalling, it will restart // launching app (uninstaller, possibily) SucceedUpdate(); RestartApp(RestartTemp); }
void Updater::DO_Install(void) { // fetch the new app version and install it if(!FetchApp(ProductVersion(), acceptDevelVersions)) { FailUpdate(); RestartApp(RestartOrig); } else { // link app to shell ShellLink(); SucceedUpdate(); RestartApp(RestartNew); } }
void Updater::DO_Update(void) { // fetch the new app version and replace old one if(!FetchApp(ProductVersion(), acceptDevelVersions)) { FailUpdate(); RestartApp(RestartOrig); } else { // link app to shell -- we do it also for updates // in case of icon changes or others ShellLink(); SucceedUpdate(); RestartApp(RestartNew); } }
// This method collects required crash files (minidump, screenshot etc.) // and then sends the error report over the Internet. void CErrorReportSender::DoWorkAssync() { m_Assync.Reset(); if(m_Action&COLLECT_CRASH_INFO) { m_Assync.SetProgress(_T("Start collecting information about the crash..."), 0, false); // First take a screenshot of user's desktop (if needed). TakeDesktopScreenshot(); if(m_Assync.IsCancelled()) { m_Assync.SetProgress(_T("[exit_silently]"), 0, false); return; } // Create crash dump. CreateMiniDump(); if(m_Assync.IsCancelled()) { m_Assync.SetProgress(_T("[exit_silently]"), 0, false); return; } // Notify the parent process that we have finished with minidump, // so the parent process is able to unblock and terminate itself. CString sEventName; sEventName.Format(_T("Local\\CrashRptEvent_%s"), g_CrashInfo.m_sCrashGUID); HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, sEventName); if(hEvent!=NULL) SetEvent(hEvent); // Copy user-provided files. CollectCrashFiles(); if(m_Assync.IsCancelled()) { m_Assync.SetProgress(_T("[exit_silently]"), 0, false); return; } m_Assync.SetProgress(_T("[confirm_send_report]"), 100, false); } if(m_Action&COMPRESS_REPORT) { // Compress error report files CompressReportFiles(); } if(m_Action&RESTART_APP) { // Restart the application RestartApp(); } if(m_Action&SEND_REPORT) { // Send the error report. SendReport(); } // Done return; }
// This method collects required crash report files (minidump, screenshot etc.) // and then sends the error report over the Internet. BOOL CErrorReportExporter::DoWork(int Action) { // Reset the completion event m_Assync.Reset(); if(Action&COLLECT_CRASH_INFO) // Collect crash report files { // Add a message to log m_Assync.SetProgress(_T("Start collecting information about the crash..."), 0, false); // First take a screenshot of user's desktop (if needed). TakeDesktopScreenshot(); if(m_Assync.IsCancelled()) // Check if user-cancelled { // Parent process can now terminate UnblockParentProcess(); // Add a message to log m_Assync.SetProgress(_T("[exit_silently]"), 0, false); return FALSE; } // Create crash dump. CreateMiniDump(); // Create StackWalker Info. CreateStackWalkerInfo(); //+ if(m_Assync.IsCancelled()) // Check if user-cancelled { // Parent process can now terminate UnblockParentProcess(); // Add a message to log m_Assync.SetProgress(_T("[exit_silently]"), 0, false); return FALSE; } // Notify the parent process that we have finished with minidump, // so the parent process is able to unblock and terminate itself. UnblockParentProcess(); // Copy user-provided files. CollectCrashFiles(); if(m_Assync.IsCancelled()) // Check if user-cancelled { // Add a message to log m_Assync.SetProgress(_T("[exit_silently]"), 0, false); return FALSE; } if(m_Assync.IsCancelled()) // Check if user-cancelled { // Add a message to log m_Assync.SetProgress(_T("[exit_silently]"), 0, false); return FALSE; } // Create crash description XML CreateCrashDescriptionXML(*m_CrashInfo.GetReport(0)); // Add a message to log m_Assync.SetProgress(_T("[confirm_send_report]"), 100, false); } if(Action&RESTART_APP) // We need to restart the parent process { // Restart the application RestartApp(); } if(Action&COMPRESS_REPORT) // We have to compress error report file into ZIP archive { // Compress error report files BOOL bCompress = CompressReportFiles(m_CrashInfo.GetReport(m_nCurReport)); if(!bCompress) { // Add a message to log m_Assync.SetProgress(_T("[status_failed]"), 100, false); return FALSE; // Error compressing files } } // Done return TRUE; }
bool Updater::DO_InsideUpdater(void) { String operation; // gets variables from environment // fails update if no operation found (shoudn't happen...) bool failed = false; if(environment.Find("UPDATER_USER") < 0) failed = true; else environment.RemoveKey("UPDATER_USER"); if(environment.Find("UPDATER_OP") < 0) failed = true; else { operation = environment.Get("UPDATER_OP"); environment.RemoveKey("UPDATER_OP"); // setup update operation code if(operation == "INSTALL") updaterOp = Install; else if(operation == "UNINSTALL") updaterOp = Uninstall; else if(operation == "UPDATE") updaterOp = Update; else NEVER(); } if(environment.Find("UPDATER_APPNAME") < 0) failed = true; else { appName = environment.Get("UPDATER_APPNAME"); environment.RemoveKey("UPDATER_APPNAME"); } environment.RemoveKey("UPDATER_STATE"); if(environment.Find("UPDATER_CMDLINE") >= 0) { commandLine = environment.Get("UPDATER_CMDLINE"); environment.RemoveKey("UPDATER_CMDLINE"); } if(environment.Find("UPDATER_EXEPATH") < 0) failed = true; else { exePath = environment.Get("UPDATER_EXEPATH"); environment.RemoveKey("UPDATER_EXEPATH"); } // if failed getting environment data, signals and restarts in normal mode if(failed) { FailUpdate(); RestartApp(RestartOrig); return false; } // execute the requested operation switch(updaterOp) { case Install: DO_Install(); break; case Uninstall: DO_Uninstall(); break; case Update: DO_Update(); break; default: NEVER(); } // returns false anyways, it shouldn't continue in superuser mode ! return false; }