phoneengine/phonecntfinder2/src/cphcntmatch2.cpp
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 22 6bb1b21d2484
parent 46 bc5a64e5bc3c
equal deleted inserted replaced
40:bab96b7ed1a4 51:f39ed5e045e0
    16 */
    16 */
    17 #include <qcontact.h>
    17 #include <qcontact.h>
    18 #include <qcontactdetail.h>
    18 #include <qcontactdetail.h>
    19 #include <qcontactname.h>
    19 #include <qcontactname.h>
    20 #include <qcontactavatar.h>
    20 #include <qcontactavatar.h>
       
    21 #include <qcontactringtone.h>
    21 #include <qcontactphonenumber.h>
    22 #include <qcontactphonenumber.h>
    22 #include <qtcontactsglobal.h>
    23 #include <qtcontactsglobal.h>
    23 #include "cphcntmatch2.h"
    24 #include "cphcntmatch2.h"
    24 #include "cphcntcontactidimpl2.h"
    25 #include "cphcntcontactidimpl2.h"
    25 #include "qtphonelog.h"
    26 #include "qtphonelog.h"
    29 // ---------------------------------------------------------------------------
    30 // ---------------------------------------------------------------------------
    30 // Constructor
    31 // Constructor
    31 // ---------------------------------------------------------------------------
    32 // ---------------------------------------------------------------------------
    32 //
    33 //
    33 CPhCntMatch2::CPhCntMatch2(const QContact aContact):
    34 CPhCntMatch2::CPhCntMatch2(const QContact aContact):
    34 iContact(aContact), iNumber(NULL), iContactId(NULL), iDummyArray(NULL)
    35 iContact(aContact), iNumber(NULL), iContactId(NULL), iDTMFArray(NULL)
    35     {
    36     {
    36     }
    37     }
    37 
    38 
    38 // ---------------------------------------------------------------------------
    39 // ---------------------------------------------------------------------------
    39 // Destructor.
    40 // Destructor.
    40 // ---------------------------------------------------------------------------
    41 // ---------------------------------------------------------------------------
    41 //
    42 //
    42 CPhCntMatch2::~CPhCntMatch2()
    43 CPhCntMatch2::~CPhCntMatch2()
    43     {
    44     {
    44     delete iNumber;
    45     delete iNumber;
    45     delete iDummyArray;
    46     delete iDTMFArray;
    46     delete iContactId; 
    47     delete iContactId; 
    47     }
    48     }
    48     
    49     
    49 // -----------------------------------------------------------------------------
    50 // -----------------------------------------------------------------------------
    50 // CPhCntMatch2::NewL
    51 // CPhCntMatch2::NewL
    83 // NumberType
    84 // NumberType
    84 // -----------------------------------------------------------------------------
    85 // -----------------------------------------------------------------------------
    85 //
    86 //
    86 MPhCntMatch::TNumberType CPhCntMatch2::NumberType() const
    87 MPhCntMatch::TNumberType CPhCntMatch2::NumberType() const
    87 {
    88 {
    88 
    89     return MPhCntMatch::ENone;
    89     MPhCntMatch::TNumberType valueToReturn = MPhCntMatch::EMobileNumber;
       
    90     /* -> TODO not yet supported
       
    91     switch (iContact->field(fieldNumber).property())
       
    92         {
       
    93         case propertyMobile: 
       
    94             {
       
    95             valueToReturn = MPhCntMatch::EMobileNumber;
       
    96             break;
       
    97             }
       
    98         default:
       
    99             {
       
   100             valueToReturn = MPhCntMatch::ENone;
       
   101             }
       
   102         
       
   103         }//switch
       
   104     */
       
   105     
       
   106     return valueToReturn;
       
   107 }
    90 }
   108 
    91 
   109 // -----------------------------------------------------------------------------
    92 // -----------------------------------------------------------------------------
   110 // Cli
    93 // Cli
   111 // -----------------------------------------------------------------------------
    94 // -----------------------------------------------------------------------------
   120 // FirstName
   103 // FirstName
   121 // -----------------------------------------------------------------------------
   104 // -----------------------------------------------------------------------------
   122 //
   105 //
   123 TPtrC CPhCntMatch2::FirstName() const
   106 TPtrC CPhCntMatch2::FirstName() const
   124 {
   107 {
   125     return FieldValue(QContactName::DefinitionName, QContactName::FieldFirst); 
   108     return iFirstname.utf16();
   126 
   109 
   127 }
   110 }
   128 // -----------------------------------------------------------------------------
   111 // -----------------------------------------------------------------------------
   129 // LastName
   112 // LastName
   130 // -----------------------------------------------------------------------------
   113 // -----------------------------------------------------------------------------
   131 //
   114 //
   132 TPtrC CPhCntMatch2::LastName() const
   115 TPtrC CPhCntMatch2::LastName() const
   133 {
   116 {
   134     return FieldValue(QContactName::DefinitionName, QContactName::FieldLast);
   117     return iLastname.utf16();
   135    
   118    
   136 }
   119 }
   137 // -----------------------------------------------------------------------------
   120 // -----------------------------------------------------------------------------
   138 // CompanyName
   121 // CompanyName
   139 // -----------------------------------------------------------------------------
   122 // -----------------------------------------------------------------------------
   146 // Number
   129 // Number
   147 // -----------------------------------------------------------------------------
   130 // -----------------------------------------------------------------------------
   148 //
   131 //
   149 TPtrC CPhCntMatch2::Number() const
   132 TPtrC CPhCntMatch2::Number() const
   150 {
   133 {
   151 //how many numbers are returned here? should be only one that matched
   134     //how many numbers are returned here? should be only one that matched 
   152     return iNumber? iNumber->Des() : 
   135     if ( iNumber == NULL ) {
   153            FieldValue(QContactPhoneNumber::DefinitionName, 
   136    
   154                       QContactPhoneNumber::FieldNumber);
   137     TPtrC ptr(FieldValue(QContactPhoneNumber::DefinitionName, 
       
   138                QContactPhoneNumber::FieldNumber).utf16());
       
   139     const_cast<HBufC*>(iNumber) = ptr.Alloc();
       
   140     }  
       
   141     return iNumber->Des();
   155 }
   142 }
   156 // -----------------------------------------------------------------------------
   143 // -----------------------------------------------------------------------------
   157 // PersonalRingingTone
   144 // PersonalRingingTone
   158 // -----------------------------------------------------------------------------
   145 // -----------------------------------------------------------------------------
   159 //
   146 //
   160 TPtrC CPhCntMatch2::PersonalRingingTone() const
   147 TPtrC CPhCntMatch2::PersonalRingingTone() const
   161 {
   148 {
   162     /*
   149     return iPersonalRingtone.utf16();
   163     //TODO
       
   164     QString returnValue;
       
   165     QList<QContactAvatar> details = iContact.details<QContactAvatar>();
       
   166     
       
   167     for (int i=0;i<details.count();++i) {
       
   168         if (details.at(i).subType() == QContactAvatar::SubTypeAudioRingtone) {
       
   169             returnValue = details.at(i).avatar();
       
   170             break;
       
   171         }
       
   172     }
       
   173 
       
   174     return returnValue.utf16();*/
       
   175     return KNullDesC();
       
   176 }
   150 }
   177 // -----------------------------------------------------------------------------
   151 // -----------------------------------------------------------------------------
   178 // BelongsToGroups
   152 // BelongsToGroups
   179 // -----------------------------------------------------------------------------
   153 // -----------------------------------------------------------------------------
   180 //
   154 //
   203 // CallImage
   177 // CallImage
   204 // -----------------------------------------------------------------------------
   178 // -----------------------------------------------------------------------------
   205 //       
   179 //       
   206 TPtrC CPhCntMatch2::CallImage() const
   180 TPtrC CPhCntMatch2::CallImage() const
   207 {
   181 {
   208     QString returnValue;
   182     return iCallImage.utf16();
   209     QList<QContactAvatar> details = iContact.details<QContactAvatar>();
       
   210 
       
   211     for (int i=0;i<details.count();++i) {
       
   212         if (details.at(i).subType() == QContactAvatar::SubTypeImage) {
       
   213             returnValue = details.at(i).avatar();
       
   214             break;
       
   215         }
       
   216     }
       
   217     
       
   218     return returnValue.utf16();
       
   219 }
   183 }
   220 // -----------------------------------------------------------------------------
   184 // -----------------------------------------------------------------------------
   221 // HasThumbnailImage
   185 // HasThumbnailImage
   222 // -----------------------------------------------------------------------------
   186 // -----------------------------------------------------------------------------
   223 //       
   187 //       
   229 // AllDtmfNumbers
   193 // AllDtmfNumbers
   230 // -----------------------------------------------------------------------------
   194 // -----------------------------------------------------------------------------
   231 //
   195 //
   232 CDesCArray& CPhCntMatch2::AllDtmfNumbers() const
   196 CDesCArray& CPhCntMatch2::AllDtmfNumbers() const
   233 {
   197 {
   234     return *iDummyArray;
   198     return *iDTMFArray;
   235 }
   199 }
   236 // -----------------------------------------------------------------------------
   200 // -----------------------------------------------------------------------------
   237 // SetNumberL
   201 // SetNumberL
   238 // -----------------------------------------------------------------------------
   202 // -----------------------------------------------------------------------------
   239 //
   203 //
   250 // -----------------------------------------------------------------------------
   214 // -----------------------------------------------------------------------------
   251 //
   215 //
   252 void CPhCntMatch2::ConstructL()
   216 void CPhCntMatch2::ConstructL()
   253     {
   217     {
   254     iContactId = CPhCntContactIdImpl2::NewL(iContact);
   218     iContactId = CPhCntContactIdImpl2::NewL(iContact);
   255     iDummyArray = new CDesCArrayFlat(1);
   219     iDTMFArray = new CDesCArrayFlat(1);
       
   220     
       
   221     //Get first and last name
       
   222     iFirstname = FieldValue(
       
   223              QContactName::DefinitionName,
       
   224              QContactName::FieldFirstName); 
       
   225     
       
   226     
       
   227     iLastname = FieldValue(
       
   228              QContactName::DefinitionName, 
       
   229              QContactName::FieldLastName);
       
   230     
       
   231     //Get caller's image
       
   232     QList<QContactAvatar> details = iContact.details<QContactAvatar>();
       
   233     for (int i=0;i<details.count();++i) {
       
   234         if (!details.at(i).imageUrl().isEmpty()) {
       
   235             iCallImage = details.at(i).imageUrl().toString();
       
   236             break;
       
   237         }
       
   238     }
       
   239     PHONE_DEBUG2("CPhCntMatch2::callImage:: value is :", iCallImage);
       
   240     
       
   241     
       
   242     //Get personal ringtone
       
   243     QContactRingtone ringtonedetail = iContact.detail<QContactRingtone>();
       
   244     iPersonalRingtone = ringtonedetail.audioRingtoneUrl().toString();
       
   245     PHONE_DEBUG2("CPhCntMatch2::personalRingingtone:: value is :", iPersonalRingtone);
       
   246 
   256     }
   247     }
   257 
   248 
   258 // -----------------------------------------------------------------------------
   249 // -----------------------------------------------------------------------------
   259 // FieldValue
   250 // FieldValue
   260 // -----------------------------------------------------------------------------
   251 // -----------------------------------------------------------------------------
   261 //
   252 //
   262 TPtrC CPhCntMatch2::FieldValue(const QString& name, const QString& key) const
   253 QString CPhCntMatch2::FieldValue(const QString& name, const QString& key) const
   263 {
   254 {
   264     QString returnValue;
   255     QString returnValue;
   265     QList<QContactDetail> details = iContact.details(name);
   256     QList<QContactDetail> details = iContact.details(name);
   266     if (details.count() == 1)
   257     if (details.count() == 1)
   267         {
   258         {
   268         returnValue = details.first().value(key);        
   259         returnValue = details.first().value(key);        
   269         }
   260         }
   270     PHONE_DEBUG4("CPhCntMatch2::FieldValue:: key is :", key, "..value is :", returnValue);
   261     PHONE_DEBUG4("CPhCntMatch2::FieldValue:: key is :", key, "..value is :", returnValue);
   271     return returnValue.utf16();    
   262     return returnValue;    
   272 }
   263 }
   273 
   264 
   274 
   265