--- a/serviceproviders/sapi_contacts_vpbk/tsrc/testing/tcontact_add/src/tcontact_addblocks.cpp Fri Jul 03 15:51:24 2009 +0100
+++ b/serviceproviders/sapi_contacts_vpbk/tsrc/testing/tcontact_add/src/tcontact_addblocks.cpp Thu Aug 27 07:43:07 2009 +0300
@@ -72,13 +72,17 @@
?code
}
*/
-
+TInt cmdNum = 0;
TInt Iterator_cnt=0;
//HBufC8 *contactid ;
HBufC8* contactid=NULL;
CSingleContact* myContact=NULL;
-
+void CContactCallback::HandleReturnArray( const TInt& aError, RPointerArray<HBufC8>& aArray, TInt aTransId )
+ {
+ CActiveScheduler::Stop();
+ iError= aError ;
+ }
void CContactCallback::HandleReturnValue( TOperationEvent aEventId, const TInt& aError, TInt aTransId )
@@ -95,22 +99,111 @@
CActiveScheduler::Stop();
- CSingleContactField* field = NULL;
- HBufC8* buf = NULL;
- TBuf8<100> buf1;
- TBuf<100> buf2;
- TBuf<100> buf3;
- TInt count=0 ;
-
-
+
+ if(cmdNum == 10)
+ {
+ aIter->NextL(myContact,contactid);
+ delete aIter;
+ if(contactid)
+ {
+ delete contactid;
+ }
+return;
+ }
if(aError==KErrNone)
{
aIter->NextL(myContact,contactid);
+ if(contactid)
+ {
+ delete contactid;
+ }
+ if(myContact)
+ {
+ delete myContact;
+ }
}
delete aIter;
return;
}
+
+ void CContactCallback:: HandleReturnId( const TInt& aError, HBufC8* acntId, TInt aTransId )
+ {
+
+ /*RFs fs;
+ RFile file;
+ User::LeaveIfError(fs.Connect());
+ CleanupClosePushL(fs);
+ TInt errfile =file.Replace(fs,_L("C:\\iter.txt"), EFileWrite | EFileStreamText);
+ file.Write(_L8("\n Starting logs"));
+ file.Flush(); */
+ CActiveScheduler::Stop();
+ //HBufC8* cntId = acntId;
+ iError = aError;
+ if(acntId == NULL)
+ {
+ /*file.Write(_L8("\n cntid is nul"));
+ file.Flush(); */
+ iError = KErrGeneral;
+ return;
+ }
+ if(cmdNum == 14)
+ {
+ CContactService* cntservice=CContactService::NewL();
+ _LIT8(KField,"FirstName");
+ _LIT(KLabel,"FirstName");
+ _LIT(KValue,"Barbie");
+ TPtrC8 fieldKey(KNullDesC8);
+ TPtrC label(KNullDesC);
+ TPtrC value(KNullDesC);
+ //CContactCallback* callbk=new(ELeave) CContactCallback;
+ TPtr8 cntIdPtrVal(acntId->Des());
+ CContactIter* iterVal;
+ TRAPD(err, iterVal = cntservice->GetListL(EContacts,cntIdPtrVal));
+ if(err != KErrNone)
+ {
+ /*file.Write(_L8("\n err code of getlist is non zero"));
+ file.Flush(); */
+ iError = KErrGeneral;
+ return;
+ }
+ iterVal->NextL(myContact,contactid);
+ if(myContact)
+ {
+ for(TInt i=0;i<myContact->FieldCount(); i++)
+ {
+ CSingleContactField* field = myContact->FieldAt(i);
+ field->GetFieldDataL(fieldKey,label,value);
+ if(value.Compare(KValue) == 0)
+ {
+ iError = KErrNone;
+ break;
+ }
+ }
+ }
+ else
+ {
+ /*file.Write(_L8("\n no contact is got"));
+ file.Flush(); */
+ iError = KErrGeneral;
+ }
+ delete cntservice;
+ delete iterVal;
+ if(myContact)
+ {
+ delete myContact;
+ }
+ if(contactid)
+ {
+ delete contactid;
+ }
+}
+ /*file.Write(_L8("\n return"));
+ file.Flush();
+
+ file.Close();*/
+ delete acntId;
+ }
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
@@ -151,6 +244,11 @@
ENTRY( "Add_Test11", Ctdeleteadd::Add_Test11L ),
ENTRY( "Add_Test12", Ctdeleteadd::Add_Test12L ),
ENTRY( "Add_Test13", Ctdeleteadd::Add_Test13L ),
+ ENTRY( "Add_Test14", Ctdeleteadd::Add_Test14L ),
+ ENTRY( "Add_Test15", Ctdeleteadd::Add_Test15L ),
+ ENTRY( "Add_Test16", Ctdeleteadd::Add_Test16L ),
+ ENTRY( "Add_Test17", Ctdeleteadd::Add_Test17L ),
+
};
@@ -167,7 +265,9 @@
TInt Ctdeleteadd::Add_Test1L( CStifItemParser& aItem )
{
-
+ __UHEAP_MARK;
+ icontactservice=CContactService::NewL();
+ icallback=new(ELeave) CContactCallback;
TInt count =KErrGeneral ;
_LIT8(KFirstName,"FirstName");
_LIT(KName,"Aaaa");
@@ -175,7 +275,9 @@
/* create contactitem to add */
CSingleContact* singleContact = CSingleContact::NewL();
+ CleanupStack::PushL(singleContact);
CSingleContactField* singleContactField = CSingleContactField::NewL();
+ CleanupStack::PushL(singleContactField);
singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName);
@@ -190,18 +292,31 @@
/* check whether add api returns the expected error code */
if(count == icallback->iError )
+ {
+ CleanupStack::Pop(singleContactField);
+ CleanupStack::Pop(singleContact);
+ delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrNone ;
-
+ }
+ CleanupStack::Pop(singleContactField);
+ CleanupStack::Pop(singleContact);
+ delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrGeneral ;
-
-
}
/* Adding contact with invalid fieldname */
TInt Ctdeleteadd::Add_Test2L( CStifItemParser& aItem )
{
-
+ __UHEAP_MARK;
+ icontactservice=CContactService::NewL();
+ icallback=new(ELeave) CContactCallback;
TInt count =KErrGeneral ;
_LIT8(KFirstName,"FrstName");
_LIT(KName,"Aaaa");
@@ -209,7 +324,9 @@
/* create contactitem with invalid fieldname "FrstName */
CSingleContact* singleContact = CSingleContact::NewL();
+ CleanupStack::PushL(singleContact);
CSingleContactField* singleContactField = CSingleContactField::NewL();
+ CleanupStack::PushL(singleContactField);
singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName);
@@ -223,8 +340,21 @@
/* check whether Add api returns the expected error code */
if(-1 == icallback->iError )
+ {
+ CleanupStack::Pop(singleContactField);
+ CleanupStack::Pop(singleContact);
+ delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrNone ;
-
+ }
+ CleanupStack::Pop(singleContactField);
+ CleanupStack::Pop(singleContact);
+ delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrGeneral ;
}
@@ -232,8 +362,9 @@
/* adding contact with more fields */
TInt Ctdeleteadd::Add_Test3L( CStifItemParser& aItem )
{
-
-
+
+ icallback=new(ELeave) CContactCallback;
+ CSingleContact* singleContact = CSingleContact::NewL();
TInt count =KErrGeneral ;
_LIT8(KFirstName,"FirstName");
_LIT(KFName,"XYZ");
@@ -260,19 +391,28 @@
//instantiate service class object
/* create contactitem to add */
CSingleContactField* FName = CSingleContactField::NewL();
+ //CleanupStack::PushL(FName);
CSingleContactField* LName = CSingleContactField::NewL();
+ //CleanupStack::PushL(LName);
CSingleContactField* Pfix = CSingleContactField::NewL();
+ //CleanupStack::PushL(Pfix);
CSingleContactField* Sfix = CSingleContactField::NewL();
+ //CleanupStack::PushL(Sfix);
CSingleContactField* Landno = CSingleContactField::NewL();
+ //CleanupStack::PushL(Landno);
CSingleContactField* Mobno = CSingleContactField::NewL();
+ //CleanupStack::PushL(Mobno);
CSingleContactField* Faxno = CSingleContactField::NewL();
+ //CleanupStack::PushL(Faxno);
CSingleContactField* Note = CSingleContactField::NewL();
+ //CleanupStack::PushL(Note);
CSingleContactField* Job = CSingleContactField::NewL();
+ //CleanupStack::PushL(Job);
CSingleContactField* Mail = CSingleContactField::NewL();
+ //CleanupStack::PushL(Mail);
CSingleContactField* Ring = CSingleContactField::NewL();
-
- CSingleContact* singleContact = CSingleContact::NewL();
-
+ //CleanupStack::PushL(Ring);
+
FName->SetFieldParamsL(KFirstName,KNullDesC,KFName);
singleContact->AddFieldToContactL(FName);
@@ -309,11 +449,22 @@
aItem.GetNextInt(count) ;
-
+ __UHEAP_MARK;
+ icontactservice=CContactService::NewL();
+ CSingleContact* singleContact1 = CSingleContact::NewL();
+ CleanupStack::PushL(singleContact1);
+ CSingleContactField* FName1 = CSingleContactField::NewL();
+ CleanupStack::PushL(FName1);
+ FName1->SetFieldParamsL(KFirstName,KNullDesC,KFName);
+ singleContact1->AddFieldToContactL(FName1);
/* Add the contactitem */
icontactservice->AddL(icallback,0,singleContact);
CActiveScheduler::Start();
-
+ CleanupStack::Pop(FName1);
+ CleanupStack::Pop(singleContact1);
+ delete singleContact1;
+ delete icontactservice;
+
TPtrC String;
// TPtrC db1(_L("cntdb://c:testcontacts2.cdb"));
@@ -323,10 +474,29 @@
{
_LIT(Kerr ,"Failed to read input file name") ;
iLog->Log(Kerr) ;
+
+//CleanupStack::Pop(11);
+//CleanupStack::Pop(singleContact);
+//delete singleContact;
+//delete singleContact;
+/*delete FName;
+ delete LName;
+ delete Pfix;
+ delete Sfix;
+ delete Landno;
+ delete Mobno;
+ delete Faxno;
+ delete Note;
+ delete Job;
+ delete Mail;
+ delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;*/
return KErrGeneral ;
}
- TBuf<256> string1;
+ /* TBuf<256> string1;
string1.Copy(String);
icontactservice->GetListL(icallback,1,EContacts,KNullDesC8) ;
@@ -336,13 +506,18 @@
icontactservice->ExportVCardL(icallback,2,string1,*contactid);
CActiveScheduler::Start();
-
+ */
/* check whether add api returns the expected error code */
if(count == icallback->iError )
+ {
+ delete icallback;
+ __UHEAP_MARKEND;
return KErrNone ;
-
- return KErrGeneral ;
+ }
+ delete icallback;
+ __UHEAP_MARKEND;
+ return KErrGeneral ;
}
@@ -351,7 +526,9 @@
/* Adding a group */
TInt Ctdeleteadd::Add_Test4L( CStifItemParser& aItem )
{
-
+ __UHEAP_MARK;
+ icontactservice=CContactService::NewL();
+ icallback=new(ELeave) CContactCallback;
// Print to UI
_LIT( Ktsapicontacts, "tsapicontacts" );
_LIT( KExample, "In GetList_Test1L" );
@@ -373,8 +550,15 @@
/* check whether add api returns the expected error code */
if(count == icallback->iError )
+ {
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrNone ;
-
+ }
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrGeneral ;
}
@@ -385,7 +569,9 @@
/* Adding the same group name twice */
TInt Ctdeleteadd::Add_Test5L( CStifItemParser& aItem )
{
-
+ __UHEAP_MARK;
+ icontactservice=CContactService::NewL();
+ icallback=new(ELeave) CContactCallback;
// Print to UI
_LIT( Ktsapicontacts, "tsapicontacts" );
_LIT( KExample, "In GetList_Test1L" );
@@ -411,8 +597,15 @@
/* check whether add api returns the expected error code */
if(count == icallback->iError )
- return KErrNone ;
-
+ {
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
+ return KErrNone ;
+ }
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrGeneral ;
}
@@ -421,7 +614,9 @@
TInt Ctdeleteadd::Add_Test6L( CStifItemParser& aItem )
{
-
+ __UHEAP_MARK;
+ icontactservice=CContactService::NewL();
+ icallback=new(ELeave) CContactCallback;
TInt count =KErrGeneral ;
_LIT8(KFirstName,"FirstName");
_LIT(KName,"Aaaa");
@@ -429,7 +624,9 @@
/* create contactitem to add */
CSingleContact* singleContact = CSingleContact::NewL();
+ CleanupStack::PushL(singleContact);
CSingleContactField* singleContactField = CSingleContactField::NewL();
+ CleanupStack::PushL(singleContactField);
singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName);
@@ -447,8 +644,21 @@
/* check whether add api returns the expected error code */
if(count == icallback->iError )
+ {
+ CleanupStack::Pop(singleContactField);
+ CleanupStack::Pop(singleContact);
+ delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrNone ;
-
+ }
+ CleanupStack::Pop(singleContactField);
+ CleanupStack::Pop(singleContact);
+ delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrGeneral ;
@@ -457,7 +667,9 @@
// same contact twice to different database
TInt Ctdeleteadd::Add_Test7L( CStifItemParser& aItem )
{
-
+ __UHEAP_MARK;
+ icontactservice=CContactService::NewL();
+ icallback=new(ELeave) CContactCallback;
_LIT(KCntDbUri, "cntdb://c:contacts.cdb");
TInt count =KErrGeneral ;
_LIT8(KFirstName,"FirstName");
@@ -466,7 +678,9 @@
/* create contactitem to add */
CSingleContact* singleContact = CSingleContact::NewL();
+ CleanupStack::PushL(singleContact);
CSingleContactField* singleContactField = CSingleContactField::NewL();
+ CleanupStack::PushL(singleContactField);
singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName);
@@ -484,8 +698,22 @@
/* check whether add api returns the expected error code */
if(count == icallback->iError )
+ {
+ CleanupStack::Pop(singleContactField);
+ CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrNone ;
-
+ }
+
+ CleanupStack::Pop(singleContactField);
+ CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrGeneral ;
@@ -495,8 +723,9 @@
TInt Ctdeleteadd::Add_Test8L( CStifItemParser& aItem )
{
-
-
+ __UHEAP_MARK;
+ icontactservice=CContactService::NewL();
+ icallback=new(ELeave) CContactCallback;
TInt count =KErrGeneral ;
_LIT8(KLandline,"LandPhoneHome");
@@ -510,8 +739,11 @@
/* create contactitem to add */
CSingleContact* singleContact = CSingleContact::NewL();
+CleanupStack::PushL(singleContact);
CSingleContactField* singleContactField1 = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField1);
CSingleContactField* singleContactField2 = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField2);
singleContactField1->SetFieldParamsL(KLandline,Land1,KLandno1);
singleContactField2->SetFieldParamsL(KLandline,Land2,KLandno2);
@@ -519,12 +751,14 @@
singleContact->AddFieldToContactL(singleContactField2);
CSingleContactField* singleContactField3 = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField3);
CSingleContactField* singleContactField4 = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField4);
singleContactField3->SetFieldParamsL(KLandline,Land1,KLandno1);
singleContactField4->SetFieldParamsL(KLandline,Land2,KLandno2);
- singleContact->AddFieldToContactL(singleContactField1);
- singleContact->AddFieldToContactL(singleContactField2);
+ singleContact->AddFieldToContactL(singleContactField3);
+ singleContact->AddFieldToContactL(singleContactField4);
aItem.GetNextInt(count) ;
/* Add the contactitem */
@@ -533,8 +767,23 @@
/* check whether add api returns the expected error code */
if(count == icallback->iError )
+ {
+
+ CleanupStack::Pop(4);
+ CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrNone ;
-
+ }
+
+ CleanupStack::Pop(4);
+ CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrGeneral ;
@@ -578,7 +827,10 @@
/* Adding single contact to default database using contactid*/
TInt Ctdeleteadd::Add_Test10L( CStifItemParser& aItem )
{
-
+ __UHEAP_MARK;
+ cmdNum =10;
+ icontactservice=CContactService::NewL();
+ icallback=new(ELeave) CContactCallback;
_LIT(KCntDbUri, "cntdb://c:contacts.cdb");
_LIT(KCntDbUri1, "cntdb://c:singlecontacts.cdb");
TInt count =KErrGeneral ;
@@ -588,7 +840,9 @@
/* create contactitem to add */
CSingleContact* singleContact = CSingleContact::NewL();
+ CleanupStack::PushL(singleContact);
CSingleContactField* singleContactField = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField);
singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName);
@@ -605,7 +859,7 @@
TBuf8<15> fstname(_L8("FirstName"));
CSearchFields *srchfield =CSearchFields :: NewL(icontactservice);
-
+ //CleanupStack::PushL(srchfield);
srchfield->AppendL(fstname);
iLog->Log(_L("Calling GetList"));
@@ -632,18 +886,46 @@
if(err1!=0 )
{
iLog->Log(_L("Error returned while calling add"));
+//CleanupStack::Pop(srchfield);
+CleanupStack::Pop(singleContactField);
+CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ delete myContact;
+ //delete srchfield;
+ __UHEAP_MARKEND;
return KErrNone ;
}
- iLog->Log(_L("Starting Schudular"));
+ iLog->Log(_L("Starting Scheuduler"));
CActiveScheduler::Start();
iLog->Log(_L("Error %d\n"),icallback->iError);
iLog->Log(_L("Add successful"));
if(count == icallback->iError )
+ {
+//CleanupStack::Pop(srchfield);
+CleanupStack::Pop(singleContactField);
+CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ delete myContact;
+ //delete srchfield;
+ __UHEAP_MARKEND;
return KErrNone ;
-
+ }
+//CleanupStack::Pop(srchfield);
+CleanupStack::Pop(singleContactField);
+CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ delete myContact;
+ //delete srchfield;
+ __UHEAP_MARKEND;
return KErrGeneral ;
@@ -652,7 +934,9 @@
/* Adding a group and contact together*/
TInt Ctdeleteadd::Add_Test11L( CStifItemParser& aItem )
{
-
+ __UHEAP_MARK;
+ icontactservice=CContactService::NewL();
+ icallback=new(ELeave) CContactCallback;
// Print to UI
_LIT( Ktsapicontacts, "tsapicontacts" );
_LIT( KExample, "In GetList_Test1L" );
@@ -672,7 +956,9 @@
/* create contactitem to add */
CSingleContact* singleContact = CSingleContact::NewL();
+CleanupStack::PushL(singleContact);
CSingleContactField* singleContactField = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField);
singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName);
@@ -684,13 +970,34 @@
TInt err1;
TRAPD(err,icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KGroup));
if(err || err1)
+ {
+CleanupStack::Pop(singleContactField);
+CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrNone;
+ }
CActiveScheduler::Start();
/* check whether add api returns the expected error code */
if(count == icallback->iError )
- return KErrNone ;
-
+ {
+CleanupStack::Pop(singleContactField);
+CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
+ return KErrNone ;
+ }
+CleanupStack::Pop(singleContactField);
+CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrGeneral ;
}
@@ -700,8 +1007,9 @@
TInt Ctdeleteadd::Add_Test12L( CStifItemParser& aItem )
{
-
-
+ __UHEAP_MARK;
+ icontactservice=CContactService::NewL();
+ icallback=new(ELeave) CContactCallback;
TInt count =KErrGeneral ;
_LIT(KCntDbUri, "cntdb://c:contacts.cdb");
_LIT8(KLandline,"LandPhoneHome");
@@ -715,8 +1023,11 @@
/* create contactitem to add */
CSingleContact* singleContact = CSingleContact::NewL();
+CleanupStack::PushL(singleContact);
CSingleContactField* singleContactField1 = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField1);
CSingleContactField* singleContactField2 = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField2);
singleContactField1->SetFieldParamsL(KLandline,Land1,KLandno1);
singleContactField2->SetFieldParamsL(KLandline,Land2,KLandno2);
@@ -724,12 +1035,14 @@
singleContact->AddFieldToContactL(singleContactField2);
CSingleContactField* singleContactField3 = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField3);
CSingleContactField* singleContactField4 = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField4);
singleContactField3->SetFieldParamsL(KLandline,Land1,KLandno1);
singleContactField4->SetFieldParamsL(KLandline,Land2,KLandno2);
- singleContact->AddFieldToContactL(singleContactField1);
- singleContact->AddFieldToContactL(singleContactField2);
+ singleContact->AddFieldToContactL(singleContactField3);
+ singleContact->AddFieldToContactL(singleContactField4);
aItem.GetNextInt(count) ;
/* Add the contactitem */
@@ -738,8 +1051,27 @@
/* check whether add api returns the expected error code */
if(count == icallback->iError )
+ {
+CleanupStack::Pop(singleContactField4);
+CleanupStack::Pop(singleContactField3);
+CleanupStack::Pop(singleContactField2);
+CleanupStack::Pop(singleContactField1);
+CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrNone ;
-
+ }
+CleanupStack::Pop(singleContactField4);
+CleanupStack::Pop(singleContactField3);
+CleanupStack::Pop(singleContactField2);
+CleanupStack::Pop(singleContactField1);
+CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrGeneral ;
@@ -751,7 +1083,9 @@
TInt Ctdeleteadd::Add_Test13L( CStifItemParser& aItem )
{
-
+ __UHEAP_MARK;
+ icontactservice=CContactService::NewL();
+ icallback=new(ELeave) CContactCallback;
TInt count =KErrGeneral ;
_LIT(KCntDbUri, "cntdb://c:contacts.cdb");
_LIT8(KLandline,"LandPhoneHome");
@@ -765,8 +1099,11 @@
/* create contactitem to add */
CSingleContact* singleContact = CSingleContact::NewL();
+CleanupStack::PushL(singleContact);
CSingleContactField* singleContactField1 = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField1);
CSingleContactField* singleContactField2 = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField2);
singleContactField1->SetFieldParamsL(KLandline,Land1,KLandno1);
singleContactField2->SetFieldParamsL(KLandline,Land1,KLandno2);
@@ -774,7 +1111,9 @@
singleContact->AddFieldToContactL(singleContactField2);
CSingleContactField* singleContactField3 = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField3);
CSingleContactField* singleContactField4 = CSingleContactField::NewL();
+CleanupStack::PushL(singleContactField4);
singleContactField3->SetFieldParamsL(KLandline,Land1,KLandno1);
singleContactField4->SetFieldParamsL(KLandline,Land1,KLandno2);
@@ -788,13 +1127,344 @@
/* check whether add api returns the expected error code */
if(count == icallback->iError )
+ {
+CleanupStack::Pop(singleContactField4);
+CleanupStack::Pop(singleContactField3);
+CleanupStack::Pop(singleContactField2);
+CleanupStack::Pop(singleContactField1);
+CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrNone ;
-
+ }
+CleanupStack::Pop(singleContactField4);
+CleanupStack::Pop(singleContactField3);
+CleanupStack::Pop(singleContactField2);
+CleanupStack::Pop(singleContactField1);
+CleanupStack::Pop(singleContact);
+delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
return KErrGeneral ;
}
+TInt Ctdeleteadd::Add_Test14L(CStifItemParser& aItem )
+ {
+
+ __UHEAP_MARK;
+ icontactservice=CContactService::NewL();
+ icallback=new(ELeave) CContactCallback;
+ TInt count =KErrGeneral ;
+ _LIT8(KFirstName,"FirstName");
+ _LIT(KName,"Aaaa");
+ //instantiate service class object
+ _LIT8(KPrefix,"Prefix");
+ _LIT(KPfix,"Princess");
+ _LIT8(KNote,"Note");
+ _LIT(KNoteVal,"Lead role in Barbie, the island princess");
+_LIT8(KAnniversary,"Anniversary");
+ _LIT8(KBday,"Date");
+ _LIT8(KNickName,"SecondName");
+ _LIT(KNickNameVal,"Doll");
+ _LIT8(KPhoto,"CallerObjImg");
+ _LIT(KPhotoVal,"C:\\data\\images\\pic.jpg");
+ _LIT8(KImpp,"IMPP");
+ _LIT(KImppLabel,"IMPP");
+
+ /* create contactitem to add */
+ CSingleContact* singleContact = CSingleContact::NewL();
+ CleanupStack::PushL(singleContact);
+ CSingleContactField* singleContactField = CSingleContactField::NewL();
+ CleanupStack::PushL(singleContactField);
+ CSingleContactField* prefix = CSingleContactField::NewL();
+CleanupStack::PushL(prefix);
+ CSingleContactField* note = CSingleContactField::NewL();
+CleanupStack::PushL(note);
+ CSingleContactField* anni = CSingleContactField::NewL();
+CleanupStack::PushL(anni);
+ CSingleContactField* bday = CSingleContactField::NewL();
+CleanupStack::PushL(bday);
+ CSingleContactField* nkname = CSingleContactField::NewL();
+CleanupStack::PushL(nkname);
+ CSingleContactField* photo = CSingleContactField::NewL();
+CleanupStack::PushL(photo);
+CSingleContactField* xspid = CSingleContactField::NewL();
+CleanupStack::PushL(xspid);
+ singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName);
+ singleContact->AddFieldToContactL(singleContactField);
+ prefix->SetFieldParamsL(KPrefix,KNullDesC,KPfix);
+ singleContact->AddFieldToContactL(prefix);
+
+ note->SetFieldParamsL(KNote,KNullDesC,KNoteVal);
+ singleContact->AddFieldToContactL(note);
+
+
+ anni->SetFieldParamsL(KAnniversary,KNullDesC,KNullDesC);
+ anni->SetDateTime(TTime(TDateTime(2007,EOctober,25,0,0,0,0)));
+ singleContact->AddFieldToContactL(anni);
+
+
+ bday->SetFieldParamsL(KBday,KNullDesC,KNullDesC);
+ bday->SetDateTime(TTime(TDateTime(2007,EOctober,25,0,0,0,0)));
+ singleContact->AddFieldToContactL(bday);
+
+ nkname->SetFieldParamsL(KNickName,KNullDesC,KNickNameVal);
+ singleContact->AddFieldToContactL(nkname);
+
+ photo->SetFieldParamsL(KPhoto,KNullDesC,KPhotoVal);
+ singleContact->AddFieldToContactL(photo);
+
+ RPointerArray<HBufC> xspidarr;
+ xspidarr.Append((_L("Yahoo:barbie@yahoo.co.in")).AllocL());
+ xspidarr.Append((_L("Google:barbie@gmail.com")).AllocL());
+ xspid->SetXspidDataL(KImpp,KImppLabel,xspidarr);
+ singleContact->AddFieldToContactL(xspid);
+
+ //aItem.GetNextInt(count);
+
+ /* Add the contactitem */
+ icontactservice->AddL(icallback,0,singleContact);
+ CActiveScheduler::Start();
+
+ /* check whether add api returns the expected error code */
+ if(KErrNone == icallback->iError )
+ {
+ CleanupStack::Pop(xspid);
+ CleanupStack::Pop(photo);
+ CleanupStack::Pop(nkname);
+ CleanupStack::Pop(bday);
+ CleanupStack::Pop(anni);
+ CleanupStack::Pop(note);
+ CleanupStack::Pop(prefix);
+ CleanupStack::Pop(singleContactField);
+ CleanupStack::Pop(singleContact);
+ delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
+ return KErrNone ;
+ }
+ CleanupStack::Pop(xspid);
+ CleanupStack::Pop(photo);
+ CleanupStack::Pop(nkname);
+ CleanupStack::Pop(bday);
+ CleanupStack::Pop(anni);
+ CleanupStack::Pop(note);
+ CleanupStack::Pop(prefix);
+ CleanupStack::Pop(singleContactField);
+ CleanupStack::Pop(singleContact);
+ delete singleContact;
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
+ return KErrGeneral ;
+
+ }
+
+TInt Ctdeleteadd::Add_Test15L(CStifItemParser& aItem )
+ {
+ __UHEAP_MARK;
+
+ cmdNum = 15;
+TInt count =KErrGeneral ;
+ _LIT8(KFirstName,"FirstName");
+ _LIT(KFName,"Barbie");
+ _LIT8(KPrefix,"Prefix");
+ _LIT(KPfix,"Princess");
+ _LIT8(KNote,"Note");
+ _LIT(KNoteVal,"Lead role in Barbie, the island princess");
+ _LIT8(KAnniversary,"Anniversary");
+ // _LIT(KAnniVal,"20090521:023443:000000");
+ //TTime annival;
+ //annival.Set(KAnniVal);
+ //_LIT(KAniiVal,"08216666");
+ _LIT8(KBday,"Date");
+ // _LIT(KBDayVal,"20099420:023443:000000");
+ // TTime bdayval;
+ // bdayval.Set(KBDayVal);
+ _LIT8(KNickName,"SecondName");
+ _LIT(KNickNameVal,"Doll");
+ _LIT8(KPhoto,"CallerObjImg");
+ _LIT(KPhotoVal,"C:\\data\\images\\pic.jpg");
+ _LIT8(KImpp,"IMPP");
+ _LIT(KImppLabel,"IMPP");
+
+
+ //instantiate service class object
+ /* create contactitem to add */
+ CSingleContact* singleContact = CSingleContact::NewL();
+ //CleanupStack::PushL(singleContact);
+ CSingleContactField* FName = CSingleContactField::NewL();
+//CleanupStack::PushL(FName);
+ CSingleContactField* prefix = CSingleContactField::NewL();
+//CleanupStack::PushL(prefix);
+ CSingleContactField* note = CSingleContactField::NewL();
+//CleanupStack::PushL(note);
+ CSingleContactField* anni = CSingleContactField::NewL();
+//CleanupStack::PushL(anni);
+ CSingleContactField* bday = CSingleContactField::NewL();
+//CleanupStack::PushL(bday);
+ CSingleContactField* nkname = CSingleContactField::NewL();
+//CleanupStack::PushL(nkname);
+ CSingleContactField* photo = CSingleContactField::NewL();
+//CleanupStack::PushL(photo);
+ CSingleContactField* xspid = CSingleContactField::NewL();
+//CleanupStack::PushL(xspid);
+
+
+ FName->SetFieldParamsL(KFirstName,KNullDesC,KFName);
+ singleContact->AddFieldToContactL(FName);
+
+ prefix->SetFieldParamsL(KPrefix,KNullDesC,KPfix);
+ singleContact->AddFieldToContactL(prefix);
+
+ note->SetFieldParamsL(KNote,KNullDesC,KNoteVal);
+ singleContact->AddFieldToContactL(note);
+
+ anni->SetFieldParamsL(KAnniversary,KNullDesC,KNullDesC);
+ anni->SetDateTime(TTime(TDateTime(2007,EOctober,25,0,0,0,0)));
+ singleContact->AddFieldToContactL(anni);
+
+
+ bday->SetFieldParamsL(KBday,KNullDesC,KNullDesC);
+ bday->SetDateTime(TTime(TDateTime(2007,EOctober,25,0,0,0,0)));
+ singleContact->AddFieldToContactL(bday);
+
+ nkname->SetFieldParamsL(KNickName,KNullDesC,KNickNameVal);
+ singleContact->AddFieldToContactL(nkname);
+
+ photo->SetFieldParamsL(KPhoto,KNullDesC,KPhotoVal);
+ singleContact->AddFieldToContactL(photo);
+
+ _LIT(KYahooId,"Yahoo:barbie@yahoo.co.in");
+ //_LIT8();
+
+ RPointerArray<HBufC> xspidarr;
+ //CleanClosePushL(xspidarr);
+ xspidarr.Append((_L("Yahoo:barbie@yahoo.co.in")).AllocL());
+ xspidarr.Append((_L("Google:barbie@gmail.com")).AllocL());
+ xspid->SetXspidDataL(KImpp,KImppLabel,xspidarr);
+ singleContact->AddFieldToContactL(xspid);
+
+
+
+
+
+ aItem.GetNextInt(count) ;
+
+ icontactservice=CContactService::NewL();
+ /* Add the contactitem */
+ HBufC8* cntId;
+ TRAPD(error,cntId= icontactservice->AddL(singleContact));
+
+
+ if(error == KErrNone)
+ {
+delete cntId;
+ delete singleContact;
+ //xspidarr.Reset();
+ delete icontactservice;
+ __UHEAP_MARKEND;
+
+ return KErrNone ;
+ }
+delete cntId;
+ delete singleContact;
+ //xspidarr.Reset();
+ delete icontactservice;
+ __UHEAP_MARKEND;
+ return KErrGeneral;
+
+
+
+
+ }
+
+/* Adding a group */
+TInt Ctdeleteadd::Add_Test16L( CStifItemParser& aItem )
+{
+__UHEAP_MARK;
+icontactservice=CContactService::NewL();
+icallback=new(ELeave) CContactCallback;
+ // Print to UI
+ _LIT( Ktsapicontacts, "tsapicontacts" );
+ _LIT( KExample, "In GetList_Test16L" );
+ TestModuleIf().Printf( 0, Ktsapicontacts, KExample );
+ // Print to log file
+ iLog->Log( KExample );
+
+
+ TInt count;
+
+ /* Group1 to add to phonebook */
+ _LIT(KGroup,"Group16") ;
+
+ aItem.GetNextInt(count) ;
+
+ /*Add group1 to phonebook */
+ icontactservice->AddL(icallback,0,NULL,KNullDesC8,KGroup);
+ CActiveScheduler::Start();
+
+/* check whether add api returns the expected error code */
+if(count == icallback->iError )
+ {
+ delete icallback;
+ delete icontactservice;
+ __UHEAP_MARKEND;
+ return KErrNone ;
+ }
+ delete icallback;
+ delete icontactservice;
+__UHEAP_MARKEND;
+ return KErrGeneral ;
+
+}
+
+/* Adding a group */
+TInt Ctdeleteadd::Add_Test17L( CStifItemParser& aItem )
+{
+__UHEAP_MARK;
+icontactservice=CContactService::NewL();
+icallback=new(ELeave) CContactCallback;
+
+ // Print to UI
+ _LIT( Ktsapicontacts, "tsapicontacts" );
+ _LIT( KExample, "In GetList_Test17L" );
+ TestModuleIf().Printf( 0, Ktsapicontacts, KExample );
+ // Print to log file
+ iLog->Log( KExample );
+
+ HBufC8* grpId;
+ TInt count;
+
+ /* Group1 to add to phonebook */
+ _LIT(KGroup,"Group17") ;
+
+ aItem.GetNextInt(count) ;
+
+ /*Add group1 to phonebook */
+ TRAPD(err,grpId = icontactservice->AddL(NULL,KNullDesC8,KGroup));
+
+ if(err != KErrNone)
+ {
+ delete icallback;
+ delete icontactservice;
+ delete grpId;
+ __UHEAP_MARKEND;
+ return KErrGeneral;
+ }
+ delete icallback;
+ delete icontactservice;
+ delete grpId;
+ __UHEAP_MARKEND;
+ return KErrNone;
+
+}
// End of File