void SieveJob::slotResult( KJob * job ) { Command lastCmd = mCommands.top(); // First, let's see if we come back from a SearchActive. If so, set // mFileExists to No if we didn't see the mUrl.fileName() during // listDir... if ( lastCmd == SearchActive && mFileExists == DontKnow && !job->error() ) mFileExists = No; // prepare for next round: mCommands.pop(); delete mDec; mDec = 0; if ( mSieveCapabilities.empty() ) { mSieveCapabilities = static_cast<KIO::Job*>(job)->queryMetaData( "sieveExtensions" ).split(' ', QString::SkipEmptyParts ); kDebug() << "Received Sieve extensions supported:\n" << mSieveCapabilities.join("\n"); } // check for errors: if ( job->error() ) { if ( static_cast<KIO::Job*>(job)->ui() ) { static_cast<KIO::Job*>(job)->ui()->setWindow( 0 ); static_cast<KIO::Job*>(job)->ui()->showErrorMessage(); } emit result( this, false, mScript, mUrl.fileName() == mActiveScriptName ); if ( lastCmd == List ) emit gotList( this, false, mAvailableScripts, mActiveScriptName ); else emit gotScript( this, false, mScript, mUrl.fileName() == mActiveScriptName ); mJob = 0; deleteLater(); return; } // check for new tasks: if ( !mCommands.empty() ) { // Don't fail getting a non-existent script: if ( mCommands.top() == Get && mFileExists == No ) { mScript.clear(); mCommands.pop(); } } if ( mCommands.empty() ) { // was last command; report success and delete this object: emit result( this, true, mScript, mUrl.fileName() == mActiveScriptName ); if ( lastCmd == List ) emit gotList( this, true, mAvailableScripts, mActiveScriptName ); else emit gotScript( this, true, mScript, mUrl.fileName() == mActiveScriptName ); mJob = 0; // deletes itself on returning from this slot deleteLater(); return; } else { // schedule the next command: schedule( mCommands.top() ); } }
/** * Syntax: * # Comment * Id=id * File=oldfile[,newfile] * AllGroups * Group=oldgroup[,newgroup] * RemoveGroup=oldgroup * Options=[copy,][overwrite,] * Key=oldkey[,newkey] * RemoveKey=ldkey * AllKeys * Keys= [Options](AllKeys|(Key|RemoveKey)*) * ScriptArguments=arguments * Script=scriptfile[,interpreter] * * Sequence: * (Id,(File(Group,Keys)*)*)* **/ bool KonfUpdate::updateFile(const QString &filename) { m_currentFilename = filename; int i = m_currentFilename.lastIndexOf('/'); if (i != -1) { m_currentFilename = m_currentFilename.mid(i + 1); } m_skip = true; QFile file(filename); if (!file.open(QIODevice::ReadOnly)) { return false; } log() << "Checking update-file '" << filename << "' for new updates" << endl; QTextStream ts(&file); ts.setCodec(QTextCodec::codecForName("ISO-8859-1")); m_lineCount = 0; resetOptions(); while (!ts.atEnd()) { m_line = ts.readLine().trimmed(); m_lineCount++; if (m_line.isEmpty() || (m_line[0] == '#')) { continue; } if (m_line.startsWith(QLatin1String("Id="))) { gotId(m_line.mid(3)); } else if (m_skip) { continue; } else if (m_line.startsWith(QLatin1String("Options="))) { gotOptions(m_line.mid(8)); } else if (m_line.startsWith(QLatin1String("File="))) { gotFile(m_line.mid(5)); } else if (m_skipFile) { continue; } else if (m_line.startsWith(QLatin1String("Group="))) { gotGroup(m_line.mid(6)); } else if (m_line.startsWith(QLatin1String("RemoveGroup="))) { gotRemoveGroup(m_line.mid(12)); resetOptions(); } else if (m_line.startsWith(QLatin1String("Script="))) { gotScript(m_line.mid(7)); resetOptions(); } else if (m_line.startsWith(QLatin1String("ScriptArguments="))) { gotScriptArguments(m_line.mid(16)); } else if (m_line.startsWith(QLatin1String("Key="))) { gotKey(m_line.mid(4)); resetOptions(); } else if (m_line.startsWith(QLatin1String("RemoveKey="))) { gotRemoveKey(m_line.mid(10)); resetOptions(); } else if (m_line == "AllKeys") { gotAllKeys(); resetOptions(); } else if (m_line == "AllGroups") { gotAllGroups(); resetOptions(); } else { logFileError() << "Parse error" << endl; } } // Flush. gotId(QString()); KDE_struct_stat buff; KDE::stat(filename, &buff); KConfigGroup cg(m_config, m_currentFilename); cg.writeEntry("ctime", int(buff.st_ctime)); cg.writeEntry("mtime", int(buff.st_mtime)); cg.sync(); return true; }