int main(void)
{
	int curVer=GetCurrentVersion();
	printf("Current version in the header=%d\n",curVer);

	FILE *fp=fopen("revision.txt","r");
	if(NULL!=fp)
	{
		char revStr[256];
		if(NULL!=fgets(revStr,255,fp))
		{
			int err=0;

			for(int i=0; 0!=revStr[i]; i++)
			{
				if((revStr[i]<'0' || '9'<revStr[i]) &&
				   (revStr[i]<'a' || 'z'<revStr[i]) &&
				   (revStr[i]<'A' || 'Z'<revStr[i]))
				{
					revStr[i]=0;
					break;
				}
			}
			fclose(fp);

			printf("Revision String=[%s]\n",revStr);
			if(curVer!=atoi(revStr))
			{
				FILE *ofp=fopen("yssvnrevision.h","w");
				if(NULL!=ofp)
				{
					fprintf(ofp,"#ifndef YSSVNREVISION_H_IS_INCLUDED\n");
					fprintf(ofp,"#define YSSVNREVISION_H_IS_INCLUDED\n");
					fprintf(ofp,"const char *YsSvnRevisionString=\"%s\";\n",revStr);
					fprintf(ofp,"#endif\n");

					fclose(ofp);
				}
				else
				{
					err=-1;
				}

				return err;
			}
			else
			{
				printf("Doesn't have to update.\n");
				return 0;
			}
		}
	}

	if(NULL!=fp)
	{
		fclose(fp);
	}

	return -1;
}
Esempio n. 2
0
void CConnClient::OnServerCommand(const CGas2GacGC_Tell_Current_Version* pCmd)
{
	string uCurrentVersion = pCmd->uCurrentVersion;
	uint32 uCurrentRevision = pCmd->uCurrentRevision;
	uint32 uRevision = GetCurrentRevision();
	string uVersion = GetCurrentVersion();
	if((uCurrentVersion!="")&&(uVersion!=""))
	{
		if(uCurrentVersion!=uVersion)
		{
			ostringstream strm;
			strm << "客户端的版本号 "<< uVersion << " 与服务器的版本号 " << uCurrentVersion << " 不匹配 " 
				<< "\n 请重新运行游戏启动器进行更新" << endl;
			ShowErrorMsg(strm.str().c_str());
			CoreShutDown("客户端的版本号不匹配");
		}
	}
	else if(uCurrentRevision != uRevision)
	{
		ostringstream strm;
		strm << "客户端的版本号 "<< uRevision << " 与服务器的版本号 " << uCurrentRevision << " 不匹配 " 
			<< "\n 请重新运行游戏启动器进行更新" << endl;
		ShowErrorMsg(strm.str().c_str());
		CoreShutDown("客户端的版本号不匹配");
	}
}
Esempio n. 3
0
void Updater::Install() {
	std::wstring version = GetCurrentVersion();
	if (version.empty())
		return;

	wxString command = wxString((wxGetApp().getInstallerLocalPath() / VersionToInstallerName(version)).wstring());
	wxExecute(command, wxEXEC_ASYNC);
}
Esempio n. 4
0
bool dbUpgrade::UpgradeDB(wxSQLite3Database * db, const wxString& DbFileName)
{
    int ver = GetCurrentVersion(db);

    if (ver == -1 || ver > dbLatestVersion)
    {
        wxMessageBox(_("MMEX database error!") + "\n\n"
            + wxString::Format(_("MMEX database version %i doesn't work with this MMEX version.\nPlease upgrade MMEX to newer version."), ver)
            , _("MMEX database upgrade"), wxOK | wxICON_ERROR);
        return false;
    }

    for (; ver < dbLatestVersion; ver++)
    {
        BackupDB(DbFileName, dbUpgrade::BACKUPTYPE::VERSION_UPGRADE, 999, ver);
        if (!UpgradeToVersion(db, ver + 1))
            return false;
    }

    wxMessageBox(wxString::Format(_("MMEX database succesfully upgraded to version %i"), ver) + "\n\n"
        + _("We suggest a database optimization under Tools -> Database -> Optimize"), _("MMEX database upgrade"), wxOK | wxICON_INFORMATION);

    return true;
}
Esempio n. 5
0
VersionInfo::eStatus VersionInfo::TestVersion(const SceneVersion& version) const
{
    const SceneVersion& current = GetCurrentVersion();

    // Checking version
    if (current.version < version.version)
        return INVALID;

    // Checking tags
    const TagsMap& tags = version.tags;
    const TagsMap& fwAllTags = GetTags();
    const TagsMap& fwVersionedTags = GetTags(version.version);

    const TagsMap& errTags = GetTagsDiff(tags, fwAllTags);            // List of tags that not supported by current version of framework
    const TagsMap& warnTags = GetTagsDiff(fwVersionedTags, tags);     // List of tags that will be added to scene

    if ( errTags.size() > 0 )
        return INVALID;

    if ( warnTags.size() > 0 )
        return COMPATIBLE;

    return VALID;
}
Esempio n. 6
0
void Updater::Run() {

	do {
		boost::xtime xt;
		boost::xtime_get(&xt, boost::TIME_UTC_);
		xt.sec = xt.sec + 300;
		boost::thread::sleep(xt);

		wxString version = m_downloader->getVersion();

		bool is_newer_available = isVersionNewer(version);

		if (is_newer_available) {

			SetCurrentVersion(version.c_str());

			if (needToDownloadFile(m_downloader->getChecksum(), version)) {
				setStatus(DOWNLOADING);

				std::wstring installer_local_path = (wxGetApp().getInstallerLocalPath() / VersionToInstallerName(GetCurrentVersion())).wstring();
				bool result = m_downloader->getInstallerFile(installer_local_path);
				if (result || !needToDownloadFile(m_downloader->getChecksum(), version)) {
					setStatus(READY_TO_INSTALL);
				} else {
					setStatus(UPDATE_ERROR);
				}
			} else {
				setStatus(READY_TO_INSTALL);
			}
		}

	} while (1);

}
Esempio n. 7
0
bool dbUpgrade::CheckUpgradeDB(wxSQLite3Database * db)
{
    int ver = GetCurrentVersion(db);

    return (ver != dbLatestVersion) ? true : false;
}
Esempio n. 8
0
void CEmuleUpdater::Check(const CString& strURL)
{
	GetCurrentVersion();//获取eMule当前版本号

	HINTERNET hInet = InternetOpen(UPDATECHECK_BROWSER_STRING, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL);
	HINTERNET hUrl = InternetOpenUrl(hInet, strURL, NULL, -1L,INTERNET_FLAG_RELOAD | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_NO_CACHE_WRITE |WININET_API_FLAG_ASYNC, NULL);

	if(hUrl)
	{
		char szBuffer[512];
		TCHAR szString[512];
		DWORD dwRead;

		if (InternetReadFile(hUrl, szBuffer, sizeof(szBuffer), &dwRead))
		{
			if (dwRead > 0)
			{
				szBuffer[dwRead-1] = 0;
				MultiByteToWideChar(CP_ACP,0,szBuffer, strlen(szBuffer)+1, szString, sizeof(szString)/2);


				CString		strSubMajor;		//主版本号
				CString		strSubMinor;		//副版本号
				CString		strSubUpdate;		//更新号
				CString		strSubBuild;		//建立日期
				CString		strSubURL;			//下载地址

					UINT     iMajor;			//主版本号
					UINT     iMinor;			//副版本号
					UINT	 iUpdate;
					UINT     iBuild;			//建立日期


				AfxExtractSubString(strSubMajor,szString, 0, '|'); //分析字符串,得到主版本号
				AfxExtractSubString(strSubMinor, szString, 1, '|');//分析字符串,得到副版本号
				AfxExtractSubString(strSubUpdate, szString, 2, '|');//分析字符串,得到更新号
				AfxExtractSubString(strSubBuild, szString, 3, '|');//分析字符串,得到建立日期
				AfxExtractSubString(strSubURL, szString, 4, '|');//分析字符串,得到下载地址

				

				iMajor		= _ttoi((LPCTSTR)strSubMajor);
				 iMinor		= _ttoi(strSubMinor);
				 iUpdate	= *(char*)strSubUpdate.GetBuffer() - 'a';
				 iBuild		= _ttoi(strSubBuild);

				 int iCurrent = m_iMajor*10000000 + m_iMinor*100000 + m_iUpdate*10000 + m_iBuild;
				 int iNewVersion = iMajor*10000000 + iMinor*100000 + iUpdate*10000 + iBuild;

				if(iNewVersion - iCurrent > 0)
				{
					UpdateAvailable(strSubURL);  //获得新版本信息,进行下载
				}
				else
				{
					UpdateNotAvailable();	//当前为最新版本,不需要下载
				}
			}
			else
			{
				UpdateNoCheck();  //与服务器连接失败
			}
		}
		else
		{
			UpdateNoCheck();//InternetCloseHandle(hUrl);//与服务器连接失败
		}
	}
	else
	{
		UpdateNoCheck();
	}
	InternetCloseHandle(hInet);
}