• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.11.3 API Reference
  • KDE Home
  • Contact Us
 

mailtransport

  • mailtransport
transportmanager.cpp
1 /*
2  Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "transportmanager.h"
21 #include "resourcesendjob_p.h"
22 #include "mailtransport_defs.h"
23 #include "sendmailjob.h"
24 #include "smtpjob.h"
25 #include "transport.h"
26 #include "transport_p.h"
27 #include "transportjob.h"
28 #include "transporttype.h"
29 #include "transporttype_p.h"
30 #include "addtransportdialog.h"
31 #include "transportconfigdialog.h"
32 #include "transportconfigwidget.h"
33 #include "sendmailconfigwidget.h"
34 #include "smtpconfigwidget.h"
35 
36 #include <QApplication>
37 #include <QtDBus/QDBusConnection>
38 #include <QtDBus/QDBusConnectionInterface>
39 #include <QtDBus/QDBusServiceWatcher>
40 #include <QPointer>
41 #include <QRegExp>
42 #include <QStringList>
43 
44 #include <KConfig>
45 #include <KConfigGroup>
46 #include <KDebug>
47 #include <KEMailSettings>
48 #include <KLocale>
49 #include <KLocalizedString>
50 #include <KMessageBox>
51 #include <KRandom>
52 #include <KGlobal>
53 #include <KUrl>
54 #include <KWallet/Wallet>
55 
56 #include <akonadi/agentinstance.h>
57 #include <akonadi/agentmanager.h>
58 
59 using namespace MailTransport;
60 using namespace KWallet;
61 
62 namespace MailTransport {
67 class TransportManagerPrivate
68 {
69  public:
70  TransportManagerPrivate( TransportManager *parent )
71  : q( parent )
72  {
73  }
74 
75  ~TransportManagerPrivate() {
76  delete config;
77  qDeleteAll( transports );
78  }
79 
80  KConfig *config;
81  QList<Transport *> transports;
82  TransportType::List types;
83  bool myOwnChange;
84  bool appliedChange;
85  KWallet::Wallet *wallet;
86  bool walletOpenFailed;
87  bool walletAsyncOpen;
88  int defaultTransportId;
89  bool isMainInstance;
90  QList<TransportJob *> walletQueue;
91  TransportManager *q;
92 
93  void readConfig();
94  void writeConfig();
95  void fillTypes();
96  int createId() const;
97  void prepareWallet();
98  void validateDefault();
99  void migrateToWallet();
100 
101  // Slots
102  void slotTransportsChanged();
103  void slotWalletOpened( bool success );
104  void dbusServiceUnregistered();
105  void agentTypeAdded( const Akonadi::AgentType &atype );
106  void agentTypeRemoved( const Akonadi::AgentType &atype );
107  void jobResult( KJob *job );
108 };
109 
110 }
111 
112 class StaticTransportManager : public TransportManager
113 {
114  public:
115  StaticTransportManager() : TransportManager() {}
116 };
117 
118 StaticTransportManager *sSelf = 0;
119 
120 static void destroyStaticTransportManager() {
121  delete sSelf;
122 }
123 
124 TransportManager::TransportManager()
125  : QObject(), d( new TransportManagerPrivate( this ) )
126 {
127  KGlobal::locale()->insertCatalog( QLatin1String( "libmailtransport" ) );
128  KGlobal::locale()->insertCatalog( QLatin1String( "libakonadi-kmime" ) );
129  qAddPostRoutine( destroyStaticTransportManager );
130  d->myOwnChange = false;
131  d->appliedChange = false;
132  d->wallet = 0;
133  d->walletOpenFailed = false;
134  d->walletAsyncOpen = false;
135  d->defaultTransportId = -1;
136  d->config = new KConfig( QLatin1String( "mailtransports" ) );
137 
138  QDBusConnection::sessionBus().registerObject( DBUS_OBJECT_PATH, this,
139  QDBusConnection::ExportScriptableSlots |
140  QDBusConnection::ExportScriptableSignals );
141 
142  QDBusServiceWatcher *watcher =
143  new QDBusServiceWatcher( DBUS_SERVICE_NAME, QDBusConnection::sessionBus(),
144  QDBusServiceWatcher::WatchForUnregistration, this );
145  connect( watcher, SIGNAL(serviceUnregistered(QString)),
146  SLOT(dbusServiceUnregistered()) );
147 
148  QDBusConnection::sessionBus().connect( QString(), QString(),
149  DBUS_INTERFACE_NAME, DBUS_CHANGE_SIGNAL,
150  this, SLOT(slotTransportsChanged()) );
151 
152  d->isMainInstance = QDBusConnection::sessionBus().registerService( DBUS_SERVICE_NAME );
153 
154  d->fillTypes();
155 }
156 
157 TransportManager::~TransportManager()
158 {
159  qRemovePostRoutine( destroyStaticTransportManager );
160  delete d;
161 }
162 
163 TransportManager *TransportManager::self()
164 {
165  if ( !sSelf ) {
166  sSelf = new StaticTransportManager;
167  sSelf->d->readConfig();
168  }
169  return sSelf;
170 }
171 
172 Transport *TransportManager::transportById( int id, bool def ) const
173 {
174  foreach ( Transport *t, d->transports ) {
175  if ( t->id() == id ) {
176  return t;
177  }
178  }
179 
180  if ( def || ( id == 0 && d->defaultTransportId != id ) ) {
181  return transportById( d->defaultTransportId, false );
182  }
183  return 0;
184 }
185 
186 Transport *TransportManager::transportByName( const QString &name, bool def ) const
187 {
188  foreach ( Transport *t, d->transports ) {
189  if ( t->name() == name ) {
190  return t;
191  }
192  }
193  if ( def ) {
194  return transportById( 0, false );
195  }
196  return 0;
197 }
198 
199 QList< Transport * > TransportManager::transports() const
200 {
201  return d->transports;
202 }
203 
204 TransportType::List TransportManager::types() const
205 {
206  return d->types;
207 }
208 
209 Transport *TransportManager::createTransport() const
210 {
211  int id = d->createId();
212  Transport *t = new Transport( QString::number( id ) );
213  t->setId( id );
214  return t;
215 }
216 
217 void TransportManager::addTransport( Transport *transport )
218 {
219  if ( d->transports.contains( transport ) ) {
220  kDebug() << "Already have this transport.";
221  return;
222  }
223 
224  kDebug() << "Added transport" << transport;
225  d->transports.append( transport );
226  d->validateDefault();
227  emitChangesCommitted();
228 }
229 
230 void TransportManager::schedule( TransportJob *job )
231 {
232  connect( job, SIGNAL(result(KJob*)), SLOT(jobResult(KJob*)) );
233 
234  // check if the job is waiting for the wallet
235  if ( !job->transport()->isComplete() ) {
236  kDebug() << "job waits for wallet:" << job;
237  d->walletQueue << job;
238  loadPasswordsAsync();
239  return;
240  }
241 
242  job->start();
243 }
244 
245 void TransportManager::createDefaultTransport()
246 {
247  KEMailSettings kes;
248  Transport *t = createTransport();
249  t->setName( i18n( "Default Transport" ) );
250  t->setHost( kes.getSetting( KEMailSettings::OutServer ) );
251  if ( t->isValid() ) {
252  t->writeConfig();
253  addTransport( t );
254  } else {
255  kWarning() << "KEMailSettings does not contain a valid transport.";
256  }
257 }
258 
259 bool TransportManager::showTransportCreationDialog( QWidget *parent,
260  ShowCondition showCondition )
261 {
262  if ( showCondition == IfNoTransportExists ) {
263  if ( !isEmpty() ) {
264  return true;
265  }
266 
267  const int response = KMessageBox::messageBox( parent,
268  KMessageBox::WarningContinueCancel,
269  i18n( "You must create an outgoing account before sending." ),
270  i18n( "Create Account Now?" ),
271  KGuiItem( i18n( "Create Account Now" ) ) );
272  if ( response != KMessageBox::Continue ) {
273  return false;
274  }
275  }
276 
277  QPointer<AddTransportDialog> dialog = new AddTransportDialog( parent );
278  const bool accepted = ( dialog->exec() == QDialog::Accepted );
279  delete dialog;
280  return accepted;
281 }
282 
283 bool TransportManager::configureTransport( Transport *transport, QWidget *parent )
284 {
285  if ( transport->type() == Transport::EnumType::Akonadi ) {
286  using namespace Akonadi;
287  AgentInstance instance = AgentManager::self()->instance( transport->host() );
288  if ( !instance.isValid() ) {
289  kWarning() << "Invalid resource instance" << transport->host();
290  }
291  instance.configure( parent ); // Async...
292  transport->writeConfig();
293  return true; // No way to know here if the user cancelled or not.
294  }
295 
296  QPointer<TransportConfigDialog> transportConfigDialog =
297  new TransportConfigDialog( transport, parent );
298  transportConfigDialog->setCaption( i18n( "Configure account" ) );
299  bool okClicked = ( transportConfigDialog->exec() == QDialog::Accepted );
300  delete transportConfigDialog;
301  return okClicked;
302 }
303 
304 TransportJob *TransportManager::createTransportJob( int transportId )
305 {
306  Transport *t = transportById( transportId, false );
307  if ( !t ) {
308  return 0;
309  }
310  t = t->clone(); // Jobs delete their transports.
311  t->updatePasswordState();
312  switch ( t->type() ) {
313  case Transport::EnumType::SMTP:
314  return new SmtpJob( t, this );
315  case Transport::EnumType::Sendmail:
316  return new SendmailJob( t, this );
317  case Transport::EnumType::Akonadi:
318  return new ResourceSendJob( t, this );
319  }
320  Q_ASSERT( false );
321  return 0;
322 }
323 
324 TransportJob *TransportManager::createTransportJob( const QString &transport )
325 {
326  bool ok = false;
327  Transport *t = 0;
328 
329  int transportId = transport.toInt( &ok );
330  if ( ok ) {
331  t = transportById( transportId );
332  }
333 
334  if ( !t ) {
335  t = transportByName( transport, false );
336  }
337 
338  if ( t ) {
339  return createTransportJob( t->id() );
340  }
341 
342  return 0;
343 }
344 
345 bool TransportManager::isEmpty() const
346 {
347  return d->transports.isEmpty();
348 }
349 
350 QList<int> TransportManager::transportIds() const
351 {
352  QList<int> rv;
353  foreach ( Transport *t, d->transports ) {
354  rv << t->id();
355  }
356  return rv;
357 }
358 
359 QStringList TransportManager::transportNames() const
360 {
361  QStringList rv;
362  foreach ( Transport *t, d->transports ) {
363  rv << t->name();
364  }
365  return rv;
366 }
367 
368 QString TransportManager::defaultTransportName() const
369 {
370  Transport *t = transportById( d->defaultTransportId, false );
371  if ( t ) {
372  return t->name();
373  }
374  return QString();
375 }
376 
377 int TransportManager::defaultTransportId() const
378 {
379  return d->defaultTransportId;
380 }
381 
382 void TransportManager::setDefaultTransport( int id )
383 {
384  if ( id == d->defaultTransportId || !transportById( id, false ) ) {
385  return;
386  }
387  d->defaultTransportId = id;
388  d->writeConfig();
389 }
390 
391 void TransportManager::removeTransport( int id )
392 {
393  Transport *t = transportById( id, false );
394  if ( !t ) {
395  return;
396  }
397  emit transportRemoved( t->id(), t->name() );
398 
399  // Kill the resource, if Akonadi-type transport.
400  if ( t->type() == Transport::EnumType::Akonadi ) {
401  using namespace Akonadi;
402  const AgentInstance instance = AgentManager::self()->instance( t->host() );
403  if ( !instance.isValid() ) {
404  kWarning() << "Could not find resource instance.";
405  }
406  AgentManager::self()->removeInstance( instance );
407  }
408 
409  d->transports.removeAll( t );
410  d->validateDefault();
411  QString group = t->currentGroup();
412  delete t;
413  d->config->deleteGroup( group );
414  d->writeConfig();
415 
416 }
417 
418 void TransportManagerPrivate::readConfig()
419 {
420  QList<Transport *> oldTransports = transports;
421  transports.clear();
422 
423  QRegExp re( QLatin1String( "^Transport (.+)$" ) );
424  QStringList groups = config->groupList().filter( re );
425  foreach ( const QString &s, groups ) {
426  re.indexIn( s );
427  Transport *t = 0;
428 
429  // see if we happen to have that one already
430  foreach ( Transport *old, oldTransports ) {
431  if ( old->currentGroup() == QLatin1String( "Transport " ) + re.cap( 1 ) ) {
432  kDebug() << "reloading existing transport:" << s;
433  t = old;
434  t->d->passwordNeedsUpdateFromWallet = true;
435  t->readConfig();
436  oldTransports.removeAll( old );
437  break;
438  }
439  }
440 
441  if ( !t ) {
442  t = new Transport( re.cap( 1 ) );
443  }
444  if ( t->id() <= 0 ) {
445  t->setId( createId() );
446  t->writeConfig();
447  }
448  transports.append( t );
449  }
450 
451  qDeleteAll( oldTransports );
452  oldTransports.clear();
453 
454  // read default transport
455  KConfigGroup group( config, "General" );
456  defaultTransportId = group.readEntry( "default-transport", 0 );
457  if ( defaultTransportId == 0 ) {
458  // migrated default transport contains the name instead
459  QString name = group.readEntry( "default-transport", QString() );
460  if ( !name.isEmpty() ) {
461  Transport *t = q->transportByName( name, false );
462  if ( t ) {
463  defaultTransportId = t->id();
464  writeConfig();
465  }
466  }
467  }
468  validateDefault();
469  migrateToWallet();
470  q->loadPasswordsAsync();
471 }
472 
473 void TransportManagerPrivate::writeConfig()
474 {
475  KConfigGroup group( config, "General" );
476  group.writeEntry( "default-transport", defaultTransportId );
477  config->sync();
478  q->emitChangesCommitted();
479 }
480 
481 void TransportManagerPrivate::fillTypes()
482 {
483  Q_ASSERT( types.isEmpty() );
484 
485  // SMTP.
486  {
487  TransportType type;
488  type.d->mType = Transport::EnumType::SMTP;
489  type.d->mName = i18nc( "@option SMTP transport", "SMTP" );
490  type.d->mDescription = i18n( "An SMTP server on the Internet" );
491  types << type;
492  }
493 
494  // Sendmail.
495  {
496  TransportType type;
497  type.d->mType = Transport::EnumType::Sendmail;
498  type.d->mName = i18nc( "@option sendmail transport", "Sendmail" );
499  type.d->mDescription = i18n( "A local sendmail installation" );
500  types << type;
501  }
502 
503  // All Akonadi resources with MailTransport capability.
504  {
505  using namespace Akonadi;
506  foreach ( const AgentType &atype, AgentManager::self()->types() ) {
507  // TODO probably the string "MailTransport" should be #defined somewhere
508  // and used like that in the resources (?)
509  if ( atype.capabilities().contains( QLatin1String( "MailTransport" ) ) ) {
510  TransportType type;
511  type.d->mType = Transport::EnumType::Akonadi;
512  type.d->mAgentType = atype;
513  type.d->mName = atype.name();
514  type.d->mDescription = atype.description();
515  types << type;
516  kDebug() << "Found Akonadi type" << atype.name();
517  }
518  }
519 
520  // Watch for appearing and disappearing types.
521  QObject::connect( AgentManager::self(), SIGNAL(typeAdded(Akonadi::AgentType)),
522  q, SLOT(agentTypeAdded(Akonadi::AgentType)) );
523  QObject::connect( AgentManager::self(), SIGNAL(typeRemoved(Akonadi::AgentType)),
524  q, SLOT(agentTypeRemoved(Akonadi::AgentType)) );
525  }
526 
527  kDebug() << "Have SMTP, Sendmail, and" << types.count() - 2 << "Akonadi types.";
528 }
529 
530 void TransportManager::emitChangesCommitted()
531 {
532  d->myOwnChange = true; // prevent us from reading our changes again
533  d->appliedChange = false; // but we have to read them at least once
534  emit transportsChanged();
535  emit changesCommitted();
536 }
537 
538 void TransportManagerPrivate::slotTransportsChanged()
539 {
540  if ( myOwnChange && appliedChange ) {
541  myOwnChange = false;
542  appliedChange = false;
543  return;
544  }
545 
546  kDebug();
547  config->reparseConfiguration();
548  // FIXME: this deletes existing transport objects!
549  readConfig();
550  appliedChange = true; // to prevent recursion
551  emit q->transportsChanged();
552 }
553 
554 int TransportManagerPrivate::createId() const
555 {
556  QList<int> usedIds;
557  foreach ( Transport *t, transports ) {
558  usedIds << t->id();
559  }
560  usedIds << 0; // 0 is default for unknown
561  int newId;
562  do {
563  newId = KRandom::random();
564  } while ( usedIds.contains( newId ) );
565  return newId;
566 }
567 
568 KWallet::Wallet * TransportManager::wallet()
569 {
570  if ( d->wallet && d->wallet->isOpen() ) {
571  return d->wallet;
572  }
573 
574  if ( !Wallet::isEnabled() || d->walletOpenFailed ) {
575  return 0;
576  }
577 
578  WId window = 0;
579  if ( qApp->activeWindow() ) {
580  window = qApp->activeWindow()->winId();
581  } else if ( !QApplication::topLevelWidgets().isEmpty() ) {
582  window = qApp->topLevelWidgets().first()->winId();
583  }
584 
585  delete d->wallet;
586  d->wallet = Wallet::openWallet( Wallet::NetworkWallet(), window );
587 
588  if ( !d->wallet ) {
589  d->walletOpenFailed = true;
590  return 0;
591  }
592 
593  d->prepareWallet();
594  return d->wallet;
595 }
596 
597 void TransportManagerPrivate::prepareWallet()
598 {
599  if ( !wallet ) {
600  return;
601  }
602  if ( !wallet->hasFolder( WALLET_FOLDER ) ) {
603  wallet->createFolder( WALLET_FOLDER );
604  }
605  wallet->setFolder( WALLET_FOLDER );
606 }
607 
608 void TransportManager::loadPasswords()
609 {
610  foreach ( Transport *t, d->transports ) {
611  t->readPassword();
612  }
613 
614  // flush the wallet queue
615  const QList<TransportJob*> copy = d->walletQueue;
616  d->walletQueue.clear();
617  foreach ( TransportJob *job, copy ) {
618  job->start();
619  }
620 
621  emit passwordsChanged();
622 }
623 
624 void TransportManager::loadPasswordsAsync()
625 {
626  kDebug();
627 
628  // check if there is anything to do at all
629  bool found = false;
630  foreach ( Transport *t, d->transports ) {
631  if ( !t->isComplete() ) {
632  found = true;
633  break;
634  }
635  }
636  if ( !found ) {
637  return;
638  }
639 
640  // async wallet opening
641  if ( !d->wallet && !d->walletOpenFailed ) {
642  WId window = 0;
643  if ( qApp->activeWindow() ) {
644  window = qApp->activeWindow()->winId();
645  } else if ( !QApplication::topLevelWidgets().isEmpty() ) {
646  window = qApp->topLevelWidgets().first()->winId();
647  }
648 
649  d->wallet = Wallet::openWallet( Wallet::NetworkWallet(), window,
650  Wallet::Asynchronous );
651  if ( d->wallet ) {
652  connect( d->wallet, SIGNAL(walletOpened(bool)), SLOT(slotWalletOpened(bool)) );
653  d->walletAsyncOpen = true;
654  } else {
655  d->walletOpenFailed = true;
656  loadPasswords();
657  }
658  return;
659  }
660  if ( d->wallet && !d->walletAsyncOpen ) {
661  loadPasswords();
662  }
663 }
664 
665 void TransportManagerPrivate::slotWalletOpened( bool success )
666 {
667  kDebug();
668  walletAsyncOpen = false;
669  if ( !success ) {
670  walletOpenFailed = true;
671  delete wallet;
672  wallet = 0;
673  } else {
674  prepareWallet();
675  }
676  q->loadPasswords();
677 }
678 
679 void TransportManagerPrivate::validateDefault()
680 {
681  if ( !q->transportById( defaultTransportId, false ) ) {
682  if ( q->isEmpty() ) {
683  defaultTransportId = -1;
684  } else {
685  defaultTransportId = transports.first()->id();
686  writeConfig();
687  }
688  }
689 }
690 
691 void TransportManagerPrivate::migrateToWallet()
692 {
693  // check if we tried this already
694  static bool firstRun = true;
695  if ( !firstRun ) {
696  return;
697  }
698  firstRun = false;
699 
700  // check if we are the main instance
701  if ( !isMainInstance ) {
702  return;
703  }
704 
705  // check if migration is needed
706  QStringList names;
707  foreach ( Transport *t, transports ) {
708  if ( t->needsWalletMigration() ) {
709  names << t->name();
710  }
711  }
712  if ( names.isEmpty() ) {
713  return;
714  }
715 
716  // ask user if he wants to migrate
717  int result = KMessageBox::questionYesNoList(
718  0,
719  i18n( "The following mail transports store their passwords in an "
720  "unencrypted configuration file.\nFor security reasons, "
721  "please consider migrating these passwords to KWallet, the "
722  "KDE Wallet management tool,\nwhich stores sensitive data "
723  "for you in a strongly encrypted file.\n"
724  "Do you want to migrate your passwords to KWallet?" ),
725  names, i18n( "Question" ),
726  KGuiItem( i18n( "Migrate" ) ), KGuiItem( i18n( "Keep" ) ),
727  QString::fromLatin1( "WalletMigrate" ) );
728  if ( result != KMessageBox::Yes ) {
729  return;
730  }
731 
732  // perform migration
733  foreach ( Transport *t, transports ) {
734  if ( t->needsWalletMigration() ) {
735  t->migrateToWallet();
736  }
737  }
738 }
739 
740 void TransportManagerPrivate::dbusServiceUnregistered()
741 {
742  QDBusConnection::sessionBus().registerService( DBUS_SERVICE_NAME );
743 }
744 
745 void TransportManagerPrivate::agentTypeAdded( const Akonadi::AgentType &atype )
746 {
747  using namespace Akonadi;
748  if ( atype.capabilities().contains( QLatin1String( "MailTransport" ) ) ) {
749  TransportType type;
750  type.d->mType = Transport::EnumType::Akonadi;
751  type.d->mAgentType = atype;
752  type.d->mName = atype.name();
753  type.d->mDescription = atype.description();
754  types << type;
755  kDebug() << "Added new Akonadi type" << atype.name();
756  }
757 }
758 
759 void TransportManagerPrivate::agentTypeRemoved( const Akonadi::AgentType &atype )
760 {
761  using namespace Akonadi;
762  foreach ( const TransportType &type, types ) {
763  if ( type.type() == Transport::EnumType::Akonadi &&
764  type.agentType() == atype ) {
765  types.removeAll( type );
766  kDebug() << "Removed Akonadi type" << atype.name();
767  }
768  }
769 }
770 
771 void TransportManagerPrivate::jobResult( KJob *job )
772 {
773  walletQueue.removeAll( static_cast<TransportJob*>( job ) );
774 }
775 
776 #include "moc_transportmanager.cpp"
MailTransport::TransportType
A representation of a transport type.
Definition: transporttype.h:51
MailTransport::TransportManager::transportRemoved
void transportRemoved(int id, const QString &name)
Emitted when a transport is deleted.
MailTransport::TransportType::name
QString name() const
Returns the i18n&#39;ed name of the transport type.
Definition: transporttype.cpp:76
MailTransport::Transport::migrateToWallet
void migrateToWallet()
Try to migrate the password from the config file to the wallet.
Definition: transport.cpp:322
MailTransport::TransportManager::loadPasswords
void loadPasswords()
Loads all passwords synchronously.
Definition: transportmanager.cpp:608
MailTransport::TransportManager::addTransport
void addTransport(Transport *transport)
Adds the given transport.
Definition: transportmanager.cpp:217
MailTransport::TransportManager::transportsChanged
Q_SCRIPTABLE void transportsChanged()
Emitted when transport settings have changed (by this or any other TransportManager instance)...
MailTransport::Transport::isComplete
bool isComplete() const
Returns true if all settings have been loaded.
Definition: transport.cpp:117
MailTransport::TransportManager::setDefaultTransport
Q_SCRIPTABLE void setDefaultTransport(int id)
Sets the default transport.
Definition: transportmanager.cpp:382
MailTransport::TransportManager::self
static TransportManager * self()
Returns the TransportManager instance.
Definition: transportmanager.cpp:163
MailTransport::TransportManager::wallet
KWallet::Wallet * wallet()
Returns a pointer to an open wallet if available, 0 otherwise.
Definition: transportmanager.cpp:568
MailTransport::TransportManager::~TransportManager
virtual ~TransportManager()
Destructor.
Definition: transportmanager.cpp:157
MailTransport::TransportManager::schedule
MAILTRANSPORT_DEPRECATED void schedule(TransportJob *job)
Executes the given transport job.
Definition: transportmanager.cpp:230
MailTransport::TransportManager
Central transport management interface.
Definition: transportmanager.h:55
MailTransport::TransportManager::defaultTransportId
Q_SCRIPTABLE int defaultTransportId() const
Returns the default transport identifier.
Definition: transportmanager.cpp:377
MailTransport::SmtpJob
Mail transport job for SMTP.
Definition: smtpjob.h:51
MailTransport::TransportManager::isEmpty
Q_SCRIPTABLE bool isEmpty() const
Returns true if there are no mail transports at all.
Definition: transportmanager.cpp:345
MailTransport::TransportManager::transportNames
Q_SCRIPTABLE QStringList transportNames() const
Returns a list of transport names.
Definition: transportmanager.cpp:359
MailTransport::TransportManager::ShowCondition
ShowCondition
Describes when to show the transport creation dialog.
Definition: transportmanager.h:168
MailTransport::TransportManager::createDefaultTransport
void createDefaultTransport()
Tries to create a transport based on KEMailSettings.
Definition: transportmanager.cpp:245
MailTransport::TransportManager::configureTransport
bool configureTransport(Transport *transport, QWidget *parent)
Open a configuration dialog for an existing transport.
Definition: transportmanager.cpp:283
MailTransport::TransportType::description
QString description() const
Returns a description of the transport type.
Definition: transporttype.cpp:81
MailTransport::TransportManager::defaultTransportName
Q_SCRIPTABLE QString defaultTransportName() const
Returns the default transport name.
Definition: transportmanager.cpp:368
MailTransport::TransportManager::showTransportCreationDialog
bool showTransportCreationDialog(QWidget *parent, ShowCondition showCondition=Always)
Shows a dialog for creating and configuring a new transport.
Definition: transportmanager.cpp:259
MailTransport::SendmailJob
Mail transport job for sendmail.
Definition: sendmailjob.h:40
MailTransport::ResourceSendJob
Mail transport job for an Akonadi resource-based transport.
Definition: resourcesendjob_p.h:44
MailTransport::TransportManager::createTransport
Transport * createTransport() const
Creates a new, empty Transport object.
Definition: transportmanager.cpp:209
MailTransport::Transport::needsWalletMigration
bool needsWalletMigration() const
Returns true if the password was not stored in the wallet.
Definition: transport.cpp:317
MailTransport::AddTransportDialog
Definition: addtransportdialog.h:39
MailTransport::TransportManager::passwordsChanged
void passwordsChanged()
Emitted when passwords have been loaded from the wallet.
MailTransport::Transport::isValid
bool isValid() const
Returns true if this transport is valid, ie.
Definition: transport.cpp:59
MailTransport::TransportJob
Abstract base class for all mail transport jobs.
Definition: transportjob.h:41
MailTransport::TransportManager::TransportManager
TransportManager()
Singleton class, the only instance resides in the static object sSelf.
Definition: transportmanager.cpp:124
MailTransport::TransportManager::transports
QList< Transport * > transports() const
Returns a list of all available transports.
Definition: transportmanager.cpp:199
MailTransport::TransportManager::createTransportJob
MAILTRANSPORT_DEPRECATED TransportJob * createTransportJob(int transportId)
Creates a mail transport job for the given transport identifier.
Definition: transportmanager.cpp:304
MailTransport::TransportManager::transportByName
Transport * transportByName(const QString &name, bool def=true) const
Returns the transport object with the given name.
Definition: transportmanager.cpp:186
MailTransport::TransportManager::changesCommitted
Q_SCRIPTABLE void changesCommitted()
Internal signal to synchronize all TransportManager instances.
MailTransport::Transport::clone
Transport * clone() const
Returns a deep copy of this Transport object which will no longer be automatically updated...
Definition: transport.cpp:335
mailtransport_defs.h
Internal file containing constant definitions etc.
MailTransport::TransportJob::start
virtual void start()
Starts this job.
Definition: transportjob.cpp:120
MailTransport::TransportManager::loadPasswordsAsync
void loadPasswordsAsync()
Tries to load passwords asynchronously from KWallet if needed.
Definition: transportmanager.cpp:624
MailTransport::TransportConfigDialog
Configuration dialog for a mail transport.
Definition: transportconfigdialog.h:40
MailTransport::TransportManager::IfNoTransportExists
Only show the transport creation dialog if no transport currently exists.
Definition: transportmanager.h:170
MailTransport::TransportManager::transportIds
Q_SCRIPTABLE QList< int > transportIds() const
Returns a list of transport identifiers.
Definition: transportmanager.cpp:350
MailTransport::TransportType::List
QList< TransportType > List
Describes a list of transport types.
Definition: transporttype.h:62
MailTransport::Transport::updatePasswordState
void updatePasswordState()
This function synchronizes the password of this transport with the password of the transport with the...
Definition: transport.cpp:101
MailTransport::TransportType::type
TransportBase::EnumType::type type() const
Definition: transporttype.cpp:71
MailTransport::Transport
Represents the settings of a specific mail transport.
Definition: transport.h:50
MailTransport::TransportManager::transportById
Transport * transportById(int id, bool def=true) const
Returns the Transport object with the given id.
Definition: transportmanager.cpp:172
MailTransport::TransportType::agentType
Akonadi::AgentType agentType() const
Returns the corresponding Akonadi::AgentType that this transport type represents. ...
Definition: transporttype.cpp:86
MailTransport::TransportManager::removeTransport
Q_SCRIPTABLE void removeTransport(int id)
Deletes the specified transport.
Definition: transportmanager.cpp:391
MailTransport::TransportManager::types
TransportType::List types() const
Returns a list of all available transport types.
Definition: transportmanager.cpp:204
MailTransport::TransportJob::transport
Transport * transport() const
Returns the Transport object containing the mail transport settings.
Definition: transportjob.cpp:79
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Nov 26 2013 09:03:01 by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailtransport

Skip menu "mailtransport"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.11.3 API Reference

Skip menu "kdepimlibs-4.11.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal