~ubuntu-branches/ubuntu/quantal/qtmobility/quantal

« back to all changes in this revision

Viewing changes to src/messaging/qmessagefilter_maemo.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-16 16:18:07 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101116161807-k2dzt2nyse975r3l
Tags: 1.1.0-0ubuntu1
* New upstream release
* Syncronise with Debian, no remaining changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
**
9
9
** $QT_BEGIN_LICENSE:LGPL$
10
10
** Commercial Usage
11
 
** Licensees holding valid Qt Commercial licenses may use this file in
12
 
** accordance with the Qt Solutions Commercial License Agreement provided
13
 
** with the Software or, alternatively, in accordance with the terms
 
11
** Licensees holding valid Qt Commercial licenses may use this file in 
 
12
** accordance with the Qt Commercial License Agreement provided with
 
13
** the Software or, alternatively, in accordance with the terms
14
14
** contained in a written agreement between you and Nokia.
15
15
**
16
16
** GNU Lesser General Public License Usage
33
33
** ensure the GNU General Public License version 3.0 requirements will be
34
34
** met: http://www.gnu.org/copyleft/gpl.html.
35
35
**
36
 
** Please note Third Party Software included with Qt Solutions may impose
37
 
** additional restrictions and it is the user's responsibility to ensure
38
 
** that they have met the licensing requirements of the GPL, LGPL, or Qt
39
 
** Solutions Commercial license and the relevant license of the Third
40
 
** Party Software they are using.
41
 
**
42
36
** If you are unsure which license is appropriate for your use, please
43
37
** contact the sales department at qt-sales@nokia.com.
44
38
** $QT_END_LICENSE$
644
638
    return result;
645
639
}
646
640
 
 
641
bool QMessageFilterPrivate::preFilter(QMessage::Type type, const QString &idPrefix, const QMessageFilterPrivate &privateFilter)
 
