13 #include <kpimutils/kfileio.h>
21 #include "utils/stringutil.h"
22 #include "util/mailutil.h"
23 #include "mailcommon/pop3settings.h"
24 #include "mailcommon/folder/foldertreeview.h"
25 #include "mailcommon/filter/kmfilterdialog.h"
26 #include "mailcommon/mailcommonsettings_base.h"
27 #include "pimcommon/util/pimutil.h"
30 #include "kdepim-version.h"
33 #include <kpimidentities/identity.h>
34 #include <kpimidentities/identitymanager.h>
35 #include <mailtransport/transport.h>
36 #include <mailtransport/transportmanager.h>
37 #include <mailtransport/dispatcherinterface.h>
38 #include <akonadi/servermanager.h>
41 #include <kwindowsystem.h>
44 #include "job/jobscheduler.h"
46 #include "messagecore/settings/globalsettings.h"
47 #include "messagelist/core/settings.h"
48 #include "messagelist/messagelistutil.h"
49 #include "messageviewer/settings/globalsettings.h"
50 #include "messagecomposer/sender/akonadisender.h"
51 #include "settings/messagecomposersettings.h"
52 #include "messagecomposer/helper/messagehelper.h"
53 #include "messagecomposer/settings/messagecomposersettings.h"
54 #include "messagecomposer/autocorrection/composerautocorrection.h"
56 #include "templateparser/templateparser.h"
57 #include "templateparser/globalsettings_base.h"
58 #include "templateparser/templatesutil.h"
60 #include "foldercollection.h"
64 #include <kmessagebox.h>
65 #include <knotification.h>
67 #include <kstandarddirs.h>
69 #include <kpassivepopup.h>
70 #include <kapplication.h>
71 #include <ksystemtrayicon.h>
72 #include <kconfiggroup.h>
74 #include <kio/jobuidelegate.h>
78 #include <kmime/kmime_message.h>
79 #include <kmime/kmime_util.h>
80 #include <Akonadi/Collection>
81 #include <Akonadi/CollectionFetchJob>
82 #include <Akonadi/ChangeRecorder>
83 #include <Akonadi/ItemFetchScope>
84 #include <Akonadi/AgentManager>
85 #include <Akonadi/ItemFetchJob>
86 #include <Akonadi/AttributeFactory>
87 #include <Akonadi/Session>
88 #include <Akonadi/EntityTreeModel>
89 #include <akonadi/entitymimetypefiltermodel.h>
90 #include <Akonadi/CollectionStatisticsJob>
95 #include <QtDBus/QtDBus>
97 #include <sys/types.h>
105 #include <kcmdlineargs.h>
106 #include <kstartupinfo.h>
107 #include <kmailadaptor.h>
108 #include "kmailinterface.h"
109 #include "foldercollectionmonitor.h"
110 #include "imapresourcesettings.h"
112 #include "mailcommon/kernel/mailkernel.h"
116 using namespace MailCommon;
126 mIdentityManager(0), mConfigureDialog(0), mMailService(0),
127 mSystemNetworkStatus ( Solid::Networking::status() ), mSystemTray(0)
129 Akonadi::AttributeFactory::registerAttribute<Akonadi::SearchDescriptionAttribute>();
130 QDBusConnection::sessionBus().registerService(QLatin1String(
"org.kde.kmail"));
132 kDebug() <<
"Starting up...";
135 the_startingUp =
true;
136 the_firstInstance =
true;
140 mFilterEditDialog = 0;
150 mJobScheduler =
new JobScheduler(
this );
151 mXmlGuiInstance = KComponentData();
153 mAutoCorrection =
new MessageComposer::ComposerAutoCorrection();
154 KMime::setFallbackCharEncoding( MessageCore::GlobalSettings::self()->fallbackCharacterEncoding() );
155 KMime::setUseOutlookAttachmentEncoding( MessageComposer::MessageComposerSettings::self()->outlookCompatibleAttachments() );
158 netCodec = QTextCodec::codecForName( KGlobal::locale()->encoding() );
168 if ( netCodec->name().toLower() ==
"eucjp"
169 #if defined Q_WS_WIN || defined Q_WS_MACX
170 || netCodec->name().toLower() ==
"shift-jis"
174 netCodec = QTextCodec::codecForName(
"jis7");
181 Akonadi::Session *session =
new Akonadi::Session(
"KMail Kernel ETM",
this );
183 mFolderCollectionMonitor =
new FolderCollectionMonitor( session,
this );
185 connect( mFolderCollectionMonitor->monitor(), SIGNAL(collectionMoved(Akonadi::Collection,Akonadi::Collection,Akonadi::Collection)), SLOT(slotCollectionMoved(Akonadi::Collection,Akonadi::Collection,Akonadi::Collection)) );
186 connect( mFolderCollectionMonitor->monitor(), SIGNAL(collectionRemoved(Akonadi::Collection)), SLOT(slotCollectionRemoved(Akonadi::Collection)));
189 mEntityTreeModel->setIncludeUnsubscribed(
false );
190 mEntityTreeModel->setItemPopulationStrategy( Akonadi::EntityTreeModel::LazyPopulation );
192 mCollectionModel =
new Akonadi::EntityMimeTypeFilterModel(
this );
193 mCollectionModel->setSourceModel( mEntityTreeModel );
194 mCollectionModel->addMimeTypeInclusionFilter( Akonadi::Collection::mimeType() );
195 mCollectionModel->setHeaderGroup( Akonadi::EntityTreeModel::CollectionTreeHeaders );
196 mCollectionModel->setDynamicSortFilter(
true );
197 mCollectionModel->setSortCaseSensitivity( Qt::CaseInsensitive );
201 SLOT(slotCollectionChanged(Akonadi::Collection,QSet<QByteArray>)) );
203 connect( MailTransport::TransportManager::self(),
204 SIGNAL(transportRemoved(
int,QString)),
205 SLOT(transportRemoved(
int,QString)) );
206 connect( MailTransport::TransportManager::self(),
207 SIGNAL(transportRenamed(
int,QString,QString)),
208 SLOT(transportRenamed(
int,QString,QString)) );
210 QDBusConnection::sessionBus().connect(QString(), QLatin1String(
"/MailDispatcherAgent" ), QLatin1String(
"org.freedesktop.Akonadi.MailDispatcherAgent"), QLatin1String(
"itemDispatchStarted"),
this, SLOT(itemDispatchStarted()) );
211 connect( Akonadi::AgentManager::self(), SIGNAL(instanceStatusChanged(Akonadi::AgentInstance)),
212 this, SLOT(instanceStatusChanged(Akonadi::AgentInstance)) );
214 connect( Akonadi::AgentManager::self(), SIGNAL(instanceError(Akonadi::AgentInstance,QString)),
215 this, SLOT(slotInstanceError(Akonadi::AgentInstance,QString)) );
217 connect( Akonadi::AgentManager::self(), SIGNAL(instanceWarning(Akonadi::AgentInstance,QString)),
218 SLOT(slotInstanceWarning(Akonadi::AgentInstance,QString)) );
220 connect( Akonadi::AgentManager::self(), SIGNAL(instanceRemoved(Akonadi::AgentInstance)),
221 this, SLOT(slotInstanceRemoved(Akonadi::AgentInstance)) );
223 connect ( Solid::Networking::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)),
224 this, SLOT(slotSystemNetworkStatusChanged(Solid::Networking::Status)) );
230 connect(
identityManager(), SIGNAL(deleted(uint)),
this, SLOT(slotDeleteIdentity(uint)) );
231 CommonKernel->registerKernelIf(
this );
232 CommonKernel->registerSettingsIf(
this );
233 CommonKernel->registerFilterIf(
this );
246 delete mAutoCorrection;
253 return mFolderCollectionMonitor->monitor();
258 return mEntityTreeModel;
263 return mCollectionModel;
268 (void)
new KmailAdaptor(
this );
269 QDBusConnection::sessionBus().registerObject( QLatin1String(
"/KMail"),
this );
276 if ( url.protocol().isEmpty() ) {
277 const QString newUrl = KCmdLineArgs::cwd() + QLatin1Char(
'/') + url.fileName();
278 return KUrl( newUrl );
287 QString
to, cc, bcc, subj, body, inReplyTo, replyTo;
288 QStringList customHeaders;
290 KUrl::List attachURLs;
293 bool viewOnly =
false;
294 bool calledWithSession =
false;
297 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
298 if (args->isSet(
"subject"))
300 subj = args->getOption(
"subject");
308 if ( subj == QLatin1String(
"ession") ) {
310 calledWithSession =
true;
316 if (args->isSet(
"cc"))
319 cc = args->getOption(
"cc");
322 if (args->isSet(
"bcc"))
325 bcc = args->getOption(
"bcc");
328 if (args->isSet(
"replyTo"))
331 replyTo = args->getOption(
"replyTo");
335 if (args->isSet(
"msg"))
338 const QString file = args->getOption(
"msg");
342 if (args->isSet(
"body"))
345 body = args->getOption(
"body");
348 const QStringList attachList = args->getOptionList(
"attach");
349 if ( !attachList.isEmpty() ) {
351 QStringList::ConstIterator end = attachList.constEnd();
352 for ( QStringList::ConstIterator it = attachList.constBegin();
354 if ( !(*it).isEmpty() ) {
360 customHeaders = args->getOptionList(
"header");
362 if (args->isSet(
"composer"))
365 if (args->isSet(
"check"))
368 if ( args->isSet(
"view" ) ) {
370 const QString filename =
371 args->getOption(
"view" );
372 messageFile = KUrl( filename );
373 if ( !messageFile.isValid() ) {
374 messageFile = KUrl();
375 messageFile.setPath( filename );
379 if ( !calledWithSession ) {
382 const int nbArgs = args->count();
383 for (
int i= 0; i < nbArgs; ++i)
385 if ( args->arg(i).startsWith( QLatin1String(
"mailto:" ), Qt::CaseInsensitive ) ) {
387 if ( !values.value( QLatin1String(
"to") ).isEmpty() )
388 to += values.value( QLatin1String(
"to") ) + QLatin1String(
", ");
389 if ( !values.value( QLatin1String(
"cc") ).isEmpty() )
390 cc += values.value( QLatin1String(
"cc") ) + QLatin1String(
", ");
391 if ( !values.value( QLatin1String(
"subject") ).isEmpty() )
392 subj = values.value( QLatin1String(
"subject") );
393 if ( !values.value( QLatin1String(
"body") ).isEmpty() )
394 body = values.value(QLatin1String(
"body") );
395 if ( !values.value( QLatin1String(
"in-reply-to") ).isEmpty() ) {
396 inReplyTo = values.value( QLatin1String(
"in-reply-to") );
398 const QString attach = values.value( QLatin1String(
"attachment") );
399 if ( !attach.isEmpty() ) {
404 QString tmpArg = args->arg(i);
406 if (url.isValid() && !url.protocol().isEmpty())
409 to += tmpArg + QLatin1String(
", ");
413 if ( !to.isEmpty() ) {
415 to.truncate( to.length() - 2 );
419 if ( !calledWithSession )
422 if ( !noArgsOpensReader && !mailto && !checkMail && !viewOnly )
428 action( mailto, checkMail, to, cc, bcc, subj, body, messageFile,
429 attachURLs, customHeaders, replyTo, inReplyTo );
441 const QString resourceGroupPattern( QLatin1String(
"Resource %1") );
443 const Akonadi::AgentInstance::List lst = MailCommon::Util::agentInstances();
444 foreach( Akonadi::AgentInstance type, lst ) {
445 const QString
id = type.identifier();
447 if ( group.readEntry(
"IncludeInManualChecks",
true ) ) {
448 if ( !type.isOnline() )
449 type.setIsOnline(
true );
450 if ( mResourcesBeingChecked.isEmpty() ) {
451 kDebug() <<
"Starting manual mail check";
455 if ( !mResourcesBeingChecked.contains(
id ) ) {
456 mResourcesBeingChecked.append(
id );
472 QStringList accountLst;
473 const Akonadi::AgentInstance::List lst = MailCommon::Util::agentInstances();
474 foreach (
const Akonadi::AgentInstance& type, lst )
478 accountLst<<type.identifier();
486 if ( account.isEmpty() )
489 Akonadi::AgentInstance agent = Akonadi::AgentManager::self()->instance( account );
490 if ( agent.isValid() )
493 kDebug() <<
"- account with name '" << account <<
"' not found";
500 KMainWindow *ktmw = 0;
503 foreach ( KMainWindow *window, KMainWindow::memberList() )
505 if ( ::qobject_cast<KMMainWin *>( window ) )
515 activate = !onlyCheck;
528 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
529 KStartupInfo::setNewStartupId( mWin, kapp->startupId() );
535 const QString &bcc,
const QString &
subject,
536 const QString &body,
bool hidden,
537 const QString &messageFile,
538 const QStringList &attachmentPaths,
539 const QStringList &customHeaders,
540 const QString &replyTo,
const QString &inReplyTo)
544 KMime::Message::Ptr msg(
new KMime::Message );
546 msg->contentType()->setCharset(
"utf-8");
548 msg->to()->fromUnicodeString( to,
"utf-8" );
551 msg->cc()->fromUnicodeString( cc,
"utf-8" );
553 if ( !bcc.isEmpty() )
554 msg->bcc()->fromUnicodeString( bcc,
"utf-8" );
556 if ( !subject.isEmpty() )
557 msg->subject()->fromUnicodeString( subject,
"utf-8" );
559 KUrl messageUrl = KUrl( messageFile );
560 if ( !messageUrl.isEmpty() && messageUrl.isLocalFile() ) {
561 const QByteArray str = KPIMUtils::kFileToByteArray( messageUrl.toLocalFile(),
true, false );
562 if( !str.isEmpty() ) {
564 msg->setBody( QString::fromLocal8Bit( str.data(), str.size() ).toUtf8() );
567 TemplateParser::TemplateParser parser( msg, TemplateParser::TemplateParser::NewMessage );
569 parser.process( msg );
572 else if ( !body.isEmpty() ) {
574 msg->setBody( body.toUtf8() );
577 TemplateParser::TemplateParser parser( msg, TemplateParser::TemplateParser::NewMessage );
579 parser.process( msg );
582 if (!inReplyTo.isEmpty()) {
583 KMime::Headers::InReplyTo *header =
new KMime::Headers::InReplyTo( msg.get(), inReplyTo,
"utf-8" );
584 msg->setHeader( header );
588 KMail::Composer * cWin = KMail::makeComposer( msg,
false,
false, context );
591 KUrl::List attachURLs = KUrl::List( attachmentPaths );
592 for ( KUrl::List::ConstIterator it = attachURLs.constBegin() ; it != attachURLs.constEnd() ; ++it ) {
593 if( KMimeType::findByUrl( *it )->name() == QLatin1String(
"inode/directory" ) ) {
594 if(KMessageBox::questionYesNo(0, i18n(
"Do you want to attach this folder \"%1\"?",(*it).prettyUrl()), i18n(
"Attach Folder")) == KMessageBox::No ) {
600 if (!replyTo.isEmpty()) {
604 if (!customHeaders.isEmpty()) {
606 QStringList::ConstIterator end = customHeaders.constEnd();
607 for ( QStringList::ConstIterator it = customHeaders.constBegin() ; it != end ; ++it ) {
608 if ( !(*it).isEmpty() ) {
609 const int pos = (*it).indexOf( QLatin1Char(
':') );
611 const QString header = (*it).left( pos ).trimmed();
612 const QString value = (*it).mid( pos+1 ).trimmed();
613 if ( !header.isEmpty() && !value.isEmpty() ) {
614 extraCustomHeaders.insert(header.toUtf8(), value);
619 if (!extraCustomHeaders.isEmpty())
626 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
627 KStartupInfo::setNewStartupId( cWin, kapp->startupId() );
634 const QString &bcc,
const QString &
subject,
635 const QString &body,
bool hidden,
636 const QString &attachName,
637 const QByteArray &attachCte,
638 const QByteArray &attachData,
639 const QByteArray &attachType,
640 const QByteArray &attachSubType,
641 const QByteArray &attachParamAttr,
642 const QString &attachParamValue,
643 const QByteArray &attachContDisp,
644 const QByteArray &attachCharset,
645 unsigned int identity )
649 KMime::Message::Ptr msg(
new KMime::Message );
650 KMime::Content *msgPart = 0;
652 msg->contentType()->setCharset(
"utf-8" );
653 if ( !cc.isEmpty() ) msg->cc()->fromUnicodeString( cc,
"utf-8" );
654 if ( !bcc.isEmpty() ) msg->bcc()->fromUnicodeString( bcc,
"utf-8" );
655 if ( !subject.isEmpty() ) msg->subject()->fromUnicodeString( subject,
"utf-8" );
656 if ( !to.isEmpty() ) msg->to()->fromUnicodeString( to,
"utf-8" );
657 if ( identity > 0 ) {
658 KMime::Headers::Generic *h =
new KMime::Headers::Generic(
"X-KMail-Identity", msg.get(), QByteArray::number( identity ) );
661 if ( !body.isEmpty() ) {
662 msg->setBody(body.toUtf8());
665 TemplateParser::TemplateParser parser( msg, TemplateParser::TemplateParser::NewMessage );
667 parser.process( KMime::Message::Ptr() );
670 bool iCalAutoSend =
false;
671 bool noWordWrap =
false;
672 bool isICalInvitation =
false;
674 if ( !attachData.isEmpty() ) {
675 isICalInvitation = (attachName ==QLatin1String(
"cal.ics")) &&
676 attachType ==
"text" &&
677 attachSubType ==
"calendar" &&
678 attachParamAttr ==
"method";
680 if ( isICalInvitation && bcc.isEmpty() )
682 if ( isICalInvitation &&
683 MessageViewer::GlobalSettings::self()->legacyBodyInvites() ) {
685 msg->setBody( attachData );
687 msg->contentType()->from7BitString(
688 QString::fromLatin1(
"text/calendar; method=%1; "
689 "charset=\"utf-8\"" ).
690 arg( attachParamValue ).toLatin1() );
696 msgPart =
new KMime::Content;
697 msgPart->contentType()->setName( attachName,
"utf-8" );
698 msgPart->contentTransferEncoding()->fromUnicodeString(QLatin1String(attachCte),
"utf-8" );
699 msgPart->setBody( attachData );
700 msgPart->contentType()->setMimeType( attachType +
'/' + attachSubType );
701 msgPart->contentDisposition()->setParameter( QLatin1String(attachParamAttr), attachParamValue );
702 if( ! MessageViewer::GlobalSettings::self()->exchangeCompatibleInvitations() ) {
703 msgPart->contentDisposition()->fromUnicodeString(QLatin1String(attachContDisp),
"utf-8" );
705 if( !attachCharset.isEmpty() ) {
707 msgPart->contentType()->setCharset( attachCharset );
710 iCalAutoSend = MessageViewer::GlobalSettings::self()->automaticSending();
715 KMail::Composer * cWin = KMail::makeComposer( KMime::Message::Ptr(),
false,
false,context );
716 cWin->
setMessage( msg,
false,
false, !isICalInvitation );
718 && MessageViewer::GlobalSettings::self()->legacyBodyInvites() );
723 if ( isICalInvitation ) {
729 if ( !hidden && !iCalAutoSend ) {
733 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
734 KStartupInfo::setNewStartupId( cWin, kapp->startupId() );
750 const QString &body,
bool hidden )
752 KMime::Message::Ptr msg(
new KMime::Message );
754 msg->contentType()->setCharset(
"utf-8");
755 if ( !cc.isEmpty() ) msg->cc()->fromUnicodeString( cc,
"utf-8" );
756 if ( !bcc.isEmpty() ) msg->bcc()->fromUnicodeString( bcc,
"utf-8" );
757 if ( !subject.isEmpty() ) msg->subject()->fromUnicodeString( subject,
"utf-8" );
758 if ( !to.isEmpty() ) msg->to()->fromUnicodeString( to,
"utf-8" );
759 if ( !body.isEmpty() ) {
760 msg->setBody( body.toUtf8() );
762 TemplateParser::TemplateParser parser( msg, TemplateParser::TemplateParser::NewMessage );
764 parser.process( KMime::Message::Ptr() );
770 KMail::Composer * cWin = KMail::makeComposer( msg,
false,
false, context );
775 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
776 KStartupInfo::setNewStartupId( cWin, kapp->startupId() );
794 const QString &_attachURL)
796 KUrl attachURL( _attachURL );
797 KMime::Message::Ptr msg(
new KMime::Message );
803 folder = currentFolderCollection();
804 id = folder ? folder->identity() : 0;
807 msg->contentType()->setCharset(
"utf-8" );
809 if ( !cc.isEmpty() ) msg->cc()->fromUnicodeString( cc,
"utf-8" );
810 if ( !bcc.isEmpty() ) msg->bcc()->fromUnicodeString( bcc,
"utf-8" );
811 if ( !to.isEmpty() ) msg->to()->fromUnicodeString( to,
"utf-8" );
814 TemplateParser::TemplateParser parser( msg, TemplateParser::TemplateParser::NewMessage );
816 Akonadi::Collection col = folder ? folder->collection() : Akonadi::Collection();
817 parser.process( msg, col );
823 if ( !attachURL.isEmpty() && attachURL.isValid() ) {
838 openCommand->
start();
844 QDBusInterface iface( QLatin1String(
"org.kde.kmail"), QLatin1String(
"/MainApplication"),
845 QLatin1String(
"org.kde.KUniqueApplication"),
846 QDBusConnection::sessionBus());
847 QDBusReply<int> reply;
848 if ( !iface.isValid() || !( reply = iface.call( QLatin1String(
"newInstance") ) ).isValid() )
850 QDBusError err = iface.lastError();
851 kError() <<
"Communication problem with KMail. "
852 <<
"Error message was:" << err.name() <<
": \"" << err.message() <<
"\"";
862 foreach ( KMainWindow* window, KMainWindow::memberList() ) {
865 if ( !l.isEmpty() && l.first() ) {
866 mainWidget = l.first();
867 if ( window->isActiveWindow() )
872 Akonadi::ItemFetchJob *job =
new Akonadi::ItemFetchJob( Akonadi::Item(serialNumber ),
this );
873 job->fetchScope().fetchFullPayload();
875 if ( job->items().count() >= 1 ) {
877 win->
showMessage( MessageCore::GlobalSettings::self()->overrideCharacterEncoding(),
878 job->items().at( 0 ) );
889 mBackgroundTasksTimer->stop();
890 mJobScheduler->pause();
895 mJobScheduler->resume();
896 mBackgroundTasksTimer->start( 4 * 60 * 60 * 1000 );
906 GlobalSettings::setNetworkState( GlobalSettings::EnumNetworkState::Offline );
907 BroadcastStatus::instance()->setStatusMsg( i18n(
"KMail is set to be offline; all network jobs are suspended"));
908 emit
onlineStatusChanged( (GlobalSettings::EnumNetworkState::type)GlobalSettings::networkState() );
914 const Akonadi::AgentInstance::List lst = MailCommon::Util::agentInstances(
false);
915 foreach ( Akonadi::AgentInstance type, lst ) {
916 const QString identifier( type.identifier() );
917 if ( identifier.contains( IMAP_RESOURCE_IDENTIFIER ) ||
918 identifier.contains( POP3_RESOURCE_IDENTIFIER ) ||
919 identifier.contains( QLatin1String(
"akonadi_maildispatcher_agent") ) ) {
920 type.setIsOnline( goOnline );
923 if ( goOnline && MessageComposer::MessageComposerSettings::self()->sendImmediate() ) {
924 const qint64 nbMsgOutboxCollection = MailCommon::Util::updatedCollection( CommonKernel->outboxCollectionFolder() ).statistics().count();
925 if(nbMsgOutboxCollection > 0) {
926 kmkernel->msgSender()->sendQueued();
936 if ( ( mSystemNetworkStatus == Solid::Networking::Connected ) ||
937 ( mSystemNetworkStatus == Solid::Networking::Unknown ) ) {
939 BroadcastStatus::instance()->setStatusMsg( i18n(
"KMail is set to be online; all network jobs resumed"));
942 BroadcastStatus::instance()->setStatusMsg( i18n (
"KMail is set to be online; all network jobs will resume when a network connection is detected" ) );
944 GlobalSettings::setNetworkState( GlobalSettings::EnumNetworkState::Online );
945 emit
onlineStatusChanged( (GlobalSettings::EnumNetworkState::type)GlobalSettings::networkState() );
954 Solid::Networking::Status networkStatus = Solid::Networking::status();
956 ( networkStatus == Solid::Networking::Unconnected ) ||
957 ( networkStatus == Solid::Networking::Disconnecting ) ||
958 ( networkStatus == Solid::Networking::Connecting ))
969 const QString resourceGroupPattern( QLatin1String(
"Resource %1") );
971 const Akonadi::AgentInstance::List lst = MailCommon::Util::agentInstances();
972 foreach( Akonadi::AgentInstance type, lst ) {
973 KConfigGroup group(
KMKernel::config(), resourceGroupPattern.arg( type.identifier() ) );
974 if ( group.readEntry(
"CheckOnStartup",
false ) ) {
975 if ( !type.isOnline() )
976 type.setIsOnline(
true );
981 if ( group.readEntry(
"OfflineOnShutdown",
false ) ) {
982 if ( !type.isOnline() )
983 type.setIsOnline(
true );
999 i18n(
"KMail is currently in offline mode. "
1000 "How do you want to proceed?"),
1001 i18n(
"Online/Offline"),
1002 KGuiItem(i18n(
"Work Online")),
1003 KGuiItem(i18n(
"Work Offline")));
1006 if( rc == KMessageBox::No ) {
1018 void KMKernel::slotSystemNetworkStatusChanged( Solid::Networking::Status status )
1020 mSystemNetworkStatus = status;
1024 if ( status == Solid::Networking::Connected || status == Solid::Networking::Unknown) {
1025 BroadcastStatus::instance()->setStatusMsg( i18n(
1026 "Network connection detected, all network jobs resumed") );
1027 kmkernel->setAccountStatus(
true );
1030 BroadcastStatus::instance()->setStatusMsg( i18n(
1031 "No network connection detected, all network jobs are suspended"));
1032 kmkernel->setAccountStatus(
false );
1097 QDir dir( pathName );
1098 if ( !dir.exists( QLatin1String(
"autosave") ) )
1102 const QFileInfoList autoSaveFiles = dir.entryInfoList();
1103 foreach(
const QFileInfo &file, autoSaveFiles ) {
1105 const QString filename = file.fileName();
1106 if( filename == QLatin1String(
"." ) ||
1107 filename == QLatin1String(
".." )
1110 kDebug() <<
"Opening autosave file:" << file.absoluteFilePath();
1111 QFile autoSaveFile( file.absoluteFilePath() );
1112 if( autoSaveFile.open( QIODevice::ReadOnly ) ) {
1113 const KMime::Message::Ptr autoSaveMessage(
new KMime::Message() );
1114 const QByteArray msgData = autoSaveFile.readAll();
1115 autoSaveMessage->setContent( msgData );
1116 autoSaveMessage->parse();
1120 autoSaveWin->
setMessage( autoSaveMessage,
false,
false,
false );
1122 autoSaveWin->show();
1123 autoSaveFile.close();
1125 KMessageBox::sorry( 0, i18n(
"Failed to open autosave file at %1.\nReason: %2" ,
1126 file.absoluteFilePath(), autoSaveFile.errorString() ),
1127 i18n(
"Opening Autosave File Failed" ) );
1133 void KMKernel::akonadiStateChanged( Akonadi::ServerManager::State state )
1135 kDebug() <<
"KMKernel has akonadi state changed to:" << int( state );
1137 if( state == Akonadi::ServerManager::Running ) {
1138 CommonKernel->initFolders();
1143 fprintf( stderr,
"*** KMail got signal %d (Exiting)\n", sigId );
1147 fprintf( stderr,
"*** Dead letters dumped.\n" );
1154 the_shuttingDown =
false;
1165 the_msgSender =
new MessageComposer::AkonadiSender;
1169 mBackgroundTasksTimer =
new QTimer(
this );
1170 mBackgroundTasksTimer->setSingleShot(
true );
1172 #ifdef DEBUG_SCHEDULER // for debugging, see jobscheduler.h
1173 mBackgroundTasksTimer->start( 10000 );
1175 mBackgroundTasksTimer->start( 5 * 60000 );
1180 kDebug() <<
"KMail init with akonadi server state:" << int( Akonadi::ServerManager::state() );
1181 if( Akonadi::ServerManager::state() == Akonadi::ServerManager::Running ) {
1182 CommonKernel->initFolders();
1185 connect( Akonadi::ServerManager::self(), SIGNAL(stateChanged(Akonadi::ServerManager::State)),
this, SLOT(akonadiStateChanged(Akonadi::ServerManager::State)) );
1186 connect(
folderCollectionMonitor(), SIGNAL(itemRemoved(Akonadi::Item)), the_undoStack, SLOT(msgDestroyed(Akonadi::Item)) );
1193 mWrapCol = MessageComposer::MessageComposerSettings::self()->lineWrapWidth();
1194 if ((mWrapCol == 0) || (mWrapCol > 78))
1196 else if (mWrapCol < 30)
1205 if (kapp->isSessionRestored()){
1207 while (KMMainWin::canBeRestored(n)){
1209 if (KMMainWin::classNameOfToplevel(n) == QLatin1String(
"KMMainWin"))
1222 foreach ( KMainWindow* window, KMainWindow::memberList() ) {
1223 if ( ::qobject_cast<KMMainWin *>(window) ||
1224 ::qobject_cast<KMail::SecondaryWindow *>(window) )
1227 window->setAttribute(Qt::WA_DeleteOnClose);
1229 windowsToDelete.append( window );
1246 qDeleteAll( windowsToDelete );
1247 windowsToDelete.clear();
1252 disconnect( Akonadi::AgentManager::self(), SIGNAL(instanceStatusChanged(Akonadi::AgentInstance)));
1253 disconnect( Akonadi::AgentManager::self(), SIGNAL(instanceError(Akonadi::AgentInstance,QString)));
1254 disconnect( Akonadi::AgentManager::self(), SIGNAL(instanceWarning(Akonadi::AgentInstance,QString)));
1255 disconnect( Akonadi::AgentManager::self(), SIGNAL(instanceRemoved(Akonadi::AgentInstance)));
1256 disconnect ( Solid::Networking::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)));
1261 the_shuttingDown =
true;
1266 MailCommon::FolderCollection::clearCache();
1269 delete the_msgSender;
1271 delete the_undoStack;
1275 Akonadi::Collection trashCollection = CommonKernel->trashCollectionFolder();
1276 if ( trashCollection.isValid() ) {
1278 Akonadi::CollectionStatisticsJob *jobStatistics =
new Akonadi::CollectionStatisticsJob( trashCollection );
1279 if ( jobStatistics->exec() ) {
1280 if ( jobStatistics->statistics().count() > 0 ) {
1281 mFolderCollectionMonitor->expunge( trashCollection,
true );
1286 delete mConfigureDialog;
1287 mConfigureDialog = 0;
1292 if ( RecentAddresses::exists() )
1293 RecentAddresses::self( config.data() )->save( config.data() );
1302 foreach ( KMainWindow* window, KMainWindow::memberList() ) {
1303 if (
KMail::Composer * win = ::qobject_cast<KMail::Composer*>( window ) ) {
1304 win->autoSaveMessage(
true);
1306 while ( win->isComposing() ) {
1307 kWarning() <<
"Danger, using an event loop, this should no longer be happening!";
1308 qApp->processEvents();
1317 const QString &cc,
const QString &bcc,
1318 const QString &subj,
const QString &body,
1319 const KUrl &messageFile,
1320 const KUrl::List &attachURLs,
1321 const QStringList &customHeaders,
1322 const QString &replyTo,
1323 const QString &inReplyTo)
1327 messageFile.pathOrUrl(), attachURLs.toStringList(),
1328 customHeaders, replyTo, inReplyTo );
1346 MessageCore::GlobalSettings::self()->writeConfig();
1347 MessageViewer::GlobalSettings::self()->writeConfig();
1348 MessageComposer::MessageComposerSettings::self()->writeConfig();
1349 TemplateParser::GlobalSettings::self()->writeConfig();
1350 MessageList::Core::Settings::self()->writeConfig();
1351 MailCommon::MailCommonSettings::self()->writeConfig();
1372 if( !mConfigureDialog ) {
1374 mConfigureDialog->setObjectName( QLatin1String(
"configure") );
1383 if( mConfigureDialog->isHidden() ) {
1384 mConfigureDialog->show();
1386 mConfigureDialog->raise();
1401 return KStandardDirs::locateLocal(
"data", QLatin1String(
"kmail2/") );
1408 return (mSystemTray!=0);
1413 if ( mSystemTray && !the_shuttingDown ) {
1419 if ( !mIdentityManager ) {
1421 mIdentityManager =
new KPIMIdentities::IdentityManager(
false,
this,
"mIdentityManager" );
1423 return mIdentityManager;
1429 foreach ( KMainWindow* window, KMainWindow::memberList() )
1430 if ( ::qobject_cast<KMMainWin *>(window) )
1436 if ( !KMainWindow::memberList().isEmpty() ) {
1437 KMainWindow *kmWin = KMainWindow::memberList().first();
1461 mySelf->mConfig = KSharedConfig::openConfig( QLatin1String(
"kmail2rc") );
1463 KMail::checkConfigUpdates();
1464 MessageList::Core::Settings::self()->setSharedConfig(
mySelf->mConfig );
1465 MessageList::Core::Settings::self()->readConfig();
1466 TemplateParser::GlobalSettings::self()->setSharedConfig(
mySelf->mConfig );
1467 TemplateParser::GlobalSettings::self()->readConfig();
1468 MessageComposer::MessageComposerSettings::self()->setSharedConfig(
mySelf->mConfig );
1469 MessageComposer::MessageComposerSettings::self()->readConfig();
1470 MessageCore::GlobalSettings::self()->setSharedConfig(
mySelf->mConfig );
1471 MessageCore::GlobalSettings::self()->readConfig();
1472 MessageViewer::GlobalSettings::self()->setSharedConfig(
mySelf->mConfig );
1473 MessageViewer::GlobalSettings::self()->readConfig();
1474 MailCommon::MailCommonSettings::self()->setSharedConfig(
mySelf->mConfig );
1475 MailCommon::MailCommonSettings::self()->readConfig();
1493 Akonadi::Collection colFolder = CommonKernel->collectionFromId(
id );
1495 if( colFolder.isValid() )
1506 const Akonadi::Collection colFolder = CommonKernel->collectionFromId( folder.toLongLong() );
1508 if( colFolder.isValid() ) {
1518 QWidgetList l = QApplication::topLevelWidgets();
1521 Q_FOREACH( wid, l ) {
1523 if ( !l2.isEmpty() && l2.first() )
1534 mFolderCollectionMonitor->expireAllFolders(
false ,
entityTreeModel() );
1537 #ifdef DEBUG_SCHEDULER // for debugging, see jobscheduler.h
1538 mBackgroundTasksTimer->start( 60 * 1000 );
1540 mBackgroundTasksTimer->start( 4 * 60 * 60 * 1000 );
1546 const QModelIndex &parent )
1548 Akonadi::Collection::List collections;
1549 const int numberOfCollection( model->rowCount( parent ) );
1550 for (
int i = 0; i < numberOfCollection; ++i ) {
1551 const QModelIndex child = model->index( i, 0, parent );
1552 Akonadi::Collection collection =
1553 model->data( child, Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
1554 if ( collection.isValid() ) {
1555 collections << collection;
1569 mFolderCollectionMonitor->expireAllFolders(
true ,
entityTreeModel() );
1577 if ( !mSystemTray || GlobalSettings::closeDespiteSystemTray() )
1579 if ( mSystemTray->
mode() == GlobalSettings::EnumSystemTrayPolicy::ShowAlways ) {
1582 }
else if ( ( mSystemTray->
mode() == GlobalSettings::EnumSystemTrayPolicy::ShowOnUnread ) ) {
1584 mSystemTray->setStatus( KStatusNotifierItem::Active );
1605 return the_msgSender;
1608 void KMKernel::transportRemoved(
int id,
const QString & name)
1613 QStringList changedIdents;
1615 KPIMIdentities::IdentityManager::Iterator end = im->modifyEnd();
1616 for ( KPIMIdentities::IdentityManager::Iterator it = im->modifyBegin(); it != end; ++it ) {
1617 if ( name == (*it).transport() ) {
1618 (*it).setTransport( QString() );
1619 changedIdents += (*it).identityName();
1625 if ( name == currentTransport )
1628 if ( !changedIdents.isEmpty() ) {
1629 QString information = i18np(
"This identity has been changed to use the default transport:",
1630 "These %1 identities have been changed to use the default transport:",
1631 changedIdents.count() );
1633 KMessageBox::informationList( 0, information, changedIdents );
1638 void KMKernel::transportRenamed(
int id,
const QString & oldName,
const QString & newName)
1642 QStringList changedIdents;
1644 KPIMIdentities::IdentityManager::Iterator end = im->modifyEnd();
1645 for ( KPIMIdentities::IdentityManager::Iterator it = im->modifyBegin(); it != end; ++it ) {
1646 if ( oldName == (*it).transport() ) {
1647 (*it).setTransport( newName );
1648 changedIdents << (*it).identityName();
1652 if ( !changedIdents.isEmpty() ) {
1653 const QString information =
1654 i18np(
"This identity has been changed to use the modified transport:",
1655 "These %1 identities have been changed to use the modified transport:",
1656 changedIdents.count() );
1658 KMessageBox::informationList( 0, information, changedIdents );
1663 void KMKernel::itemDispatchStarted()
1667 MailTransport::DispatcherInterface().dispatcherInstance(),
1668 QString::fromLatin1(
"Sender" ),
1669 i18n(
"Sending messages" ),
1670 i18n(
"Initiating sending process..." ),
1674 void KMKernel::instanceStatusChanged(
const Akonadi::AgentInstance &instance )
1676 if (instance.identifier() == QLatin1String(
"akonadi_mailfilter_agent" ) ) {
1680 instance.identifier(), instance.name(), instance.statusMessage(),
1682 progress->setProperty(
"AgentIdentifier", instance.identifier() );
1685 if ( MailCommon::Util::agentInstances(
true).contains( instance ) ) {
1686 if ( instance.status() == Akonadi::AgentInstance::Running ) {
1688 if ( mResourcesBeingChecked.isEmpty() ) {
1689 kDebug() <<
"A Resource started to synchronize, starting a mail check.";
1693 const QString identifier(instance.identifier());
1694 if ( !mResourcesBeingChecked.contains( identifier ) ) {
1695 mResourcesBeingChecked.append( identifier );
1698 bool useCrypto =
false;
1699 if(mResourceCryptoSettingCache.contains(identifier)) {
1700 useCrypto = mResourceCryptoSettingCache.value(identifier);
1702 if ( identifier.contains( IMAP_RESOURCE_IDENTIFIER ) ) {
1703 OrgKdeAkonadiImapSettingsInterface *iface = PimCommon::Util::createImapSettingsInterface( identifier );
1704 if ( iface->isValid() ) {
1705 const QString imapSafety = iface->safety();
1706 useCrypto = ( imapSafety == QLatin1String(
"SSL" ) || imapSafety == QLatin1String(
"STARTTLS" ) );
1707 mResourceCryptoSettingCache.insert(identifier,useCrypto);
1710 }
else if ( identifier.contains( POP3_RESOURCE_IDENTIFIER ) ) {
1711 OrgKdeAkonadiPOP3SettingsInterface *iface = MailCommon::Util::createPop3SettingsInterface( identifier );
1712 if ( iface->isValid() ) {
1713 useCrypto = ( iface->useSSL() || iface->useTLS() );
1714 mResourceCryptoSettingCache.insert(identifier,useCrypto);
1724 instance.identifier(), instance.name(), instance.statusMessage(),
1726 progress->setProperty(
"AgentIdentifier", instance.identifier() );
1727 }
else if ( instance.status() == Akonadi::AgentInstance::Broken ) {
1735 const QString summary = i18n(
"Resource %1 is broken. This resource is now %2", instance.name(), instance.isOnline() ? i18n(
"online" ) : i18n(
"offline" ) );
1737 KNotification::event( QLatin1String(
"akonadi-resource-broken"),
1741 KNotification::CloseOnTimeout,
1744 KNotification::event( QLatin1String(
"akonadi-resource-broken"),
1748 KNotification::CloseOnTimeout );
1755 const QString identifier = item->property(
"AgentIdentifier" ).toString();
1756 const Akonadi::AgentInstance agent = Akonadi::AgentManager::self()->instance( identifier );
1757 if ( agent.isValid() ) {
1758 mResourcesBeingChecked.removeAll( identifier );
1759 if ( mResourcesBeingChecked.isEmpty() ) {
1760 kDebug() <<
"Last resource finished syncing, mail check done";
1774 const Akonadi::AgentInstance agentInstance = Akonadi::AgentManager::self()->instance( col.resource() );
1775 isOnline = agentInstance.isOnline();
1777 return (agentInstance.type().identifier() == IMAP_RESOURCE_IDENTIFIER);
1783 const QString resourceGroupPattern( QLatin1String(
"Resource %1") );
1785 const Akonadi::AgentInstance::List lst = MailCommon::Util::agentInstances();
1786 foreach( Akonadi::AgentInstance type, lst ) {
1787 KConfigGroup group(
KMKernel::config(), resourceGroupPattern.arg( type.identifier() ) );
1790 if ( group.readEntry(
"OfflineOnShutdown",
false ) )
1791 type.setIsOnline(
false );
1795 void KMKernel::slotCollectionRemoved(
const Akonadi::Collection &col)
1797 KConfigGroup group(
KMKernel::config(), MailCommon::FolderCollection::configGroupName( col ) );
1798 group.deleteGroup();
1800 const QString colStr = QString::number( col.id() );
1801 TemplateParser::Util::deleteTemplate( colStr );
1802 MessageList::Util::deleteConfig( colStr );
1805 void KMKernel::slotDeleteIdentity( uint identity)
1807 TemplateParser::Util::deleteTemplate( QString::fromLatin1(
"IDENTITY_%1" ).arg( identity ) );
1810 void KMKernel::slotCollectionMoved(
const Akonadi::Collection &collection,
const Akonadi::Collection &source,
const Akonadi::Collection &destination )
1842 return GlobalSettingsBase::self()->customTemplates();
1847 if ( !mFilterEditDialog ) {
1848 mFilterEditDialog =
new MailCommon::KMFilterDialog(
getKMMainWidget()->actionCollections(), 0, createDummyFilter );
1849 mFilterEditDialog->setObjectName( QLatin1String(
"filterdialog") );
1851 mFilterEditDialog->show();
1852 mFilterEditDialog->raise();
1853 mFilterEditDialog->activateWindow();
1858 mFilterEditDialog->createFilter( field, value );
1865 const Akonadi::AgentInstance::List lst = MailCommon::Util::agentInstances();
1866 foreach(
const Akonadi::AgentInstance& type, lst ) {
1867 if ( type.status() == Akonadi::AgentInstance::Broken )
1869 if ( type.identifier().contains( IMAP_RESOURCE_IDENTIFIER ) ) {
1870 OrgKdeAkonadiImapSettingsInterface *iface = PimCommon::Util::createImapSettingsInterface( type.identifier() );
1871 if ( iface->isValid() ) {
1872 foreach(
const Akonadi::Collection& collection, collectionList ) {
1873 const Akonadi::Collection::Id collectionId = collection.id();
1874 if ( iface->trashCollection() == collectionId ) {
1876 iface->setTrashCollection( CommonKernel->trashCollectionFolder().id() );
1877 iface->writeConfig();
1884 else if ( type.identifier().contains( POP3_RESOURCE_IDENTIFIER ) ) {
1885 OrgKdeAkonadiPOP3SettingsInterface *iface = MailCommon::Util::createPop3SettingsInterface( type.identifier() );
1886 if ( iface->isValid() ) {
1887 foreach(
const Akonadi::Collection& collection, collectionList ) {
1888 const Akonadi::Collection::Id collectionId = collection.id();
1889 if ( iface->targetCollection() == collectionId ) {
1891 iface->setTargetCollection( CommonKernel->inboxCollectionFolder().id() );
1892 iface->writeConfig();
1910 void KMKernel::slotInstanceWarning(
const Akonadi::AgentInstance &instance ,
const QString &message)
1912 const QString summary = i18nc(
"<source>: <error message>",
"%1: %2", instance.name(), message );
1914 KNotification::event( QLatin1String(
"akonadi-instance-warning"),
1918 KNotification::CloseOnTimeout,
1921 KNotification::event( QLatin1String(
"akonadi-instance-warning"),
1925 KNotification::CloseOnTimeout );
1929 void KMKernel::slotInstanceError(
const Akonadi::AgentInstance &instance,
const QString &message)
1931 const QString summary = i18nc(
"<source>: <error message>",
"%1: %2", instance.name(), message );
1933 KNotification::event( QLatin1String(
"akonadi-instance-error"),
1937 KNotification::CloseOnTimeout,
1940 KNotification::event( QLatin1String(
"akonadi-instance-error"),
1944 KNotification::CloseOnTimeout );
1949 void KMKernel::slotInstanceRemoved(
const Akonadi::AgentInstance& instance)
1951 const QString identifier(instance.identifier());
1952 const QString resourceGroup = QString::fromLatin1(
"Resource %1" ).arg( identifier );
1955 group.deleteGroup();
1958 if(mResourceCryptoSettingCache.contains(identifier)) {
1959 mResourceCryptoSettingCache.remove(identifier);
1979 void KMKernel::resourceGoOnLine()
1984 Akonadi::Collection collection = widget->
currentFolder()->collection();
1985 Akonadi::AgentInstance instance = Akonadi::AgentManager::self()->instance( collection.resource() );
1986 instance.setIsOnline(
true );
1995 case MessageViewer::Viewer::AllResources:
1998 case MessageViewer::Viewer::SelectedResource:
2006 return mAutoCorrection;
2017 kDebug() <<
"deleting systray";
2023 if ( mSystemTray ) {
2033 if (!collectionId.isEmpty()) {
2034 const Akonadi::Collection::Id
id = collectionId.toLongLong();
2039 void KMKernel::slotCollectionChanged(
const Akonadi::Collection &,
const QSet<QByteArray> &
set)
2041 if(set.contains(
"newmailnotifierattribute")) {
2042 if ( mSystemTray ) {
2048 #include "kmkernel.moc"
void updatePreferredCharsets()
Re-read the preferred charsets from settings.
virtual void setFocusToSubject()=0
Sets the focus to the subject line edit.
KMKernel(QObject *parent=0, const char *name=0)
Q_SCRIPTABLE QStringList accounts()
void createFilter(const QByteArray &field, const QString &value)
static bool s_askingToGoOnline
Q_SCRIPTABLE int viewMessage(const QString &messageFile)
static ProgressManager * instance()
Q_SCRIPTABLE void setSystrayIconNotificationsEnabled(bool enabled)
Enables/disables systray icon changing when mail arrives.
static ProgressItem * createProgressItem(const QString &label)
virtual void disableForgottenAttachmentsCheck()=0
virtual void addExtraCustomHeaders(const QMap< QByteArray, QString > &header)=0
void showMessage(const QString &encoding, const Akonadi::Item &msg, const Akonadi::Collection &parentCollection=Akonadi::Collection())
take ownership of and show
Q_SCRIPTABLE void stopNetworkJobs()
Stops all network related jobs and enter offline mode New network jobs cannot be started.
void slotShowConfigurationDialog()
static KUrl makeAbsoluteUrl(const QString &str)
virtual void setAutoSaveFileName(const QString &fileName)=0
MessageComposer::ComposerAutoCorrection * composerAutoCorrection()
Q_SCRIPTABLE int openComposer(const QString &to, const QString &cc, const QString &bcc, const QString &subject, const QString &body, bool hidden, const QString &messageFile, const QStringList &attachmentPaths, const QStringList &customHeaders, const QString &replyTo=QString(), const QString &inReplyTo=QString())
Opens a composer window and prefills it with different message parts.
Central point of coordination in KMail.
Q_SCRIPTABLE void openReader()
bool isImapFolder(const Akonadi::Collection &, bool &isOnline) const
Q_SCRIPTABLE QDBusObjectPath newMessage(const QString &to, const QString &cc, const QString &bcc, bool hidden, bool useFolderId, const QString &messageFile, const QString &attachURL)
Opens a composer window and prefills it with different message parts.
void updatedTemplates()
Custom templates have changed, so all windows using them need to regenerate their menus...
virtual void disableWordWrap()=0
virtual void setMessage(const KMime::Message::Ptr &newMsg, bool lastSignState=false, bool lastEncryptState=false, bool mayAutoSign=true, bool allowDecryption=false, bool isModified=false)=0
Set the message the composer shall work with.
void action(bool mailto, bool check, const QString &to, const QString &cc, const QString &bcc, const QString &subj, const QString &body, const KUrl &messageFile, const KUrl::List &attach, const QStringList &customHeaders, const QString &replyTo, const QString &inReplyTo)
void setSystrayIconNotificationsEnabled(bool enable)
Use this method to disable any systray icon changing.
Akonadi::EntityMimeTypeFilterModel * collectionModel() const
Returns a model of all folders in KMail.
QSharedPointer< MailCommon::FolderCollection > currentFolder() const
Akonadi::ChangeRecorder * folderCollectionMonitor() const
const KComponentData & xmlGuiInstance()
void customTemplatesChanged()
static KMKernel * self()
normal control stuff
KSharedConfig::Ptr config()
MailCommon::FolderTreeView * folderTreeView() const
void selectCollectionFromId(const Akonadi::Collection::Id id)
void updatePaneTagComboBox()
virtual void addAttachment(const KUrl &url, const QString &comment)=0
Q_SCRIPTABLE void resumeNetworkJobs()
Resumes all network related jobs and enter online mode New network jobs can be started.
const QAbstractItemModel * treeviewModelSelection()
virtual void addAttach(KMime::Content *msgPart)=0
Add an attachment to the list.
Q_SCRIPTABLE void makeResourceOnline(MessageViewer::Viewer::ResourceOnlineMode mode)
void updatePaneTagComboBox()
Q_SCRIPTABLE void checkAccount(const QString &account)
Checks the account with the specified name for new mail.
Q_SCRIPTABLE bool selectFolder(const QString &folder)
void checkMailOnStartup()
End of D-Bus callable stuff.
void recoverDeadLetters()
Q_SCRIPTABLE void updateConfig()
Q_SCRIPTABLE void checkMail()
Start of D-Bus callable stuff.
Q_SCRIPTABLE bool showMail(quint32 serialNumber, const QString &messageId)
virtual void setCurrentReplyTo(const QString &replyTo)=0
void slotRunBackgroundTasks()
static bool isOffline()
Checks if the current network state is online or offline.
void slotRequestConfigSync()
Call this slot instead of directly KConfig::sync() to minimize the overall config writes...
static const PtrList * mainWidgetList()
Returns a list of all KMMainWidgets.
void setAccountStatus(bool)
bool excludeImportantMailFromExpiry()
bool haveSystemTrayApplet() const
Returns true if we have a system tray applet.
bool hasUnreadMail() const
virtual void setSigningAndEncryptionDisabled(bool v)=0
Disabled signing and encryption completely for this composer window.
void slotSelectCollectionFolder(const Akonadi::Collection &col)
bool shuttingDown() const
void set(quint32, const QString &, const QString &, const QString &, const QString &, time_t)
static GlobalSettings * self()
static bool askToGoOnline()
A static helper function that asks the user if they want to go online.
Q_SCRIPTABLE void showFolder(const QString &collectionId)
virtual QString dbusObjectPath() const =0
void agentInstanceBroken(const Akonadi::AgentInstance &instance)
Akonadi::EntityTreeModel * entityTreeModel() const
Returns the main model, which contains all folders and the items of recently opened folders...
static CodecManager * self()
Returns the CodecManager instance.
static void kmCrashHandler(int sigId)
Q_SCRIPTABLE void resumeBackgroundJobs()
Resumes all background jobs and allows new jobs to be started.
Q_SCRIPTABLE bool handleCommandLine(bool noArgsOpensReader)
void dumpDeadLetters()
Save contents of all open composer widnows to ~/dead.letter.
KPIMIdentities::IdentityManager * identityManager()
return the pointer to the identity manager
bool doSessionManagement()
void openFilterDialog(bool createDummyFilter=true)
void setShowUnreadCount(bool showUnreadCount)
static Akonadi::Collection::List collect_collections(const QAbstractItemModel *model, const QModelIndex &parent)
KMainWindow * mainWin()
returns a reference to the first Mainwin or a temporary Mainwin
void closeAllKMailWindows()
quint32 serialNumber() const
virtual void forceDisableHtml()=0
MessageComposer::MessageSender * msgSender()
virtual void setCollectionForNewMessage(const Akonadi::Collection &folder)=0
qreal closeToQuotaThreshold()
void checkFolderFromResources(const Akonadi::Collection::List &collectionList)
void setLastSelectedFolder(const Akonadi::Collection::Id &col)
QStringList customTemplates()
void slotSyncConfig()
Sync the config immediatley.
void expireAllFoldersNow()
Expire all folders, used for the gui action.
void onlineStatusChanged(GlobalSettings::EnumNetworkState::type)
Akonadi::Collection::Id lastSelectedFolder()
Akonadi::Collection::List allFolders() const
Returns a list of all currently loaded folders.
static QString localDataPath()
Returns the full path of the user's local data directory for KMail.
Q_SCRIPTABLE bool canQueryClose()
Q_SCRIPTABLE void pauseBackgroundJobs()
Pauses all background jobs and does not allow new background jobs to be started.
virtual void slotSendNow()=0
KMMainWidget * getKMMainWidget()
Get first mainwidget.