bool AutoUpdater::isUpdateAvailable() { VersionInfo newVersion = getUpdateVersion(); if (newVersion.timestamp <= TIMESTAMP || newVersion.versionString.isEmpty() || newVersion.versionString == GIT_VERSION) return false; else return true; }
void AutoUpdater::checkUpdatesAsyncInteractiveWorker() { if (!isUpdateAvailable()) return; // If there's already an update dir, resume updating, otherwise ask the user QString updateDirStr = Settings::getInstance().getSettingsDirPath() + "/update/"; QDir updateDir(updateDirStr); if (updateDir.exists() && QFile(updateDirStr+"flist").exists()) { setProgressVersion(getUpdateVersion().versionString); downloadUpdate(); return; } VersionInfo newVersion = getUpdateVersion(); QString contentText = QObject::tr("An update is available, do you want to download it now?\n" "It will be installed when qTox restarts."); if (!newVersion.versionString.isEmpty()) contentText += "\n\n" + QObject::tr("Version %1, %2").arg(newVersion.versionString, QDateTime::fromMSecsSinceEpoch(newVersion.timestamp*1000).toString()); if (abortFlag) return; if (GUI::askQuestion(QObject::tr("Update", "The title of a message box"), contentText, true, false)) { setProgressVersion(newVersion.versionString); GUI::showUpdateDownloadProgress(); downloadUpdate(); } }
LoadState SkFontManager::checkPreData() { LoadState state = load_true; SkStream * inStream = openReadStream( SYSTEM_DL_PREDATA_FILE ); preDataHeader header = { 0, 0, 0 }; if( !inStream ) { state = load_false; goto END0; } inStream->read( &header, SYSTEM_DL_PREDATA_HEADER_LEN ); if( header.tag != __key() ) { state = load_false; goto END0; } if( getUpdateVersion() == header.updateVersion ) { state = load_true; goto END0; } else { state = load_change; goto END0; } END0: if( inStream ) SkDELETE( inStream ); return state; }
LoadState SkFontManager::loadPreData( uint32_t * newFontIndex, bool boot ) { LoadState state = load_true; preDataHeader header = { 0, 0, 0 }; uint32_t curFontIndex = ( boot == true ? readFontConfig() : getCurrentFontIndex() ); uint32_t curNewFontIndex = curFontIndex; uint32_t numEmbeddedFonts = mEmbeddedFonts.numFonts(); bool statePass = ( curFontIndex < numEmbeddedFonts ? true : false ); bool system = ( newFontIndex != NULL ? true : false ); SkStream * stream = NULL; if( openPreDataRead( &stream ) == false ) { if( no_such_file() || permission_denied() ) goto SKIP_ERROR0; HyLogef( "openPreDataRead(%s (%d))", strerror( errno ), errno ); goto ERROR0; } stream->read( &header, SYSTEM_DL_PREDATA_HEADER_LEN ); if( header.tag != __key() ) { HyLogef( "Wrong tag" ); goto ERROR0; } LOAD_START: if( getUpdateVersion() == 0 ) // Boot Load & reload. { setUpdateVersion( header.updateVersion ); if( header.count == 0 ) goto SUCCEED0; for( uint32_t n = 0 ; n < header.count ; n++ ) { SkFontData * font = SkNEW( SkFontData ); if( font ) { font->readPreData( stream ); if( font->checkCertify( system ) == true ) { font->loadFont(); mDownloadFonts.addFonts( font ); } else { if( ( system == true ) && ( statePass == false ) ) { if( state != load_restart ) { if( ( numEmbeddedFonts + n ) == curFontIndex ) { state = load_restart; } else { state = load_change; if( ( numEmbeddedFonts + n ) < curFontIndex ) curNewFontIndex--; } } } else { state = load_change; } font->deleteFiles(); SkDELETE( font ); font = NULL; } } else { HyLogef( "SkNEW( SkFontData )" ); continue; } } } else // Fonts change { if( getUpdateVersion() == header.updateVersion ) { goto SUCCEED0; } else { mDownloadFonts.resetFonts(); setUpdateVersion( 0 ); goto LOAD_START; } } SUCCEED0: if( ( system == true ) && ( statePass == false ) ) { switch( state ) { case load_change: *newFontIndex = curNewFontIndex; break; case load_restart: *newFontIndex = SYSTEM_DEFAULT_FAMILY_INDEX; break; default: *newFontIndex = curFontIndex; break; } } else if( ( system == true ) && ( statePass == true ) ) { *newFontIndex = curFontIndex; } if( stream ) SkDELETE( stream ); return state; SKIP_ERROR0: return load_false; ERROR0: if( stream ) SkDELETE( stream ); return load_false; }