Changeset View
Changeset View
Standalone View
Standalone View
src/kmkernel.cpp
Show First 20 Lines • Show All 268 Lines • ▼ Show 20 Line(s) | |||||
269 | 269 | | |||
270 | bool KMKernel::handleCommandLine(bool noArgsOpensReader, const QStringList &args, const QString &workingDir) | 270 | bool KMKernel::handleCommandLine(bool noArgsOpensReader, const QStringList &args, const QString &workingDir) | ||
271 | { | 271 | { | ||
272 | QString to, cc, bcc, subj, body, inReplyTo, replyTo; | 272 | QString to, cc, bcc, subj, body, inReplyTo, replyTo; | ||
273 | QStringList customHeaders; | 273 | QStringList customHeaders; | ||
274 | QUrl messageFile; | 274 | QUrl messageFile; | ||
275 | QList<QUrl> attachURLs; | 275 | QList<QUrl> attachURLs; | ||
276 | QString identity; | 276 | QString identity; | ||
277 | bool startInTray = false; | ||||
277 | bool mailto = false; | 278 | bool mailto = false; | ||
278 | bool checkMail = false; | 279 | bool checkMail = false; | ||
279 | bool viewOnly = false; | 280 | bool viewOnly = false; | ||
280 | bool calledWithSession = false; // for ignoring '-session foo' | 281 | bool calledWithSession = false; // for ignoring '-session foo' | ||
281 | 282 | | |||
282 | // process args: | 283 | // process args: | ||
283 | QCommandLineParser parser; | 284 | QCommandLineParser parser; | ||
284 | kmail_options(&parser); | 285 | kmail_options(&parser); | ||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | |||||
366 | if (parser.isSet(QStringLiteral("composer"))) { | 367 | if (parser.isSet(QStringLiteral("composer"))) { | ||
367 | mailto = true; | 368 | mailto = true; | ||
368 | } | 369 | } | ||
369 | 370 | | |||
370 | if (parser.isSet(QStringLiteral("check"))) { | 371 | if (parser.isSet(QStringLiteral("check"))) { | ||
371 | checkMail = true; | 372 | checkMail = true; | ||
372 | } | 373 | } | ||
373 | 374 | | |||
375 | if(parser.isSet(QStringLiteral("startintray"))) { | ||||
376 | KMailSettings::self()->setSystemTrayEnabled(true); | ||||
377 | startInTray = true; | ||||
378 | } | ||||
379 | | ||||
374 | if (parser.isSet(QStringLiteral("identity"))) { | 380 | if (parser.isSet(QStringLiteral("identity"))) { | ||
375 | identity = parser.value(QStringLiteral("identity")); | 381 | identity = parser.value(QStringLiteral("identity")); | ||
376 | } | 382 | } | ||
377 | 383 | | |||
378 | if (parser.isSet(QStringLiteral("view"))) { | 384 | if (parser.isSet(QStringLiteral("view"))) { | ||
379 | viewOnly = true; | 385 | viewOnly = true; | ||
380 | const QString filename | 386 | const QString filename | ||
381 | = parser.value(QStringLiteral("view")); | 387 | = parser.value(QStringLiteral("view")); | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | |||||
451 | 457 | | |||
452 | if (!noArgsOpensReader && !mailto && !checkMail && !viewOnly) { | 458 | if (!noArgsOpensReader && !mailto && !checkMail && !viewOnly) { | ||
453 | return false; | 459 | return false; | ||
454 | } | 460 | } | ||
455 | 461 | | |||
456 | if (viewOnly) { | 462 | if (viewOnly) { | ||
457 | viewMessage(messageFile); | 463 | viewMessage(messageFile); | ||
458 | } else { | 464 | } else { | ||
459 | action(mailto, checkMail, to, cc, bcc, subj, body, messageFile, | 465 | action(mailto, checkMail, startInTray, to, cc, bcc, subj, body, messageFile, | ||
460 | attachURLs, customHeaders, replyTo, inReplyTo, identity); | 466 | attachURLs, customHeaders, replyTo, inReplyTo, identity); | ||
461 | } | 467 | } | ||
462 | return true; | 468 | return true; | ||
463 | } | 469 | } | ||
464 | 470 | | |||
465 | /********************************************************************/ | 471 | /********************************************************************/ | ||
466 | /* D-Bus-callable, and command line actions */ | 472 | /* D-Bus-callable, and command line actions */ | ||
467 | /********************************************************************/ | 473 | /********************************************************************/ | ||
Show All 23 Lines | 486 | if (group.readEntry("IncludeInManualChecks", true)) { | |||
491 | } | 497 | } | ||
492 | type.synchronize(); | 498 | type.synchronize(); | ||
493 | } | 499 | } | ||
494 | } | 500 | } | ||
495 | } | 501 | } | ||
496 | 502 | | |||
497 | void KMKernel::openReader() | 503 | void KMKernel::openReader() | ||
498 | { | 504 | { | ||
499 | openReader(false); | 505 | openReader(false, false); | ||
500 | } | 506 | } | ||
501 | 507 | | |||
502 | QStringList KMKernel::accounts() const | 508 | QStringList KMKernel::accounts() const | ||
503 | { | 509 | { | ||
504 | QStringList accountLst; | 510 | QStringList accountLst; | ||
505 | const Akonadi::AgentInstance::List lst = MailCommon::Util::agentInstances(); | 511 | const Akonadi::AgentInstance::List lst = MailCommon::Util::agentInstances(); | ||
506 | accountLst.reserve(lst.count()); | 512 | accountLst.reserve(lst.count()); | ||
507 | for (const Akonadi::AgentInstance &type : lst) { | 513 | for (const Akonadi::AgentInstance &type : lst) { | ||
Show All 13 Lines | 525 | } else { | |||
521 | if (agent.isValid()) { | 527 | if (agent.isValid()) { | ||
522 | agent.synchronize(); | 528 | agent.synchronize(); | ||
523 | } else { | 529 | } else { | ||
524 | qCDebug(KMAIL_LOG) << "- account with name '" << account << "' not found"; | 530 | qCDebug(KMAIL_LOG) << "- account with name '" << account << "' not found"; | ||
525 | } | 531 | } | ||
526 | } | 532 | } | ||
527 | } | 533 | } | ||
528 | 534 | | |||
529 | void KMKernel::openReader(bool onlyCheck) | 535 | void KMKernel::openReader(bool onlyCheck, bool startInTray) | ||
530 | { | 536 | { | ||
531 | KMainWindow *ktmw = nullptr; | 537 | KMainWindow *ktmw = nullptr; | ||
532 | 538 | | |||
533 | foreach (KMainWindow *window, KMainWindow::memberList()) { | 539 | foreach (KMainWindow *window, KMainWindow::memberList()) { | ||
534 | if (::qobject_cast<KMMainWin *>(window)) { | 540 | if (::qobject_cast<KMMainWin *>(window)) { | ||
535 | ktmw = window; | 541 | ktmw = window; | ||
536 | break; | 542 | break; | ||
537 | } | 543 | } | ||
538 | } | 544 | } | ||
539 | 545 | | |||
540 | bool activate; | 546 | bool activate; | ||
541 | if (ktmw) { | 547 | if (ktmw) { | ||
542 | KMMainWin *win = static_cast<KMMainWin *>(ktmw); | 548 | KMMainWin *win = static_cast<KMMainWin *>(ktmw); | ||
543 | activate = !onlyCheck; // existing window: only activate if not --check | 549 | activate = !onlyCheck; // existing window: only activate if not --check | ||
544 | if (activate) { | 550 | if (activate) { | ||
545 | win->show(); | 551 | win->show(); | ||
546 | } | 552 | } | ||
547 | } else { | 553 | } else { | ||
548 | KMMainWin *win = new KMMainWin; | 554 | KMMainWin *win = new KMMainWin; | ||
555 | if(!startInTray && !KMailSettings::self()->startInTray()) | ||||
549 | win->show(); | 556 | win->show(); | ||
550 | activate = false; // new window: no explicit activation (#73591) | 557 | activate = false; // new window: no explicit activation (#73591) | ||
551 | } | 558 | } | ||
552 | } | 559 | } | ||
553 | 560 | | |||
554 | void KMKernel::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, const QString &inReplyTo, const QString &identity) | 561 | void KMKernel::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, const QString &inReplyTo, const QString &identity) | ||
555 | { | 562 | { | ||
556 | const OpenComposerSettings settings(to, cc, | 563 | const OpenComposerSettings settings(to, cc, | ||
▲ Show 20 Lines • Show All 581 Lines • ▼ Show 20 Line(s) | 1142 | if (KMail::Composer *win = ::qobject_cast<KMail::Composer *>(window)) { | |||
1138 | while (win->isComposing()) { | 1145 | while (win->isComposing()) { | ||
1139 | qCWarning(KMAIL_LOG) << "Danger, using an event loop, this should no longer be happening!"; | 1146 | qCWarning(KMAIL_LOG) << "Danger, using an event loop, this should no longer be happening!"; | ||
1140 | qApp->processEvents(); | 1147 | qApp->processEvents(); | ||
1141 | } | 1148 | } | ||
1142 | } | 1149 | } | ||
1143 | } | 1150 | } | ||
1144 | } | 1151 | } | ||
1145 | 1152 | | |||
1146 | void KMKernel::action(bool mailto, bool check, const QString &to, const QString &cc, const QString &bcc, const QString &subj, const QString &body, const QUrl &messageFile, const QList<QUrl> &attachURLs, const QStringList &customHeaders, const QString &replyTo, const QString &inReplyTo, const QString &identity) | 1153 | void KMKernel::action(bool mailto, bool check, bool startInTray, const QString &to, const QString &cc, const QString &bcc, const QString &subj, const QString &body, const QUrl &messageFile, const QList<QUrl> &attachURLs, const QStringList &customHeaders, const QString &replyTo, const QString &inReplyTo, const QString &identity) | ||
1147 | { | 1154 | { | ||
1148 | if (mailto) { | 1155 | if (mailto) { | ||
1149 | openComposer(to, cc, bcc, subj, body, 0, | 1156 | openComposer(to, cc, bcc, subj, body, 0, | ||
1150 | messageFile.toLocalFile(), QUrl::toStringList(attachURLs), | 1157 | messageFile.toLocalFile(), QUrl::toStringList(attachURLs), | ||
1151 | customHeaders, replyTo, inReplyTo, identity); | 1158 | customHeaders, replyTo, inReplyTo, identity); | ||
1152 | } else { | 1159 | } else { | ||
1153 | openReader(check); | 1160 | openReader(check, startInTray); | ||
1154 | } | 1161 | } | ||
1155 | 1162 | | |||
1156 | if (check) { | 1163 | if (check) { | ||
1157 | checkMail(); | 1164 | checkMail(); | ||
1158 | } | 1165 | } | ||
1159 | //Anything else? | 1166 | //Anything else? | ||
1160 | } | 1167 | } | ||
1161 | 1168 | | |||
▲ Show 20 Lines • Show All 770 Lines • Show Last 20 Lines |