642
{
 
643
    bool result = true;
 
644
 
 
645
    switch (privateFilter._field) {
 
646
    case QMessageFilterPrivate::Id:
 
647
        {
 
648
        if (privateFilter._comparatorType == QMessageFilterPrivate::Equality) {
 
649
            QMessageDataComparator::EqualityComparator cmp(static_cast<QMessageDataComparator::EqualityComparator>(privateFilter._comparatorValue));
 
650
            if (cmp == QMessageDataComparator::Equal) {
 
651
                if (!privateFilter._value.toString().isEmpty()) {
 
652
                    if (!privateFilter._value.toString().startsWith(idPrefix)) {
 
653
                        result = false;
 
654
                    }
 
655
                }
 
656
            } else { // NotEqual
 
657
                // => Filter must be handled
 
658
            }
 
659
        } else if (privateFilter._comparatorType == QMessageFilterPrivate::Inclusion) {
 
660
            QMessageDataComparator::InclusionComparator cmp(static_cast<QMessageDataComparator::InclusionComparator>(privateFilter._comparatorValue));
 
661
            if (privateFilter._ids.count() > 0) { // QMessageIdList
 
662
               if (cmp == QMessageDataComparator::Includes) {
 
663
                   result = false;
 
664
                   for (int i = 0; i < privateFilter._ids.count(); i++) {
 
665
                       if (privateFilter._ids[i].toString().startsWith(idPrefix)) {
 
666
                           result = true;
 
667
                           break;
 
668
                       }
 
669
                   }
 
670
               } else { // Excludes
 
671
                   // => Filter must be handled
 
672
               }
 
673
            } else { // QMessageFilter
 
674
               if (cmp == QMessageDataComparator::Includes) {
 
675
                   // TODO:
 
676
               } else { // Excludes
 
677
                   // TODO:
 
678
               }
 
679
            }
 
680
        }
 
681
        break;
 
682
        }
 
683
    case QMessageFilterPrivate::Type:
 
684
        {
 
685
        QMessage::Type typeFromFilter = static_cast<QMessage::Type>(privateFilter._value.toInt());
 
686
        if (privateFilter._comparatorType == QMessageFilterPrivate::Equality) {
 
687
            QMessageDataComparator::EqualityComparator cmp(static_cast<QMessageDataComparator::EqualityComparator>(privateFilter._comparatorValue));
 
688
            if (cmp == QMessageDataComparator::Equal) {
 
689
                if (typeFromFilter != QMessage::NoType && type != typeFromFilter) {
 
690
                    result = false;
 
691
                }
 
692
            } else { // NotEqual
 
693
                if (typeFromFilter != QMessage::NoType && type == typeFromFilter) {
 
694
                    result = false;
 
695
                }
 
696
            }
 
697
        } else if (privateFilter._comparatorType == QMessageFilterPrivate::Inclusion) {
 
698
            QMessageDataComparator::InclusionComparator cmp(static_cast<QMessageDataComparator::InclusionComparator>(privateFilter._comparatorValue));
 
699
            if (cmp == QMessageDataComparator::Includes) {
 
700
                if ((type & typeFromFilter) == 0) {
 
701
                    result = false;
 
702
                }
 
703
            } else { // Excludes
 
704
                if ((type & typeFromFilter) == type) {
 
705
                    result = false;
 
706
                }
 
707
            }
 
708
        }
 
709
        break;
 
710
        }
 
711
    case QMessageFilterPrivate::ParentAccountId:
 
712
        {
 
713
        if (privateFilter._comparatorType == QMessageFilterPrivate::Equality) {
 
714
            QMessageDataComparator::EqualityComparator cmp(static_cast<QMessageDataComparator::EqualityComparator>(privateFilter._comparatorValue));
 
715
            if (cmp == QMessageDataComparator::Equal) {
 
716
                if (!privateFilter._value.toString().isEmpty()) {
 
717
                    if (!privateFilter._value.toString().startsWith(idPrefix)) {
 
718
                        result = false;
 
719
                    }
 
720
                }
 
721
            } else { // NotEqual
 
722
                // => Filter must be handled
 
723
            }
 
724
        }
 
725
        break;
 
726
        }
 
727
    case QMessageFilterPrivate::ParentFolderId:
 
728
        {
 
729
        if (privateFilter._comparatorType == QMessageFilterPrivate::Equality) {
 
730
            QMessageDataComparator::EqualityComparator cmp(static_cast<QMessageDataComparator::EqualityComparator>(privateFilter._comparatorValue));
 
731
            if (cmp == QMessageDataComparator::Equal) {
 
732
                if (!privateFilter._value.toString().isEmpty()) {
 
733
                    if (!privateFilter._value.toString().startsWith(idPrefix)) {
 
734
                        result = false;
 
735
                    }
 
736
                }
 
737
            } else { // NotEqual
 
738
                // => Filter must be handled
 
739
            }
 
740
        } else if (privateFilter._comparatorType == QMessageFilterPrivate::Inclusion) {
 
741
            QMessageDataComparator::InclusionComparator cmp(static_cast<QMessageDataComparator::InclusionComparator>(privateFilter._comparatorValue));
 
742
                if (cmp == QMessageDataComparator::Includes) {
 
743
                result = false;
 
744
                for (int i = 0; i < privateFilter._ids.count(); i++) {
 
745
                    if (privateFilter._ids[i].toString().startsWith(idPrefix)) {
 
746
                        result = true;
 
747
                        break;
 
748
                    }
 
749
                }
 
750
            } else { // Excludes
 
751
                // => Filter must be handled
 
752
            }
 
753
        }
 
754
        break;
 
755
        }
 
756
    case QMessageFilterPrivate::AncestorFolderIds:
 
757
        {
 
758
        if (privateFilter._comparatorType == QMessageFilterPrivate::Inclusion) {
 
759
            QMessageDataComparator::InclusionComparator cmp(static_cast<QMessageDataComparator::InclusionComparator>(privateFilter._comparatorValue));
 
760
            if (!privateFilter._value.isNull()) { // QMessageFolderId
 
761
                if (cmp == QMessageDataComparator::Includes) {
 
762
                    result = false;
 
763
                    for (int i = 0; i < privateFilter._ids.count(); i++) {
 
764
                        if (privateFilter._ids[i].toString().startsWith(idPrefix)) {
 
765
                            result = true;
 
766
                            break;
 
767
                        }
 
768
                    }
 
769
                } else { // Excludes
 
770
                    // => Filter must be handled
 
771
                }
 
772
            } else { // QMessageFolderFilter
 
773
                if (cmp == QMessageDataComparator::Includes) {
 
774
                    // TODO:
 
775
                } else { // Excludes
 
776
                    // TODO:
 
777
                }
 
778
            }
 
779
        }
 
780
        break;
 
781
        }
 
782
    case QMessageFilterPrivate::ParentAccountIdFilter:
 
783
    case QMessageFilterPrivate::ParentFolderIdFilter:
 
784
    case QMessageFilterPrivate::StandardFolder:
 
785
    case QMessageFilterPrivate::TimeStamp:
 
786
    case QMessageFilterPrivate::ReceptionTimeStamp:
 
787
    case QMessageFilterPrivate::Sender:
 
788
    case QMessageFilterPrivate::Recipients:
 
789
    case QMessageFilterPrivate::Subject:
 
790
    case QMessageFilterPrivate::Status:
 
791
    case QMessageFilterPrivate::Priority:
 
792
    case QMessageFilterPrivate::Size:
 
793
    case QMessageFilterPrivate::None:
 
794
        break;
 
795
    }
 
796
 
 
797
    return result;
 
798
}
 
799
 
 
800
bool QMessageFilterPrivate::preFilterRow(QMessage::Type type, const QString &idPrefix, const SortedMessageFilterList &filterRow)
 
801
{
 
802
    bool result = true;
 
803
 
 
804
    for (int i=0; i < filterRow.count(); i++) {
 
805
        result = preFilter(type, idPrefix, *filterRow[i].d_ptr);
 
806
        if (result == false) {
 
807
            break;
 
808
        }
 
809
    }
 
810
 
 
811
    return result;
 
812
}
 
813
 
 
814
bool QMessageFilterPrivate::preFilter(QMessage::Type type, const QString idPrefix) const
 
815
{
 
816
    bool result = false;
 
817
 
 
818
    SortedMessageFilterList filterRow;
 
819
 
 
820
    if (_filterList.count() == 0) {
 
821
        result = preFilter(type, idPrefix, *this);
 
822
    } else {
 
823
        for (int i=0; i < _filterList.count(); i++) {
 
824
            result = preFilterRow(type, idPrefix, _filterList[i]);
 
825
            if (result == true) {
 
826
                break;
 
827
            }
 
828
        }
 
829
    }
 
830
 
 
831
    return result;
 
832
}
 
833
 
647
834
QMessageFilterPrivate* QMessageFilterPrivate::implementation(const QMessageFilter &filter)
648
835
 
649
836
{