Changeset View
Changeset View
Standalone View
Standalone View
src/filter/mailfilter.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
49 | 49 | | |||
50 | MailFilter::MailFilter() | 50 | MailFilter::MailFilter() | ||
51 | { | 51 | { | ||
52 | generateRandomIdentifier(); | 52 | generateRandomIdentifier(); | ||
53 | bApplyOnInbound = true; | 53 | bApplyOnInbound = true; | ||
54 | bApplyBeforeOutbound = false; | 54 | bApplyBeforeOutbound = false; | ||
55 | bApplyOnOutbound = false; | 55 | bApplyOnOutbound = false; | ||
56 | bApplyOnExplicit = true; | 56 | bApplyOnExplicit = true; | ||
57 | bApplyOnAllFolders = false; | ||||
57 | bStopProcessingHere = true; | 58 | bStopProcessingHere = true; | ||
58 | bConfigureShortcut = false; | 59 | bConfigureShortcut = false; | ||
59 | bConfigureToolbar = false; | 60 | bConfigureToolbar = false; | ||
60 | bAutoNaming = true; | 61 | bAutoNaming = true; | ||
61 | mApplicability = All; | 62 | mApplicability = All; | ||
62 | bEnabled = true; | 63 | bEnabled = true; | ||
63 | } | 64 | } | ||
64 | 65 | | |||
65 | MailFilter::MailFilter(const KConfigGroup &aConfig, bool interactive, bool &needUpdate) | 66 | MailFilter::MailFilter(const KConfigGroup &aConfig, bool interactive, bool &needUpdate) | ||
66 | { | 67 | { | ||
67 | needUpdate = readConfig(aConfig, interactive); | 68 | needUpdate = readConfig(aConfig, interactive); | ||
68 | } | 69 | } | ||
69 | 70 | | |||
70 | MailFilter::MailFilter(const MailFilter &aFilter) | 71 | MailFilter::MailFilter(const MailFilter &aFilter) | ||
71 | { | 72 | { | ||
72 | mIdentifier = aFilter.mIdentifier; | 73 | mIdentifier = aFilter.mIdentifier; | ||
73 | mPattern = aFilter.mPattern; | 74 | mPattern = aFilter.mPattern; | ||
74 | 75 | | |||
75 | bApplyOnInbound = aFilter.applyOnInbound(); | 76 | bApplyOnInbound = aFilter.applyOnInbound(); | ||
76 | bApplyBeforeOutbound = aFilter.applyBeforeOutbound(); | 77 | bApplyBeforeOutbound = aFilter.applyBeforeOutbound(); | ||
77 | bApplyOnOutbound = aFilter.applyOnOutbound(); | 78 | bApplyOnOutbound = aFilter.applyOnOutbound(); | ||
78 | bApplyOnExplicit = aFilter.applyOnExplicit(); | 79 | bApplyOnExplicit = aFilter.applyOnExplicit(); | ||
80 | bApplyOnAllFolders = aFilter.applyOnAllFoldersInbound(); | ||||
79 | bStopProcessingHere = aFilter.stopProcessingHere(); | 81 | bStopProcessingHere = aFilter.stopProcessingHere(); | ||
80 | bConfigureShortcut = aFilter.configureShortcut(); | 82 | bConfigureShortcut = aFilter.configureShortcut(); | ||
81 | bConfigureToolbar = aFilter.configureToolbar(); | 83 | bConfigureToolbar = aFilter.configureToolbar(); | ||
82 | mToolbarName = aFilter.toolbarName(); | 84 | mToolbarName = aFilter.toolbarName(); | ||
83 | mApplicability = aFilter.applicability(); | 85 | mApplicability = aFilter.applicability(); | ||
84 | bAutoNaming = aFilter.isAutoNaming(); | 86 | bAutoNaming = aFilter.isAutoNaming(); | ||
85 | bEnabled = aFilter.isEnabled(); | 87 | bEnabled = aFilter.isEnabled(); | ||
86 | mIcon = aFilter.icon(); | 88 | mIcon = aFilter.icon(); | ||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Line(s) | 232 | { | |||
231 | bApplyOnExplicit = aApply; | 233 | bApplyOnExplicit = aApply; | ||
232 | } | 234 | } | ||
233 | 235 | | |||
234 | bool MailFilter::applyOnExplicit() const | 236 | bool MailFilter::applyOnExplicit() const | ||
235 | { | 237 | { | ||
236 | return bApplyOnExplicit; | 238 | return bApplyOnExplicit; | ||
237 | } | 239 | } | ||
238 | 240 | | |||
241 | void MailFilter::setApplyOnAllFoldersInbound(bool aApply) | ||||
242 | { | ||||
243 | bApplyOnAllFolders = aApply; | ||||
244 | } | ||||
245 | | ||||
246 | bool MailFilter::applyOnAllFoldersInbound() const | ||||
247 | { | ||||
248 | return bApplyOnAllFolders; | ||||
249 | } | ||||
250 | | ||||
239 | void MailFilter::setApplicability(AccountType aApply) | 251 | void MailFilter::setApplicability(AccountType aApply) | ||
240 | { | 252 | { | ||
241 | mApplicability = aApply; | 253 | mApplicability = aApply; | ||
242 | } | 254 | } | ||
243 | 255 | | |||
244 | MailFilter::AccountType MailFilter::applicability() const | 256 | MailFilter::AccountType MailFilter::applicability() const | ||
245 | { | 257 | { | ||
246 | return mApplicability; | 258 | return mApplicability; | ||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Line(s) | 404 | { | |||
397 | mIdentifier = config.readEntry("identifier", KRandom::randomString(16)); | 409 | mIdentifier = config.readEntry("identifier", KRandom::randomString(16)); | ||
398 | 410 | | |||
399 | const QStringList sets = config.readEntry("apply-on", QStringList()); | 411 | const QStringList sets = config.readEntry("apply-on", QStringList()); | ||
400 | if (sets.isEmpty() && !config.hasKey("apply-on")) { | 412 | if (sets.isEmpty() && !config.hasKey("apply-on")) { | ||
401 | bApplyBeforeOutbound = false; | 413 | bApplyBeforeOutbound = false; | ||
402 | bApplyOnOutbound = false; | 414 | bApplyOnOutbound = false; | ||
403 | bApplyOnInbound = true; | 415 | bApplyOnInbound = true; | ||
404 | bApplyOnExplicit = true; | 416 | bApplyOnExplicit = true; | ||
417 | bApplyOnAllFolders = false; | ||||
405 | mApplicability = ButImap; | 418 | mApplicability = ButImap; | ||
406 | } else { | 419 | } else { | ||
407 | bApplyBeforeOutbound = bool(sets.contains(QStringLiteral("before-send-mail"))); | 420 | bApplyBeforeOutbound = bool(sets.contains(QStringLiteral("before-send-mail"))); | ||
408 | bApplyOnInbound = bool(sets.contains(QStringLiteral("check-mail"))); | 421 | bApplyOnInbound = bool(sets.contains(QStringLiteral("check-mail"))); | ||
409 | bApplyOnOutbound = bool(sets.contains(QStringLiteral("send-mail"))); | 422 | bApplyOnOutbound = bool(sets.contains(QStringLiteral("send-mail"))); | ||
410 | bApplyOnExplicit = bool(sets.contains(QStringLiteral("manual-filtering"))); | 423 | bApplyOnExplicit = bool(sets.contains(QStringLiteral("manual-filtering"))); | ||
424 | bApplyOnAllFolders = bool(sets.contains(QStringLiteral("all-folders"))); | ||||
411 | mApplicability = (AccountType)config.readEntry( | 425 | mApplicability = (AccountType)config.readEntry( | ||
412 | "Applicability", (int)ButImap); | 426 | "Applicability", (int)ButImap); | ||
413 | } | 427 | } | ||
414 | 428 | | |||
415 | bStopProcessingHere = config.readEntry("StopProcessingHere", true); | 429 | bStopProcessingHere = config.readEntry("StopProcessingHere", true); | ||
416 | bConfigureShortcut = config.readEntry("ConfigureShortcut", false); | 430 | bConfigureShortcut = config.readEntry("ConfigureShortcut", false); | ||
417 | QString shortcut(config.readEntry("Shortcut", QString())); | 431 | QString shortcut(config.readEntry("Shortcut", QString())); | ||
418 | if (!shortcut.isEmpty()) { | 432 | if (!shortcut.isEmpty()) { | ||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | 538 | if (bApplyBeforeOutbound) { | |||
525 | sets.append(QStringLiteral("before-send-mail")); | 539 | sets.append(QStringLiteral("before-send-mail")); | ||
526 | } | 540 | } | ||
527 | if (bApplyOnOutbound) { | 541 | if (bApplyOnOutbound) { | ||
528 | sets.append(QStringLiteral("send-mail")); | 542 | sets.append(QStringLiteral("send-mail")); | ||
529 | } | 543 | } | ||
530 | if (bApplyOnExplicit) { | 544 | if (bApplyOnExplicit) { | ||
531 | sets.append(QStringLiteral("manual-filtering")); | 545 | sets.append(QStringLiteral("manual-filtering")); | ||
532 | } | 546 | } | ||
547 | if (bApplyOnAllFolders) { | ||||
548 | sets.append(QStringLiteral("all-folders")); | ||||
549 | } | ||||
533 | config.writeEntry("apply-on", sets); | 550 | config.writeEntry("apply-on", sets); | ||
534 | 551 | | |||
535 | config.writeEntry("StopProcessingHere", bStopProcessingHere); | 552 | config.writeEntry("StopProcessingHere", bStopProcessingHere); | ||
536 | config.writeEntry("ConfigureShortcut", bConfigureShortcut); | 553 | config.writeEntry("ConfigureShortcut", bConfigureShortcut); | ||
537 | if (!mShortcut.isEmpty()) { | 554 | if (!mShortcut.isEmpty()) { | ||
538 | config.writeEntry("Shortcut", mShortcut.toString()); | 555 | config.writeEntry("Shortcut", mShortcut.toString()); | ||
539 | } | 556 | } | ||
540 | config.writeEntry("ConfigureToolbar", bConfigureToolbar); | 557 | config.writeEntry("ConfigureToolbar", bConfigureToolbar); | ||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | 653 | if (bApplyBeforeOutbound) { | |||
637 | result += " before-Outbound"; | 654 | result += " before-Outbound"; | ||
638 | } | 655 | } | ||
639 | if (bApplyOnOutbound) { | 656 | if (bApplyOnOutbound) { | ||
640 | result += " Outbound"; | 657 | result += " Outbound"; | ||
641 | } | 658 | } | ||
642 | if (bApplyOnExplicit) { | 659 | if (bApplyOnExplicit) { | ||
643 | result += " Explicit"; | 660 | result += " Explicit"; | ||
644 | } | 661 | } | ||
662 | if (bApplyOnAllFolders) { | ||||
663 | result += " All Folders"; | ||||
664 | } | ||||
645 | result += '\n'; | 665 | result += '\n'; | ||
646 | if (bApplyOnInbound && mApplicability == All) { | 666 | if (bApplyOnInbound && mApplicability == All) { | ||
647 | result += "This filter applies to all accounts.\n"; | 667 | result += "This filter applies to all accounts.\n"; | ||
648 | } else if (bApplyOnInbound && mApplicability == ButImap) { | 668 | } else if (bApplyOnInbound && mApplicability == ButImap) { | ||
649 | result += "This filter applies to all but IMAP accounts.\n"; | 669 | result += "This filter applies to all but IMAP accounts.\n"; | ||
650 | } else if (bApplyOnInbound) { | 670 | } else if (bApplyOnInbound) { | ||
651 | QStringList::ConstIterator it2; | 671 | QStringList::ConstIterator it2; | ||
652 | result += "This filter applies to the following accounts:"; | 672 | result += "This filter applies to the following accounts:"; | ||
Show All 31 Lines | 692 | { | |||
684 | stream << filter.mAccounts; | 704 | stream << filter.mAccounts; | ||
685 | stream << filter.mIcon; | 705 | stream << filter.mIcon; | ||
686 | stream << filter.mToolbarName; | 706 | stream << filter.mToolbarName; | ||
687 | stream << filter.mShortcut; | 707 | stream << filter.mShortcut; | ||
688 | stream << filter.bApplyOnInbound; | 708 | stream << filter.bApplyOnInbound; | ||
689 | stream << filter.bApplyBeforeOutbound; | 709 | stream << filter.bApplyBeforeOutbound; | ||
690 | stream << filter.bApplyOnOutbound; | 710 | stream << filter.bApplyOnOutbound; | ||
691 | stream << filter.bApplyOnExplicit; | 711 | stream << filter.bApplyOnExplicit; | ||
712 | stream << filter.bApplyOnAllFolders; | ||||
692 | stream << filter.bStopProcessingHere; | 713 | stream << filter.bStopProcessingHere; | ||
693 | stream << filter.bConfigureShortcut; | 714 | stream << filter.bConfigureShortcut; | ||
694 | stream << filter.bConfigureToolbar; | 715 | stream << filter.bConfigureToolbar; | ||
695 | stream << filter.bAutoNaming; | 716 | stream << filter.bAutoNaming; | ||
696 | stream << filter.mApplicability; | 717 | stream << filter.mApplicability; | ||
697 | stream << filter.bEnabled; | 718 | stream << filter.bEnabled; | ||
698 | 719 | | |||
699 | return stream; | 720 | return stream; | ||
700 | } | 721 | } | ||
701 | 722 | | |||
702 | QDataStream &MailCommon::operator>>(QDataStream &stream, MailCommon::MailFilter &filter) | 723 | QDataStream &MailCommon::operator>>(QDataStream &stream, MailCommon::MailFilter &filter) | ||
703 | { | 724 | { | ||
704 | QByteArray pattern; | 725 | QByteArray pattern; | ||
705 | int numberOfActions; | 726 | int numberOfActions; | ||
706 | QKeySequence shortcut; | 727 | QKeySequence shortcut; | ||
707 | bool bApplyOnInbound; | 728 | bool bApplyOnInbound; | ||
708 | bool bApplyBeforeOutbound; | 729 | bool bApplyBeforeOutbound; | ||
709 | bool bApplyOnOutbound; | 730 | bool bApplyOnOutbound; | ||
710 | bool bApplyOnExplicit; | 731 | bool bApplyOnExplicit; | ||
732 | bool bApplyOnAllFolders; | ||||
711 | bool bStopProcessingHere; | 733 | bool bStopProcessingHere; | ||
712 | bool bConfigureShortcut; | 734 | bool bConfigureShortcut; | ||
713 | bool bConfigureToolbar; | 735 | bool bConfigureToolbar; | ||
714 | bool bAutoNaming; | 736 | bool bAutoNaming; | ||
715 | int applicability; | 737 | int applicability; | ||
716 | bool bEnabled; | 738 | bool bEnabled; | ||
717 | 739 | | |||
718 | stream >> filter.mIdentifier; | 740 | stream >> filter.mIdentifier; | ||
Show All 23 Lines | |||||
742 | stream >> filter.mAccounts; | 764 | stream >> filter.mAccounts; | ||
743 | stream >> filter.mIcon; | 765 | stream >> filter.mIcon; | ||
744 | stream >> filter.mToolbarName; | 766 | stream >> filter.mToolbarName; | ||
745 | stream >> shortcut; | 767 | stream >> shortcut; | ||
746 | stream >> bApplyOnInbound; | 768 | stream >> bApplyOnInbound; | ||
747 | stream >> bApplyBeforeOutbound; | 769 | stream >> bApplyBeforeOutbound; | ||
748 | stream >> bApplyOnOutbound; | 770 | stream >> bApplyOnOutbound; | ||
749 | stream >> bApplyOnExplicit; | 771 | stream >> bApplyOnExplicit; | ||
772 | stream >> bApplyOnAllFolders; | ||||
750 | stream >> bStopProcessingHere; | 773 | stream >> bStopProcessingHere; | ||
751 | stream >> bConfigureShortcut; | 774 | stream >> bConfigureShortcut; | ||
752 | stream >> bConfigureToolbar; | 775 | stream >> bConfigureToolbar; | ||
753 | stream >> bAutoNaming; | 776 | stream >> bAutoNaming; | ||
754 | stream >> applicability; | 777 | stream >> applicability; | ||
755 | stream >> bEnabled; | 778 | stream >> bEnabled; | ||
756 | 779 | | |||
757 | filter.mPattern.deserialize(pattern); | 780 | filter.mPattern.deserialize(pattern); | ||
758 | filter.mShortcut = shortcut; | 781 | filter.mShortcut = shortcut; | ||
759 | filter.bApplyOnInbound = bApplyOnInbound; | 782 | filter.bApplyOnInbound = bApplyOnInbound; | ||
760 | filter.bApplyBeforeOutbound = bApplyBeforeOutbound; | 783 | filter.bApplyBeforeOutbound = bApplyBeforeOutbound; | ||
761 | filter.bApplyOnOutbound = bApplyOnOutbound; | 784 | filter.bApplyOnOutbound = bApplyOnOutbound; | ||
762 | filter.bApplyOnExplicit = bApplyOnExplicit; | 785 | filter.bApplyOnExplicit = bApplyOnExplicit; | ||
786 | filter.bApplyOnAllFolders = bApplyOnAllFolders; | ||||
763 | filter.bStopProcessingHere = bStopProcessingHere; | 787 | filter.bStopProcessingHere = bStopProcessingHere; | ||
764 | filter.bConfigureShortcut = bConfigureShortcut; | 788 | filter.bConfigureShortcut = bConfigureShortcut; | ||
765 | filter.bConfigureToolbar = bConfigureToolbar; | 789 | filter.bConfigureToolbar = bConfigureToolbar; | ||
766 | filter.bAutoNaming = bAutoNaming; | 790 | filter.bAutoNaming = bAutoNaming; | ||
767 | filter.bEnabled = bEnabled; | 791 | filter.bEnabled = bEnabled; | ||
768 | filter.mApplicability = static_cast<MailCommon::MailFilter::AccountType>(applicability); | 792 | filter.mApplicability = static_cast<MailCommon::MailFilter::AccountType>(applicability); | ||
769 | 793 | | |||
770 | return stream; | 794 | return stream; | ||
Show All 11 Lines |