mailtransport
transportmanager.cpp
00001 /* 00002 Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 00018 */ 00019 00020 #include "transportmanager.h" 00021 #include "resourcesendjob_p.h" 00022 #include "mailtransport_defs.h" 00023 #include "sendmailjob.h" 00024 #include "smtpjob.h" 00025 #include "transport.h" 00026 #include "transport_p.h" 00027 #include "transportjob.h" 00028 #include "transporttype.h" 00029 #include "transporttype_p.h" 00030 #include "addtransportdialog.h" 00031 #include "transportconfigdialog.h" 00032 #include "transportconfigwidget.h" 00033 #include "sendmailconfigwidget.h" 00034 #include "smtpconfigwidget.h" 00035 00036 #include <QApplication> 00037 #include <QtDBus/QDBusConnection> 00038 #include <QtDBus/QDBusConnectionInterface> 00039 #include <QtDBus/QDBusServiceWatcher> 00040 #include <QPointer> 00041 #include <QRegExp> 00042 #include <QStringList> 00043 00044 #include <KConfig> 00045 #include <KConfigGroup> 00046 #include <KDebug> 00047 #include <KEMailSettings> 00048 #include <KLocale> 00049 #include <KMessageBox> 00050 #include <KRandom> 00051 #include <KUrl> 00052 #include <KWallet/Wallet> 00053 00054 #include <akonadi/agentinstance.h> 00055 #include <akonadi/agentmanager.h> 00056 00057 using namespace MailTransport; 00058 using namespace KWallet; 00059 00060 namespace MailTransport { 00065 class TransportManagerPrivate 00066 { 00067 public: 00068 TransportManagerPrivate( TransportManager *parent ) 00069 : q( parent ) 00070 { 00071 } 00072 00073 ~TransportManagerPrivate() { 00074 delete config; 00075 qDeleteAll( transports ); 00076 } 00077 00078 KConfig *config; 00079 QList<Transport *> transports; 00080 TransportType::List types; 00081 bool myOwnChange; 00082 bool appliedChange; 00083 KWallet::Wallet *wallet; 00084 bool walletOpenFailed; 00085 bool walletAsyncOpen; 00086 int defaultTransportId; 00087 bool isMainInstance; 00088 QList<TransportJob *> walletQueue; 00089 TransportManager *q; 00090 00091 void readConfig(); 00092 void writeConfig(); 00093 void fillTypes(); 00094 int createId() const; 00095 void prepareWallet(); 00096 void validateDefault(); 00097 void migrateToWallet(); 00098 00099 // Slots 00100 void slotTransportsChanged(); 00101 void slotWalletOpened( bool success ); 00102 void dbusServiceUnregistered(); 00103 void agentTypeAdded( const Akonadi::AgentType &atype ); 00104 void agentTypeRemoved( const Akonadi::AgentType &atype ); 00105 void jobResult( KJob *job ); 00106 }; 00107 00108 } 00109 00110 class StaticTransportManager : public TransportManager 00111 { 00112 public: 00113 StaticTransportManager() : TransportManager() {} 00114 }; 00115 00116 StaticTransportManager *sSelf = 0; 00117 00118 static void destroyStaticTransportManager() { 00119 delete sSelf; 00120 } 00121 00122 TransportManager::TransportManager() 00123 : QObject(), d( new TransportManagerPrivate( this ) ) 00124 { 00125 KGlobal::locale()->insertCatalog( QLatin1String( "libmailtransport" ) ); 00126 KGlobal::locale()->insertCatalog( QLatin1String( "libakonadi-kmime" ) ); 00127 qAddPostRoutine( destroyStaticTransportManager ); 00128 d->myOwnChange = false; 00129 d->appliedChange = false; 00130 d->wallet = 0; 00131 d->walletOpenFailed = false; 00132 d->walletAsyncOpen = false; 00133 d->defaultTransportId = -1; 00134 d->config = new KConfig( QLatin1String( "mailtransports" ) ); 00135 00136 QDBusConnection::sessionBus().registerObject( DBUS_OBJECT_PATH, this, 00137 QDBusConnection::ExportScriptableSlots | 00138 QDBusConnection::ExportScriptableSignals ); 00139 00140 QDBusServiceWatcher *watcher = 00141 new QDBusServiceWatcher( DBUS_SERVICE_NAME, QDBusConnection::sessionBus(), 00142 QDBusServiceWatcher::WatchForUnregistration, this ); 00143 connect( watcher, SIGNAL(serviceUnregistered(QString)), 00144 SLOT(dbusServiceUnregistered()) ); 00145 00146 QDBusConnection::sessionBus().connect( QString(), QString(), 00147 DBUS_INTERFACE_NAME, DBUS_CHANGE_SIGNAL, 00148 this, SLOT(slotTransportsChanged()) ); 00149 00150 d->isMainInstance = QDBusConnection::sessionBus().registerService( DBUS_SERVICE_NAME ); 00151 00152 d->fillTypes(); 00153 } 00154 00155 TransportManager::~TransportManager() 00156 { 00157 qRemovePostRoutine( destroyStaticTransportManager ); 00158 delete d; 00159 } 00160 00161 TransportManager *TransportManager::self() 00162 { 00163 if ( !sSelf ) { 00164 sSelf = new StaticTransportManager; 00165 sSelf->d->readConfig(); 00166 } 00167 return sSelf; 00168 } 00169 00170 Transport *TransportManager::transportById( int id, bool def ) const 00171 { 00172 foreach ( Transport *t, d->transports ) { 00173 if ( t->id() == id ) { 00174 return t; 00175 } 00176 } 00177 00178 if ( def || ( id == 0 && d->defaultTransportId != id ) ) { 00179 return transportById( d->defaultTransportId, false ); 00180 } 00181 return 0; 00182 } 00183 00184 Transport *TransportManager::transportByName( const QString &name, bool def ) const 00185 { 00186 foreach ( Transport *t, d->transports ) { 00187 if ( t->name() == name ) { 00188 return t; 00189 } 00190 } 00191 if ( def ) { 00192 return transportById( 0, false ); 00193 } 00194 return 0; 00195 } 00196 00197 QList< Transport * > TransportManager::transports() const 00198 { 00199 return d->transports; 00200 } 00201 00202 TransportType::List TransportManager::types() const 00203 { 00204 return d->types; 00205 } 00206 00207 Transport *TransportManager::createTransport() const 00208 { 00209 int id = d->createId(); 00210 Transport *t = new Transport( QString::number( id ) ); 00211 t->setId( id ); 00212 return t; 00213 } 00214 00215 void TransportManager::addTransport( Transport *transport ) 00216 { 00217 if ( d->transports.contains( transport ) ) { 00218 kDebug() << "Already have this transport."; 00219 return; 00220 } 00221 00222 kDebug() << "Added transport" << transport; 00223 d->transports.append( transport ); 00224 d->validateDefault(); 00225 emitChangesCommitted(); 00226 } 00227 00228 void TransportManager::schedule( TransportJob *job ) 00229 { 00230 connect( job, SIGNAL(result(KJob*)), SLOT(jobResult(KJob*)) ); 00231 00232 // check if the job is waiting for the wallet 00233 if ( !job->transport()->isComplete() ) { 00234 kDebug() << "job waits for wallet:" << job; 00235 d->walletQueue << job; 00236 loadPasswordsAsync(); 00237 return; 00238 } 00239 00240 job->start(); 00241 } 00242 00243 void TransportManager::createDefaultTransport() 00244 { 00245 KEMailSettings kes; 00246 Transport *t = createTransport(); 00247 t->setName( i18n( "Default Transport" ) ); 00248 t->setHost( kes.getSetting( KEMailSettings::OutServer ) ); 00249 if ( t->isValid() ) { 00250 t->writeConfig(); 00251 addTransport( t ); 00252 } else { 00253 kWarning() << "KEMailSettings does not contain a valid transport."; 00254 } 00255 } 00256 00257 bool TransportManager::showTransportCreationDialog( QWidget *parent, 00258 ShowCondition showCondition ) 00259 { 00260 if ( showCondition == IfNoTransportExists ) { 00261 if ( !isEmpty() ) { 00262 return true; 00263 } 00264 00265 const int response = KMessageBox::messageBox( parent, 00266 KMessageBox::WarningContinueCancel, 00267 i18n( "You must create an outgoing account before sending." ), 00268 i18n( "Create Account Now?" ), 00269 KGuiItem( i18n( "Create Account Now" ) ) ); 00270 if ( response != KMessageBox::Continue ) { 00271 return false; 00272 } 00273 } 00274 00275 QPointer<AddTransportDialog> dialog = new AddTransportDialog( parent ); 00276 const bool accepted = ( dialog->exec() == QDialog::Accepted ); 00277 delete dialog; 00278 return accepted; 00279 } 00280 00281 bool TransportManager::configureTransport( Transport *transport, QWidget *parent ) 00282 { 00283 if( transport->type() == Transport::EnumType::Akonadi ) { 00284 using namespace Akonadi; 00285 AgentInstance instance = AgentManager::self()->instance( transport->host() ); 00286 if( !instance.isValid() ) { 00287 kWarning() << "Invalid resource instance" << transport->host(); 00288 } 00289 instance.configure( parent ); // Async... 00290 transport->writeConfig(); 00291 return true; // No way to know here if the user cancelled or not. 00292 } 00293 00294 QPointer<KDialog> dialog = new KDialog( parent ); 00295 TransportConfigWidget *configWidget = 0; 00296 switch( transport->type() ) { 00297 case Transport::EnumType::SMTP: 00298 { 00299 configWidget = new SMTPConfigWidget( transport, dialog ); 00300 break; 00301 } 00302 case Transport::EnumType::Sendmail: 00303 { 00304 configWidget = new SendmailConfigWidget( transport, dialog ); 00305 break; 00306 } 00307 default: 00308 { 00309 Q_ASSERT( false ); 00310 delete dialog; 00311 return false; 00312 } 00313 } 00314 dialog->setMainWidget( configWidget ); 00315 dialog->setCaption( i18n( "Configure account" ) ); 00316 dialog->setButtons( KDialog::Ok | KDialog::Cancel ); 00317 bool okClicked = ( dialog->exec() == QDialog::Accepted ); 00318 if( okClicked ) { 00319 configWidget->apply(); // calls transport->writeConfig() 00320 } 00321 delete dialog; 00322 return okClicked; 00323 } 00324 00325 TransportJob *TransportManager::createTransportJob( int transportId ) 00326 { 00327 Transport *t = transportById( transportId, false ); 00328 if ( !t ) { 00329 return 0; 00330 } 00331 t = t->clone(); // Jobs delete their transports. 00332 t->updatePasswordState(); 00333 switch ( t->type() ) { 00334 case Transport::EnumType::SMTP: 00335 return new SmtpJob( t, this ); 00336 case Transport::EnumType::Sendmail: 00337 return new SendmailJob( t, this ); 00338 case Transport::EnumType::Akonadi: 00339 return new ResourceSendJob( t, this ); 00340 } 00341 Q_ASSERT( false ); 00342 return 0; 00343 } 00344 00345 TransportJob *TransportManager::createTransportJob( const QString &transport ) 00346 { 00347 bool ok = false; 00348 Transport *t = 0; 00349 00350 int transportId = transport.toInt( &ok ); 00351 if ( ok ) { 00352 t = transportById( transportId ); 00353 } 00354 00355 if ( !t ) { 00356 t = transportByName( transport, false ); 00357 } 00358 00359 if ( t ) { 00360 return createTransportJob( t->id() ); 00361 } 00362 00363 return 0; 00364 } 00365 00366 bool TransportManager::isEmpty() const 00367 { 00368 return d->transports.isEmpty(); 00369 } 00370 00371 QList<int> TransportManager::transportIds() const 00372 { 00373 QList<int> rv; 00374 foreach ( Transport *t, d->transports ) { 00375 rv << t->id(); 00376 } 00377 return rv; 00378 } 00379 00380 QStringList TransportManager::transportNames() const 00381 { 00382 QStringList rv; 00383 foreach ( Transport *t, d->transports ) { 00384 rv << t->name(); 00385 } 00386 return rv; 00387 } 00388 00389 QString TransportManager::defaultTransportName() const 00390 { 00391 Transport *t = transportById( d->defaultTransportId, false ); 00392 if ( t ) { 00393 return t->name(); 00394 } 00395 return QString(); 00396 } 00397 00398 int TransportManager::defaultTransportId() const 00399 { 00400 return d->defaultTransportId; 00401 } 00402 00403 void TransportManager::setDefaultTransport( int id ) 00404 { 00405 if ( id == d->defaultTransportId || !transportById( id, false ) ) { 00406 return; 00407 } 00408 d->defaultTransportId = id; 00409 d->writeConfig(); 00410 } 00411 00412 void TransportManager::removeTransport( int id ) 00413 { 00414 Transport *t = transportById( id, false ); 00415 if ( !t ) { 00416 return; 00417 } 00418 emit transportRemoved( t->id(), t->name() ); 00419 00420 // Kill the resource, if Akonadi-type transport. 00421 if( t->type() == Transport::EnumType::Akonadi ) { 00422 using namespace Akonadi; 00423 const AgentInstance instance = AgentManager::self()->instance( t->host() ); 00424 if( !instance.isValid() ) { 00425 kWarning() << "Could not find resource instance."; 00426 } 00427 AgentManager::self()->removeInstance( instance ); 00428 } 00429 00430 d->transports.removeAll( t ); 00431 d->validateDefault(); 00432 QString group = t->currentGroup(); 00433 delete t; 00434 d->config->deleteGroup( group ); 00435 d->writeConfig(); 00436 00437 } 00438 00439 void TransportManagerPrivate::readConfig() 00440 { 00441 QList<Transport *> oldTransports = transports; 00442 transports.clear(); 00443 00444 QRegExp re( QLatin1String( "^Transport (.+)$" ) ); 00445 QStringList groups = config->groupList().filter( re ); 00446 foreach ( const QString &s, groups ) { 00447 re.indexIn( s ); 00448 Transport *t = 0; 00449 00450 // see if we happen to have that one already 00451 foreach ( Transport *old, oldTransports ) { 00452 if ( old->currentGroup() == QLatin1String( "Transport " ) + re.cap( 1 ) ) { 00453 kDebug() << "reloading existing transport:" << s; 00454 t = old; 00455 t->d->passwordNeedsUpdateFromWallet = true; 00456 t->readConfig(); 00457 oldTransports.removeAll( old ); 00458 break; 00459 } 00460 } 00461 00462 if ( !t ) { 00463 t = new Transport( re.cap( 1 ) ); 00464 } 00465 if ( t->id() <= 0 ) { 00466 t->setId( createId() ); 00467 t->writeConfig(); 00468 } 00469 transports.append( t ); 00470 } 00471 00472 qDeleteAll( oldTransports ); 00473 oldTransports.clear(); 00474 00475 // read default transport 00476 KConfigGroup group( config, "General" ); 00477 defaultTransportId = group.readEntry( "default-transport", 0 ); 00478 if ( defaultTransportId == 0 ) { 00479 // migrated default transport contains the name instead 00480 QString name = group.readEntry( "default-transport", QString() ); 00481 if ( !name.isEmpty() ) { 00482 Transport *t = q->transportByName( name, false ); 00483 if ( t ) { 00484 defaultTransportId = t->id(); 00485 writeConfig(); 00486 } 00487 } 00488 } 00489 validateDefault(); 00490 migrateToWallet(); 00491 } 00492 00493 void TransportManagerPrivate::writeConfig() 00494 { 00495 KConfigGroup group( config, "General" ); 00496 group.writeEntry( "default-transport", defaultTransportId ); 00497 config->sync(); 00498 q->emitChangesCommitted(); 00499 } 00500 00501 void TransportManagerPrivate::fillTypes() 00502 { 00503 Q_ASSERT( types.isEmpty() ); 00504 00505 // SMTP. 00506 { 00507 TransportType type; 00508 type.d->mType = Transport::EnumType::SMTP; 00509 type.d->mName = i18nc( "@option SMTP transport", "SMTP" ); 00510 type.d->mDescription = i18n( "An SMTP server on the Internet" ); 00511 types << type; 00512 } 00513 00514 // Sendmail. 00515 { 00516 TransportType type; 00517 type.d->mType = Transport::EnumType::Sendmail; 00518 type.d->mName = i18nc( "@option sendmail transport", "Sendmail" ); 00519 type.d->mDescription = i18n( "A local sendmail installation" ); 00520 types << type; 00521 } 00522 00523 // All Akonadi resources with MailTransport capability. 00524 { 00525 using namespace Akonadi; 00526 foreach ( const AgentType &atype, AgentManager::self()->types() ) { 00527 // TODO probably the string "MailTransport" should be #defined somewhere 00528 // and used like that in the resources (?) 00529 if( atype.capabilities().contains( QLatin1String( "MailTransport" ) ) ) { 00530 TransportType type; 00531 type.d->mType = Transport::EnumType::Akonadi; 00532 type.d->mAgentType = atype; 00533 type.d->mName = atype.name(); 00534 type.d->mDescription = atype.description(); 00535 types << type; 00536 kDebug() << "Found Akonadi type" << atype.name(); 00537 } 00538 } 00539 00540 // Watch for appearing and disappearing types. 00541 QObject::connect( AgentManager::self(), SIGNAL(typeAdded(Akonadi::AgentType)), 00542 q, SLOT(agentTypeAdded(Akonadi::AgentType)) ); 00543 QObject::connect( AgentManager::self(), SIGNAL(typeRemoved(Akonadi::AgentType)), 00544 q, SLOT(agentTypeRemoved(Akonadi::AgentType)) ); 00545 } 00546 00547 kDebug() << "Have SMTP, Sendmail, and" << types.count() - 2 << "Akonadi types."; 00548 } 00549 00550 void TransportManager::emitChangesCommitted() 00551 { 00552 d->myOwnChange = true; // prevent us from reading our changes again 00553 d->appliedChange = false; // but we have to read them at least once 00554 emit transportsChanged(); 00555 emit changesCommitted(); 00556 } 00557 00558 void TransportManagerPrivate::slotTransportsChanged() 00559 { 00560 if ( myOwnChange && appliedChange ) { 00561 myOwnChange = false; 00562 appliedChange = false; 00563 return; 00564 } 00565 00566 kDebug(); 00567 config->reparseConfiguration(); 00568 // FIXME: this deletes existing transport objects! 00569 readConfig(); 00570 appliedChange = true; // to prevent recursion 00571 emit q->transportsChanged(); 00572 } 00573 00574 int TransportManagerPrivate::createId() const 00575 { 00576 QList<int> usedIds; 00577 foreach ( Transport *t, transports ) { 00578 usedIds << t->id(); 00579 } 00580 usedIds << 0; // 0 is default for unknown 00581 int newId; 00582 do { 00583 newId = KRandom::random(); 00584 } while ( usedIds.contains( newId ) ); 00585 return newId; 00586 } 00587 00588 KWallet::Wallet * TransportManager::wallet() 00589 { 00590 if ( d->wallet && d->wallet->isOpen() ) { 00591 return d->wallet; 00592 } 00593 00594 if ( !Wallet::isEnabled() || d->walletOpenFailed ) { 00595 return 0; 00596 } 00597 00598 WId window = 0; 00599 if ( qApp->activeWindow() ) { 00600 window = qApp->activeWindow()->winId(); 00601 } else if ( !QApplication::topLevelWidgets().isEmpty() ) { 00602 window = qApp->topLevelWidgets().first()->winId(); 00603 } 00604 00605 delete d->wallet; 00606 d->wallet = Wallet::openWallet( Wallet::NetworkWallet(), window ); 00607 00608 if ( !d->wallet ) { 00609 d->walletOpenFailed = true; 00610 return 0; 00611 } 00612 00613 d->prepareWallet(); 00614 return d->wallet; 00615 } 00616 00617 void TransportManagerPrivate::prepareWallet() 00618 { 00619 if ( !wallet ) { 00620 return; 00621 } 00622 if ( !wallet->hasFolder( WALLET_FOLDER ) ) { 00623 wallet->createFolder( WALLET_FOLDER ); 00624 } 00625 wallet->setFolder( WALLET_FOLDER ); 00626 } 00627 00628 void TransportManager::loadPasswords() 00629 { 00630 foreach ( Transport *t, d->transports ) { 00631 t->readPassword(); 00632 } 00633 00634 // flush the wallet queue 00635 const QList<TransportJob*> copy = d->walletQueue; 00636 d->walletQueue.clear(); 00637 foreach ( TransportJob *job, copy ) { 00638 job->start(); 00639 } 00640 00641 emit passwordsChanged(); 00642 } 00643 00644 void TransportManager::loadPasswordsAsync() 00645 { 00646 kDebug(); 00647 00648 // check if there is anything to do at all 00649 bool found = false; 00650 foreach ( Transport *t, d->transports ) { 00651 if ( !t->isComplete() ) { 00652 found = true; 00653 break; 00654 } 00655 } 00656 if ( !found ) { 00657 return; 00658 } 00659 00660 // async wallet opening 00661 if ( !d->wallet && !d->walletOpenFailed ) { 00662 WId window = 0; 00663 if ( qApp->activeWindow() ) { 00664 window = qApp->activeWindow()->winId(); 00665 } else if ( !QApplication::topLevelWidgets().isEmpty() ) { 00666 window = qApp->topLevelWidgets().first()->winId(); 00667 } 00668 00669 d->wallet = Wallet::openWallet( Wallet::NetworkWallet(), window, 00670 Wallet::Asynchronous ); 00671 if ( d->wallet ) { 00672 connect( d->wallet, SIGNAL(walletOpened(bool)), SLOT(slotWalletOpened(bool)) ); 00673 d->walletAsyncOpen = true; 00674 } else { 00675 d->walletOpenFailed = true; 00676 loadPasswords(); 00677 } 00678 return; 00679 } 00680 if ( d->wallet && !d->walletAsyncOpen ) { 00681 loadPasswords(); 00682 } 00683 } 00684 00685 void TransportManagerPrivate::slotWalletOpened( bool success ) 00686 { 00687 kDebug(); 00688 walletAsyncOpen = false; 00689 if ( !success ) { 00690 walletOpenFailed = true; 00691 delete wallet; 00692 wallet = 0; 00693 } else { 00694 prepareWallet(); 00695 } 00696 q->loadPasswords(); 00697 } 00698 00699 void TransportManagerPrivate::validateDefault() 00700 { 00701 if ( !q->transportById( defaultTransportId, false ) ) { 00702 if ( q->isEmpty() ) { 00703 defaultTransportId = -1; 00704 } else { 00705 defaultTransportId = transports.first()->id(); 00706 writeConfig(); 00707 } 00708 } 00709 } 00710 00711 void TransportManagerPrivate::migrateToWallet() 00712 { 00713 // check if we tried this already 00714 static bool firstRun = true; 00715 if ( !firstRun ) { 00716 return; 00717 } 00718 firstRun = false; 00719 00720 // check if we are the main instance 00721 if ( !isMainInstance ) { 00722 return; 00723 } 00724 00725 // check if migration is needed 00726 QStringList names; 00727 foreach ( Transport *t, transports ) { 00728 if ( t->needsWalletMigration() ) { 00729 names << t->name(); 00730 } 00731 } 00732 if ( names.isEmpty() ) { 00733 return; 00734 } 00735 00736 // ask user if he wants to migrate 00737 int result = KMessageBox::questionYesNoList( 00738 0, 00739 i18n( "The following mail transports store their passwords in an " 00740 "unencrypted configuration file.\nFor security reasons, " 00741 "please consider migrating these passwords to KWallet, the " 00742 "KDE Wallet management tool,\nwhich stores sensitive data " 00743 "for you in a strongly encrypted file.\n" 00744 "Do you want to migrate your passwords to KWallet?" ), 00745 names, i18n( "Question" ), 00746 KGuiItem( i18n( "Migrate" ) ), KGuiItem( i18n( "Keep" ) ), 00747 QString::fromAscii( "WalletMigrate" ) ); 00748 if ( result != KMessageBox::Yes ) { 00749 return; 00750 } 00751 00752 // perform migration 00753 foreach ( Transport *t, transports ) { 00754 if ( t->needsWalletMigration() ) { 00755 t->migrateToWallet(); 00756 } 00757 } 00758 } 00759 00760 void TransportManagerPrivate::dbusServiceUnregistered() 00761 { 00762 QDBusConnection::sessionBus().registerService( DBUS_SERVICE_NAME ); 00763 } 00764 00765 void TransportManagerPrivate::agentTypeAdded( const Akonadi::AgentType &atype ) 00766 { 00767 using namespace Akonadi; 00768 if( atype.capabilities().contains( QLatin1String( "MailTransport" ) ) ) { 00769 TransportType type; 00770 type.d->mType = Transport::EnumType::Akonadi; 00771 type.d->mAgentType = atype; 00772 type.d->mName = atype.name(); 00773 type.d->mDescription = atype.description(); 00774 types << type; 00775 kDebug() << "Added new Akonadi type" << atype.name(); 00776 } 00777 } 00778 00779 void TransportManagerPrivate::agentTypeRemoved( const Akonadi::AgentType &atype ) 00780 { 00781 using namespace Akonadi; 00782 foreach ( const TransportType &type, types ) { 00783 if( type.type() == Transport::EnumType::Akonadi && 00784 type.agentType() == atype ) { 00785 types.removeAll( type ); 00786 kDebug() << "Removed Akonadi type" << atype.name(); 00787 } 00788 } 00789 } 00790 00791 void TransportManagerPrivate::jobResult( KJob *job ) 00792 { 00793 walletQueue.removeAll( static_cast<TransportJob*>( job ) ); 00794 } 00795 00796 #include "transportmanager.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:09:04 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:09:04 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.