static KUrl urlFromAccount( const KMail::ImapAccountBase * a ) { const SieveConfig sieve = a->sieveConfig(); if ( !sieve.managesieveSupported() ) return KUrl(); KUrl u; if ( sieve.reuseConfig() ) { // assemble Sieve url from the settings of the account: u.setProtocol( "sieve" ); u.setHost( a->host() ); u.setUser( a->login() ); u.setPass( a->passwd() ); u.setPort( sieve.port() ); // Translate IMAP LOGIN to PLAIN: u.addQueryItem( "x-mech", a->auth() == "*" ? "PLAIN" : a->auth() ); if ( !a->useSSL() && !a->useTLS() ) u.addQueryItem( "x-allow-unencrypted", "true" ); } else { u = sieve.alternateURL(); if ( u.protocol().toLower() == "sieve" && !a->useSSL() && !a->useTLS() && u.queryItem("x-allow-unencrypted").isEmpty() ) u.addQueryItem( "x-allow-unencrypted", "true" ); } return u; }
void SieveDebugDialog::slotDiagNextScript() { if(mScriptList.isEmpty()) { // Continue handling accounts instead mScriptList.clear(); QTimer::singleShot(0, this, SLOT(slotDiagNextAccount())); return; } QString scriptFile = mScriptList.first(); mScriptList.pop_front(); mEdit->append(i18n("Contents of script '%1':\n").arg(scriptFile)); SieveConfig sieve = mAccountBase->sieveConfig(); if(sieve.reuseConfig()) { // assemble Sieve url from the settings of the account: mUrl.setProtocol("sieve"); mUrl.setHost(mAccountBase->host()); mUrl.setUser(mAccountBase->login()); mUrl.setPass(mAccountBase->passwd()); mUrl.setPort(sieve.port()); // Translate IMAP LOGIN to PLAIN mUrl.setQuery("x-mech=" + (mAccountBase->auth() == "*" ? "PLAIN" : mAccountBase->auth())); mUrl.setFileName(scriptFile); } else { sieve.alternateURL(); mUrl.setFileName(scriptFile); } mSieveJob = SieveJob::get(mUrl); connect(mSieveJob, SIGNAL(gotScript(KMail::SieveJob *, bool, const QString &, bool)), SLOT(slotGetScript(KMail::SieveJob *, bool, const QString &, bool))); }
void SieveDebugDialog::slotDiagNextAccount() { if(mAccountList.isEmpty()) return; KMAccount *acc = mAccountList.first(); mAccountList.pop_front(); mEdit->append(i18n("Collecting data for account '%1'...\n").arg(acc->name())); mEdit->append(i18n("------------------------------------------------------------\n")); mAccountBase = dynamic_cast<KMail::ImapAccountBase *>(acc); if(mAccountBase) { // Detect URL for this IMAP account SieveConfig sieve = mAccountBase->sieveConfig(); if(!sieve.managesieveSupported()) { mEdit->append(i18n("(Account does not support Sieve)\n\n")); } else { if(sieve.reuseConfig()) { // assemble Sieve url from the settings of the account: mUrl.setProtocol("sieve"); mUrl.setHost(mAccountBase->host()); mUrl.setUser(mAccountBase->login()); mUrl.setPass(mAccountBase->passwd()); mUrl.setPort(sieve.port()); // Translate IMAP LOGIN to PLAIN: mUrl.setQuery("x-mech=" + (mAccountBase->auth() == "*" ? "PLAIN" : mAccountBase->auth())); } else { sieve.alternateURL(); mUrl.setFileName(sieve.vacationFileName()); } mSieveJob = SieveJob::list(mUrl); connect(mSieveJob, SIGNAL(gotList(KMail::SieveJob *, bool, const QStringList &, const QString &)), SLOT(slotGetScriptList(KMail::SieveJob *, bool, const QStringList &, const QString &))); // Bypass the singleShot timer -- it's fired when we get our data return; } } else { mEdit->append(i18n("(Account is not an IMAP account)\n\n")); } // Handle next account async QTimer::singleShot(0, this, SLOT(slotDiagNextAccount())); }