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

Skip menu "kdepimlibs-4.14.10 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