plugins/contacts/symbian/plugin/inc/filtering/cntfilterdetail.h
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtCore module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef CNTFILTERDETAIL_H
       
    43 #define CNTFILTERDETAIL_H
       
    44 
       
    45 #include "cntabstractcontactfilter.h"
       
    46 #include "cntsymbiansrvconnection.h"
       
    47 #include "cntdbinfo.h"
       
    48 
       
    49 #include <qmobilityglobal.h>
       
    50 
       
    51 QTM_USE_NAMESPACE
       
    52 
       
    53 enum TNumberType { ENotInitialized, EUnknown, EDigit, EPlus, EOneZero, ETwoZeros };
       
    54 
       
    55 class CntFilterDetail : public CntAbstractContactFilter
       
    56 {
       
    57 private:
       
    58     class TMatch {
       
    59         public:
       
    60             TMatch();
       
    61         
       
    62             static TInt32 createHash(const TDesC& phoneNumberString,
       
    63                                      TInt matchLength,
       
    64                                      TInt& numPhoneDigits);
       
    65             static void stripOutNonDigitChars(TDes& text);
       
    66             static TInt32 padOutPhoneMatchNumber(TInt32& phoneNumber,
       
    67                                                  TInt padOutLength);
       
    68             static TBool validateBestMatchingRulesL(const TDesC& phoneNumber, const TDesC& matchNumber);
       
    69             static TBool checkBestMatchingRules(const TDesC& numberA, TNumberType numberAType,
       
    70                                          const TDesC& numberB, TNumberType numberBType);
       
    71             static TInt formatAndCheckNumberType(TDes& number);
       
    72         public:
       
    73             TInt32 iLowerSevenDigits;
       
    74             TInt32 iUpperDigits;
       
    75             TInt iNumLowerDigits;
       
    76             TInt iNumUpperDigits;
       
    77     };
       
    78 public:
       
    79     CntFilterDetail(CContactDatabase& contactDatabase, CntSymbianSrvConnection &cntServer,CntDbInfo& dbInfo);
       
    80     ~CntFilterDetail();
       
    81     QList<QContactLocalId> contacts(
       
    82             const QContactFilter &filter,
       
    83             const QList<QContactSortOrder> &sortOrders,
       
    84             bool &filterSupported,
       
    85             QContactManager::Error* error);
       
    86     bool filterSupported(const QContactFilter& filter) ;
       
    87     
       
    88     void getTableNameWhereClause(const QContactDetailFilter& filter,
       
    89                                  QString& tableName,
       
    90                                  QString& sqlWhereClause ,
       
    91                                  QContactManager::Error* error) const;
       
    92     void createSelectQuery(const QContactFilter& filter,
       
    93                            QString& sqlQuery,
       
    94                            QContactManager::Error* error);
       
    95     void createMatchPhoneNumberQuery(const QContactFilter& filter,
       
    96                                      QString& sqlQuery,
       
    97                                      QContactManager::Error* error);
       
    98 #ifdef PBK_UNIT_TEST
       
    99     void emulateBestMatching();
       
   100 #endif //PBK_UNIT_TEST
       
   101     
       
   102 private:
       
   103     void updateForMatchFlag( const QContactDetailFilter& filter,
       
   104                              QString& fieldToUpdate ,
       
   105                              QContactManager::Error* error) const;
       
   106     QList<QContactLocalId>  HandlePredictiveSearchFilter(const QContactFilter& filter,
       
   107                                                          QContactManager::Error* error);
       
   108     
       
   109     CntFilterDetail::TMatch createPaddedPhoneDigits(const TDesC& number, 
       
   110                                                     const TInt numLowerDigits,
       
   111                                                     const TInt numUpperDigits,
       
   112                                                     QContactManager::Error* error);
       
   113     CntFilterDetail::TMatch createPhoneMatchNumber(const TDesC& text,
       
   114                                                    TInt lowerMatchLength,
       
   115                                                    TInt upperMatchLength,
       
   116                                                    QContactManager::Error* error);
       
   117     bool getMatchLengthL(TInt& matchLength);
       
   118     bool bestMatchingEnabled();
       
   119     QList<QContactLocalId> getBestMatchPhoneNumbersL(const QString number,
       
   120                                                      const QList<QContactLocalId>& idList,
       
   121                                                      QContactManager::Error* error);
       
   122     
       
   123     
       
   124 protected:
       
   125     CContactDatabase& m_contactdatabase;
       
   126     CntSymbianSrvConnection &m_srvConnection;
       
   127     CntDbInfo& m_dbInfo;
       
   128     bool m_emulateBestMatching; //PBK_UNIT_TEST
       
   129 };
       
   130 
       
   131 #endif