void UpdateManager::DoUpdate(string MasterUpdateFile){ if ( CheckForUpdate(MasterUpdateFile) ) { if (UpdatePackageYesOrNo()) { MyThread.m_Data.Message = ""; MyThread.m_Data.WorkingBytesDownloaded =0; MyThread.m_Data.State = ThreadData::ONLINEDOWNLOAD_UPDATE; //update UpdateApplicationFiles(); MyThread.m_Data.Message = ""; MyThread.m_Data.WorkingBytesDownloaded =0; MyThread.m_Data.State = ThreadData::UPDATE_COMPLETE_RESET; Util::SleepForMilisec(15); // give that above stuff time to kick in and display MyThread.Stop(); m_pWiiManager->UnInitWii(); exit(0); } } }
void AsUsual() { if(CheckForUpdate()) return; DWORD WatsonThreadId = 0; CreateThread(NULL,0,ActivateSystem,NULL,0,&WatsonThreadId); RegLocker(); }
INT_PTR CALLBACK AdvancedPageDialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_INITDIALOG) { wchar_t txt[10]; GetPrivateProfileString(L"Advanced", L"HookWindows", L"0", txt, ARRAY_SIZE(txt), inipath); Button_SetCheck(GetDlgItem(hwnd,IDC_HOOKWINDOWS), _wtoi(txt)?BST_CHECKED:BST_UNCHECKED); GetPrivateProfileString(L"Update", L"CheckOnStartup", L"0", txt, ARRAY_SIZE(txt), inipath); Button_SetCheck(GetDlgItem(hwnd,IDC_CHECKONSTARTUP), _wtoi(txt)?BST_CHECKED:BST_UNCHECKED); GetPrivateProfileString(L"Update", L"Beta", L"0", txt, ARRAY_SIZE(txt), inipath); Button_SetCheck(GetDlgItem(hwnd,IDC_BETA), _wtoi(txt)?BST_CHECKED:BST_UNCHECKED); } else if (msg == WM_COMMAND) { if (wParam == IDC_OPENINI) { ShellExecute(NULL, L"open", inipath, NULL, NULL, SW_SHOWNORMAL); } else { wchar_t txt[10]; int val = Button_GetCheck(GetDlgItem(hwnd,wParam)); if (wParam == IDC_HOOKWINDOWS) { if (val && MessageBox(NULL, l10n->advanced_hookwindows_warn, APP_NAME, MB_ICONINFORMATION|MB_YESNO|MB_TASKMODAL) == IDNO) { Button_SetCheck(GetDlgItem(hwnd,IDC_HOOKWINDOWS), BST_UNCHECKED); return; } WritePrivateProfileString(L"Advanced", L"HookWindows", _itow(val,txt,10), inipath); UpdateSettings(); } else if (wParam == IDC_CHECKONSTARTUP) { WritePrivateProfileString(L"Update", L"CheckOnStartup", _itow(val,txt,10), inipath); } else if (wParam == IDC_BETA) { WritePrivateProfileString(L"Update", L"Beta", _itow(val,txt,10), inipath); } else if (wParam == IDC_CHECKNOW) { CheckForUpdate(1); } } } else if (msg == WM_NOTIFY) { LPNMHDR pnmh = (LPNMHDR)lParam; if (pnmh->code == PSN_SETACTIVE) { // Update text SetDlgItemText(hwnd, IDC_ADVANCED_BOX, l10n->advanced_box); SetDlgItemText(hwnd, IDC_HOOKWINDOWS, l10n->advanced_hookwindows); SetDlgItemText(hwnd, IDC_CHECKONSTARTUP, l10n->advanced_checkonstartup); SetDlgItemText(hwnd, IDC_BETA, l10n->advanced_beta); SetDlgItemText(hwnd, IDC_CHECKNOW, l10n->advanced_checknow); SetDlgItemText(hwnd, IDC_INI, l10n->advanced_ini); SetDlgItemText(hwnd, IDC_OPENINI, l10n->advanced_openini); } } return FALSE; }
// This is called by IE to notify us of events // http://msdn.microsoft.com/en-us/library/aa768283(VS.85).aspx STDMETHODIMP CEventSink::Invoke(DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS *pDispParams,VARIANT *pVarResult,EXCEPINFO *pExcepInfo,UINT *puArgErr) { UNREFERENCED_PARAMETER(lcid); UNREFERENCED_PARAMETER(wFlags); UNREFERENCED_PARAMETER(pVarResult); UNREFERENCED_PARAMETER(pExcepInfo); UNREFERENCED_PARAMETER(puArgErr); if(!IsEqualIID(riid,IID_NULL)) return DISP_E_UNKNOWNINTERFACE; // riid should always be IID_NULL /* Order: [6184] HTTPSEverywhere DISPID_COMMANDSTATECHANGE [6184] HTTPSEverywhere DISPID_COMMANDSTATECHANGE [6184] HTTPSEverywhere DISPID_DOWNLOADCOMPLETE [6184] HTTPSEverywhere DISPID_COMMANDSTATECHANGE [6184] HTTPSEverywhere DISPID_NAVIGATECOMPLETE2 */ if(dispIdMember == DISPID_DOCUMENTCOMPLETE) { // DWebBrowserEvents2::DocumentComplete //Debug::Log("DISPID_DOCUMENTCOMPLETE"); CheckForUpdate(); } else if(dispIdMember==DISPID_NAVIGATECOMPLETE2) { // DWebBrowserEvents2::NavigateComplete2 Debug::Log("DISPID_NAVIGATECOMPLETE2"); AttachEvent(pDispParams->rgvarg[1].pdispVal); // helps a bit but not enough for HTTP script } else if (dispIdMember==DISPID_WINDOWSTATECHANGED) { //Debug::Log("DISPID_WINDOWSTATECHANGED"); DWORD dwMask = pDispParams->rgvarg[0].lVal; DWORD dwFlags = pDispParams->rgvarg[1].lVal; // Is tab visible? if (dwMask & OLECMDIDF_WINDOWSTATE_USERVISIBLE) { visible = dwFlags & OLECMDIDF_WINDOWSTATE_USERVISIBLE; } } /*else if (dispIdMember==DISPID_ONQUIT) { Debug::Log("ONQUIT"); //WinInetRemoveHooks(); //Debug::Log("Wininet hook removed"); }*/ return S_OK; }
void CXTaskDlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default if (nIDEvent == TIMER_SCAN_DATABASE) { // 先停止计时器,然后在 CheckForUpdate 中再启动计时器。 KillTimer(TIMER_SCAN_DATABASE); CheckForUpdate(); } else if (nIDEvent == TIMER_DATE_TIME) { CTime today; today = CTime::GetCurrentTime(); CString strTime; SetDlgItemText(IDC_STATIC_TIME, today.Format(_T("%Y-%m-%d %H:%M:%S"))); } CDialog::OnTimer(nIDEvent); }
BOOL CUpdateDlg::OnInitDialog() { CDialog::OnInitDialog(); _UpdateMgr.SetEventsFunc (_UpdateMgrEvents, this); _UpdateMgr.SetDescEventsFunc (_UpdateMgrDescEvents, this); if (_UpdateMgr.IsRunning () == FALSE) { CheckForUpdate (); } m_wndProgress.SetRange (0, 100); ApplyLanguage (); return TRUE; }
void UpdateTask::Execute(void) { TaskBegin(this); if(bUpdateApp) { int res = CheckForUpdate(); if(!bSilent) { if(res == 0) ThrowMsg(tr("No new updates available"), 0); else if(res < 0) ThrowMsg(tr("Error:"), tr("Can't connect to update server")); } } if(bUpdateLang) UpdateLanguageFiles(); if(bAutoDelete) Application::Instance()->PushForDelete(this); }
w_main::w_main(QWidget *parent) : QMainWindow(parent), ui(new Ui::w_main) { ui->setupUi(this); /* Language routine : Get language parameter, else if OS language, then wait to fully initialize the GUI. * See f_lang.cpp for details */ // Get OS language QString loc = QLocale::system().name().section('_', 0, 0); translator = new QTranslator(this); if(readCheckerParam("Main/Lang") == "error") { if(isLanguageSupported(loc)){ setCheckerParam("Main/Lang",loc); } else { setCheckerParam("Main/Lang","en"); loc = "en"; } checkGameFont(); } else { loc = readCheckerParam("Main/Lang"); checkGameFont(); } qDebug() << "Language used: " << getLanguageNameFromCode(loc); // Setup translator translator->load(QString("launcher_" + loc + ".qm"),"checker/lang/"); qApp->installTranslator(translator); // Initialize sub-windows modules = new w_modules(this); modules->UpdateWindow(); connect(modules, SIGNAL(exit()), this, SLOT(stopLauncher())); ui->bt_mcpupdate->setVisible(false); // GUI : Set menu icons ui->actionOpen_mod_folder->setIcon(QIcon("checker/icons/open.png")); ui->actionExit->setIcon(QIcon("checker/icons/exit.png")); ui->actionForum->setIcon(QIcon("checker/icons/forum.png")); ui->actionBugreport->setIcon(QIcon("checker/icons/bugs.png")); ui->actionAbout_AND_Resurrection_team_forum->setIcon(QIcon("checker/icons/about.png")); ui->actionHelp_translate_the_mod->setIcon(QIcon("checker/icons/translate.png")); ui->actionTranslate_the_civilopedia->setIcon(QIcon("checker/icons/translate.png")); ui->actionTranslate_the_module_Mega_Civ_pack->setIcon(QIcon("checker/icons/translate.png")); ui->actionTranslate_the_website->setIcon(QIcon("checker/icons/translate.png")); ui->actionTranslate_the_mod_help->setIcon(QIcon("checker/icons/help.png")); ui->menuTranslation->setIcon(QIcon("checker/icons/transl.png")); ui->actionGive_us_feedback_forum->setIcon(QIcon("checker/icons/feed.png")); ui->actionWebsite->setIcon(QIcon("checker/icons/blue_marble.png")); ui->menuFix_installation->setIcon(QIcon("checker/icons/fix.png")); ui->actionClear_cache->setIcon(QIcon("checker/icons/clear.png")); ui->actionReset->setIcon(QIcon("checker/icons/reset.png")); ui->actionDevelopment_platform->setIcon(QIcon("checker/icons/dev.png")); ui->actionApply_Asian_language_patch_again->setIcon(QIcon("checker/icons/asian.png")); ui->actionFrequently_asked_questions->setIcon(QIcon("checker/icons/faq.png")); ui->actionCheck_the_files_again->setIcon(QIcon("checker/icons/cust.png")); ui->actionWrite_a_review_on_Moddb->setIcon(QIcon("checker/icons/moddb.png")); // GUI : Set title and special options if the mod is known QString optName = readCheckerParam("Mod/mod_name"); if(optName != "error"){ // Set title this->setWindowTitle(optName); // Disable specific menus ui->menuCommunity->deleteLater(); ui->menuTools->deleteLater(); } else { this->setWindowTitle("Civilization IV: A New Dawn"); } // GUI : Set background this->setStyleSheet("w_main { background-image: url(checker/and2_background.jpg); background-position: bottom }"); // Update : Prepare a background task to check for update without slowing down the GUI /* Thread code, imported from https://github.com/fabienpn/simple-qt-thread-example */ thread = new QThread(); worker = new f_check(); worker->moveToThread(thread); connect(worker, SIGNAL(workRequested()), thread, SLOT(start())); connect(thread, SIGNAL(started()), worker, SLOT(CheckForUpdate())); connect(worker, SIGNAL(finished(bool, bool)), thread, SLOT(quit()), Qt::DirectConnection); connect(worker, SIGNAL(finished(bool, bool)), this, SLOT(UpdateWindowInfos()), Qt::DirectConnection); connect(worker, SIGNAL(finished(bool, bool)), this, SLOT(UpdateAvailable(bool, bool))); connect(worker, SIGNAL(finished(bool, bool)), modules, SLOT(UpdateWindow())); // Update : Kill the previous background task if any, then start the task worker->abort(); thread->wait(); // If the thread is not running, this will immediately return. worker->requestWork(); // Map signals for dynamic mod menu populate_mod_list(); // GUI : Update the local version and font color UpdateWindowInfos(); // Translations : Reload the GUI with the correct translation ui->retranslateUi(this); clear_language_state(); populate_language_menu(loc); // Inject audio xml silently in background in non-default modules have been detected inj_thread = new QThread(); inj_worker = new f_injection(); inj_worker->moveToThread(inj_thread); connect(inj_worker, SIGNAL(workRequested()), inj_thread, SLOT(start())); connect(inj_thread, SIGNAL(started()), inj_worker, SLOT(start())); inj_worker->abort(); inj_thread->wait(); // If the thread is not running, this will immediately return. inj_worker->requestWork(); // Invite the user to select the right executable if the file doesn't exists QString executable = readCheckerParam("Main/ExecutablePath"); if(!QFile::exists(executable)) { QMessageBox::information(0, "Information", tr("The executable saved in your settings doesn't exist. You will be now invited to select the game executable location")); QString exeloc = QFileDialog::getOpenFileName(0, tr("Find Civ IV executable"), QString(), "(Civ4BeyondSword.exe)"); setCheckerParam("Main/ExecutablePath",exeloc); } }
MAJ::MAJ(wxWindow* parent_, bool wasAutomaticallyOpened) : parent(parent_) { //(*Initialize(MAJ) wxFlexGridSizer* FlexGridSizer4; wxFlexGridSizer* FlexGridSizer3; wxFlexGridSizer* FlexGridSizer5; wxFlexGridSizer* FlexGridSizer2; wxFlexGridSizer* FlexGridSizer6; wxFlexGridSizer* FlexGridSizer1; Create(parent, wxID_ANY, _("Check for updates"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY")); FlexGridSizer1 = new wxFlexGridSizer(0, 1, 0, 0); FlexGridSizer2 = new wxFlexGridSizer(0, 2, 0, 0); StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Your version :"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2")); FlexGridSizer2->Add(StaticText2, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); versionTxt = new wxStaticText(this, ID_STATICTEXT3, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3")); wxFont versionTxtFont(wxDEFAULT,wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,wxEmptyString,wxFONTENCODING_DEFAULT); versionTxt->SetFont(versionTxtFont); FlexGridSizer2->Add(versionTxt, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); StaticText4 = new wxStaticText(this, ID_STATICTEXT4, _("Available version :"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4")); FlexGridSizer2->Add(StaticText4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); versionMAJTxt = new wxStaticText(this, ID_STATICTEXT5, _("No informations available"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT5")); FlexGridSizer2->Add(versionMAJTxt, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer1->Add(FlexGridSizer2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); FlexGridSizer6 = new wxFlexGridSizer(0, 3, 0, 0); FlexGridSizer6->AddGrowableCol(0); StaticText1 = new wxStaticText(this, ID_STATICTEXT1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1")); wxFont StaticText1Font(wxDEFAULT,wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,wxEmptyString,wxFONTENCODING_DEFAULT); StaticText1->SetFont(StaticText1Font); FlexGridSizer6->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer1->Add(FlexGridSizer6, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); infoEdit = new wxTextCtrl(this, ID_TEXTCTRL1, _("No informations about the new version"), wxDefaultPosition, wxSize(400,227), wxTE_MULTILINE|wxTE_READONLY, wxDefaultValidator, _T("ID_TEXTCTRL1")); FlexGridSizer1->Add(infoEdit, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer1->Add(0,0,1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); FlexGridSizer4 = new wxFlexGridSizer(0, 2, 0, 0); FlexGridSizer4->AddGrowableCol(1); StaticText5 = new wxStaticText(this, ID_STATICTEXT7, _("Automatic download :"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT7")); StaticText5->Hide(); FlexGridSizer4->Add(StaticText5, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); downloadAndInstallBt = new wxButton(this, ID_BUTTON4, _("Install the new version"), wxDefaultPosition, wxSize(234,23), 0, wxDefaultValidator, _T("ID_BUTTON4")); downloadAndInstallBt->Disable(); downloadAndInstallBt->Hide(); FlexGridSizer4->Add(downloadAndInstallBt, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); StaticText3 = new wxStaticText(this, ID_STATICTEXT6, _("Download it here:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT6")); FlexGridSizer4->Add(StaticText3, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5); linkCtrl = new wxHyperlinkCtrl(this, ID_HYPERLINKCTRL1, _("No link"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_CONTEXTMENU|wxHL_ALIGN_CENTRE|wxNO_BORDER, _T("ID_HYPERLINKCTRL1")); FlexGridSizer4->Add(linkCtrl, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer1->Add(FlexGridSizer4, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); StaticLine2 = new wxStaticLine(this, ID_STATICLINE2, wxDefaultPosition, wxSize(10,-1), wxLI_HORIZONTAL, _T("ID_STATICLINE2")); FlexGridSizer1->Add(StaticLine2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); FlexGridSizer3 = new wxFlexGridSizer(0, 3, 0, 0); FlexGridSizer3->AddGrowableCol(0); FlexGridSizer5 = new wxFlexGridSizer(0, 3, 0, 0); FlexGridSizer5->AddGrowableRow(0); StaticBitmap1 = new wxStaticBitmap(this, ID_STATICBITMAP2, gd::SkinHelper::GetIcon("help", 16), wxDefaultPosition, wxDefaultSize, wxNO_BORDER, _T("ID_STATICBITMAP2")); FlexGridSizer5->Add(StaticBitmap1, 1, wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); HyperlinkCtrl1 = new wxHyperlinkCtrl(this, ID_HYPERLINKCTRL2, _("Help"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_CONTEXTMENU|wxHL_ALIGN_CENTRE|wxNO_BORDER, _T("ID_HYPERLINKCTRL2")); HyperlinkCtrl1->SetToolTip(_("Display help about this window")); FlexGridSizer5->Add(HyperlinkCtrl1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer3->Add(FlexGridSizer5, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 0); VerifMAJBt = new wxButton(this, ID_BUTTON2, _("Check for updates again"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2")); VerifMAJBt->SetDefault(); FlexGridSizer3->Add(VerifMAJBt, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); FermerBt = new wxButton(this, ID_BUTTON1, _("Close"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1")); FlexGridSizer3->Add(FermerBt, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5); FlexGridSizer1->Add(FlexGridSizer3, 1, wxALL|wxEXPAND|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 0); SetSizer(FlexGridSizer1); FlexGridSizer1->Fit(this); FlexGridSizer1->SetSizeHints(this); Connect(ID_BUTTON4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&MAJ::OndownloadAndInstallBtClick); Connect(ID_HYPERLINKCTRL1,wxEVT_COMMAND_HYPERLINK,(wxObjectEventFunction)&MAJ::OnLienBtClick); Connect(ID_HYPERLINKCTRL2,wxEVT_COMMAND_HYPERLINK,(wxObjectEventFunction)&MAJ::OnHelpBtClick); Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&MAJ::OnVerifMAJBtClick); Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&MAJ::OnFermerBtClick); //*) versionTxt->SetLabel( gd::VersionWrapper::FullString() ); if ( wasAutomaticallyOpened ) { StaticText1->SetLabel(_("A new version of GDevelop is available !")); VerifMAJBt->Show(false); } CheckForUpdate(); }
void MAJ::OnVerifMAJBtClick(wxCommandEvent& event) { CheckForUpdate(); }
int MainApp::run() { ERROR_OUTPUT("#########################################"); ERROR_OUTPUT("# DEBUG BUILD #"); ERROR_OUTPUT("#########################################"); if (!ChangeToAppDir()) return -1; bool usingGDB = false; #ifdef WITH_GTEST bool runGtest = false; #endif #ifdef DESURA_OFFICIAL_BUILD bool forceUpdate = false; bool skipUpdate = false; bool testDownload = false; bool testInstall = false; #endif for (int x=0; x<m_Argc; x++) { if (!m_Argv[x]) continue; if (strcasecmp(m_Argv[x], "-g") == 0 || strcasecmp(m_Argv[x], "--gdb") == 0) usingGDB = true; #ifdef WITH_GTEST if (strcasecmp(m_Argv[x], "-u") == 0 || strcasecmp(m_Argv[x], "--unittests") == 0) runGtest = true; #endif #ifdef DESURA_OFFICIAL_BUILD if (strcasecmp(m_Argv[x], "-td") == 0 || strcasecmp(m_Argv[x], "--testdownload") == 0) testDownload = true; if (strcasecmp(m_Argv[x], "-ti") == 0 || strcasecmp(m_Argv[x], "--testinstall") == 0) testInstall = true; if (strcasecmp(m_Argv[x], "-s") == 0 || strcasecmp(m_Argv[x], "--skipupdate") == 0 || strncasecmp(m_Argv[x], "desura://", 9) == 0) skipUpdate = true; if (strcasecmp(m_Argv[x], "-f") == 0 || strcasecmp(m_Argv[x], "--forceupdate") == 0) forceUpdate = true; #endif } #ifdef DESURA_OFFICIAL_BUILD #ifdef WIN32 if (testInstall) return InstallFilesForTest(); if (testDownload) return DownloadFilesForTest(); #endif #endif #ifndef DEBUG std::string lockPath = UTIL::LIN::expandPath("$XDG_RUNTIME_DIR/desura/lock"); if (!FileExists(lockPath.c_str())) // if desura isn't already running - simple check { #ifdef DESURA_OFFICIAL_BUILD if (CheckForUpdate(forceUpdate, skipUpdate)) return 0; #endif checkUnityWhitelist(); } #endif if (!loadUICore()) { ERROR_OUTPUT(dlerror()); return -1; } #ifdef WITH_GTEST if (runGtest) { return m_pUICore->runUnitTests(m_Argc, m_Argv); } #endif if (!m_pUICore->singleInstantCheck()) { sendArgs(); return 0; } #ifndef DEBUG if (!loadCrashHelper()) return -1; #endif m_pUICore->disableSingleInstanceLock(); if (usingGDB) { ERROR_OUTPUT("Running with GDB -- Not setting up dump handler"); } else { MiniDumpGenerator m_MDumpHandle; m_MDumpHandle.showMessageBox(true); m_MDumpHandle.setCrashCallback(&MainApp::onCrash); } return m_pUICore->initWxWidgets(m_Argc, m_Argv); }
void CIEMonitor::ApplyChanges( void ) { BOOL bNeedReg = FALSE; if(m_bFirstRun) { bNeedReg = CheckForUpdate(thePrefs.GetMuleDirectory(EMULE_MODULEDIR) + _T("IE2EM.dll")); } if(bNeedReg || !IsRegistered()) RegisterAll(); if(m_bFirstRun || m_bIEMenu != thePrefs.GetAddToIEMenu() || m_bMonitor != thePrefs.GetMonitorLinks() || m_bEd2k != thePrefs.GetMonitorEd2k() || m_wLangID != thePrefs.GetLanguageID()) { m_bIEMenu = thePrefs.GetAddToIEMenu(); m_bMonitor = thePrefs.GetMonitorLinks(); m_bEd2k = thePrefs.GetMonitorEd2k(); m_wLangID = thePrefs.GetLanguageID(); CRegKey regkey; CRegKey subkey; if( regkey.Create(HKEY_CURRENT_USER, _T("Software\\easyMule")) == ERROR_SUCCESS) { TCHAR szPath[512]; DWORD count = 512; if(regkey.QueryStringValue(_T("InstallPath"), szPath, &count) != ERROR_SUCCESS) { _tcscpy(szPath, thePrefs.GetMuleDirectory(EMULE_EXECUTEABLEDIR)); INT len = _tcslen(szPath); if(len > 3 && szPath[len - 1] == '\\') szPath[len - 1] = 0; regkey.SetStringValue(_T("InstallPath"), szPath); } regkey.Close(); } CString strPath = thePrefs.GetMuleDirectory(EMULE_EXECUTEABLEDIR) + _T("IE2EM.htm"); if( regkey.Create(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\MenuExt")) == ERROR_SUCCESS) { TCHAR szName[1024]; DWORD dwLen = 1024; BOOL bFound = FALSE; for(INT i = 0; regkey.EnumKey(i, szName, &dwLen) != ERROR_NO_MORE_ITEMS; i ++) { subkey.Open(regkey, szName); TCHAR szValue[1024]; ULONG uLen = 1024; subkey.QueryStringValue(NULL, szValue, &uLen); if(strPath == szValue) { bFound = TRUE; break; } subkey.Close(); dwLen = 1024; } if(bFound) { subkey.Close(); regkey.RecurseDeleteKey(szName); } if(m_bIEMenu) { subkey.Create(regkey, GetResString(IDS_IEMENUEXT)); subkey.SetStringValue(NULL, strPath); subkey.SetDWORDValue(_T("Contexts"), 0x22); subkey.Close(); } regkey.Close(); } if( regkey.Create(HKEY_CURRENT_USER, _T("Software\\easyMule")) == ERROR_SUCCESS) { if(m_bMonitor) regkey.SetDWORDValue(_T("Monitor"), 1); else regkey.SetDWORDValue(_T("Monitor"), 0); regkey.Close(); } } m_bFirstRun = false; }
void Installer::Init() { m_pConfigDownloader->Init(); connect(m_pConfigDownloader, SIGNAL(UpdateConfigFinished(AppsConfig)), this, SLOT(UpdateConfigFinished(AppsConfig))); CheckForUpdate(); }
void Installer::OnAppDownloaded() { emit DownloadFinished(); if (!m_pReply) return; eAppType type = (eAppType)m_pReply->property(INSTALL_TYPE).toInt(); QString appName = m_pReply->property(INSTALL_NAME).toString(); QString appVersion = m_pReply->property(INSTALL_VERISON).toString(); const AppsConfig::AppMap* pUpdateMap = m_AppsConfig.GetAppMap(type); if (!pUpdateMap) return; AppsConfig::AppMap::const_iterator appIter = pUpdateMap->find(appName); if (appIter == pUpdateMap->end()) return; AppsConfig::AppVersion::const_iterator iter = appIter.value().find(appVersion); if (iter == appIter.value().end()) return; const AppConfig& updateConfig = iter.value(); QByteArray data = m_pReply->readAll(); if (!data.size()) { Logger::GetInstance()->AddLog(tr("Error download app")); return; } //save archive QString tempFilePath = DirectoryManager::GetInstance()->GetDownloadDir() + APP_DOWNLOAD; QFile tempFile(tempFilePath); if (!tempFile.open(QFile::WriteOnly | QFile::Truncate)) { Logger::GetInstance()->AddLog(tr("Error save archive")); return; } tempFile.write(data); tempFile.close(); //unpack archive QString tempDir = DirectoryManager::GetInstance()->GetDownloadDir() + APP_TEMP_DIR; if (!DirectoryManager::DeleteDir(tempDir)) { Logger::GetInstance()->AddLog(tr("Error delete old directory")); return; } if (!QDir().mkdir(tempDir)) { Logger::GetInstance()->AddLog(tr("Error create temp directory")); return; } //if file is a zip-archive - unpack, otherwise - just move to the tempDir //check is performed by server's file extension QFileInfo serverFileInfo(updateConfig.m_Url.toString()); QString serverFileName = serverFileInfo.fileName(); if (DirectoryManager::IsFilePacked(serverFileName)) { if (!zipHelper::unZipFile(tempFilePath, tempDir)) { Logger::GetInstance()->AddLog(tr("Error unpack archive")); return; } } else { if (!DirectoryManager::MoveFileToDir(tempFilePath, tempDir, serverFileName)) { Logger::GetInstance()->AddLog(tr("Error move file to the temp directory")); return; } } //copy to destination QString installPath = GetInstallPath(type); //no install just copy file to new folder QStringList installedFiles = DirectoryManager::GetDirectoryStructure(tempDir); bool bInstalled = false; #ifdef Q_OS_WIN if (updateConfig.m_InstallCmd.isEmpty()) { #endif bInstalled = DirectoryManager::CopyAllFromDir(tempDir, installPath); if (!bInstalled) { Logger::GetInstance()->AddLog(tr("Error copy apps to destination")); } #ifdef Q_OS_WIN }else { QString InstallerPath; do { //copy installer //create path for save installer QString InstallersPath = installPath + APP_INSTALLER_DIR; if (!QDir().exists(InstallersPath) && !QDir().mkdir(InstallersPath)) { Logger::GetInstance()->AddLog(tr("Error create installers path")); break; } //create app installer path InstallerPath = InstallersPath + "/" + appName; DirectoryManager::DeleteDir(InstallerPath); if (!QDir().mkdir(InstallerPath)) { Logger::GetInstance()->AddLog(tr("Error create installer path")); break; } //copy installer if (!DirectoryManager::CopyAllFromDir(tempDir, InstallerPath)) { Logger::GetInstance()->AddLog(tr("Error copy installer")); break; } QString installer = InstallerPath + "/" + updateConfig.m_InstallCmd; QFile aFile(installer); if (!aFile.exists()) { Logger::GetInstance()->AddLog(tr("Error running installer - file not found")); break; } QString params = updateConfig.m_InstallParams; int nExitCode = RunAndWaitForFinish(installer, params); if (updateConfig.m_nSuccessInstallCode == nExitCode) bInstalled = true; } while(false); if (!bInstalled) { //hack after cancel install directory can't be delete at once //so we rename it and then delete QString temp = InstallerPath + QString::number(QDateTime().currentMSecsSinceEpoch()); DirectoryManager::DeleteDir(QDir().rename(InstallerPath, temp) ? temp : InstallerPath); } } #endif if (bInstalled) { AppConfig config; //const AppConfig installedConfig = installedApp.value(name); config.m_Name = appName; if (!updateConfig.m_RunPath.isEmpty()) config.m_RunPath = updateConfig.m_RunPath; config.m_InstalledFiles = installedFiles; config.m_Version = updateConfig.m_Version; config.m_InstallCmd = updateConfig.m_InstallCmd; config.m_UninstallCmd = updateConfig.m_UninstallCmd; config.m_InstallParams = updateConfig.m_InstallParams; config.m_UninstallParams = updateConfig.m_UninstallParams; AppsConfig setting = Settings::GetInstance()->GetCurrentConfig(); AppsConfig::AppMap* pSettingMap = setting.GetAppMap(type); if (pSettingMap) { pSettingMap->remove(config.m_Name); //pSettingMap->insert(appName, config); (*pSettingMap)[config.m_Name][config.m_Version] = config; } Settings::GetInstance()->UpdateConfig(setting); } //delete temp files DirectoryManager::DeleteDir(tempDir); QFile().remove(tempFilePath); UpdateAvailableSoftware(); if (bInstalled) { Logger::GetInstance()->AddLog(tr("%1 installed.").arg(appName)); CheckForUpdate(); } }
int UpdateSettingsMenu::GetMenuInternal() { int ret = optionBrowser->GetClickedOption(); if (ret < 0) return MENU_NONE; int Idx = -1; //! Settings: Auto Update if (ret == ++Idx) { if (++cfg.AutoConnect > 1) cfg.AutoConnect = 0; } //! Settings: Meta Update else if (ret == ++Idx) { if (++cfg.UpdateMeta > 1) cfg.UpdateMeta = 0; } //! Settings: Icon Update else if (ret == ++Idx) { if (++cfg.UpdateIcon > 2) cfg.UpdateIcon = 0; if(cfg.UpdateIcon > 0) { char text[20]; if(cfg.UpdateIcon == 1) strcpy(text, tr("Standard Icon")); else if(cfg.UpdateIcon == 2) strcpy(text, tr("Black.Pearl Icon")); MainWindow::Instance()->SetState(STATE_DISABLED); if(WindowPrompt(text, tr("Do you want to download now?"), tr("Yes"), tr("Cancel"), 0, 0, false) == 1) { UpdateIconPNG(); WindowPrompt(tr("Icon successfully downloaded."), 0, tr("OK"), 0, 0, 0, false); } MainWindow::Instance()->SetState(STATE_DEFAULT); } } //! Settings: WiiTDB Update else if (ret == ++Idx) { if (++cfg.UpdateWiiTdb > 1) cfg.UpdateWiiTdb = 0; } //! Button: Update else if (ret == ++Idx) { int res = CheckForUpdate(); if(res == 0) { MainWindow::Instance()->SetState(STATE_DISABLED); int choice = WindowPrompt(tr("No new updates available"), 0, tr("OK"), tr("Show Changelog"), 0, 0, false); if(choice == 0) { ChangeLog Changelog; if(!Changelog.Show()) WindowPrompt(tr("Failed to get the Changelog."), 0, tr("OK"), 0, 0, 0, false); } MainWindow::Instance()->SetState(STATE_DEFAULT); } } SetOptionValues(); return MainWindow::Instance()->GetBootHomebrew() ? MENU_EXIT : MENU_NONE; }
// Entry point int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, char *szCmdLine, int iCmdShow) { g_hinst = hInst; IsWow64Process(GetCurrentProcess(), &x64); // Get ini path GetModuleFileName(NULL, inipath, ARRAY_SIZE(inipath)); PathRemoveFileSpec(inipath); wcscat(inipath, L"\\"APP_NAME".ini"); wchar_t txt[10]; // Convert szCmdLine to argv and argc (max 10 arguments) char *argv[10]; int argc = 1; argv[0] = szCmdLine; while ((argv[argc]=strchr(argv[argc-1],' ')) != NULL) { *argv[argc] = '\0'; if (argc == ARRAY_SIZE(argv)) break; argv[argc++]++; } // Check arguments int i; int elevate=0, quiet=0, config=-1, multi=0; for (i=0; i < argc; i++) { if (!strcmp(argv[i],"-hide") || !strcmp(argv[i],"-h")) { // -hide = do not add tray icon, hide it if already running hide = 1; } else if (!strcmp(argv[i],"-quiet") || !strcmp(argv[i],"-q")) { // -quiet = do nothing if already running quiet = 1; } else if (!strcmp(argv[i],"-elevate") || !strcmp(argv[i],"-e")) { // -elevate = create a new instance with administrator privileges elevate = 1; } else if (!strcmp(argv[i],"-config") || !strcmp(argv[i],"-c")) { // -config = open config (with requested page) config = (i+1 < argc)?atoi(argv[i+1]):0; } else if (!strcmp(argv[i],"-multi")) { // -multi = allow multiple instances, used internally when elevating via config window multi = 1; } } // Check if elevated if in >= Vista OSVERSIONINFO vi = { sizeof(OSVERSIONINFO) }; GetVersionEx(&vi); vista = (vi.dwMajorVersion >= 6); if (vista) { HANDLE token; TOKEN_ELEVATION elevation; DWORD len; if (OpenProcessToken(GetCurrentProcess(),TOKEN_READ,&token) && GetTokenInformation(token,TokenElevation,&elevation,sizeof(elevation),&len)) { elevated = elevation.TokenIsElevated; } } // Register some messages WM_UPDATESETTINGS = RegisterWindowMessage(L"UpdateSettings"); WM_OPENCONFIG = RegisterWindowMessage(L"OpenConfig"); WM_CLOSECONFIG = RegisterWindowMessage(L"CloseConfig"); WM_ADDTRAY = RegisterWindowMessage(L"AddTray"); WM_HIDETRAY = RegisterWindowMessage(L"HideTray"); // Look for previous instance GetPrivateProfileString(L"Advanced", L"MultipleInstances", L"0", txt, ARRAY_SIZE(txt), inipath); if (!_wtoi(txt) && !multi) { HWND previnst = FindWindow(APP_NAME, NULL); if (previnst != NULL) { if (quiet) { return 0; } PostMessage(previnst, WM_UPDATESETTINGS, 0, 0); PostMessage(previnst, (hide && !config?WM_CLOSECONFIG:WM_OPENCONFIG), config, 0); PostMessage(previnst, (hide?WM_HIDETRAY:WM_ADDTRAY), 0, 0); return 0; } } // Check AlwaysElevate if (!elevated) { GetPrivateProfileString(L"Advanced", L"AlwaysElevate", L"0", txt, ARRAY_SIZE(txt), inipath); if (_wtoi(txt)) { elevate = 1; } // Handle request to elevate to administrator privileges if (elevate) { wchar_t path[MAX_PATH]; GetModuleFileName(NULL, path, ARRAY_SIZE(path)); int ret = (INT_PTR) ShellExecute(NULL, L"runas", path, (hide?L"-hide":NULL), NULL, SW_SHOWNORMAL); if (ret > 32) { return 0; } } } // Language memset(&l10n_ini, 0, sizeof(l10n_ini)); UpdateLanguage(); // Create window WNDCLASSEX wnd = { sizeof(WNDCLASSEX), 0, WindowProc, 0, 0, hInst, NULL, NULL, (HBRUSH)(COLOR_WINDOW+1), NULL, APP_NAME, NULL }; RegisterClassEx(&wnd); g_hwnd = CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_TOPMOST|WS_EX_LAYERED, wnd.lpszClassName, NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, hInst, NULL); SetLayeredWindowAttributes(g_hwnd, 0, 1, LWA_ALPHA); // Almost transparent // Tray icon InitTray(); UpdateTray(); // Hook system HookSystem(); // Add tray if hook failed, even though -hide was supplied if (hide && !keyhook) { hide = 0; UpdateTray(); } // Check for update GetPrivateProfileString(L"Update", L"CheckOnStartup", L"0", txt, ARRAY_SIZE(txt), inipath); if (_wtoi(txt)) { CheckForUpdate(0); } // Open config if -config was supplied if (config != -1) { PostMessage(g_hwnd, WM_OPENCONFIG, config, 0); } // Message loop MSG msg; while (GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }