Exemplo n.º 1
0
//all messageboxes need to be modal, updater closes immeadiately when receiving the UpdateFinished event
void UpdaterClass::OnDownloadEvent( wxCommandEvent& event )
{
    int code = event.GetInt();
    if ( code != 0)
        customMessageBox(SL_MAIN_ICON, _("There was an error downloading for the latest version.\nPlease try again later.\nIf the problem persists, please use Help->Report Bug to report this bug."), _("Error"));
    else {
        if (!PostMinGW44( m_newexe ) ) {
            customMessageBox(SL_MAIN_ICON, _("Automatic update failed\n\nyou will be redirected to a web page with instructions and the download link will be opened in your browser."), _("Updater error.") );
			OpenWebBrowser( _T("http://projects.springlobby.info/wiki/springlobby/Install#Windows-Binary") );
            OpenWebBrowser( GetDownloadUrl( m_latest_version ) );
        }
        if ( !UpdateExe( m_newexe , false ) ) {
			customMessageBox(SL_MAIN_ICON,
							 wxFormat( _("There was an error while trying to replace the current executable version.\n Please manually copy springlobby.exe from: %s\n to: %s\n") )
											   % m_newexe
											   % m_currentexe,
							 _("Error") );
        }
        else {
            bool locale_ok = UpdateLocale( m_newexe, false );
            if ( locale_ok ) {
				customMessageBox(SL_MAIN_ICON, IdentityString( _("Update complete. \nPlease restart %s now.") ), _("Success"));
            }
            else {
				customMessageBox(SL_MAIN_ICON,
								 IdentityString( _("Binary updated successfully. \nSome translation files could not be updated.\nPlease report this in #springlobby. \nPlease restart %s now.") ),
								 _("Partial success") );
            }
            wxRmdir( m_newexe );
        }
    }
    GetGlobalEventSender( GlobalEvents::UpdateFinished ).SendEvent( 0 );
}
Exemplo n.º 2
0
void ContentManager::UpdateApplication(){
	const std::string latestVersion = GetLatestApplicationVersionAvailable();
	const std::string updatedir = SlPaths::GetUpdateDir();
	const size_t mindirlen = 9; // safety, minimal is/should be: C:\update
	if ((updatedir.size() <= mindirlen)) {
		throw Exception(_T("Invalid update dir: ") + TowxString(updatedir));
	}
	if (wxDirExists(updatedir)) {
		if (!SlPaths::RmDir(updatedir)) {
			throw Exception(_T("Couldn't cleanup ") + TowxString(updatedir));
		}
	}
	if (!SlPaths::mkDir(updatedir)) {
		throw Exception(_T("couldn't create update directory") + TowxString(updatedir));
	}

	if (!wxFileName::IsDirWritable(updatedir)) {
		throw Exception(_T("dir not writable: ") + TowxString(updatedir));
	}

	const std::string dlfilepath = SlPaths::GetLobbyWriteDir() + "springlobby-latest.zip";
	if (wxFileExists(dlfilepath) && !(wxRemoveFile(dlfilepath))) {
		throw Exception(_T("couldn't delete: ") + dlfilepath);
	}
	const std::string dlurl = GetDownloadUrl(latestVersion);
	prDownloader().Download(DownloadEnum::CAT_SPRINGLOBBY, dlurl, dlfilepath);
}
Exemplo n.º 3
0
BOOL CPicDowloadThread::Run()
{
	//tString tstrUrl;
	//tString tstrFriendId;
	PicInfo* pInfo = (PicInfo*)m_pPara;
	//TCHAR  tszPicPath[MAX_PATH] = {0x0};

	GetDownloadUrl();

	// 向 界面发送消息将已经有的头像图片贴上去
	PostMessage(pInfo->m_hWnd, WM_SETHEADPICTURE, MAKELPARAM(m_downloadType, 0), (LPARAM)this);

	HINSTANCE hDll = NULL;
#ifdef USE_WININET_DOWNLOAD
	#ifdef _DEBUG
		hDll = LoadLibrary(_T("HtttpDownload_d.dll"));
	#else
		hDll = LoadLibrary(_T("HtttpDownload.dll"));
	#endif
#endif
	for (map<std::string, tString>::iterator it = pInfo->m_mapIdNotHadPic.begin(); it != pInfo->m_mapIdNotHadPic.end(); it++)
	{
		TCHAR tszPicPath[MAX_PATH] = {0x0};
		LPTSTR lptId = NULL;
		C2T(&lptId, it->first.c_str());
		GetLinkmanPicPath(tszPicPath, MAX_PATH,it->second.c_str(), lptId);

		if (URLDownloadPicture(it->second.c_str(), tszPicPath, hDll))
		
			it->second = tszPicPath;
		else
			//下载失败
			it->second = _T("");
		SAFE_ARRYDELETE(lptId);
	}	
#ifdef USE_WININET_DOWNLOAD
	FreeLibrary(hDll);
#endif
	//下载的图片
	PostMessage(pInfo->m_hWnd, WM_SETHEADPICTURE, MAKELPARAM(m_downloadType, 1), (LPARAM)this);
	return FALSE;
}
Exemplo n.º 4
0
bool UpdaterClass::StartUpdate( const wxString& latestVersion, const wxString& exe_to_update )
{
    wxString sep = wxFileName::GetPathSeparator();
    m_latest_version = latestVersion;
    m_currentexe = exe_to_update;
    if ( !wxFileName::IsDirWritable( wxPathOnly( m_currentexe ) ) ) {
        wxLogError( _T("dir not writable: ") + m_currentexe );
        customMessageBox(SL_MAIN_ICON, _("Unable to write to the lobby installation directory.\nPlease update manually or enable write permissions for the current user."), _("Error"));
        return false;
    }
    m_newexe = sett().GetLobbyWriteDir() + _T("update") + sep;
    wxLogError( m_newexe  );
    if ( !wxDirExists( m_newexe ) ) {
        if ( !wxMkdir( m_newexe ) ){
            wxLogError( _T("couldn't create update directory") );
            return false;
        }
    }

    m_http_thread = new HttpDownloaderThread<UpdaterClass>( GetDownloadUrl( m_latest_version ), m_newexe + _T("temp.zip"), *this, wxNewId(), true, true );

    //could prolly use some test on the thread here instead
    return true;
}