void GoogleTranslator::finishedTranslation(QNetworkReply* reply) { if( reply ) { if( reply->error() == QNetworkReply::NoError ) { if( reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200 ) { #ifdef debug_translator qDebug() << "GoogleTranslator: HTTP (Translate) Request Complete" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); #endif QString response = QString::fromUtf8(reply->readAll()).trimmed(); QRegExp rxValid("^\\{\\s*\"data\":\\s*\\{\\s*\"translations\":"); if(rxValid.indexIn(response)==-1) { #ifdef debug_translator qDebug() << "GoogleTranslator: HTTP (Translate) Unrecognised Response: " << response; #else qDebug() << "GoogleTranslator: HTTP (Translate) Unrecognised Response."; #endif } else { QRegExp rxDecode("&#([0-9]*);"); QRegExp rxItem("\\{\\s*\"translatedText\":\\s*\"([^\"]*)\"\\s*\\}"); QStringList translations; int pos=0; while((pos = rxItem.indexIn(response, pos)+1)!=0) { QString item = rxItem.cap(1); while(rxDecode.indexIn(item)!=-1) item = item.replace(rxDecode.cap(0), QString("%1").arg((char)rxDecode.cap(1).toInt())); translations.append(item); } apply(translations); saveCache(); } } else qWarning() << "GoogleTranslator: Error during HTTP (Translate) fetch:" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) << reply->errorString() << reply->url().toString(); } else qWarning() << "GoogleTranslator: Error during HTTP (Translate) fetch:" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) << reply->errorString() << reply->url().toString(); reply->deleteLater(); reply = NULL; } repTranslate->deleteLater(); repTranslate = NULL; }
QMakeSourceFileInfo::~QMakeSourceFileInfo() { //cache if(!cachefile.isEmpty() /*&& files_changed*/) saveCache(cachefile); //buffer if(spare_buffer) { free(spare_buffer); spare_buffer = 0; spare_buffer_size = 0; } //quick project lookup delete files; delete includes; }
TableGenerator::TableGenerator() : m_state(NoErrors), m_systemComposeDir(QString()) { initPossibleLocations(); QString composeFilePath = findComposeFile(); #ifdef DEBUG_GENERATOR // don't use cache when in debug mode. if (!composeFilePath.isEmpty()) qDebug() << "Using Compose file from: " << composeFilePath; #else QComposeCacheFileHeader fileInfo = readFileMetadata(composeFilePath); if (fileInfo.fileSize != 0) m_composeTable = loadCache(fileInfo); #endif if (m_composeTable.isEmpty() && cleanState()) { if (composeFilePath.isEmpty()) { m_state = MissingComposeFile; } else { QFile composeFile(composeFilePath); composeFile.open(QIODevice::ReadOnly); parseComposeFile(&composeFile); orderComposeTable(); if (m_composeTable.isEmpty()) { m_state = EmptyTable; #ifndef DEBUG_GENERATOR // don't save cache when in debug mode } else { fileInfo.cacheVersion = SupportedCacheVersion; saveCache(fileInfo, m_composeTable); #endif } } } #ifdef DEBUG_GENERATOR printComposeTable(); #endif }
void SecretManager::cacheSambaLoginData(const QJsonObject &obj) { QJsonValue v(obj); m_smbLoginObjs.insert(obj.value("id").toString(), v); saveCache(); }
MeiqueCache::~MeiqueCache() { if (m_autoSave) saveCache(); delete m_compiler; }
int CacheSyncSource::endSync() { saveCache(); return 0; }