serviceproviders/sapi_contacts_vpbk/tsrc/testing/tcontact_getIds/src/tcontact_getIdsblocks.cpp
changeset 22 fc9cf246af83
child 24 f4292e0e20df
equal deleted inserted replaced
19:989d2f495d90 22:fc9cf246af83
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <e32svr.h>
       
    23 #include <StifParser.h>
       
    24 #include <Stiftestinterface.h>
       
    25 #include "tcontact_getIds.h"
       
    26 
       
    27 // EXTERNAL DATA STRUCTURES
       
    28 //extern  ?external_data;
       
    29 
       
    30 // EXTERNAL FUNCTION PROTOTYPES  
       
    31 //extern ?external_function( ?arg_type,?arg_type );
       
    32 
       
    33 // CONSTANTS
       
    34 //const ?type ?constant_var = ?constant;
       
    35 
       
    36 // MACROS
       
    37 //#define ?macro ?macro_def
       
    38 
       
    39 // LOCAL CONSTANTS AND MACROS
       
    40 //const ?type ?constant_var = ?constant;
       
    41 //#define ?macro_name ?macro_def
       
    42 
       
    43 // MODULE DATA STRUCTURES
       
    44 //enum ?declaration
       
    45 //typedef ?declaration
       
    46 
       
    47 // LOCAL FUNCTION PROTOTYPES
       
    48 //?type ?function_name( ?arg_type, ?arg_type );
       
    49 
       
    50 // FORWARD DECLARATIONS
       
    51 //class ?FORWARD_CLASSNAME;
       
    52 
       
    53 // ============================= LOCAL FUNCTIONS ===============================
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // ?function_name ?description.
       
    57 // ?description
       
    58 // Returns: ?value_1: ?description
       
    59 //          ?value_n: ?description_line1
       
    60 //                    ?description_line2
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 /*
       
    64 ?type ?function_name(
       
    65     ?arg_type arg,  // ?description
       
    66     ?arg_type arg)  // ?description
       
    67     {
       
    68 
       
    69     ?code  // ?comment
       
    70 
       
    71     // ?comment
       
    72     ?code
       
    73     }
       
    74 */
       
    75 
       
    76 // ============================ MEMBER FUNCTIONS ===============================
       
    77 _LIT(KCntDbUri, "cntdb://c:contacts.cdb");
       
    78 _LIT(KCntDbUri1, "sim://global_adn");
       
    79 TInt cmdFlag = 1;
       
    80 TInt tCount = 0;
       
    81 TInt tIdCount=0;
       
    82  HBufC8* contactid;
       
    83  CSingleContact* myContact=NULL;
       
    84  _LIT(KContactId, "id");
       
    85  
       
    86  void CContactCallback::HandleReturnId(const TInt& aError, HBufC8* aId, TInt aTransId )
       
    87      {
       
    88      CActiveScheduler::Stop();  
       
    89      iError = aError;
       
    90      }
       
    91  
       
    92  
       
    93  void CContactCallback::HandleReturnArray(const TInt& aError, RPointerArray<HBufC8>& aArray, TInt aTransId )
       
    94      {
       
    95      CActiveScheduler::Stop();  
       
    96      iError = aError;
       
    97      tIdCount = aArray.Count();
       
    98      aArray.ResetAndDestroy();
       
    99      }
       
   100  
       
   101 void CContactCallback::HandleReturnValue( TOperationEvent aEventId, const TInt& aError, TInt aTransId )
       
   102 {
       
   103 CActiveScheduler::Stop();  
       
   104 iError= aError;  
       
   105 }
       
   106 
       
   107 
       
   108  void CContactCallback:: HandleReturnIter(const TInt& aError, CContactIter* aIter, TInt aTransId )
       
   109  {
       
   110  CActiveScheduler::Stop();
       
   111  CSingleContactField* field = NULL; 
       
   112  TPtrC8 buf1;
       
   113  TPtrC buf2;
       
   114  TPtrC buf3;
       
   115  TInt count=0 ;  
       
   116  if(cmdFlag == 0)
       
   117      {     
       
   118      tCount = 0;
       
   119   if(aError==KErrNone)
       
   120   {
       
   121      aIter->NextL(myContact,contactid);
       
   122      if(contactid)
       
   123      {
       
   124       delete contactid;
       
   125       contactid = NULL;
       
   126      }
       
   127 
       
   128     while(myContact)
       
   129    {  
       
   130       tCount++;
       
   131       if(myContact)
       
   132      {
       
   133        count++; 
       
   134        TInt len,i ;
       
   135        len=myContact->FieldCount();
       
   136        for(i=0;i<len;i++)
       
   137         {
       
   138           field = myContact->FieldAt(i);
       
   139           CleanupStack::PushL(field);
       
   140            if(field!=NULL)
       
   141                {                
       
   142                field->GetFieldDataL(buf1,buf2,buf3);        
       
   143               
       
   144                    //if(buf1.CompareF(_L8("emailgen"))==0) break;                            
       
   145                }
       
   146            CleanupStack::Pop(field);
       
   147                             
       
   148          } //for 
       
   149              
       
   150      } //if
       
   151      if(myContact)
       
   152        {
       
   153        	delete myContact;
       
   154         myContact = NULL;
       
   155        }
       
   156      aIter->NextL(myContact,contactid);
       
   157      if(contactid)
       
   158      {
       
   159       delete contactid;
       
   160       contactid = NULL;
       
   161      }
       
   162                       
       
   163    } //while
       
   164    delete  aIter;
       
   165      }
       
   166      }
       
   167 } 
       
   168 
       
   169  // -----------------------------------------------------------------------------
       
   170 // Ctcontactgetids::Delete
       
   171 // Delete here all resources allocated and opened from test methods. 
       
   172 // Called from destructor. 
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 void Ctcontactgetids::Delete() 
       
   176     {
       
   177 
       
   178     }
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // Ctcontactgetids::RunMethodL
       
   182 // Run specified method. Contains also table of test mothods and their names.
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 TInt Ctcontactgetids::RunMethodL( 
       
   186     CStifItemParser& aItem ) 
       
   187     {
       
   188 
       
   189     static TStifFunctionInfo const KFunctions[] =
       
   190         {  
       
   191         // Copy this line for every implemented function.
       
   192         // First string is the function name used in TestScripter script file.
       
   193         // Second is the actual implementation member function. 
       
   194         ENTRY( "GetIds_Test1", Ctcontactgetids::GetIds_Test1L ),
       
   195         ENTRY( "GetIds_Test2", Ctcontactgetids::GetIds_Test2L ),
       
   196         ENTRY( "GetIds_Test3", Ctcontactgetids::GetIds_Test3L ),
       
   197         ENTRY( "GetIds_Test4", Ctcontactgetids::GetIds_Test4L ),
       
   198         ENTRY( "GetIds_Test5", Ctcontactgetids::GetIds_Test5L ),
       
   199         ENTRY( "GetIds_Test6", Ctcontactgetids::GetIds_Test6L ), 
       
   200         ENTRY( "GetIds_Test7", Ctcontactgetids::GetIds_Test7L ), 
       
   201         ENTRY( "GetIds_Test8", Ctcontactgetids::GetIds_Test8L ),
       
   202         ENTRY( "GetIds_Test9", Ctcontactgetids::GetIds_Test9L ),
       
   203 /*		ENTRY( "GetIds_Test10", Ctcontactgetids::GetIds_Test10L ),
       
   204 		ENTRY( "GetIds_Test11", Ctcontactgetids::GetIds_Test11L ),*/
       
   205         };
       
   206 
       
   207     const TInt count = sizeof( KFunctions ) / 
       
   208                         sizeof( TStifFunctionInfo );
       
   209 
       
   210     return RunInternalL( KFunctions, count, aItem );
       
   211 
       
   212     }
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // Ctcontactgetids::ExampleL
       
   216 // Example test method function.
       
   217 // (other items were commented in a header).
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 
       
   221  /*Get the list of all contact ids in phone database*/ 	   
       
   222  TInt Ctcontactgetids::GetIds_Test1L( CStifItemParser& /*aItem */)
       
   223     {
       
   224     ////__UHEAP_MARK;
       
   225     icontactservice=CContactService::NewL();
       
   226     icallback=new(ELeave) CContactCallback;
       
   227   // Print to UI
       
   228     /*_LIT( Ktsapicontacts, "tsapicontacts" );
       
   229     _LIT( KExample, "In GetIds_Test1L" );
       
   230     TestModuleIf().Printf( 0, Ktsapicontacts, KExample );
       
   231     // Print to log file
       
   232     iLog->Log( KExample );*/
       
   233     //TInt val =1;
       
   234     //cmdFlag = 0;
       
   235  //   icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc,KCntDbUri);  
       
   236  //   CActiveScheduler::Start();
       
   237     //cmdFlag = 1;
       
   238     icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc,KCntDbUri,EGetIds);
       
   239     CActiveScheduler::Start(); 
       
   240     if(icallback->iError == KErrNone)
       
   241             {
       
   242            // _LIT(KErrCode, "ErrorCode is 0");
       
   243            // iLog->Log(KErrCode);
       
   244             if(tIdCount >= tCount)
       
   245                 {
       
   246   /*              _LIT(KLogInfo, "Count: ");
       
   247                 iLog->Log(KLogInfo);
       
   248                 TBuf8<16> logInfo;
       
   249                 logInfo.Num(tIdCount);
       
   250                 iLog->Log(logInfo);*/
       
   251                 delete icallback;
       
   252 				  delete icontactservice;
       
   253                 //__UHEAP_MARKEND;
       
   254                 return KErrNone;    
       
   255                 }         
       
   256             }
       
   257 //    delete this;
       
   258     delete icallback;
       
   259    delete icontactservice;
       
   260     //__UHEAP_MARKEND;
       
   261         return KErrGeneral;
       
   262  }
       
   263 
       
   264 
       
   265 /* get all contacts from the phonebook ie contacts.cdb*/
       
   266 /*TInt Ctcontactgetids::GetIds_Test2L( CStifItemParser& aItem )
       
   267 {
       
   268 
       
   269   // Print to UI
       
   270     _LIT( Ktsapicontacts, "tsapicontacts" );
       
   271     _LIT( KExample, "In GetList_Test1L" );
       
   272     TestModuleIf().Printf( 0, Ktsapicontacts, KExample );
       
   273     // Print to log file
       
   274     iLog->Log( KExample );
       
   275     
       
   276     cmdFlag = 0;
       
   277  icontactservice->GetListL(icallback,1,EContacts);  
       
   278  CActiveScheduler::Start();
       
   279  cmdFlag = 1;
       
   280  TInt val =1;
       
   281  _LIT(KCntDbUri, "cntdb://c:contacts.cdb");
       
   282     icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc,KCntDbUri,val);
       
   283  CActiveScheduler::Start();
       
   284  if(icallback->iError == KErrNone)
       
   285         {
       
   286         _LIT(KErrCode, "ErrorCode is 0");
       
   287         iLog->Log(KErrCode);
       
   288         if(tIdCount >= tCount)
       
   289             {
       
   290             _LIT(KLogInfo, "Count: ");
       
   291             iLog->Log(KLogInfo);
       
   292             TBuf8<16> logInfo;
       
   293             logInfo.Num(tIdCount);
       
   294             iLog->Log(logInfo);
       
   295             return KErrNone;    
       
   296             }         
       
   297         }
       
   298     return KErrGeneral;
       
   299   
       
   300     
       
   301   }
       
   302 */
       
   303 
       
   304 
       
   305 /*Get the list of all the groups in the phone database*/
       
   306   TInt Ctcontactgetids::GetIds_Test2L( CStifItemParser& /*aItem*/ )
       
   307     {
       
   308     //__UHEAP_MARK;
       
   309 	 icontactservice=CContactService::NewL();
       
   310 	 icallback=new(ELeave) CContactCallback;
       
   311   // Print to UI
       
   312    /* _LIT( Ktsapicontacts, "tsapicontacts" );
       
   313     _LIT( KExample, "In GetIds_Test2L" );
       
   314     TestModuleIf().Printf( 0, Ktsapicontacts, KExample );
       
   315     // Print to log file
       
   316     iLog->Log( KExample );
       
   317     cmdFlag = 0;
       
   318   /*icontactservice->GetListL(icallback,1,EGroups,KNullDesC8,KNullDesC,NULL,EAsc,KCntDbUri);  
       
   319     CActiveScheduler::Start();
       
   320   if(icallback->iError != KErrNone)
       
   321       {
       
   322       return KErrGeneral;
       
   323       }*/
       
   324   cmdFlag = 1;
       
   325   TInt val =1;
       
   326   
       
   327      icontactservice->GetListL(icallback,1,EGroups,KNullDesC8,KNullDesC,NULL,EAsc,KCntDbUri,EGetIds);
       
   328   CActiveScheduler::Start();
       
   329   if(icallback->iError == KErrNone)
       
   330          {
       
   331          /*_LIT(KErrCode, "ErrorCode is 0");
       
   332          iLog->Log(KErrCode);*/
       
   333          if(tIdCount >= tCount)
       
   334              {
       
   335              /*_LIT(KLogInfo, "Count: ");
       
   336              iLog->Log(KLogInfo);
       
   337              TBuf8<16> logInfo;
       
   338              logInfo.Num(tIdCount);
       
   339              iLog->Log(logInfo);*/
       
   340              delete icallback;
       
   341 			 delete icontactservice;
       
   342              //__UHEAP_MARKEND;
       
   343              return KErrNone;    
       
   344              }         
       
   345          }
       
   346   delete icallback;
       
   347 		 delete icontactservice;
       
   348     //__UHEAP_MARKEND;
       
   349      return KErrGeneral;
       
   350      }
       
   351   
       
   352   
       
   353 /*get the list of contact ids based on a search criteria*/
       
   354   TInt Ctcontactgetids::GetIds_Test3L( CStifItemParser& /*aItem*/ )
       
   355       {
       
   356       //////__UHEAP_MARK;
       
   357 	   icontactservice=CContactService::NewL();
       
   358 	   icallback=new(ELeave) CContactCallback;
       
   359 /*  _LIT( Ktsapicontacts, "tsapicontacts" );
       
   360       _LIT( KExample, "In GetIds_Test3L" );
       
   361       TestModuleIf().Printf( 0, Ktsapicontacts, KExample );
       
   362       // Print to log file
       
   363       iLog->Log( KExample );*/
       
   364       _LIT8(KFirstName,"FirstName");
       
   365       _LIT(KName,"Jerry"); 
       
   366       _LIT(KFirst,"First Name");
       
   367       /* create contactitem with invalid fieldname "FrstName */
       
   368       CSingleContact* singleContact = CSingleContact::NewL();
       
   369       CleanupStack::PushL(singleContact);
       
   370       CSingleContactField* singleContactField = CSingleContactField::NewL();
       
   371       CleanupStack::PushL(singleContactField);
       
   372       singleContactField->SetFieldParamsL(KFirstName,KFirst,KName);
       
   373       singleContact->AddFieldToContactL(singleContactField);
       
   374       /* Add the contactitem */
       
   375       icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KNullDesC,KCntDbUri);
       
   376       CActiveScheduler::Start();
       
   377       if(icallback->iError != KErrNone)
       
   378           {
       
   379           CleanupStack::Pop(singleContactField);
       
   380           CleanupStack::Pop(singleContact);
       
   381           delete singleContact;
       
   382           delete icallback;
       
   383             delete icontactservice;
       
   384         //  //__UHEAP_MARKEND;
       
   385           return KErrGeneral;
       
   386           }
       
   387       _LIT(Kname,"Lee");
       
   388       TBuf8<15> fstname(_L8("FirstName"));
       
   389       
       
   390       CSearchFields *srchfield =CSearchFields :: NewL(icontactservice);
       
   391       srchfield->AppendL(fstname);
       
   392       TPtrC searchval(_L("Jerry"));
       
   393       TOrder sortorder =EAsc;
       
   394       
       
   395       cmdFlag = 0;
       
   396       icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,searchval,srchfield,EAsc,KCntDbUri);
       
   397       CActiveScheduler::Start();
       
   398             TBuf8<15> fstName(_L8("FirstName"));
       
   399             CSearchFields *searchfield =CSearchFields :: NewL(icontactservice);
       
   400             searchfield->AppendL(fstName);
       
   401             TPtrC srchval(_L("Jerry"));
       
   402       
       
   403       TInt val =1;
       
   404       cmdFlag = 1;
       
   405       icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,srchval,searchfield,EAsc,KCntDbUri,EGetIds);
       
   406       CActiveScheduler::Start();
       
   407             
       
   408       if(icallback->iError == KErrNone)
       
   409               {
       
   410          /*     _LIT(KErrCode, "ErrorCode is 0");
       
   411               iLog->Log(KErrCode);*/
       
   412               if(tIdCount >= tCount)
       
   413                   {
       
   414                   /*_LIT(KLogInfo, "Count: ");
       
   415                   iLog->Log(KLogInfo);
       
   416                   TBuf8<16> logInfo;
       
   417                   logInfo.Num(tIdCount);
       
   418                   iLog->Log(logInfo);*/
       
   419                   CleanupStack::Pop(singleContactField);
       
   420                    CleanupStack::Pop(singleContact);
       
   421                   delete singleContact;
       
   422                   delete icallback;
       
   423                     delete icontactservice;
       
   424                   ////__UHEAP_MARKEND;
       
   425                   return KErrNone;    
       
   426                   }         
       
   427               }
       
   428       CleanupStack::Pop(singleContactField);
       
   429                 CleanupStack::Pop(singleContact);
       
   430       delete singleContact;
       
   431       delete icallback;
       
   432         delete icontactservice;
       
   433       ////__UHEAP_MARKEND;
       
   434           return KErrGeneral;
       
   435       }
       
   436  
       
   437 /*get the ids of all contacts in phone database in descending order*/
       
   438   TInt Ctcontactgetids::GetIds_Test4L( CStifItemParser& /*aItem*/ )
       
   439       {
       
   440       ////__UHEAP_MARK;
       
   441 	   icontactservice=CContactService::NewL();
       
   442 	   icallback=new(ELeave) CContactCallback;
       
   443 /*      _LIT( Ktsapicontacts, "tsapicontacts" );
       
   444         _LIT( KExample, "In GetIds_Test4L" );
       
   445         TestModuleIf().Printf( 0, Ktsapicontacts, KExample );
       
   446         // Print to log file
       
   447         iLog->Log( KExample );*/
       
   448         TInt val =1;
       
   449         cmdFlag = 0;
       
   450         icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EDesc,KCntDbUri);  
       
   451         CActiveScheduler::Start();
       
   452         cmdFlag = 1;
       
   453         icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EDesc,KCntDbUri,EGetIds);
       
   454         CActiveScheduler::Start(); 
       
   455         if(icallback->iError == KErrNone)
       
   456                 {
       
   457                 /*_LIT(KErrCode, "ErrorCode is 0");
       
   458                 iLog->Log(KErrCode);*/
       
   459                 if(tIdCount >= tCount)
       
   460                     {
       
   461                     /*_LIT(KLogInfo, "Count: ");
       
   462                     iLog->Log(KLogInfo);
       
   463                     TBuf8<16> logInfo;
       
   464                     logInfo.Num(tIdCount);
       
   465                     iLog->Log(logInfo);*/
       
   466                     delete icallback;
       
   467                       delete icontactservice;
       
   468                     //__UHEAP_MARKEND;
       
   469                     return KErrNone;    
       
   470                     }         
       
   471                 }
       
   472         delete icallback;
       
   473           delete icontactservice;
       
   474         //__UHEAP_MARKEND;
       
   475         return KErrGeneral;
       
   476       }
       
   477   
       
   478   /*get all the group ids in phone db in descending order*/
       
   479   TInt Ctcontactgetids::GetIds_Test5L( CStifItemParser& /*aItem*/ )
       
   480         {
       
   481         ////__UHEAP_MARK;
       
   482 		 icontactservice=CContactService::NewL();
       
   483 		 icallback=new(ELeave) CContactCallback;
       
   484   /*_LIT( Ktsapicontacts, "tsapicontacts" );
       
   485     _LIT( KExample, "In GetIds_Test5L" );
       
   486     TestModuleIf().Printf( 0, Ktsapicontacts, KExample );
       
   487     // Print to log file
       
   488     iLog->Log( KExample );
       
   489     cmdFlag = 0;*/
       
   490   /*icontactservice->GetListL(icallback,1,EGroups,KNullDesC8,KNullDesC,NULL,EDesc,KCntDbUri);  
       
   491   CActiveScheduler::Start();
       
   492   if(icallback->iError != KErrNone)
       
   493       {
       
   494       return KErrGeneral;
       
   495       }*/
       
   496   cmdFlag = 1;
       
   497   TInt val =1;
       
   498   
       
   499      icontactservice->GetListL(icallback,1,EGroups,KNullDesC8,KNullDesC,NULL,EDesc,KCntDbUri,EGetIds);
       
   500   CActiveScheduler::Start();
       
   501   if(icallback->iError == KErrNone)
       
   502          {
       
   503          /*_LIT(KErrCode, "ErrorCode is 0");
       
   504          iLog->Log(KErrCode);*/
       
   505          if(tIdCount >= tCount)
       
   506              {
       
   507              /*_LIT(KLogInfo, "Count: ");
       
   508              iLog->Log(KLogInfo);
       
   509              TBuf8<16> logInfo;
       
   510              logInfo.Num(tIdCount);
       
   511              iLog->Log(logInfo);*/
       
   512              delete icallback;
       
   513                delete icontactservice;
       
   514              //__UHEAP_MARKEND;
       
   515              return KErrNone;    
       
   516              }         
       
   517          }
       
   518   delete icallback;
       
   519     delete icontactservice;
       
   520     //__UHEAP_MARKEND;
       
   521      return KErrGeneral;
       
   522      }
       
   523   
       
   524 
       
   525   /*get the list of all contact ids in sim database*/
       
   526   TInt Ctcontactgetids::GetIds_Test6L( CStifItemParser& /*aItem*/ )
       
   527         {
       
   528         ////__UHEAP_MARK;
       
   529 		 icontactservice=CContactService::NewL();
       
   530 		 icallback=new(ELeave) CContactCallback;
       
   531         /*_LIT( Ktsapicontacts, "tsapicontacts" );
       
   532           _LIT( KExample, "In GetIds_Test6L" );
       
   533           TestModuleIf().Printf( 0, Ktsapicontacts, KExample );
       
   534           // Print to log file
       
   535           iLog->Log( KExample );*/
       
   536           TInt val =1;
       
   537           cmdFlag = 0;
       
   538           icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc,KCntDbUri1);  
       
   539           CActiveScheduler::Start();
       
   540           cmdFlag = 1;
       
   541           icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc,KCntDbUri1,EGetIds);
       
   542           CActiveScheduler::Start(); 
       
   543           if(icallback->iError == KErrNone)
       
   544                   {
       
   545                   /*_LIT(KErrCode, "ErrorCode is 0");
       
   546                   iLog->Log(KErrCode);*/
       
   547                   if(tIdCount >= tCount)
       
   548                       {
       
   549                       /*_LIT(KLogInfo, "Count: ");
       
   550                       iLog->Log(KLogInfo);
       
   551                       TBuf8<16> logInfo;
       
   552                       logInfo.Num(tIdCount);
       
   553                       iLog->Log(logInfo);*/
       
   554                       delete icallback;
       
   555                         delete icontactservice;
       
   556                       //__UHEAP_MARKEND;
       
   557                       return KErrNone;    
       
   558                       }         
       
   559                   }
       
   560           delete icallback;
       
   561            delete icontactservice;
       
   562           //__UHEAP_MARKEND;
       
   563           return KErrGeneral;
       
   564         }
       
   565   
       
   566   TInt Ctcontactgetids::GetIds_Test7L( CStifItemParser& /*aItem*/ )
       
   567         {
       
   568         ////__UHEAP_MARK;
       
   569 		 icontactservice=CContactService::NewL();
       
   570 		 icallback=new(ELeave) CContactCallback;
       
   571         /*_LIT( Ktsapicontacts, "tsapicontacts" );
       
   572             _LIT( KExample, "In GetIds_Test7L" );
       
   573             TestModuleIf().Printf( 0, Ktsapicontacts, KExample );
       
   574             // Print to log file
       
   575             iLog->Log( KExample );*/
       
   576        /*     _LIT8(KFirstName,"FirstName");
       
   577             _LIT(KName,"Tom"); 
       
   578             _LIT(KFirst,"First Name");
       
   579         
       
   580             CSingleContact* singleContact = CSingleContact::NewL();
       
   581             CSingleContactField* singleContactField = CSingleContactField::NewL();
       
   582             singleContactField->SetFieldParamsL(KFirstName,KFirst,KName);
       
   583             singleContact->AddFieldToContactL(singleContactField);
       
   584             // Add the contactitem 
       
   585             icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KNullDesC,KCntDbUri1);
       
   586             CActiveScheduler::Start();
       
   587             if(icallback->iError != KErrNone)
       
   588                 {
       
   589                 return KErrGeneral;
       
   590                 }*/
       
   591             _LIT(Kname,"Lee");
       
   592             TBuf8<15> fstname(_L8("FirstName"));
       
   593             
       
   594             CSearchFields *srchfield =CSearchFields :: NewL(icontactservice);
       
   595             srchfield->AppendL(fstname);
       
   596             TPtrC searchval(_L("Arnold"));
       
   597             TOrder sortorder =EAsc;
       
   598             
       
   599             cmdFlag = 0;
       
   600             icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,searchval,srchfield,EAsc,KCntDbUri,EGetList);
       
   601             CActiveScheduler::Start();
       
   602             if(icallback->iError != KErrNone)
       
   603                 {
       
   604                 /*_LIT( KErrorMsg, "The GetList returned non zero error" );
       
   605                 iLog->Log( KErrorMsg );
       
   606                 TBuf<25> errorcodedes(KNullDesC);
       
   607                 errorcodedes.Num(icallback->iError);
       
   608                 iLog->Log(_L("Error code:"));
       
   609                 iLog->Log(errorcodedes); */
       
   610                 delete icallback;
       
   611                  delete icontactservice;		
       
   612                 //__UHEAP_MARKEND;
       
   613                 return KErrGeneral;
       
   614                 }
       
   615                   TBuf8<15> fstName(_L8("FirstName"));
       
   616                   CSearchFields *searchfield =CSearchFields :: NewL(icontactservice);
       
   617                   searchfield->AppendL(fstName);
       
   618                   TPtrC srchval(_L("Arnold"));
       
   619             
       
   620             TInt val =1;
       
   621             cmdFlag = 1;
       
   622             icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,srchval,searchfield,EAsc,KCntDbUri1,EGetIds);
       
   623             CActiveScheduler::Start();
       
   624                   
       
   625             if(icallback->iError == KErrNone)
       
   626                     {
       
   627                     /*_LIT(KErrCode, "ErrorCode is 0");
       
   628                     iLog->Log(KErrCode);*/
       
   629                     if(tIdCount >= tCount)
       
   630                         {
       
   631                        /* _LIT(KLogInfo, "Count: ");
       
   632                         iLog->Log(KLogInfo);
       
   633                         TBuf8<16> logInfo;
       
   634                         logInfo.Num(tIdCount);
       
   635                         iLog->Log(logInfo);*/
       
   636                         delete icallback;
       
   637                         delete icontactservice;
       
   638                         //__UHEAP_MARKEND;
       
   639                         return KErrNone;    
       
   640                         }         
       
   641                     }
       
   642             /*_LIT( KErrorMsg2, "The GetIds returned non zero error" );
       
   643              iLog->Log( KErrorMsg2 );
       
   644 			 delete icontactservice;*/
       
   645             delete icallback;
       
   646             delete icontactservice;
       
   647              //__UHEAP_MARKEND;
       
   648              return KErrGeneral;
       
   649         }
       
   650   /*get the ids of all contacts in phone database in default order*/
       
   651     TInt Ctcontactgetids::GetIds_Test8L( CStifItemParser& /*aItem*/ )
       
   652         {
       
   653         ////__UHEAP_MARK;
       
   654 		 icontactservice=CContactService::NewL();
       
   655 		 icallback=new(ELeave) CContactCallback;
       
   656         /*_LIT( Ktsapicontacts, "tsapicontacts" );
       
   657           _LIT( KExample, "In GetIds_Test8L" );
       
   658           TestModuleIf().Printf( 0, Ktsapicontacts, KExample );
       
   659           // Print to log file
       
   660           iLog->Log( KExample );*/
       
   661           TInt val =1;
       
   662           cmdFlag = 0;
       
   663           icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,ENULL,KCntDbUri);  
       
   664           CActiveScheduler::Start();
       
   665           cmdFlag = 1;
       
   666           icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,ENULL,KCntDbUri,EGetIds);
       
   667           CActiveScheduler::Start(); 
       
   668           if(icallback->iError == KErrNone)
       
   669                   {
       
   670                   /*_LIT(KErrCode, "ErrorCode is 0");
       
   671                   iLog->Log(KErrCode);*/
       
   672                   if(tIdCount >= tCount)
       
   673                       {
       
   674                       /*_LIT(KLogInfo, "Count: ");
       
   675                       iLog->Log(KLogInfo);
       
   676                       TBuf8<16> logInfo;
       
   677                       logInfo.Num(tIdCount);
       
   678                       iLog->Log(logInfo);*/
       
   679                       delete icallback;
       
   680                       delete icontactservice;
       
   681                       //__UHEAP_MARKEND;
       
   682                       return KErrNone;    
       
   683                       }         
       
   684                   }
       
   685           delete icallback;
       
   686           delete icontactservice;
       
   687           //__UHEAP_MARKEND;
       
   688           return KErrGeneral;
       
   689         }
       
   690  /*get the list of all group ids in default sort order*/
       
   691     TInt Ctcontactgetids::GetIds_Test9L( CStifItemParser& /*aItem*/ )
       
   692        {
       
   693        ////__UHEAP_MARK;
       
   694 	    icontactservice=CContactService::NewL();
       
   695 	    icallback=new(ELeave) CContactCallback;
       
   696      // Print to UI
       
   697        /*_LIT( Ktsapicontacts, "tsapicontacts" );
       
   698        _LIT( KExample, "In GetIds_Test9L" );
       
   699        TestModuleIf().Printf( 0, Ktsapicontacts, KExample );
       
   700        // Print to log file
       
   701        iLog->Log( KExample );
       
   702        cmdFlag = 0;*/
       
   703  /*    icontactservice->GetListL(icallback,1,EGroups,KNullDesC8,KNullDesC,NULL,ENULL,KCntDbUri);  
       
   704      CActiveScheduler::Start();
       
   705      if(icallback->iError != KErrNone)
       
   706          {
       
   707          return KErrGeneral;
       
   708          }*/
       
   709      cmdFlag = 1;
       
   710      TInt val =1;
       
   711      
       
   712         icontactservice->GetListL(icallback,1,EGroups,KNullDesC8,KNullDesC,NULL,ENULL,KCntDbUri,EGetIds);
       
   713      CActiveScheduler::Start();
       
   714      if(icallback->iError == KErrNone)
       
   715             {
       
   716             /*_LIT(KErrCode, "ErrorCode is 0");
       
   717             iLog->Log(KErrCode);*/
       
   718             if(tIdCount >= tCount)
       
   719                 {
       
   720                 /*_LIT(KLogInfo, "Count: ");
       
   721                 iLog->Log(KLogInfo);
       
   722                 TBuf8<16> logInfo;
       
   723                 logInfo.Num(tIdCount);
       
   724                 iLog->Log(logInfo);*/
       
   725                 delete icallback;
       
   726                 delete icontactservice;
       
   727                 ////__UHEAP_MARKEND;
       
   728                 return KErrNone;    
       
   729                 }         
       
   730             }
       
   731      delete icallback;
       
   732      delete icontactservice;
       
   733         ////__UHEAP_MARKEND;
       
   734         return KErrGeneral;
       
   735         }
       
   736 //  End of File