author | Pat Downey <patd@symbian.org> |
Wed, 01 Sep 2010 12:28:47 +0100 | |
branch | RCL_3 |
changeset 66 | a9c0808a1095 |
parent 65 | 0b68a1b0c15e |
permissions | -rw-r--r-- |
19 | 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> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
24 |
#include <StifTestInterface.h> |
19 | 25 |
#include <VPbkEng.rsg> |
66 | 26 |
#include <mmfcontrollerpluginresolver.h> |
19 | 27 |
#include <MVPbkContactFieldTextData.h> |
28 |
#include <MVPbkContactStoreList.h> |
|
29 |
#include <MVPbkContactOperationBase.h> |
|
30 |
#include <MVPbkContactLink.h> |
|
31 |
#include <CVPbkContactLinkArray.h> |
|
32 |
#include <MVPbkContactGroup.h> |
|
33 |
#include <utf.h> |
|
34 |
#include <CVPbkPhoneNumberMatchStrategy.h> |
|
35 |
#include <CVPbkContactStoreUriArray.h> |
|
36 |
#include <TVPbkContactStoreUriPtr.h> |
|
37 |
#include "tcontacts_async.h" |
|
38 |
#include "singlecontact.h" |
|
39 |
||
40 |
// CONSTANTS |
|
41 |
_LIT(KError,"Error code is"); |
|
42 |
_LIT(KSuccess,"Successful"); |
|
43 |
_LIT(KNewLine,"\n"); |
|
44 |
_LIT(KServiceOpen,"Service handle created"); |
|
45 |
_LIT(KServiceClose,"Service handle deleted"); |
|
46 |
_LIT(KPhoneNumber,"9886431364"); |
|
47 |
_LIT(KGroup1,"Test1"); |
|
48 |
TInt KInvalidKey = -1; |
|
49 |
// ============================ MEMBER FUNCTIONS =============================== |
|
50 |
||
51 |
// ----------------------------------------------------------------------------- |
|
52 |
// CContactsUT::Delete |
|
53 |
// Delete here all resources allocated and opened from test methods. |
|
54 |
// Called from destructor. |
|
55 |
// ----------------------------------------------------------------------------- |
|
56 |
// |
|
57 |
void CContactsUT::Delete() |
|
58 |
{ |
|
59 |
||
60 |
} |
|
61 |
||
62 |
// ----------------------------------------------------------------------------- |
|
63 |
// CContactsUT::RunMethodL |
|
64 |
// Run specified method. Contains also table of test mothods and their names. |
|
65 |
// ----------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
TInt CContactsUT::RunMethodL( |
|
68 |
CStifItemParser& aItem ) |
|
69 |
{ |
|
70 |
||
71 |
static TStifFunctionInfo const KFunctions[] = |
|
72 |
{ |
|
73 |
ENTRY( "Add_contact_sapi", CContactsUT::AddContactSAPIL ), |
|
74 |
ENTRY( "Delete_contact_sapi", CContactsUT::DeleteContactSAPIL ), |
|
75 |
ENTRY( "Modify_contact_sapi", CContactsUT::ModifyContactSAPIL ), |
|
76 |
ENTRY( "Getlist_delete_contact", CContactsUT::GetListDeleteContactL ), |
|
77 |
ENTRY( "Add_getlist_contact", CContactsUT::AddContactGetListL ), |
|
78 |
ENTRY( "Get_group", CContactsUT::GetGroupsL ), |
|
79 |
ENTRY( "Get_contact", CContactsUT::GetContactsL ), |
|
80 |
ENTRY( "Get_database", CContactsUT::GetDatabaseL ), |
|
81 |
ENTRY( "Add_contact", CContactsUT::AddL ), |
|
82 |
ENTRY( "Add_group", CContactsUT::AddGroupL ), |
|
83 |
ENTRY( "Modify_contact", CContactsUT::ModifyL ), |
|
84 |
ENTRY( "Modify_group", CContactsUT::ModifyGroupL ), |
|
85 |
ENTRY( "Delete_contact", CContactsUT::DeleteContactL ), |
|
86 |
ENTRY( "Delete_group", CContactsUT::DeleteGroupL ), |
|
87 |
ENTRY( "Organise_add", CContactsUT::OrganiseAddL ), |
|
88 |
ENTRY( "Organise_delete", CContactsUT::OrganiseDeleteL ), |
|
89 |
ENTRY( "Import", CContactsUT::ImportL ), |
|
90 |
ENTRY( "Export", CContactsUT::ExportL ), |
|
91 |
ENTRY( "Get_SearchContact", CContactsUT::GetSearchContactL ), |
|
92 |
ENTRY( "Get_ContactAsc", CContactsUT::GetContactsAscOrderL ), |
|
93 |
ENTRY( "Get_ContactDsc", CContactsUT::GetContactsDscOrderL ), |
|
94 |
ENTRY( "Get_ContactbyId", CContactsUT::GetListConactIdL ), |
|
95 |
ENTRY( "AddInvalidField", CContactsUT::AddInvalidFieldL ), |
|
96 |
ENTRY( "AddMultiplePhoneNumbersContact", CContactsUT::AddMultiplePhoneNumbersContactL ), |
|
97 |
ENTRY( "DeleteSingleContact", CContactsUT::DeleteSingleContactL ), |
|
98 |
ENTRY( "GetListCancelTest", CContactsUT::GetListCancelL ), |
|
99 |
ENTRY( "GetListSrchCancelTest", CContactsUT::GetListSrchCancelL ), |
|
100 |
ENTRY( "ExportCancelTest", CContactsUT::ExportCancelL ), |
|
101 |
ENTRY( "AddCancelTest", CContactsUT::AddCancelL ), |
|
102 |
ENTRY( "ImportCancelTest", CContactsUT::ImportCancelL ), |
|
103 |
ENTRY( "DeleteCancelTest", CContactsUT::DeleteCancelL ), |
|
104 |
ENTRY( "OrganiseCancelTest", CContactsUT::OrganiseCancelL), |
|
105 |
}; |
|
106 |
||
107 |
const TInt count = sizeof( KFunctions ) / |
|
108 |
sizeof( TStifFunctionInfo ); |
|
109 |
||
110 |
return RunInternalL( KFunctions, count, aItem ); |
|
111 |
||
112 |
} |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
113 |
void CContactsUT::HandleReturnId( const TInt& aError, HBufC8* acntId, TInt aTransId ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
114 |
{ |
66 | 115 |
delete acntId; |
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
116 |
CActiveScheduler::Stop(); |
66 | 117 |
if(aError == KErrNone) |
118 |
iErr = KErrNone; |
|
119 |
||
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
120 |
} |
19 | 121 |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
122 |
void CContactsUT::HandleReturnArray(const TInt& aError, RPointerArray<HBufC8>& aArray, TInt aTransId ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
123 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
124 |
CActiveScheduler::Stop(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
125 |
} |
19 | 126 |
void CContactsUT::HandleReturnValue(TOperationEvent /*aEvent*/, const TInt& aError, TInt /*aTransId*/ ) |
127 |
{ |
|
128 |
CActiveScheduler::Stop(); |
|
129 |
_LIT(KFunc,"In Handle Return Value\n"); |
|
130 |
iLog->Log(KFunc); |
|
131 |
if(aError == KErrArgument) |
|
132 |
iErr = KErrNone; |
|
133 |
else |
|
134 |
iErr = aError; |
|
135 |
TBuf<5> buf; |
|
136 |
buf.Num(aError); |
|
137 |
iLog->Log(KError); |
|
138 |
iLog->Log(buf); |
|
139 |
iLog->Log(KNewLine); |
|
140 |
} |
|
141 |
||
142 |
void CContactsUT::HandleReturnIter(const TInt& aError, CContactIter* aIter, TInt /*aTransId*/ ) |
|
143 |
{ |
|
144 |
CActiveScheduler::Stop(); |
|
145 |
_LIT(KFunc,"In Handle Return Iter\n"); |
|
146 |
iLog->Log(KFunc); |
|
147 |
iErr = aError; |
|
148 |
TBuf<5> buf; |
|
149 |
buf.Num(aError); |
|
150 |
iLog->Log(KError); |
|
151 |
iLog->Log(buf); |
|
152 |
iLog->Log(KNewLine); |
|
153 |
||
154 |
if(EGetContactDelete == iOperation ) |
|
155 |
{ |
|
156 |
iOperation = ENone; |
|
157 |
CSingleContact* singleContact = NULL; |
|
158 |
HBufC8* buf = NULL; |
|
159 |
TInt count = 0; |
|
160 |
while(ETrue) |
|
161 |
{ |
|
162 |
aIter->NextL(singleContact,buf); |
|
163 |
if(!singleContact) |
|
164 |
{ |
|
165 |
break; |
|
166 |
} |
|
167 |
iBuffer = buf; |
|
168 |
// delete buf; |
|
169 |
delete singleContact; |
|
170 |
break; |
|
171 |
} |
|
172 |
} |
|
173 |
if(iOperation == EContact) |
|
174 |
{ |
|
175 |
iOperation = ENone; |
|
176 |
iErr = KErrGeneral; |
|
177 |
CSingleContact* singleContact = NULL; |
|
178 |
HBufC8* buf = NULL; |
|
179 |
||
180 |
_LIT(KPhone,"Birbal"); |
|
181 |
_LIT8(KField,"FirstName"); |
|
182 |
||
183 |
while(ETrue) |
|
184 |
{ |
|
185 |
__UHEAP_MARK; |
|
186 |
aIter->NextL(singleContact,buf); |
|
187 |
if(!singleContact) |
|
188 |
{ |
|
189 |
break; |
|
190 |
} |
|
191 |
CleanupStack::PushL(singleContact); |
|
192 |
//CleanupStack::PushL(buf); |
|
193 |
if(!buf->Compare(*iBuffer)) |
|
194 |
{ |
|
195 |
TInt count(singleContact->FieldCount()); |
|
196 |
CSingleContactField* field = NULL; |
|
197 |
while(count) |
|
198 |
{ |
|
199 |
TPtrC8 fieldKey; |
|
200 |
TPtrC label; |
|
201 |
TPtrC value; |
|
202 |
field = singleContact->FieldAt(--count); |
|
203 |
field->GetFieldDataL(fieldKey,label,value); |
|
204 |
if(!fieldKey.Compare(KField)) |
|
205 |
{ |
|
206 |
field->SetFieldParamsL(KField,KNullDesC,KPhone); |
|
207 |
iLog->Log(_L("Phone Contact Field modified \n")); |
|
208 |
__UHEAP_MARK; |
|
209 |
iServiceHandle->AddL(this,0,singleContact); |
|
66 | 210 |
__UHEAP_MARKEND; |
211 |
||
19 | 212 |
iLog->Log(_L("AddL called\n")); |
213 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
214 |
CActiveScheduler::Start(); |
|
215 |
break; |
|
216 |
} |
|
217 |
} |
|
218 |
} |
|
219 |
||
220 |
//CleanupStack::PopAndDestroy(buf); |
|
221 |
delete buf; |
|
222 |
CleanupStack::PopAndDestroy(singleContact); |
|
223 |
__UHEAP_MARKEND; |
|
224 |
} |
|
225 |
} |
|
226 |
if(EGetContact == iOperation ) |
|
227 |
{ |
|
228 |
iOperation = ENone; |
|
229 |
//iErr = KErrGeneral; |
|
230 |
_LIT8(KFirstName,"FirstName"); |
|
231 |
_LIT(KName,"Kats"); |
|
232 |
CSingleContact* singleContact = NULL; |
|
233 |
HBufC8* buf = NULL; |
|
234 |
TInt count = 0; |
|
235 |
while(ETrue) |
|
236 |
{ |
|
237 |
aIter->NextL(singleContact,buf); |
|
238 |
if(!singleContact) |
|
239 |
{ |
|
240 |
break; |
|
241 |
} |
|
242 |
++count; |
|
243 |
TInt count(singleContact->FieldCount()); |
|
244 |
while(count) |
|
245 |
{ |
|
246 |
CSingleContactField* field = singleContact->FieldAt(--count); |
|
247 |
TPtrC8 fieldKey; |
|
248 |
TPtrC label; |
|
249 |
TPtrC value; |
|
250 |
field->GetFieldDataL(fieldKey,label,value); |
|
251 |
if (fieldKey == KFirstName && value == KName) |
|
252 |
{ |
|
253 |
iErr = KErrNone; |
|
254 |
} |
|
255 |
// delete field; |
|
256 |
} |
|
257 |
delete buf; |
|
258 |
delete singleContact; |
|
259 |
} |
|
260 |
delete buf; |
|
261 |
} |
|
262 |
if(EContactVerify == iOperation ) |
|
263 |
{ |
|
264 |
iOperation = ENone; |
|
265 |
iErr = KErrGeneral; |
|
266 |
_LIT8(KFirstName,"FirstName"); |
|
267 |
_LIT(KName,"Tenali"); |
|
268 |
CSingleContact* singleContact = NULL; |
|
269 |
HBufC8* buf = NULL; |
|
270 |
aIter->NextL(singleContact,buf); |
|
271 |
if(buf->Compare(*iBuf)==0) |
|
272 |
{ |
|
273 |
iErr = KErrNone; |
|
274 |
} |
|
275 |
} |
|
276 |
if(EContactId == iOperation ) |
|
277 |
{ |
|
278 |
iOperation = ENone; |
|
279 |
//iErr = KErrGeneral; |
|
280 |
_LIT8(KFirstName,"FirstName"); |
|
281 |
_LIT(KName,"Tenali"); |
|
282 |
CSingleContact* singleContact = NULL; |
|
283 |
HBufC8* buf = NULL; |
|
284 |
TInt count = 0; |
|
285 |
||
286 |
aIter->NextL(singleContact,buf); |
|
287 |
iOperation = EContactVerify; |
|
288 |
iBuf = buf; |
|
289 |
iServiceHandle->GetListL(this,0,EContacts,*buf); |
|
290 |
CActiveScheduler::Start(); |
|
291 |
delete singleContact; |
|
292 |
} |
|
293 |
if(ESearchContact == iOperation ) |
|
294 |
{ |
|
295 |
iOperation = ENone; |
|
296 |
iErr = KErrGeneral; |
|
297 |
_LIT8(KFirstName,"FirstName"); |
|
298 |
_LIT(KName,"Tenali"); |
|
299 |
CSingleContact* singleContact = NULL; |
|
300 |
HBufC8* buf = NULL; |
|
301 |
TInt count = 0; |
|
302 |
while(ETrue) |
|
303 |
{ |
|
304 |
aIter->NextL(singleContact,buf); |
|
305 |
if(!singleContact) |
|
306 |
{ |
|
307 |
break; |
|
308 |
} |
|
309 |
++count; |
|
310 |
TInt count(singleContact->FieldCount()); |
|
311 |
while(count) |
|
312 |
{ |
|
313 |
CSingleContactField* field = singleContact->FieldAt(--count); |
|
314 |
TPtrC8 fieldKey; |
|
315 |
TPtrC label; |
|
316 |
TPtrC value; |
|
317 |
field->GetFieldDataL(fieldKey,label,value); |
|
318 |
if (fieldKey == KFirstName && value == KName) |
|
319 |
{ |
|
320 |
iErr = KErrNone; |
|
321 |
} |
|
322 |
else if (fieldKey == KFirstName) |
|
323 |
{ |
|
324 |
break; |
|
325 |
} |
|
326 |
} |
|
327 |
delete singleContact; |
|
328 |
} |
|
329 |
} |
|
330 |
if(EAscContact == iOperation ) |
|
331 |
{ |
|
332 |
iOperation = ENone; |
|
333 |
iErr = KErrGeneral; |
|
334 |
_LIT8(KFirstName,"FirstName"); |
|
335 |
_LIT(KNameT,"Tenali"); |
|
336 |
_LIT(KNameB,"Birbal"); |
|
337 |
TInt count1 = 0; |
|
338 |
TInt tCount = 0; |
|
339 |
TInt bCount = 0; |
|
340 |
CSingleContact* singleContact = NULL; |
|
341 |
HBufC8* buf = NULL; |
|
342 |
TInt count = 0; |
|
343 |
||
344 |
while(ETrue) |
|
345 |
{ |
|
346 |
aIter->NextL(singleContact,buf); |
|
347 |
if(!singleContact) |
|
348 |
{ |
|
349 |
break; |
|
350 |
} |
|
351 |
++count; |
|
352 |
TInt count(singleContact->FieldCount()); |
|
353 |
while(count) |
|
354 |
{ |
|
355 |
CSingleContactField* field = singleContact->FieldAt(--count); |
|
356 |
TPtrC8 fieldKey; |
|
357 |
TPtrC label; |
|
358 |
TPtrC value; |
|
359 |
field->GetFieldDataL(fieldKey,label,value); |
|
360 |
if (fieldKey == KFirstName && value == KNameT) |
|
361 |
{ |
|
362 |
++count1; |
|
363 |
tCount = count1; |
|
364 |
} |
|
365 |
if (fieldKey == KFirstName && value == KNameB) |
|
366 |
{ |
|
367 |
++count1; |
|
368 |
bCount = count1; |
|
369 |
} |
|
370 |
||
371 |
} |
|
372 |
delete singleContact; |
|
373 |
} |
|
374 |
||
375 |
if(bCount>0 && tCount>0 && bCount<tCount) |
|
376 |
{ |
|
377 |
iErr = KErrNone; |
|
378 |
} |
|
379 |
} |
|
380 |
||
381 |
if(EDscContact == iOperation ) |
|
382 |
{ |
|
383 |
iOperation = ENone; |
|
384 |
iErr = KErrGeneral; |
|
385 |
_LIT8(KFirstName,"FirstName"); |
|
386 |
_LIT(KNameT,"Tenali"); |
|
387 |
_LIT(KNameB,"Birbal"); |
|
388 |
TInt count1 = 0; |
|
389 |
TInt tCount = 0; |
|
390 |
TInt bCount = 0; |
|
391 |
CSingleContact* singleContact = NULL; |
|
392 |
HBufC8* buf = NULL; |
|
393 |
TInt count = 0; |
|
394 |
while(ETrue) |
|
395 |
{ |
|
396 |
aIter->NextL(singleContact,buf); |
|
397 |
if(!singleContact) |
|
398 |
{ |
|
399 |
break; |
|
400 |
} |
|
401 |
++count; |
|
402 |
TInt count(singleContact->FieldCount()); |
|
403 |
while(count) |
|
404 |
{ |
|
405 |
CSingleContactField* field = singleContact->FieldAt(--count); |
|
406 |
TPtrC8 fieldKey; |
|
407 |
TPtrC label; |
|
408 |
TPtrC value; |
|
409 |
field->GetFieldDataL(fieldKey,label,value); |
|
410 |
if (fieldKey == KFirstName && value == KNameT) |
|
411 |
{ |
|
412 |
++count1; |
|
413 |
tCount = count1; |
|
414 |
} |
|
415 |
if (fieldKey == KFirstName && value == KNameB) |
|
416 |
{ |
|
417 |
++count1; |
|
418 |
bCount = count1; |
|
419 |
} |
|
420 |
} |
|
421 |
delete singleContact; |
|
422 |
} |
|
423 |
if(bCount>tCount) |
|
424 |
{ |
|
425 |
iErr = KErrNone; |
|
426 |
} |
|
427 |
} |
|
428 |
if(EGetGroup == iOperation ) |
|
429 |
{ |
|
430 |
iOperation = ENone; |
|
431 |
iErr = KErrGeneral; |
|
432 |
CSingleContact* singleContact = NULL; |
|
433 |
HBufC8* buf = NULL; |
|
434 |
TInt count = 0; |
|
435 |
while(ETrue) |
|
436 |
{ |
|
437 |
aIter->NextL(singleContact,buf); |
|
438 |
iBuffer = buf; |
|
439 |
if(!singleContact) |
|
440 |
{ |
|
441 |
break; |
|
442 |
} |
|
443 |
++count; |
|
444 |
TInt fields(singleContact->FieldCount()); |
|
445 |
while(fields) |
|
446 |
{ |
|
447 |
CSingleContactField* field = singleContact->FieldAt(--fields); |
|
448 |
TPtrC groupId; |
|
449 |
RPointerArray<TDesC8> array; |
|
450 |
field->GetFieldDataL(groupId,array); |
|
451 |
||
452 |
||
453 |
if(groupId.Compare(KGroup1)==0) |
|
454 |
{ |
|
455 |
iErr = KErrNone; |
|
456 |
break; |
|
457 |
} |
|
458 |
||
459 |
} |
|
460 |
||
461 |
} |
|
462 |
} |
|
463 |
delete aIter; |
|
464 |
} |
|
465 |
||
466 |
void CContactsUT::HandleRetrieveContact( MVPbkStoreContact* /*aStoreContact*/, TInt /*aTransId*/ ) |
|
467 |
{ |
|
468 |
CActiveScheduler::Stop(); |
|
469 |
_LIT(KFunc,"In Handle Retrieve Contact\n"); |
|
470 |
iLog->Log(KFunc); |
|
471 |
} |
|
472 |
||
473 |
void CContactsUT::ContactOperationCompleted(TContactOpResult aResult) |
|
474 |
{ |
|
475 |
CActiveScheduler::Stop(); |
|
476 |
_LIT(KFunc,"In ContactOperationCompleted \n"); |
|
477 |
iLog->Log(KFunc); |
|
478 |
iErr = KErrNone; |
|
479 |
TBuf<5> buf; |
|
480 |
buf.Num(aResult.iOpCode); |
|
481 |
iLog->Log(KSuccess); |
|
482 |
iLog->Log(buf); |
|
483 |
iLog->Log(KNewLine); |
|
484 |
switch(iOperation) |
|
485 |
{/* |
|
486 |
case EContact: delete iStoreContact; |
|
487 |
iStoreContact = NULL; |
|
488 |
break;*/ |
|
489 |
case EGroup: delete iGroup; |
|
490 |
iGroup = NULL; |
|
491 |
break; |
|
492 |
} |
|
493 |
iOperation = ENone; |
|
494 |
} |
|
495 |
void CContactsUT::ContactOperationFailed |
|
496 |
(TContactOp /*aOpCode*/, TInt aErrorCode, TBool /*aErrorNotified*/) |
|
497 |
{ |
|
498 |
CActiveScheduler::Stop(); |
|
499 |
_LIT(KFunc,"In ContactOperationFailed \n"); |
|
500 |
iLog->Log(KFunc); |
|
501 |
iErr = aErrorCode; |
|
502 |
TBuf<5> buf; |
|
503 |
buf.Num(aErrorCode); |
|
504 |
iLog->Log(KError); |
|
505 |
iLog->Log(buf); |
|
506 |
iLog->Log(KNewLine); |
|
507 |
switch(iOperation) |
|
508 |
{ |
|
509 |
case EContact:/* delete iStoreContact; |
|
510 |
iStoreContact = NULL; |
|
511 |
break;*/ |
|
512 |
case EGroup: delete iGroup; |
|
513 |
iGroup = NULL; |
|
514 |
break; |
|
515 |
} |
|
516 |
iOperation = ENone; |
|
517 |
} |
|
518 |
||
519 |
void CContactsUT::FindCompleteL( MVPbkContactLinkArray* aResults ) |
|
520 |
{ |
|
521 |
CActiveScheduler::Stop(); |
|
522 |
_LIT(KFunc,"In FindCompleteL \n"); |
|
523 |
iLog->Log(KFunc); |
|
524 |
iErr = KErrNone; |
|
525 |
TInt count = aResults->Count(); |
|
526 |
iFindResults = aResults; |
|
527 |
iLog->Log(KSuccess); |
|
528 |
} |
|
529 |
void CContactsUT::FindFailed( TInt aError ) |
|
530 |
{ |
|
531 |
CActiveScheduler::Stop(); |
|
532 |
_LIT(KFunc,"In FindFailed \n"); |
|
533 |
iLog->Log(KFunc); |
|
534 |
iErr = aError; |
|
535 |
TBuf<5> buf; |
|
536 |
buf.Num(aError); |
|
537 |
iLog->Log(KError); |
|
538 |
iLog->Log(buf); |
|
539 |
iLog->Log(KNewLine); |
|
540 |
} |
|
541 |
||
542 |
void CContactsUT::VPbkSingleContactOperationComplete( |
|
543 |
MVPbkContactOperationBase& aOperation, |
|
544 |
MVPbkStoreContact* aContact ) |
|
545 |
{ |
|
546 |
CActiveScheduler::Stop(); |
|
547 |
_LIT(KFunc,"In VPbkSingleContactOperationComplete \n"); |
|
548 |
iLog->Log(KFunc); |
|
549 |
iErr = KErrNone; |
|
550 |
||
551 |
if(iOperation == EVCard) |
|
552 |
{ |
|
553 |
iDestStream.CommitL(); |
|
554 |
delete iOp; |
|
555 |
iOp = NULL; |
|
556 |
iDestStream.Close(); |
|
557 |
delete iResult; |
|
558 |
iResult = NULL; |
|
559 |
} |
|
560 |
else if(iOperation == EVCardEx) |
|
561 |
{ |
|
562 |
delete iOp; |
|
563 |
iOp = NULL; |
|
564 |
} |
|
565 |
else |
|
566 |
{ |
|
567 |
delete iStoreContact; |
|
568 |
iStoreContact = NULL; |
|
569 |
iStoreContact = aContact; |
|
570 |
if( iOp == &aOperation ) |
|
571 |
{ |
|
572 |
delete iOp; |
|
573 |
iOp = NULL; |
|
574 |
} |
|
575 |
} |
|
576 |
iOperation = ENone; |
|
577 |
iLog->Log(KSuccess); |
|
578 |
} |
|
579 |
||
580 |
||
581 |
void CContactsUT::VPbkSingleContactOperationFailed( |
|
582 |
MVPbkContactOperationBase& aOperation, |
|
583 |
TInt aError ) |
|
584 |
{ |
|
585 |
CActiveScheduler::Stop(); |
|
586 |
_LIT(KFunc,"In VPbkSingleContactOperationFailed \n"); |
|
587 |
iLog->Log(KFunc); |
|
588 |
iErr = aError; |
|
589 |
; |
|
590 |
if(iOperation == EVCard) |
|
591 |
{ |
|
592 |
iDestStream.CommitL(); |
|
593 |
delete iOp; |
|
594 |
iOp = NULL; |
|
595 |
iDestStream.Close(); |
|
596 |
delete iBuffer; |
|
597 |
iBuffer = NULL; |
|
598 |
delete iResult; |
|
599 |
iResult = NULL; |
|
600 |
} |
|
601 |
else if(iOperation == EVCardEx) |
|
602 |
{ |
|
603 |
delete iOp; |
|
604 |
iOp = NULL; |
|
605 |
} |
|
606 |
else |
|
607 |
{ |
|
608 |
delete iStoreContact; |
|
609 |
iStoreContact = NULL; |
|
610 |
if( iOp == &aOperation ) |
|
611 |
{ |
|
612 |
delete iOp; |
|
613 |
iOp = NULL; |
|
614 |
} |
|
615 |
} |
|
616 |
TBuf<5> buf; |
|
617 |
buf.Num(aError); |
|
618 |
iLog->Log(KError); |
|
619 |
iLog->Log(buf); |
|
620 |
iLog->Log(KNewLine); |
|
621 |
||
622 |
iOperation = ENone; |
|
623 |
} |
|
624 |
||
625 |
void CContactsUT::StepComplete( |
|
626 |
MVPbkContactOperationBase& /*aOperation*/, |
|
627 |
TInt /*aStepSize*/ ) |
|
628 |
{ |
|
629 |
_LIT(KFunc,"In StepComplete \n"); |
|
630 |
iLog->Log(KFunc); |
|
631 |
iLog->Log(KSuccess); |
|
632 |
iLog->Log(KNewLine); |
|
633 |
} |
|
634 |
||
635 |
TBool CContactsUT::StepFailed( |
|
636 |
MVPbkContactOperationBase& /*aOperation*/, |
|
637 |
TInt /*aStepSize*/, TInt /*aError*/ ) |
|
638 |
{ |
|
639 |
_LIT(KFunc,"In StepFailed \n"); |
|
640 |
iLog->Log(KFunc); |
|
641 |
return EFalse; |
|
642 |
} |
|
643 |
||
644 |
void CContactsUT::OperationComplete( |
|
645 |
MVPbkContactOperationBase& /*aOperation*/ ) |
|
646 |
{ |
|
647 |
CActiveScheduler::Stop(); |
|
648 |
_LIT(KFunc,"In OperationComplete \n"); |
|
649 |
iLog->Log(KFunc); |
|
650 |
iErr = KErrNone; |
|
651 |
iLog->Log(KSuccess); |
|
652 |
iLog->Log(KNewLine); |
|
653 |
} |
|
654 |
||
655 |
||
656 |
//Delete all contacts |
|
657 |
void CContactsUT::DeleteAllL() |
|
658 |
{ |
|
659 |
// Print to UI |
|
660 |
_LIT( KContactsTest, "ContactsUT" ); |
|
661 |
_LIT( KExample, "In DeleteAllL" ); |
|
662 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
663 |
// Print to log file |
|
664 |
iLog->Log( KExample ); |
|
665 |
||
666 |
iErr = KErrNone; |
|
667 |
||
66 | 668 |
// __UHEAP_MARK; |
19 | 669 |
iOp = iContactManager->MatchPhoneNumberL( |
670 |
KPhoneNumber, KPhoneNumber().Length(), *this ); |
|
671 |
CActiveScheduler::Start(); |
|
672 |
delete iOp; |
|
673 |
iOp = NULL; |
|
674 |
||
675 |
TInt count(iFindResults->Count()); |
|
676 |
iContactToDelete = CVPbkContactLinkArray::NewLC(); |
|
677 |
while(count) |
|
678 |
{ |
|
679 |
MVPbkContactLink* link = iFindResults->At(--count).CloneLC(); |
|
680 |
iContactToDelete->AppendL(link); |
|
681 |
CleanupStack::Pop(); |
|
682 |
} |
|
683 |
delete iFindResults; |
|
684 |
iFindResults = NULL; |
|
685 |
||
686 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
687 |
CActiveScheduler::Start(); |
|
688 |
delete iOp; |
|
689 |
iOp = NULL; |
|
690 |
CleanupStack::PopAndDestroy(iContactToDelete); |
|
691 |
iContactToDelete = NULL; |
|
692 |
||
693 |
||
66 | 694 |
// __UHEAP_MARKEND; |
19 | 695 |
} |
696 |
||
697 |
//Add 1 contact |
|
698 |
void CContactsUT::AddOneContactL(TDesC& aName) |
|
699 |
{ |
|
700 |
// Print to UI |
|
701 |
_LIT( KContactsTest, "ContactsUT" ); |
|
702 |
_LIT( KExample, "In AddOneContactL" ); |
|
703 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
704 |
// Print to log file |
|
705 |
iLog->Log( KExample ); |
|
706 |
||
707 |
iErr = KErrNone; |
|
708 |
||
709 |
__UHEAP_MARK; |
|
710 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
711 |
CleanupStack::PushL(fieldTypeRefList); |
|
712 |
||
713 |
fieldTypeRefList->AppendL( |
|
714 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
715 |
fieldTypeRefList->AppendL( |
|
716 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
717 |
||
718 |
// Create first contact |
|
719 |
iStoreContact = iStore->CreateNewContactLC(); |
|
720 |
||
721 |
// Create contact field for contact |
|
722 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
723 |
// Set contact field data |
|
724 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( aName ); |
|
725 |
// Add the contact field to contact |
|
726 |
iStoreContact->AddFieldL( field ); |
|
727 |
CleanupStack::Pop(); // field |
|
728 |
||
729 |
// Create contact field for contact |
|
730 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
731 |
// Set contact field data |
|
732 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KPhoneNumber ); |
|
733 |
// Add the contact field to contact |
|
734 |
iStoreContact->AddFieldL( field ); |
|
735 |
CleanupStack::Pop(); // field |
|
736 |
||
737 |
// Commit the new created contact to contact store |
|
738 |
iStoreContact->CommitL( *this ); |
|
739 |
CActiveScheduler::Start(); |
|
740 |
CleanupStack::PopAndDestroy(); // iStoreContact |
|
741 |
iStoreContact = NULL; |
|
742 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
743 |
__UHEAP_MARKEND; |
|
744 |
} |
|
745 |
||
746 |
//Check for contact |
|
747 |
void CContactsUT::CheckContactsL(TInt& aCount,RPointerArray<TDesC8>& aIdArray) |
|
66 | 748 |
{ |
749 |
CleanupResetAndDestroyPushL(aIdArray); |
|
19 | 750 |
// Print to UI |
751 |
_LIT( KContactsTest, "ContactsUT" ); |
|
752 |
_LIT( KExample, "In CheckContactsL" ); |
|
753 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
754 |
// Print to log file |
|
755 |
iLog->Log( KExample ); |
|
756 |
||
757 |
iErr = KErrNone; |
|
758 |
||
759 |
//__UHEAP_MARK; |
|
760 |
iOp = iContactManager->MatchPhoneNumberL( |
|
761 |
KPhoneNumber, KPhoneNumber().Length(), *this ); |
|
762 |
CActiveScheduler::Start(); |
|
763 |
delete iOp; |
|
764 |
iOp = NULL; |
|
765 |
||
766 |
aCount = iFindResults->Count(); |
|
767 |
TInt count(aCount); |
|
768 |
while(count) |
|
769 |
{ |
|
770 |
aIdArray.AppendL((const_cast<MVPbkContactLink&>(iFindResults->At(--count))).PackLC()); |
|
771 |
CleanupStack::Pop(); |
|
772 |
} |
|
773 |
delete iFindResults; |
|
774 |
iFindResults = NULL; |
|
66 | 775 |
// __UHEAP_MARKENDC(aCount); |
776 |
CleanupStack::Pop(&aIdArray); |
|
19 | 777 |
} |
778 |
||
779 |
// ----------------------------------------------------------------------------- |
|
780 |
// CContactsUT::?member_function |
|
781 |
// ?implementation_description |
|
782 |
// (other items were commented in a header). |
|
783 |
// ----------------------------------------------------------------------------- |
|
784 |
// |
|
785 |
TInt CContactsUT::AddContactSAPIL( CStifItemParser& aItem ) |
|
786 |
{ |
|
787 |
// Print to UI |
|
788 |
_LIT( KContactsTest, "ContactsUT" ); |
|
789 |
_LIT( KExample, "In AddContactSAPIL" ); |
|
790 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
791 |
// Print to log file |
|
792 |
iLog->Log( KExample ); |
|
793 |
||
794 |
TInt i = 0; |
|
795 |
TPtrC string; |
|
796 |
_LIT( KParam, "Param[%i]: %S" ); |
|
797 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
798 |
{ |
|
799 |
TestModuleIf().Printf( i, KContactsTest, |
|
800 |
KParam, i, &string ); |
|
801 |
i++; |
|
802 |
} |
|
803 |
||
804 |
iErr = KErrNone; |
|
805 |
||
806 |
DeleteAllL(); |
|
807 |
||
808 |
/**Add contact using SAPI Core class*/ |
|
809 |
||
810 |
_LIT8(KFirstName,"FirstName"); |
|
811 |
_LIT(KName,"Sikandar"); |
|
812 |
_LIT8(KNumber,"MobilePhoneGen"); |
|
813 |
||
814 |
__UHEAP_MARK; |
|
815 |
//instantiate service class |
|
816 |
CContactService* serviceHandle = CContactService::NewL(); |
|
817 |
CleanupStack::PushL(serviceHandle); |
|
818 |
iLog->Log( KServiceOpen ); |
|
819 |
||
820 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
821 |
CleanupStack::PushL(singleContact); |
|
822 |
iLog->Log(_L("single Contact created\n")); |
|
823 |
||
824 |
CSingleContactField* nameContactField = CSingleContactField::NewL(); |
|
825 |
CleanupStack::PushL(nameContactField); |
|
826 |
iLog->Log(_L("Name Contact Field created \n")); |
|
827 |
||
828 |
CSingleContactField* phoneContactField = CSingleContactField::NewL(); |
|
829 |
CleanupStack::PushL(phoneContactField); |
|
830 |
iLog->Log(_L("Phone Contact Field created \n")); |
|
831 |
||
832 |
nameContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
833 |
singleContact->AddFieldToContactL(nameContactField); |
|
834 |
iLog->Log(_L("Name Contact Field added \n")); |
|
835 |
||
836 |
phoneContactField->SetFieldParamsL(KNumber,KNullDesC,KPhoneNumber); |
|
837 |
singleContact->AddFieldToContactL(phoneContactField); |
|
838 |
iLog->Log(_L("Phone Contact Field added \n")); |
|
839 |
||
840 |
serviceHandle->AddL(this,0,singleContact); |
|
841 |
iLog->Log(_L("AddL called\n")); |
|
842 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
843 |
CActiveScheduler::Start(); |
|
844 |
||
845 |
CleanupStack::Pop(phoneContactField);//singleContactField |
|
846 |
CleanupStack::Pop(nameContactField);//singleContactField |
|
847 |
CleanupStack::PopAndDestroy(singleContact);//singleContact |
|
848 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
849 |
iLog->Log( KServiceClose ); |
|
850 |
__UHEAP_MARKEND; |
|
851 |
/**end */ |
|
852 |
||
853 |
TInt count; |
|
854 |
RPointerArray<TDesC8> idArray; |
|
855 |
CheckContactsL(count,idArray); |
|
856 |
if(count != 1) |
|
857 |
{ |
|
858 |
iErr = KErrGeneral; |
|
859 |
} |
|
860 |
idArray.ResetAndDestroy(); |
|
861 |
||
862 |
DeleteAllL(); |
|
863 |
return iErr; |
|
864 |
} |
|
865 |
||
866 |
// ----------------------------------------------------------------------------- |
|
867 |
// CContactsUT::?member_function |
|
868 |
// ?implementation_description |
|
869 |
// (other items were commented in a header). |
|
870 |
// ----------------------------------------------------------------------------- |
|
871 |
// |
|
872 |
TInt CContactsUT::DeleteContactSAPIL( CStifItemParser& aItem ) |
|
873 |
{ |
|
874 |
// Print to UI |
|
875 |
_LIT( KContactsTest, "ContactsUT" ); |
|
876 |
_LIT( KExample, "In DeleteContactSAPIL" ); |
|
877 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
878 |
// Print to log file |
|
879 |
iLog->Log( KExample ); |
|
880 |
||
881 |
TInt i = 0; |
|
882 |
TPtrC string; |
|
883 |
_LIT( KParam, "Param[%i]: %S" ); |
|
884 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
885 |
{ |
|
886 |
TestModuleIf().Printf( i, KContactsTest, |
|
887 |
KParam, i, &string ); |
|
888 |
i++; |
|
889 |
} |
|
890 |
||
891 |
iErr = KErrNone; |
|
892 |
||
893 |
DeleteAllL(); |
|
894 |
_LIT(KName,"SpiderMan"); |
|
895 |
TPtrC name(KName); |
|
896 |
AddOneContactL(name); |
|
897 |
||
898 |
TInt count(0); |
|
899 |
RPointerArray<TDesC8> idArray; |
|
900 |
CleanupClosePushL(idArray); |
|
901 |
CheckContactsL(count,idArray); |
|
902 |
if(count != 1) |
|
903 |
{ |
|
904 |
return KErrGeneral; |
|
905 |
} |
|
906 |
||
907 |
/**Delete using SAPI core class*/ |
|
908 |
||
909 |
__UHEAP_MARK; |
|
910 |
CContactService* serviceHandle = CContactService::NewL(); |
|
911 |
CleanupStack::PushL(serviceHandle); |
|
912 |
iLog->Log( KServiceOpen ); |
|
913 |
||
914 |
serviceHandle->DeleteL(this,0,idArray); |
|
915 |
iLog->Log(_L("DeleteL called\n")); |
|
916 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
917 |
CActiveScheduler::Start(); |
|
918 |
||
919 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
920 |
iLog->Log( KServiceClose ); |
|
921 |
__UHEAP_MARKEND; |
|
922 |
/**end*/ |
|
923 |
CleanupStack::Pop(&idArray); |
|
924 |
idArray.ResetAndDestroy(); |
|
925 |
||
926 |
RPointerArray<TDesC8> idArray1; |
|
927 |
CleanupClosePushL(idArray1); |
|
928 |
CheckContactsL(count,idArray1); |
|
929 |
if(count) |
|
930 |
{ |
|
931 |
iErr = KErrGeneral; |
|
932 |
} |
|
933 |
CleanupStack::Pop(&idArray1); |
|
934 |
idArray.ResetAndDestroy(); |
|
935 |
return iErr; |
|
936 |
||
937 |
} |
|
938 |
||
939 |
// ----------------------------------------------------------------------------- |
|
940 |
// CContactsUT::?member_function |
|
941 |
// ?implementation_description |
|
942 |
// (other items were commented in a header). |
|
943 |
// ----------------------------------------------------------------------------- |
|
944 |
// |
|
945 |
TInt CContactsUT::ModifyContactSAPIL( CStifItemParser& aItem ) |
|
946 |
{ |
|
947 |
// Print to UI |
|
948 |
_LIT( KContactsTest, "ContactsUT" ); |
|
949 |
_LIT( KExample, "In ModifyContactSAPIL" ); |
|
950 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
951 |
// Print to log file |
|
952 |
iLog->Log( KExample ); |
|
953 |
||
954 |
TInt i = 0; |
|
955 |
TPtrC string; |
|
956 |
_LIT( KParam, "Param[%i]: %S" ); |
|
957 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
958 |
{ |
|
959 |
TestModuleIf().Printf( i, KContactsTest, |
|
960 |
KParam, i, &string ); |
|
961 |
i++; |
|
962 |
} |
|
963 |
||
964 |
iErr = KErrNone; |
|
965 |
||
966 |
DeleteAllL(); |
|
967 |
_LIT(KName,"SuperMan"); |
|
968 |
TPtrC name(KName); |
|
969 |
AddOneContactL(name); |
|
970 |
||
971 |
TInt count(0); |
|
972 |
RPointerArray<TDesC8> idArray; |
|
973 |
CleanupClosePushL(idArray); |
|
974 |
CheckContactsL(count,idArray); |
|
975 |
if(count != 1) |
|
976 |
{ |
|
977 |
return KErrGeneral; |
|
978 |
} |
|
979 |
||
980 |
/**Get using SAPI core class*/ |
|
981 |
__UHEAP_MARK; |
|
982 |
CContactService* serviceHandle = CContactService::NewL(); |
|
983 |
CleanupStack::PushL(serviceHandle); |
|
984 |
iLog->Log( KServiceOpen ); |
|
985 |
||
986 |
serviceHandle->GetListL(this,0,EContacts,*idArray[0]); |
|
987 |
iLog->Log(_L("GetListL called\n")); |
|
988 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
989 |
CActiveScheduler::Start(); |
|
990 |
||
991 |
if(!iSingleContact) |
|
992 |
{ |
|
993 |
return KErrGeneral; |
|
994 |
} |
|
995 |
||
996 |
_LIT(KName1,"SpiderMan"); |
|
997 |
_LIT8(KFirstName,"FirstName"); |
|
998 |
CSingleContactField* field = NULL; |
|
999 |
TInt fieldCount(iSingleContact->FieldCount()); |
|
1000 |
while(fieldCount) |
|
1001 |
{ |
|
1002 |
TPtrC8 fieldKey; |
|
1003 |
TPtrC label; |
|
1004 |
TPtrC value; |
|
1005 |
field = iSingleContact->FieldAt(--fieldCount); |
|
1006 |
field->GetFieldDataL(fieldKey,label,value); |
|
1007 |
if(!fieldKey.Compare(KFirstName) && !value.Compare(KName)) |
|
1008 |
{ |
|
1009 |
field->SetFieldParamsL(KFirstName,KNullDesC,KName1); |
|
1010 |
iLog->Log(_L("Phone Contact Field modified \n")); |
|
1011 |
break; |
|
1012 |
} |
|
1013 |
} |
|
1014 |
||
1015 |
__UHEAP_MARK; |
|
1016 |
serviceHandle->AddL(this,0,iSingleContact); |
|
1017 |
iLog->Log(_L("AddL called\n")); |
|
1018 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1019 |
CActiveScheduler::Start(); |
|
1020 |
__UHEAP_MARKEND; |
|
1021 |
||
1022 |
delete iSingleContact; |
|
1023 |
iSingleContact = NULL; |
|
1024 |
||
1025 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
1026 |
iLog->Log( KServiceClose ); |
|
1027 |
__UHEAP_MARKEND; |
|
1028 |
/**end*/ |
|
1029 |
||
1030 |
||
1031 |
CleanupStack::Pop(&idArray); |
|
1032 |
idArray.ResetAndDestroy(); |
|
1033 |
||
1034 |
RPointerArray<TDesC8> idArray1; |
|
1035 |
CleanupClosePushL(idArray1); |
|
1036 |
CheckContactsL(count,idArray1); |
|
1037 |
if(count != 1) |
|
1038 |
{ |
|
1039 |
iErr = KErrGeneral; |
|
1040 |
} |
|
1041 |
CleanupStack::Pop(); |
|
1042 |
idArray1.ResetAndDestroy(); |
|
1043 |
//to implement ..checking name |
|
1044 |
return iErr; |
|
1045 |
||
1046 |
} |
|
1047 |
||
1048 |
// ----------------------------------------------------------------------------- |
|
1049 |
// CContactsUT::?member_function |
|
1050 |
// ?implementation_description |
|
1051 |
// (other items were commented in a header). |
|
1052 |
// ----------------------------------------------------------------------------- |
|
1053 |
// |
|
1054 |
TInt CContactsUT::ImportContactSAPIL( CStifItemParser& aItem ) |
|
1055 |
{ |
|
1056 |
// Print to UI |
|
1057 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1058 |
_LIT( KExample, "In ImportContactSAPIL" ); |
|
1059 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1060 |
// Print to log file |
|
1061 |
iLog->Log( KExample ); |
|
1062 |
||
1063 |
TInt i = 0; |
|
1064 |
TPtrC string; |
|
1065 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1066 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1067 |
{ |
|
1068 |
TestModuleIf().Printf( i, KContactsTest, |
|
1069 |
KParam, i, &string ); |
|
1070 |
i++; |
|
1071 |
} |
|
1072 |
||
1073 |
iErr = KErrNone; |
|
1074 |
_LIT(KFileName,"c:\\vcardim.vcf"); |
|
1075 |
||
1076 |
/* DeleteAllL(); |
|
1077 |
||
1078 |
_LIT(KName,"SuperMan"); |
|
1079 |
TPtrC name(KName); |
|
1080 |
AddOneContactL(name); |
|
1081 |
||
1082 |
TInt count(0); |
|
1083 |
RPointerArray<TDesC8> idArray; |
|
1084 |
CleanupClosePushL(idArray); |
|
1085 |
CheckContactsL(count,idArray); |
|
1086 |
if(count != 1) |
|
1087 |
{ |
|
1088 |
return KErrGeneral; |
|
1089 |
} |
|
1090 |
||
1091 |
//__UHEAP_MARK; |
|
1092 |
MVPbkContactLinkArray* linkArray = iContactManager->CreateLinksLC(*idArray[0]); |
|
1093 |
iVCardEngine = CVPbkVCardEng::NewL( *iContactManager ); |
|
1094 |
// Create the buffer to store the contact |
|
1095 |
iBuffer = HBufC8::NewL( 1024 ); |
|
1096 |
TPtr8 bufferPtr( iBuffer->Des() ); |
|
1097 |
iDestStream.Open( bufferPtr ); |
|
1098 |
//export the contact from MVPbkContactLink |
|
1099 |
// __UHEAP_MARK; |
|
1100 |
iOp = iVCardEngine->ExportVCardL( iDestStream, linkArray->At(0), *this ); |
|
1101 |
CActiveScheduler::Start(); |
|
1102 |
||
1103 |
// __UHEAP_MARKEND; |
|
1104 |
if( !iErr ) |
|
1105 |
{ |
|
1106 |
iDestStream.CommitL(); |
|
1107 |
} |
|
1108 |
||
1109 |
iDestStream.Close(); |
|
1110 |
if(iBuffer) |
|
1111 |
{ |
|
1112 |
RFile file; |
|
1113 |
CleanupClosePushL(file); |
|
1114 |
file.Replace(iRfs,KFileName,EFileWrite); |
|
1115 |
file.Write(0,*iBuffer); |
|
1116 |
CleanupStack::PopAndDestroy(&file); |
|
1117 |
} |
|
1118 |
delete iBuffer; |
|
1119 |
iBuffer = NULL; |
|
1120 |
delete iVCardEngine; |
|
1121 |
iVCardEngine = NULL; |
|
1122 |
CleanupStack::PopAndDestroy();//linkArray |
|
1123 |
//__UHEAP_MARKEND; |
|
1124 |
||
1125 |
CleanupStack::Pop(&idArray); |
|
1126 |
idArray.ResetAndDestroy(); |
|
1127 |
DeleteAllL(); |
|
1128 |
*/ |
|
1129 |
DeleteAllL(); |
|
1130 |
__UHEAP_MARK; |
|
1131 |
CContactService* serviceHandle = CContactService::NewL(); |
|
1132 |
CleanupStack::PushL(serviceHandle); |
|
1133 |
iLog->Log( KServiceOpen ); |
|
1134 |
||
1135 |
TFileName importFile(KFileName); |
|
1136 |
||
1137 |
serviceHandle->ImportVCardToStoreL(this,0,importFile); |
|
1138 |
iLog->Log(_L("ImportVCardToStoreL called\n")); |
|
1139 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1140 |
CActiveScheduler::Start(); |
|
1141 |
||
1142 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
1143 |
iLog->Log( KServiceClose ); |
|
1144 |
__UHEAP_MARKEND; |
|
1145 |
||
1146 |
TInt count = 0; |
|
1147 |
RPointerArray<TDesC8> idArray; |
|
1148 |
CleanupClosePushL(idArray); |
|
1149 |
CheckContactsL(count,idArray); |
|
1150 |
if(count != 1) |
|
1151 |
{ |
|
1152 |
return KErrGeneral; |
|
1153 |
} |
|
1154 |
CleanupStack::Pop(&idArray); |
|
1155 |
idArray.ResetAndDestroy(); |
|
1156 |
return iErr; |
|
1157 |
} |
|
1158 |
||
1159 |
// ----------------------------------------------------------------------------- |
|
1160 |
// CContactsUT::?member_function |
|
1161 |
// ?implementation_description |
|
1162 |
// (other items were commented in a header). |
|
1163 |
// ----------------------------------------------------------------------------- |
|
1164 |
// |
|
1165 |
TInt CContactsUT::ExportContactSAPIL( CStifItemParser& aItem ) |
|
1166 |
{ |
|
1167 |
// Print to UI |
|
1168 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1169 |
_LIT( KExample, "In ExportContactSAPIL" ); |
|
1170 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1171 |
// Print to log file |
|
1172 |
iLog->Log( KExample ); |
|
1173 |
||
1174 |
TInt i = 0; |
|
1175 |
TPtrC string; |
|
1176 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1177 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1178 |
{ |
|
1179 |
TestModuleIf().Printf( i, KContactsTest, |
|
1180 |
KParam, i, &string ); |
|
1181 |
i++; |
|
1182 |
} |
|
1183 |
||
1184 |
iErr = KErrNone; |
|
1185 |
_LIT(KFileName,"c:\\vcardim.vcf"); |
|
1186 |
_LIT(KFileName1,"c:\\vcardim1.vcf"); |
|
1187 |
||
1188 |
DeleteAllL(); |
|
1189 |
||
1190 |
_LIT(KName,"SuperMan"); |
|
1191 |
TPtrC name(KName); |
|
1192 |
AddOneContactL(name); |
|
1193 |
||
1194 |
_LIT(KName1,"SpiderMan"); |
|
1195 |
TPtrC name1(KName1); |
|
1196 |
AddOneContactL(name1); |
|
1197 |
||
1198 |
TInt count(0); |
|
1199 |
RPointerArray<TDesC8> idArray; |
|
1200 |
CleanupClosePushL(idArray); |
|
1201 |
CheckContactsL(count,idArray); |
|
1202 |
TInt ret = iRfs.Delete(KFileName); |
|
1203 |
// ret = iRfs.Delete(KFileName1); |
|
1204 |
/* if(count != 1) |
|
1205 |
{ |
|
1206 |
return KErrGeneral; |
|
1207 |
}*/ |
|
1208 |
||
1209 |
/* __UHEAP_MARK; |
|
1210 |
RFile writeStream; |
|
1211 |
CleanupClosePushL(writeStream); |
|
1212 |
User::LeaveIfError(writeStream.Create(iRfs,KFileName,EFileWrite)); |
|
1213 |
while(count) |
|
1214 |
{ |
|
1215 |
writeStream.Write(*idArray[--count]); |
|
1216 |
} |
|
1217 |
CleanupStack::PopAndDestroy(&writeStream); |
|
1218 |
__UHEAP_MARKEND; |
|
1219 |
*/ |
|
1220 |
//iBuffer = HBufC8::NewL( 1024 ); |
|
1221 |
//TPtr8 bfrPtr(iBuffer->Des()); |
|
1222 |
// __UHEAP_MARK; |
|
1223 |
//RFileReadStream readStream; |
|
1224 |
// CleanupClosePushL(readStream); |
|
1225 |
// User::LeaveIfError(readStream.Open(iRfs,KFileName,EFileRead)); |
|
1226 |
||
1227 |
//TInt cells = User::CountAllocCells(); |
|
1228 |
__UHEAP_MARK; |
|
1229 |
RFileWriteStream destStream; |
|
1230 |
CleanupClosePushL(destStream); |
|
1231 |
User::LeaveIfError(destStream.Create(iRfs,KFileName,EFileWrite)); |
|
1232 |
iVCardEngine = CVPbkVCardEng::NewL( *iContactManager ); |
|
1233 |
while(count) |
|
1234 |
{ |
|
1235 |
MVPbkContactLinkArray* linkArray = iContactManager->CreateLinksLC(*idArray[--count]); |
|
1236 |
const MVPbkContactLink& link = linkArray->At(0); |
|
1237 |
iOp = iVCardEngine->ExportVCardL( destStream, link, *this ); |
|
1238 |
CActiveScheduler::Start(); |
|
1239 |
destStream.CommitL(); |
|
1240 |
CleanupStack::PopAndDestroy(); |
|
1241 |
} |
|
1242 |
delete iVCardEngine; |
|
1243 |
iVCardEngine = NULL; |
|
1244 |
CleanupStack::PopAndDestroy(&destStream); |
|
1245 |
__UHEAP_MARKEND; |
|
1246 |
CleanupStack::Pop(&idArray); |
|
1247 |
idArray.ResetAndDestroy(); |
|
1248 |
||
1249 |
/* |
|
1250 |
//CleanupStack::PushL(linkArray); |
|
1251 |
cells = User::CountAllocCells(); |
|
1252 |
iVCardEngine = CVPbkVCardEng::NewL( *iContactManager ); |
|
1253 |
||
1254 |
cells = User::CountAllocCells(); |
|
1255 |
RDesWriteStream destStream; |
|
1256 |
CleanupClosePushL(destStream); |
|
1257 |
//User::LeaveIfError(destStream.Create(iRfs,KFileName1,EFileWrite)); |
|
1258 |
destStream.Open(bfrPtr); |
|
1259 |
TInt links = linkArray->Count(); |
|
1260 |
while(links) |
|
1261 |
{ |
|
1262 |
const MVPbkContactLink& link = linkArray->At(--links); |
|
1263 |
iOp = iVCardEngine->ExportVCardL( destStream, link, *this ); |
|
1264 |
CActiveScheduler::Start(); |
|
1265 |
} |
|
1266 |
destStream.CommitL(); |
|
1267 |
CleanupStack::PopAndDestroy(&destStream); |
|
1268 |
||
1269 |
cells = User::CountAllocCells(); |
|
1270 |
delete iVCardEngine; |
|
1271 |
iVCardEngine = NULL; |
|
1272 |
cells = User::CountAllocCells(); |
|
1273 |
||
1274 |
CleanupStack::PopAndDestroy(); |
|
1275 |
cells = User::CountAllocCells(); |
|
1276 |
CleanupStack::PopAndDestroy(&readStream); |
|
1277 |
||
1278 |
// __UHEAP_MARKEND; |
|
1279 |
if(iBuffer) |
|
1280 |
{ |
|
1281 |
RFile file; |
|
1282 |
CleanupClosePushL(file); |
|
1283 |
file.Replace(iRfs,KFileName,EFileWrite); |
|
1284 |
file.Write(0,*iBuffer); |
|
1285 |
CleanupStack::PopAndDestroy(&file); |
|
1286 |
} |
|
1287 |
delete iBuffer; |
|
1288 |
iBuffer = NULL; |
|
1289 |
CleanupStack::Pop(&idArray); |
|
1290 |
idArray.ResetAndDestroy(); |
|
1291 |
/* |
|
1292 |
// Create the buffer to store the contact |
|
1293 |
iBuffer = HBufC8::NewL( 1024 ); |
|
1294 |
TPtr8 bufferPtr( iBuffer->Des() ); |
|
1295 |
iDestStream.Open( bufferPtr ); |
|
1296 |
//export the contact from MVPbkContactLink |
|
1297 |
// __UHEAP_MARK; |
|
1298 |
||
1299 |
CActiveScheduler::Start(); |
|
1300 |
||
1301 |
// __UHEAP_MARKEND; |
|
1302 |
if( !iErr ) |
|
1303 |
{ |
|
1304 |
iDestStream.CommitL(); |
|
1305 |
} |
|
1306 |
||
1307 |
iDestStream.Close(); |
|
1308 |
if(iBuffer) |
|
1309 |
{ |
|
1310 |
RFile file; |
|
1311 |
CleanupClosePushL(file); |
|
1312 |
file.Replace(iRfs,KFileName,EFileWrite); |
|
1313 |
file.Write(0,*iBuffer); |
|
1314 |
CleanupStack::PopAndDestroy(&file); |
|
1315 |
} |
|
1316 |
delete iBuffer; |
|
1317 |
iBuffer = NULL; |
|
1318 |
delete iVCardEngine; |
|
1319 |
iVCardEngine = NULL; |
|
1320 |
CleanupStack::PopAndDestroy();//linkArray |
|
1321 |
//__UHEAP_MARKEND; |
|
1322 |
||
1323 |
CleanupStack::Pop(&idArray); |
|
1324 |
idArray.ResetAndDestroy(); |
|
1325 |
DeleteAllL(); |
|
1326 |
*/ |
|
1327 |
/* __UHEAP_MARK; |
|
1328 |
CContactService* serviceHandle = CContactService::NewL(); |
|
1329 |
CleanupStack::PushL(serviceHandle); |
|
1330 |
iLog->Log( KServiceOpen ); |
|
1331 |
||
1332 |
TFileName exportFile(KFileName); |
|
1333 |
||
1334 |
serviceHandle->ExportVCardL(this,0,exportFile,idArray); |
|
1335 |
iLog->Log(_L("ExportVCardL called\n")); |
|
1336 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1337 |
CActiveScheduler::Start(); |
|
1338 |
||
1339 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
1340 |
iLog->Log( KServiceClose ); |
|
1341 |
__UHEAP_MARKEND; |
|
1342 |
*//* |
|
1343 |
TInt count = 0; |
|
1344 |
RPointerArray<TDesC8> idArray; |
|
1345 |
CleanupClosePushL(idArray); |
|
1346 |
CheckContactsL(count,idArray); |
|
1347 |
if(count != 1) |
|
1348 |
{ |
|
1349 |
return KErrGeneral; |
|
1350 |
}*/ |
|
1351 |
/* CleanupStack::Pop(&idArray); |
|
1352 |
idArray.ResetAndDestroy();*/ |
|
1353 |
return iErr; |
|
1354 |
} |
|
1355 |
// ----------------------------------------------------------------------------- |
|
1356 |
// CContactsUT::?member_function |
|
1357 |
// ?implementation_description |
|
1358 |
// (other items were commented in a header). |
|
1359 |
// ----------------------------------------------------------------------------- |
|
1360 |
// |
|
1361 |
TInt CContactsUT::GetListDeleteContactL( CStifItemParser& aItem ) |
|
1362 |
{ |
|
1363 |
// Print to UI |
|
1364 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1365 |
_LIT( KExample, "In Add" ); |
|
1366 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1367 |
// Print to log file |
|
1368 |
iLog->Log( KExample ); |
|
1369 |
||
1370 |
TInt i = 0; |
|
1371 |
TPtrC string; |
|
1372 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1373 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1374 |
{ |
|
1375 |
TestModuleIf().Printf( i, KContactsTest, |
|
1376 |
KParam, i, &string ); |
|
1377 |
i++; |
|
1378 |
} |
|
1379 |
||
1380 |
iErr = KErrNone; |
|
1381 |
||
1382 |
||
1383 |
/**Getlist using SAPI core class*/ |
|
1384 |
||
1385 |
//__UHEAP_MARK; |
|
1386 |
CContactService* serviceHandle = CContactService::NewL(); |
|
1387 |
CleanupStack::PushL(serviceHandle); |
|
1388 |
iLog->Log( KServiceOpen ); |
|
1389 |
||
1390 |
iOperation = EGetContactDelete; |
|
1391 |
serviceHandle->GetListL(this,0,EContacts); |
|
1392 |
iLog->Log(_L("GetListL called\n")); |
|
1393 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1394 |
CActiveScheduler::Start(); |
|
1395 |
||
1396 |
//iOperation = EGetContact; |
|
1397 |
//iServiceHandle->GetListL(this,0,EContacts,*iBuffer); |
|
1398 |
//CActiveScheduler::Start(); |
|
1399 |
/**Delete using SAPI core class*/ |
|
1400 |
||
1401 |
// __UHEAP_MARK; |
|
1402 |
RPointerArray<TDesC8> idArray; |
|
1403 |
CleanupClosePushL(idArray); |
|
1404 |
idArray.AppendL(iBuffer); |
|
1405 |
||
1406 |
||
1407 |
serviceHandle->DeleteL(this,0,idArray); |
|
1408 |
iLog->Log(_L("DeleteL called\n")); |
|
1409 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1410 |
CActiveScheduler::Start(); |
|
1411 |
||
1412 |
||
1413 |
CleanupStack::PopAndDestroy(&idArray);//singleContactField |
|
1414 |
||
1415 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
1416 |
iLog->Log( KServiceClose ); |
|
1417 |
// __UHEAP_MARKEND; |
|
1418 |
||
1419 |
||
1420 |
||
1421 |
return iErr; |
|
1422 |
} |
|
1423 |
// ----------------------------------------------------------------------------- |
|
1424 |
// CContactsUT::?member_function |
|
1425 |
// ?implementation_description |
|
1426 |
// (other items were commented in a header). |
|
1427 |
// ----------------------------------------------------------------------------- |
|
1428 |
// |
|
1429 |
TInt CContactsUT::AddContactGetListL( CStifItemParser& aItem ) |
|
1430 |
{ |
|
1431 |
// Print to UI |
|
1432 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1433 |
_LIT( KExample, "In Add" ); |
|
1434 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1435 |
// Print to log file |
|
1436 |
iLog->Log( KExample ); |
|
1437 |
||
1438 |
TInt i = 0; |
|
1439 |
TPtrC string; |
|
1440 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1441 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1442 |
{ |
|
1443 |
TestModuleIf().Printf( i, KContactsTest, |
|
1444 |
KParam, i, &string ); |
|
1445 |
i++; |
|
1446 |
} |
|
1447 |
||
1448 |
iErr = KErrNone; |
|
1449 |
||
1450 |
/**Add contact using SAPI Core class*/ |
|
1451 |
||
1452 |
_LIT8(KFirstName,"FirstName"); |
|
1453 |
_LIT(KName,"Kats"); |
|
1454 |
_LIT8(KNumber,"MobilePhoneHome"); |
|
1455 |
_LIT(KPhone,"98789"); |
|
1456 |
||
1457 |
// __UHEAP_MARK; |
|
1458 |
//instantiate service class |
|
1459 |
CContactService* serviceHandle = CContactService::NewL(); |
|
1460 |
CleanupStack::PushL(serviceHandle); |
|
1461 |
iLog->Log( KServiceOpen ); |
|
1462 |
||
1463 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
1464 |
CleanupStack::PushL(singleContact); |
|
1465 |
iLog->Log(_L("single Contact created\n")); |
|
1466 |
||
1467 |
CSingleContactField* nameContactField = CSingleContactField::NewL(); |
|
1468 |
CleanupStack::PushL(nameContactField); |
|
1469 |
iLog->Log(_L("Name Contact Field created \n")); |
|
1470 |
||
1471 |
CSingleContactField* phoneContactField = CSingleContactField::NewL(); |
|
1472 |
CleanupStack::PushL(phoneContactField); |
|
1473 |
iLog->Log(_L("Phone Contact Field created \n")); |
|
1474 |
||
1475 |
nameContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
1476 |
singleContact->AddFieldToContactL(nameContactField); |
|
1477 |
iLog->Log(_L("Name Contact Field added \n")); |
|
1478 |
||
1479 |
phoneContactField->SetFieldParamsL(KNumber,KNullDesC,KPhone); |
|
1480 |
singleContact->AddFieldToContactL(phoneContactField); |
|
1481 |
iLog->Log(_L("Phone Contact Field added \n")); |
|
1482 |
||
1483 |
serviceHandle->AddL(this,0,singleContact,KNullDesC8,KNullDesC); |
|
1484 |
iLog->Log(_L("AddL called\n")); |
|
1485 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1486 |
CActiveScheduler::Start(); |
|
1487 |
||
1488 |
CleanupStack::Pop(phoneContactField);//singleContactField |
|
1489 |
CleanupStack::Pop(nameContactField);//singleContactField |
|
1490 |
CleanupStack::PopAndDestroy(singleContact);//singleContact |
|
1491 |
// CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
1492 |
// iLog->Log( KServiceClose ); |
|
1493 |
// __UHEAP_MARKENDC(1); |
|
1494 |
/**end */ |
|
1495 |
||
1496 |
if(iErr) |
|
1497 |
{ |
|
1498 |
return iErr; |
|
1499 |
} |
|
1500 |
||
1501 |
/**Getlist using SAPI core class*/ |
|
1502 |
||
1503 |
//__UHEAP_MARK; |
|
1504 |
//serviceHandle = CContactService::NewL(); |
|
1505 |
// CleanupStack::PushL(serviceHandle); |
|
1506 |
iLog->Log( KServiceOpen ); |
|
1507 |
||
1508 |
iOperation = EGetContact; |
|
1509 |
serviceHandle->GetListL(this,0,EContacts); |
|
1510 |
iLog->Log(_L("GetListL called\n")); |
|
1511 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1512 |
CActiveScheduler::Start(); |
|
1513 |
||
1514 |
//iOperation = EGetContact; |
|
1515 |
//iServiceHandle->GetListL(this,0,EContacts,*iBuffer); |
|
1516 |
//CActiveScheduler::Start(); |
|
1517 |
||
1518 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
1519 |
iLog->Log( KServiceClose ); |
|
1520 |
// __UHEAP_MARKEND; |
|
1521 |
||
1522 |
if(iErr) |
|
1523 |
{ |
|
1524 |
return iErr; |
|
1525 |
} |
|
1526 |
/**Delete using virtual Phonebook */ |
|
1527 |
||
1528 |
||
1529 |
// Create find operation |
|
1530 |
iOp = iContactManager->MatchPhoneNumberL( |
|
1531 |
KPhone, KPhone().Length(), *this ); |
|
1532 |
CActiveScheduler::Start(); |
|
1533 |
||
1534 |
iErr = KErrGeneral; |
|
1535 |
TInt count(iFindResults->Count()); |
|
1536 |
while(count) |
|
1537 |
{ |
|
1538 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
1539 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count)))); |
|
1540 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
1541 |
CActiveScheduler::Start(); |
|
1542 |
} |
|
1543 |
/**end */ |
|
1544 |
||
1545 |
||
1546 |
return iErr; |
|
1547 |
} |
|
1548 |
// ----------------------------------------------------------------------------- |
|
1549 |
// CContactsUT::?member_function |
|
1550 |
// ?implementation_description |
|
1551 |
// (other items were commented in a header). |
|
1552 |
// ----------------------------------------------------------------------------- |
|
1553 |
// |
|
1554 |
TInt CContactsUT::GetGroupsL( CStifItemParser& aItem ) |
|
1555 |
{ |
|
1556 |
||
1557 |
// Print to UI |
|
1558 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1559 |
_LIT( KExample, "In Add" ); |
|
1560 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1561 |
// Print to log file |
|
1562 |
iLog->Log( KExample ); |
|
1563 |
||
1564 |
TInt i = 0; |
|
1565 |
TPtrC string; |
|
1566 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1567 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1568 |
{ |
|
1569 |
TestModuleIf().Printf( i, KContactsTest, |
|
1570 |
KParam, i, &string ); |
|
1571 |
i++; |
|
1572 |
} |
|
1573 |
||
1574 |
iErr = KErrNone; |
|
1575 |
||
1576 |
/**Add 1 group using virtual phonebook */ |
|
1577 |
||
1578 |
||
1579 |
||
1580 |
iGroup = iStore->CreateNewContactGroupLC(); |
|
1581 |
iGroup->SetGroupLabelL(KGroup1); |
|
1582 |
iOperation = EGroup; |
|
1583 |
iGroup->CommitL(*this); |
|
1584 |
||
1585 |
CActiveScheduler::Start(); |
|
1586 |
CleanupStack::Pop(); |
|
1587 |
||
1588 |
||
1589 |
// __UHEAP_MARK; |
|
1590 |
iServiceHandle = CContactService::NewL(); |
|
1591 |
iLog->Log( KServiceOpen ); |
|
1592 |
||
1593 |
iOperation = EGetGroup; |
|
1594 |
iServiceHandle->GetListL(this,0,EGroups); |
|
1595 |
iLog->Log(_L("GetListL called\n")); |
|
1596 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1597 |
CActiveScheduler::Start(); |
|
1598 |
iOperation = EGetContactDelete; |
|
1599 |
iServiceHandle->GetListL(this, 0, EGroups, *iBuffer); |
|
1600 |
CActiveScheduler::Start(); |
|
1601 |
||
1602 |
delete iServiceHandle;//serviceHandle |
|
1603 |
iServiceHandle = NULL; |
|
1604 |
iLog->Log( KServiceClose ); |
|
1605 |
// __UHEAP_MARKEND; |
|
1606 |
||
1607 |
||
1608 |
||
1609 |
||
1610 |
return iErr; |
|
1611 |
||
1612 |
} |
|
1613 |
||
1614 |
TInt CContactsUT::GetDatabaseL( CStifItemParser& aItem ) |
|
1615 |
{ |
|
1616 |
||
1617 |
// Print to UI |
|
1618 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1619 |
_LIT( KExample, "In Add" ); |
|
1620 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1621 |
// Print to log file |
|
1622 |
iLog->Log( KExample ); |
|
1623 |
||
1624 |
TInt i = 0; |
|
1625 |
TPtrC string; |
|
1626 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1627 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1628 |
{ |
|
1629 |
TestModuleIf().Printf( i, KContactsTest, |
|
1630 |
KParam, i, &string ); |
|
1631 |
i++; |
|
1632 |
} |
|
1633 |
||
1634 |
iErr = KErrNone; |
|
1635 |
||
1636 |
||
1637 |
||
1638 |
// __UHEAP_MARK; |
|
1639 |
iServiceHandle = CContactService::NewL(); |
|
1640 |
iLog->Log( KServiceOpen ); |
|
1641 |
||
1642 |
iOperation = EGetDatabase; |
|
1643 |
||
1644 |
CContactIter* iter = CContactIter::NewL(); |
|
1645 |
iServiceHandle->GetListL(*iter); |
|
1646 |
iLog->Log(_L("GetListL called\n")); |
|
1647 |
TPtrC DbName; |
|
1648 |
iter->NextL(DbName); |
|
1649 |
||
1650 |
while(!DbName.Compare(KNullDesC)) |
|
1651 |
{ |
|
1652 |
iter->NextL(DbName); |
|
1653 |
} |
|
1654 |
||
1655 |
delete iServiceHandle;//serviceHandle |
|
1656 |
iServiceHandle = NULL; |
|
1657 |
iLog->Log( KServiceClose ); |
|
1658 |
// __UHEAP_MARKEND; |
|
1659 |
||
1660 |
||
1661 |
||
1662 |
||
1663 |
return iErr; |
|
1664 |
||
1665 |
} |
|
1666 |
||
1667 |
// ----------------------------------------------------------------------------- |
|
1668 |
// CContactsUT::?member_function |
|
1669 |
// ?implementation_description |
|
1670 |
// (other items were commented in a header). |
|
1671 |
// ----------------------------------------------------------------------------- |
|
1672 |
// |
|
1673 |
TInt CContactsUT::GetContactsL( CStifItemParser& aItem ) |
|
1674 |
{ |
|
1675 |
||
1676 |
// Print to UI |
|
1677 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1678 |
_LIT( KExample, "In Add" ); |
|
1679 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1680 |
// Print to log file |
|
1681 |
iLog->Log( KExample ); |
|
1682 |
||
1683 |
TInt i = 0; |
|
1684 |
TPtrC string; |
|
1685 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1686 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1687 |
{ |
|
1688 |
TestModuleIf().Printf( i, KContactsTest, |
|
1689 |
KParam, i, &string ); |
|
1690 |
i++; |
|
1691 |
} |
|
1692 |
||
1693 |
iErr = KErrNone; |
|
1694 |
||
1695 |
/**Delete using virtual Phonebook */ |
|
1696 |
||
1697 |
_LIT(KPhone,"13579"); |
|
1698 |
// Create find operation |
|
1699 |
iOp = iContactManager->MatchPhoneNumberL( |
|
1700 |
KPhone, KPhone().Length(), *this ); |
|
1701 |
CActiveScheduler::Start(); |
|
1702 |
||
1703 |
iErr = KErrGeneral; |
|
1704 |
TInt count1(iFindResults->Count()); |
|
1705 |
while(count1) |
|
1706 |
{ |
|
1707 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
1708 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count1)))); |
|
1709 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
1710 |
CActiveScheduler::Start(); |
|
1711 |
} |
|
1712 |
/**end */ |
|
1713 |
||
1714 |
/**Add 2 contacts using virtual phonebook*/ |
|
1715 |
||
1716 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
1717 |
CleanupStack::PushL(fieldTypeRefList); |
|
1718 |
||
1719 |
fieldTypeRefList->AppendL( |
|
1720 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
1721 |
fieldTypeRefList->AppendL( |
|
1722 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
1723 |
||
1724 |
// Create first contact |
|
1725 |
iStoreContact = iStore->CreateNewContactLC(); |
|
1726 |
||
1727 |
// Create contact field for contact |
|
1728 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
1729 |
// Set contact field data |
|
1730 |
_LIT(KFirstName,"Tenali"); |
|
1731 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
1732 |
// Add the contact field to contact |
|
1733 |
iStoreContact->AddFieldL( field ); |
|
1734 |
CleanupStack::Pop(); // field |
|
1735 |
||
1736 |
// Create contact field for contact |
|
1737 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
1738 |
// Set contact field data |
|
1739 |
_LIT(KFirstNumber,"13579"); |
|
1740 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
1741 |
// Add the contact field to contact |
|
1742 |
iStoreContact->AddFieldL( field ); |
|
1743 |
CleanupStack::Pop(); // field |
|
1744 |
||
1745 |
// Commit the new created contact to contact store |
|
1746 |
iStoreContact->CommitL( *this ); |
|
1747 |
CActiveScheduler::Start(); |
|
1748 |
CleanupStack::Pop(); // iStoreContact |
|
1749 |
||
1750 |
||
1751 |
// Create second contact |
|
1752 |
iStoreContact = iStore->CreateNewContactLC(); |
|
1753 |
||
1754 |
// Create contact field for contact |
|
1755 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
1756 |
// Set contact field data |
|
1757 |
_LIT(KSecondName,"Birbal"); |
|
1758 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
1759 |
// Add the contact field to contact |
|
1760 |
iStoreContact->AddFieldL( field ); |
|
1761 |
CleanupStack::Pop(); // field |
|
1762 |
||
1763 |
// Create contact field for contact |
|
1764 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
1765 |
// Set contact field data |
|
1766 |
_LIT(KSecondNumber,"13579"); |
|
1767 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
1768 |
// Add the contact field to contact |
|
1769 |
iStoreContact->AddFieldL( field ); |
|
1770 |
CleanupStack::Pop(); // field |
|
1771 |
||
1772 |
// Commit the new created contact to contact store |
|
1773 |
iStoreContact->CommitL( *this ); |
|
1774 |
CActiveScheduler::Start(); |
|
1775 |
CleanupStack::Pop(); // iStoreContact |
|
1776 |
||
1777 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
1778 |
/**end*/ |
|
1779 |
__UHEAP_MARK; |
|
1780 |
iServiceHandle = CContactService::NewL(); |
|
1781 |
iLog->Log( KServiceOpen ); |
|
1782 |
||
1783 |
iOperation = EGetContact; |
|
1784 |
iServiceHandle->GetListL(this,0,EContacts); |
|
1785 |
iLog->Log(_L("GetListL called\n")); |
|
1786 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1787 |
CActiveScheduler::Start(); |
|
1788 |
||
1789 |
delete iServiceHandle;//serviceHandle |
|
1790 |
iServiceHandle = NULL; |
|
1791 |
iLog->Log( KServiceClose ); |
|
1792 |
__UHEAP_MARKEND; |
|
1793 |
return iErr; |
|
1794 |
||
1795 |
} |
|
1796 |
||
1797 |
||
1798 |
TInt CContactsUT::GetContactsAscOrderL( CStifItemParser& aItem ) |
|
1799 |
{ |
|
1800 |
||
1801 |
// Print to UI |
|
1802 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1803 |
_LIT( KExample, "In Add" ); |
|
1804 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1805 |
// Print to log file |
|
1806 |
iLog->Log( KExample ); |
|
1807 |
||
1808 |
TInt i = 0; |
|
1809 |
TPtrC string; |
|
1810 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1811 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1812 |
{ |
|
1813 |
TestModuleIf().Printf( i, KContactsTest, |
|
1814 |
KParam, i, &string ); |
|
1815 |
i++; |
|
1816 |
} |
|
1817 |
||
1818 |
iErr = KErrNone; |
|
1819 |
||
1820 |
||
1821 |
_LIT(KPhone,"13579"); |
|
1822 |
// Create find operation |
|
1823 |
iOp = iContactManager->MatchPhoneNumberL( |
|
1824 |
KPhone, KPhone().Length(), *this ); |
|
1825 |
CActiveScheduler::Start(); |
|
1826 |
||
1827 |
iErr = KErrGeneral; |
|
1828 |
TInt count1(iFindResults->Count()); |
|
1829 |
while(count1) |
|
1830 |
{ |
|
1831 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
1832 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count1)))); |
|
1833 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
1834 |
CActiveScheduler::Start(); |
|
1835 |
} |
|
1836 |
/*end */ |
|
1837 |
||
1838 |
/**Add 2 contact using virtual phonebook*/ |
|
1839 |
||
1840 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
1841 |
CleanupStack::PushL(fieldTypeRefList); |
|
1842 |
||
1843 |
fieldTypeRefList->AppendL( |
|
1844 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
1845 |
fieldTypeRefList->AppendL( |
|
1846 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
1847 |
||
1848 |
// Create first contact |
|
1849 |
iStoreContact = iStore->CreateNewContactLC(); |
|
1850 |
||
1851 |
// Create contact field for contact |
|
1852 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
1853 |
// Set contact field data |
|
1854 |
_LIT(KFirstName,"Tenali"); |
|
1855 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
1856 |
// Add the contact field to contact |
|
1857 |
iStoreContact->AddFieldL( field ); |
|
1858 |
CleanupStack::Pop(); // field |
|
1859 |
||
1860 |
// Create contact field for contact |
|
1861 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
1862 |
// Set contact field data |
|
1863 |
_LIT(KFirstNumber,"13579"); |
|
1864 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
1865 |
// Add the contact field to contact |
|
1866 |
iStoreContact->AddFieldL( field ); |
|
1867 |
CleanupStack::Pop(); // field |
|
1868 |
||
1869 |
// Commit the new created contact to contact store |
|
1870 |
iStoreContact->CommitL( *this ); |
|
1871 |
CActiveScheduler::Start(); |
|
1872 |
CleanupStack::Pop(); // iStoreContact |
|
1873 |
||
1874 |
||
1875 |
// Create second contact |
|
1876 |
iStoreContact = iStore->CreateNewContactLC(); |
|
1877 |
||
1878 |
// Create contact field for contact |
|
1879 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
1880 |
// Set contact field data |
|
1881 |
_LIT(KSecondName,"Birbal"); |
|
1882 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
1883 |
// Add the contact field to contact |
|
1884 |
iStoreContact->AddFieldL( field ); |
|
1885 |
CleanupStack::Pop(); // field |
|
1886 |
||
1887 |
// Create contact field for contact |
|
1888 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
1889 |
// Set contact field data |
|
1890 |
_LIT(KSecondNumber,"13579"); |
|
1891 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
1892 |
// Add the contact field to contact |
|
1893 |
iStoreContact->AddFieldL( field ); |
|
1894 |
CleanupStack::Pop(); // field |
|
1895 |
||
1896 |
// Commit the new created contact to contact store |
|
1897 |
iStoreContact->CommitL( *this ); |
|
1898 |
CActiveScheduler::Start(); |
|
1899 |
CleanupStack::Pop(); // iStoreContact |
|
1900 |
||
1901 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
1902 |
/**end*/ |
|
1903 |
||
1904 |
||
1905 |
||
1906 |
||
1907 |
||
1908 |
/**GetList using SAPI Core class */ |
|
1909 |
// __UHEAP_MARK; |
|
1910 |
iServiceHandle = CContactService::NewL(); |
|
1911 |
iLog->Log( KServiceOpen ); |
|
1912 |
||
1913 |
iOperation = EAscContact; |
|
1914 |
iServiceHandle->GetListL(this,0,EContacts,KNullDesC8,_L(""),NULL,EAsc); |
|
1915 |
iLog->Log(_L("GetListL called\n")); |
|
1916 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
1917 |
CActiveScheduler::Start(); |
|
1918 |
||
1919 |
delete iServiceHandle;//serviceHandle |
|
1920 |
iServiceHandle = NULL; |
|
1921 |
iLog->Log( KServiceClose ); |
|
1922 |
||
1923 |
||
1924 |
return iErr; |
|
1925 |
||
1926 |
} |
|
1927 |
||
1928 |
||
1929 |
||
1930 |
TInt CContactsUT::GetContactsDscOrderL( CStifItemParser& aItem ) |
|
1931 |
{ |
|
1932 |
||
1933 |
// Print to UI |
|
1934 |
_LIT( KContactsTest, "ContactsUT" ); |
|
1935 |
_LIT( KExample, "In Add" ); |
|
1936 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
1937 |
// Print to log file |
|
1938 |
iLog->Log( KExample ); |
|
1939 |
||
1940 |
TInt i = 0; |
|
1941 |
TPtrC string; |
|
1942 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1943 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1944 |
{ |
|
1945 |
TestModuleIf().Printf( i, KContactsTest, |
|
1946 |
KParam, i, &string ); |
|
1947 |
i++; |
|
1948 |
} |
|
1949 |
||
1950 |
iErr = KErrNone; |
|
1951 |
||
1952 |
/**Delete using virtual Phonebook */ |
|
1953 |
||
1954 |
_LIT(KPhone,"13579"); |
|
1955 |
// Create find operation |
|
1956 |
iOp = iContactManager->MatchPhoneNumberL( |
|
1957 |
KPhone, KPhone().Length(), *this ); |
|
1958 |
CActiveScheduler::Start(); |
|
1959 |
||
1960 |
iErr = KErrGeneral; |
|
1961 |
TInt count1(iFindResults->Count()); |
|
1962 |
while(count1) |
|
1963 |
{ |
|
1964 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
1965 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count1)))); |
|
1966 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
1967 |
CActiveScheduler::Start(); |
|
1968 |
} |
|
1969 |
/**end */ |
|
1970 |
||
1971 |
/**Add 2 contact using virtual phonebook*/ |
|
1972 |
||
1973 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
1974 |
CleanupStack::PushL(fieldTypeRefList); |
|
1975 |
||
1976 |
fieldTypeRefList->AppendL( |
|
1977 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
1978 |
fieldTypeRefList->AppendL( |
|
1979 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
1980 |
||
1981 |
// Create first contact |
|
1982 |
iStoreContact = iStore->CreateNewContactLC(); |
|
1983 |
||
1984 |
// Create contact field for contact |
|
1985 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
1986 |
// Set contact field data |
|
1987 |
_LIT(KFirstName,"Tenali"); |
|
1988 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
1989 |
// Add the contact field to contact |
|
1990 |
iStoreContact->AddFieldL( field ); |
|
1991 |
CleanupStack::Pop(); // field |
|
1992 |
||
1993 |
// Create contact field for contact |
|
1994 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
1995 |
// Set contact field data |
|
1996 |
_LIT(KFirstNumber,"13579"); |
|
1997 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
1998 |
// Add the contact field to contact |
|
1999 |
iStoreContact->AddFieldL( field ); |
|
2000 |
CleanupStack::Pop(); // field |
|
2001 |
||
2002 |
// Commit the new created contact to contact store |
|
2003 |
iStoreContact->CommitL( *this ); |
|
2004 |
CActiveScheduler::Start(); |
|
2005 |
CleanupStack::Pop(); // iStoreContact |
|
2006 |
||
2007 |
||
2008 |
// Create second contact |
|
2009 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2010 |
||
2011 |
// Create contact field for contact |
|
2012 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2013 |
// Set contact field data |
|
2014 |
_LIT(KSecondName,"Birbal"); |
|
2015 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
2016 |
// Add the contact field to contact |
|
2017 |
iStoreContact->AddFieldL( field ); |
|
2018 |
CleanupStack::Pop(); // field |
|
2019 |
||
2020 |
// Create contact field for contact |
|
2021 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2022 |
// Set contact field data |
|
2023 |
_LIT(KSecondNumber,"13579"); |
|
2024 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
2025 |
// Add the contact field to contact |
|
2026 |
iStoreContact->AddFieldL( field ); |
|
2027 |
CleanupStack::Pop(); // field |
|
2028 |
||
2029 |
// Commit the new created contact to contact store |
|
2030 |
iStoreContact->CommitL( *this ); |
|
2031 |
CActiveScheduler::Start(); |
|
2032 |
CleanupStack::Pop(); // iStoreContact |
|
2033 |
||
2034 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
2035 |
/**end*/ |
|
2036 |
||
2037 |
||
2038 |
||
2039 |
||
2040 |
||
2041 |
/**GetList using SAPI Core class */ |
|
2042 |
// __UHEAP_MARK; |
|
2043 |
iServiceHandle = CContactService::NewL(); |
|
2044 |
iLog->Log( KServiceOpen ); |
|
2045 |
||
2046 |
iOperation = EDscContact; |
|
2047 |
iServiceHandle->GetListL(this,0,EContacts,KNullDesC8,_L(""),NULL,EDesc); |
|
2048 |
iLog->Log(_L("GetListL called\n")); |
|
2049 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2050 |
CActiveScheduler::Start(); |
|
2051 |
||
2052 |
||
2053 |
||
2054 |
delete iServiceHandle;//serviceHandle |
|
2055 |
iServiceHandle = NULL; |
|
2056 |
iLog->Log( KServiceClose ); |
|
2057 |
||
2058 |
||
2059 |
return iErr; |
|
2060 |
||
2061 |
} |
|
2062 |
||
2063 |
TInt CContactsUT::GetSearchContactL( CStifItemParser& aItem ) |
|
2064 |
{ |
|
2065 |
||
2066 |
// Print to UI |
|
2067 |
_LIT( KContactsTest, "ContactsUT" ); |
|
2068 |
_LIT( KExample, "In Add" ); |
|
2069 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2070 |
// Print to log file |
|
2071 |
iLog->Log( KExample ); |
|
2072 |
||
2073 |
TInt i = 0; |
|
2074 |
TPtrC string; |
|
2075 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2076 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2077 |
{ |
|
2078 |
TestModuleIf().Printf( i, KContactsTest, |
|
2079 |
KParam, i, &string ); |
|
2080 |
i++; |
|
2081 |
} |
|
2082 |
||
2083 |
iErr = KErrNone; |
|
2084 |
||
2085 |
||
2086 |
/**Delete using virtual Phonebook */ |
|
2087 |
||
2088 |
_LIT(KPhone,"13579"); |
|
2089 |
// Create find operation |
|
2090 |
iOp = iContactManager->MatchPhoneNumberL( |
|
2091 |
KPhone, KPhone().Length(), *this ); |
|
2092 |
CActiveScheduler::Start(); |
|
2093 |
||
2094 |
iErr = KErrGeneral; |
|
2095 |
TInt count1(iFindResults->Count()); |
|
2096 |
while(count1) |
|
2097 |
{ |
|
2098 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
2099 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count1)))); |
|
2100 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
2101 |
CActiveScheduler::Start(); |
|
2102 |
} |
|
2103 |
/**end */ |
|
2104 |
||
2105 |
/**Add 2 contact using virtual phonebook*/ |
|
2106 |
||
2107 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
2108 |
CleanupStack::PushL(fieldTypeRefList); |
|
2109 |
||
2110 |
fieldTypeRefList->AppendL( |
|
2111 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
2112 |
fieldTypeRefList->AppendL( |
|
2113 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
2114 |
||
2115 |
// Create first contact |
|
2116 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2117 |
||
2118 |
// Create contact field for contact |
|
2119 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2120 |
// Set contact field data |
|
2121 |
_LIT(KFirstName,"Tenali"); |
|
2122 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
2123 |
// Add the contact field to contact |
|
2124 |
iStoreContact->AddFieldL( field ); |
|
2125 |
CleanupStack::Pop(); // field |
|
2126 |
||
2127 |
// Create contact field for contact |
|
2128 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2129 |
// Set contact field data |
|
2130 |
_LIT(KFirstNumber,"13579"); |
|
2131 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
2132 |
// Add the contact field to contact |
|
2133 |
iStoreContact->AddFieldL( field ); |
|
2134 |
CleanupStack::Pop(); // field |
|
2135 |
||
2136 |
// Commit the new created contact to contact store |
|
2137 |
iStoreContact->CommitL( *this ); |
|
2138 |
CActiveScheduler::Start(); |
|
2139 |
CleanupStack::Pop(); // iStoreContact |
|
2140 |
||
2141 |
||
2142 |
// Create second contact |
|
2143 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2144 |
||
2145 |
// Create contact field for contact |
|
2146 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2147 |
// Set contact field data |
|
2148 |
_LIT(KSecondName,"Birbal"); |
|
2149 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
2150 |
// Add the contact field to contact |
|
2151 |
iStoreContact->AddFieldL( field ); |
|
2152 |
CleanupStack::Pop(); // field |
|
2153 |
||
2154 |
// Create contact field for contact |
|
2155 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2156 |
// Set contact field data |
|
2157 |
_LIT(KSecondNumber,"13579"); |
|
2158 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
2159 |
// Add the contact field to contact |
|
2160 |
iStoreContact->AddFieldL( field ); |
|
2161 |
CleanupStack::Pop(); // field |
|
2162 |
||
2163 |
// Commit the new created contact to contact store |
|
2164 |
iStoreContact->CommitL( *this ); |
|
2165 |
CActiveScheduler::Start(); |
|
2166 |
CleanupStack::Pop(); // iStoreContact |
|
2167 |
||
2168 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
2169 |
/**end*/ |
|
2170 |
||
2171 |
||
2172 |
||
2173 |
||
2174 |
||
2175 |
/**GetList using SAPI Core class */ |
|
2176 |
// __UHEAP_MARK; |
|
2177 |
iServiceHandle = CContactService::NewL(); |
|
2178 |
iLog->Log( KServiceOpen ); |
|
2179 |
||
2180 |
iOperation = ESearchContact; |
|
2181 |
iServiceHandle->GetListL(this,0,EContacts,KNullDesC8,_L(""),NULL,EAsc); |
|
2182 |
iLog->Log(_L("GetListL called\n")); |
|
2183 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2184 |
CActiveScheduler::Start(); |
|
2185 |
||
2186 |
||
2187 |
delete iServiceHandle;//serviceHandle |
|
2188 |
iServiceHandle = NULL; |
|
2189 |
iLog->Log( KServiceClose ); |
|
2190 |
||
2191 |
||
2192 |
return iErr; |
|
2193 |
||
2194 |
} |
|
2195 |
TInt CContactsUT::GetListConactIdL( CStifItemParser& aItem ) |
|
2196 |
{ |
|
2197 |
// Print to UI |
|
2198 |
_LIT( KContactsTest, "ContactsUT" ); |
|
2199 |
_LIT( KExample, "In Add" ); |
|
2200 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2201 |
// Print to log file |
|
2202 |
iLog->Log( KExample ); |
|
2203 |
||
2204 |
TInt i = 0; |
|
2205 |
TPtrC string; |
|
2206 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2207 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2208 |
{ |
|
2209 |
TestModuleIf().Printf( i, KContactsTest, |
|
2210 |
KParam, i, &string ); |
|
2211 |
i++; |
|
2212 |
} |
|
2213 |
||
2214 |
iErr = KErrNone; |
|
2215 |
||
2216 |
||
2217 |
/**Delete using virtual Phonebook */ |
|
2218 |
||
2219 |
_LIT(KPhone,"13579"); |
|
2220 |
// Create find operation |
|
2221 |
iOp = iContactManager->MatchPhoneNumberL( |
|
2222 |
KPhone, KPhone().Length(), *this ); |
|
2223 |
CActiveScheduler::Start(); |
|
2224 |
||
2225 |
iErr = KErrGeneral; |
|
2226 |
TInt count1(iFindResults->Count()); |
|
2227 |
while(count1) |
|
2228 |
{ |
|
2229 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
2230 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count1)))); |
|
2231 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
2232 |
CActiveScheduler::Start(); |
|
2233 |
} |
|
2234 |
/**end */ |
|
2235 |
||
2236 |
/**Add 2 contact using virtual phonebook*/ |
|
2237 |
||
2238 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
2239 |
CleanupStack::PushL(fieldTypeRefList); |
|
2240 |
||
2241 |
fieldTypeRefList->AppendL( |
|
2242 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
2243 |
fieldTypeRefList->AppendL( |
|
2244 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
2245 |
||
2246 |
// Create first contact |
|
2247 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2248 |
||
2249 |
// Create contact field for contact |
|
2250 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2251 |
// Set contact field data |
|
2252 |
_LIT(KFirstName,"Tenali"); |
|
2253 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
2254 |
// Add the contact field to contact |
|
2255 |
iStoreContact->AddFieldL( field ); |
|
2256 |
CleanupStack::Pop(); // field |
|
2257 |
||
2258 |
// Create contact field for contact |
|
2259 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2260 |
// Set contact field data |
|
2261 |
_LIT(KFirstNumber,"13579"); |
|
2262 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
2263 |
// Add the contact field to contact |
|
2264 |
iStoreContact->AddFieldL( field ); |
|
2265 |
CleanupStack::Pop(); // field |
|
2266 |
||
2267 |
// Commit the new created contact to contact store |
|
2268 |
iStoreContact->CommitL( *this ); |
|
2269 |
CActiveScheduler::Start(); |
|
2270 |
CleanupStack::Pop(); // iStoreContact |
|
2271 |
||
2272 |
||
2273 |
// Create second contact |
|
2274 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2275 |
||
2276 |
// Create contact field for contact |
|
2277 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2278 |
// Set contact field data |
|
2279 |
_LIT(KSecondName,"Birbal"); |
|
2280 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
2281 |
// Add the contact field to contact |
|
2282 |
iStoreContact->AddFieldL( field ); |
|
2283 |
CleanupStack::Pop(); // field |
|
2284 |
||
2285 |
// Create contact field for contact |
|
2286 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2287 |
// Set contact field data |
|
2288 |
_LIT(KSecondNumber,"13579"); |
|
2289 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
2290 |
// Add the contact field to contact |
|
2291 |
iStoreContact->AddFieldL( field ); |
|
2292 |
CleanupStack::Pop(); // field |
|
2293 |
||
2294 |
// Commit the new created contact to contact store |
|
2295 |
iStoreContact->CommitL( *this ); |
|
2296 |
CActiveScheduler::Start(); |
|
2297 |
CleanupStack::Pop(); // iStoreContact |
|
2298 |
||
2299 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
2300 |
/**end*/ |
|
2301 |
||
2302 |
||
2303 |
||
2304 |
||
2305 |
||
2306 |
/**GetList using SAPI Core class */ |
|
2307 |
// __UHEAP_MARK; |
|
2308 |
iServiceHandle = CContactService::NewL(); |
|
2309 |
iLog->Log( KServiceOpen ); |
|
2310 |
||
2311 |
iOperation = EContactId; |
|
2312 |
iServiceHandle->GetListL(this,0,EContacts); |
|
2313 |
iLog->Log(_L("GetListL called\n")); |
|
2314 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2315 |
CActiveScheduler::Start(); |
|
2316 |
||
2317 |
||
2318 |
delete iServiceHandle;//serviceHandle |
|
2319 |
iServiceHandle = NULL; |
|
2320 |
iLog->Log( KServiceClose ); |
|
2321 |
||
2322 |
||
2323 |
return iErr; |
|
2324 |
||
2325 |
} |
|
2326 |
||
2327 |
// ----------------------------------------------------------------------------- |
|
2328 |
// CContactsUT::?member_function |
|
2329 |
// ?implementation_description |
|
2330 |
// (other items were commented in a header). |
|
2331 |
// ----------------------------------------------------------------------------- |
|
2332 |
// |
|
2333 |
TInt CContactsUT::AddL( CStifItemParser& aItem ) |
|
2334 |
{ |
|
2335 |
||
2336 |
// Print to UI |
|
2337 |
_LIT( KContactsTest, "ContactsUT" ); |
|
2338 |
_LIT( KExample, "In Add" ); |
|
2339 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2340 |
// Print to log file |
|
2341 |
iLog->Log( KExample ); |
|
2342 |
||
2343 |
TInt i = 0; |
|
2344 |
TPtrC string; |
|
2345 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2346 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2347 |
{ |
|
2348 |
TestModuleIf().Printf( i, KContactsTest, |
|
2349 |
KParam, i, &string ); |
|
2350 |
i++; |
|
2351 |
} |
|
2352 |
||
2353 |
iErr = KErrNone; |
|
2354 |
||
2355 |
/**Add contact using SAPI Core class*/ |
|
2356 |
||
2357 |
_LIT8(KFirstName,"FirstName"); |
|
2358 |
_LIT(KName,"Sikandar"); |
|
2359 |
_LIT8(KNumber,"MobilePhoneHome"); |
|
2360 |
_LIT(KPhone,"123456"); |
|
2361 |
||
2362 |
// __UHEAP_MARK; |
|
2363 |
//instantiate service class |
|
2364 |
CContactService* serviceHandle = CContactService::NewL(); |
|
2365 |
CleanupStack::PushL(serviceHandle); |
|
2366 |
iLog->Log( KServiceOpen ); |
|
2367 |
||
2368 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
2369 |
CleanupStack::PushL(singleContact); |
|
2370 |
iLog->Log(_L("single Contact created\n")); |
|
2371 |
||
2372 |
CSingleContactField* nameContactField = CSingleContactField::NewL(); |
|
2373 |
CleanupStack::PushL(nameContactField); |
|
2374 |
iLog->Log(_L("Name Contact Field created \n")); |
|
2375 |
||
2376 |
CSingleContactField* phoneContactField = CSingleContactField::NewL(); |
|
2377 |
CleanupStack::PushL(phoneContactField); |
|
2378 |
iLog->Log(_L("Phone Contact Field created \n")); |
|
2379 |
||
2380 |
nameContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
2381 |
singleContact->AddFieldToContactL(nameContactField); |
|
2382 |
iLog->Log(_L("Name Contact Field added \n")); |
|
2383 |
||
2384 |
phoneContactField->SetFieldParamsL(KNumber,KNullDesC,KPhone); |
|
2385 |
singleContact->AddFieldToContactL(phoneContactField); |
|
2386 |
iLog->Log(_L("Phone Contact Field added \n")); |
|
2387 |
||
2388 |
serviceHandle->AddL(this,0,singleContact,KNullDesC8,KNullDesC); |
|
2389 |
iLog->Log(_L("AddL called\n")); |
|
2390 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2391 |
CActiveScheduler::Start(); |
|
2392 |
||
2393 |
CleanupStack::Pop(phoneContactField);//singleContactField |
|
2394 |
CleanupStack::Pop(nameContactField);//singleContactField |
|
2395 |
CleanupStack::PopAndDestroy(singleContact);//singleContact |
|
2396 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
2397 |
iLog->Log( KServiceClose ); |
|
2398 |
// __UHEAP_MARKEND; |
|
2399 |
/**end */ |
|
2400 |
||
2401 |
if(iErr) |
|
2402 |
{ |
|
2403 |
return iErr; |
|
2404 |
} |
|
2405 |
||
2406 |
/**Delete using virtual Phonebook */ |
|
2407 |
/* |
|
2408 |
||
2409 |
// Create find operation |
|
2410 |
iOp = iContactManager->MatchPhoneNumberL( |
|
2411 |
KPhone, KPhone().Length(), *this ); |
|
2412 |
CActiveScheduler::Start(); |
|
2413 |
||
2414 |
iErr = KErrGeneral; |
|
2415 |
TInt count(iFindResults->Count()); |
|
2416 |
while(count) |
|
2417 |
{ |
|
2418 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
2419 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count)))); |
|
2420 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
2421 |
CActiveScheduler::Start(); |
|
2422 |
} |
|
2423 |
/**end */ |
|
2424 |
||
2425 |
||
2426 |
return iErr; |
|
2427 |
||
2428 |
} |
|
2429 |
||
2430 |
||
2431 |
// ----------------------------------------------------------------------------- |
|
2432 |
// CContactsUT::?member_function |
|
2433 |
// ?implementation_description |
|
2434 |
// (other items were commented in a header). |
|
2435 |
// ----------------------------------------------------------------------------- |
|
2436 |
// |
|
2437 |
TInt CContactsUT::AddInvalidFieldL( CStifItemParser& aItem ) |
|
2438 |
{ |
|
2439 |
||
2440 |
// Print to UI |
|
2441 |
_LIT( KContactsTest, "ContactsUT" ); |
|
2442 |
_LIT( KExample, "In Add" ); |
|
2443 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2444 |
// Print to log file |
|
2445 |
iLog->Log( KExample ); |
|
2446 |
||
2447 |
TInt i = 0; |
|
2448 |
TPtrC string; |
|
2449 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2450 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2451 |
{ |
|
2452 |
TestModuleIf().Printf( i, KContactsTest, |
|
2453 |
KParam, i, &string ); |
|
2454 |
i++; |
|
2455 |
} |
|
2456 |
||
2457 |
iErr = KErrNone; |
|
2458 |
||
2459 |
/**Add contact using SAPI Core class*/ |
|
2460 |
||
2461 |
_LIT8(KFirstName,"FistName"); //invalid field |
|
2462 |
_LIT(KName,"Sikandar"); |
|
2463 |
_LIT8(KNumber,"MobilePhoneHome"); |
|
2464 |
_LIT(KPhone,"123456"); |
|
2465 |
||
2466 |
// __UHEAP_MARK; |
|
2467 |
//instantiate service class |
|
2468 |
CContactService* serviceHandle = CContactService::NewL(); |
|
2469 |
CleanupStack::PushL(serviceHandle); |
|
2470 |
iLog->Log( KServiceOpen ); |
|
2471 |
||
2472 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
2473 |
CleanupStack::PushL(singleContact); |
|
2474 |
iLog->Log(_L("single Contact created\n")); |
|
2475 |
||
2476 |
CSingleContactField* nameContactField = CSingleContactField::NewL(); |
|
2477 |
CleanupStack::PushL(nameContactField); |
|
2478 |
iLog->Log(_L("Name Contact Field created \n")); |
|
2479 |
||
2480 |
CSingleContactField* phoneContactField = CSingleContactField::NewL(); |
|
2481 |
CleanupStack::PushL(phoneContactField); |
|
2482 |
iLog->Log(_L("Phone Contact Field created \n")); |
|
2483 |
||
2484 |
nameContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
2485 |
singleContact->AddFieldToContactL(nameContactField); |
|
2486 |
iLog->Log(_L("Name Contact Field added \n")); |
|
2487 |
||
2488 |
phoneContactField->SetFieldParamsL(KNumber,KNullDesC,KPhone); |
|
2489 |
singleContact->AddFieldToContactL(phoneContactField); |
|
2490 |
iLog->Log(_L("Phone Contact Field added \n")); |
|
2491 |
||
2492 |
serviceHandle->AddL(this,0,singleContact,KNullDesC8,KNullDesC); |
|
2493 |
iLog->Log(_L("AddL called\n")); |
|
2494 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2495 |
CActiveScheduler::Start(); |
|
2496 |
||
2497 |
CleanupStack::Pop(phoneContactField);//singleContactField |
|
2498 |
CleanupStack::Pop(nameContactField);//singleContactField |
|
2499 |
CleanupStack::PopAndDestroy(singleContact);//singleContact |
|
2500 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
2501 |
iLog->Log( KServiceClose ); |
|
2502 |
// __UHEAP_MARKEND; |
|
2503 |
/**end */ |
|
2504 |
||
2505 |
if( KInvalidKey == iErr ) |
|
2506 |
{ |
|
2507 |
return KErrNone; |
|
2508 |
} |
|
2509 |
||
2510 |
||
2511 |
return iErr; |
|
2512 |
||
2513 |
} |
|
2514 |
||
2515 |
||
2516 |
||
2517 |
// ----------------------------------------------------------------------------- |
|
2518 |
// CContactsUT::?member_function |
|
2519 |
// ?implementation_description |
|
2520 |
// (other items were commented in a header). |
|
2521 |
// ----------------------------------------------------------------------------- |
|
2522 |
// |
|
2523 |
TInt CContactsUT::AddMultiplePhoneNumbersContactL( CStifItemParser& aItem ) |
|
2524 |
{ |
|
2525 |
||
2526 |
// Print to UI |
|
2527 |
_LIT( KContactsTest, "ContactsUT" ); |
|
2528 |
_LIT( KExample, "In Add" ); |
|
2529 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2530 |
// Print to log file |
|
2531 |
iLog->Log( KExample ); |
|
2532 |
||
2533 |
TInt i = 0; |
|
2534 |
TPtrC string; |
|
2535 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2536 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2537 |
{ |
|
2538 |
TestModuleIf().Printf( i, KContactsTest, |
|
2539 |
KParam, i, &string ); |
|
2540 |
i++; |
|
2541 |
} |
|
2542 |
||
2543 |
iErr = KErrNone; |
|
2544 |
||
2545 |
/**Add contact using SAPI Core class*/ |
|
2546 |
||
2547 |
_LIT8(KFirstName,"FirstName"); |
|
2548 |
_LIT(KName,"Sikandar"); |
|
2549 |
_LIT8(KNumber,"MobilePhoneHome"); |
|
2550 |
_LIT(KPhone,"123456"); |
|
2551 |
_LIT8(KNumber2,"MobilePhoneWork"); |
|
2552 |
_LIT(KPhone2,"654321"); |
|
2553 |
||
2554 |
// __UHEAP_MARK; |
|
2555 |
//instantiate service class |
|
2556 |
CContactService* serviceHandle = CContactService::NewL(); |
|
2557 |
CleanupStack::PushL(serviceHandle); |
|
2558 |
iLog->Log( KServiceOpen ); |
|
2559 |
||
2560 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
2561 |
CleanupStack::PushL(singleContact); |
|
2562 |
iLog->Log(_L("single Contact created\n")); |
|
2563 |
||
2564 |
CSingleContactField* nameContactField = CSingleContactField::NewL(); |
|
2565 |
CleanupStack::PushL(nameContactField); |
|
2566 |
iLog->Log(_L("Name Contact Field created \n")); |
|
2567 |
||
2568 |
CSingleContactField* phoneContactField = CSingleContactField::NewL(); |
|
2569 |
CleanupStack::PushL(phoneContactField); |
|
2570 |
iLog->Log(_L("Phone Contact Field created \n")); |
|
2571 |
||
2572 |
CSingleContactField* workPhoneContactField = CSingleContactField::NewL(); |
|
2573 |
CleanupStack::PushL(workPhoneContactField); |
|
2574 |
iLog->Log(_L("Work Phone Contact Field created \n")); |
|
2575 |
||
2576 |
nameContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
2577 |
singleContact->AddFieldToContactL(nameContactField); |
|
2578 |
iLog->Log(_L("Name Contact Field added \n")); |
|
2579 |
||
2580 |
phoneContactField->SetFieldParamsL(KNumber,KNullDesC,KPhone); |
|
2581 |
singleContact->AddFieldToContactL(phoneContactField); |
|
2582 |
iLog->Log(_L("Phone Contact Field added \n")); |
|
2583 |
||
2584 |
workPhoneContactField->SetFieldParamsL(KNumber2,KNullDesC,KPhone2); |
|
2585 |
singleContact->AddFieldToContactL(workPhoneContactField); |
|
2586 |
iLog->Log(_L("Phone Contact Field added \n")); |
|
2587 |
||
2588 |
serviceHandle->AddL(this,0,singleContact,KNullDesC8,KNullDesC); |
|
2589 |
iLog->Log(_L("AddL called\n")); |
|
2590 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2591 |
CActiveScheduler::Start(); |
|
2592 |
||
2593 |
CleanupStack::Pop(workPhoneContactField);//singleContactField |
|
2594 |
CleanupStack::Pop(phoneContactField);//singleContactField |
|
2595 |
CleanupStack::Pop(nameContactField);//singleContactField |
|
2596 |
CleanupStack::PopAndDestroy(singleContact);//singleContact |
|
2597 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
2598 |
iLog->Log( KServiceClose ); |
|
2599 |
// __UHEAP_MARKEND; |
|
2600 |
/**end */ |
|
2601 |
||
2602 |
if(iErr) |
|
2603 |
{ |
|
2604 |
return iErr; |
|
2605 |
} |
|
2606 |
||
2607 |
/**Delete using virtual Phonebook */ |
|
2608 |
/* |
|
2609 |
||
2610 |
// Create find operation |
|
2611 |
iOp = iContactManager->MatchPhoneNumberL( |
|
2612 |
KPhone, KPhone().Length(), *this ); |
|
2613 |
CActiveScheduler::Start(); |
|
2614 |
||
2615 |
iErr = KErrGeneral; |
|
2616 |
TInt count(iFindResults->Count()); |
|
2617 |
while(count) |
|
2618 |
{ |
|
2619 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
2620 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count)))); |
|
2621 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
2622 |
CActiveScheduler::Start(); |
|
2623 |
} |
|
2624 |
/**end */ |
|
2625 |
||
2626 |
||
2627 |
return iErr; |
|
2628 |
||
2629 |
} |
|
2630 |
||
2631 |
||
2632 |
||
2633 |
||
2634 |
// ----------------------------------------------------------------------------- |
|
2635 |
// CContactsUT::AddGroupL |
|
2636 |
// Example test method function. |
|
2637 |
// (other items were commented in a header). |
|
2638 |
// ----------------------------------------------------------------------------- |
|
2639 |
// |
|
2640 |
TInt CContactsUT::AddGroupL( CStifItemParser& aItem ) |
|
2641 |
{ |
|
2642 |
||
2643 |
// Print to UI |
|
2644 |
_LIT( KContactsTest, "ContactsTest" ); |
|
2645 |
_LIT( KExample, "In AddGroup" ); |
|
2646 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2647 |
// Print to log file |
|
2648 |
iLog->Log( KExample ); |
|
2649 |
||
2650 |
TInt i = 0; |
|
2651 |
TPtrC string; |
|
2652 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2653 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2654 |
{ |
|
2655 |
TestModuleIf().Printf( i, KContactsTest, |
|
2656 |
KParam, i, &string ); |
|
2657 |
i++; |
|
2658 |
} |
|
2659 |
||
2660 |
iErr = KErrNone; |
|
2661 |
||
2662 |
/**Add group using SAPI core class */ |
|
2663 |
__UHEAP_MARK; |
|
2664 |
_LIT(KGroup,"Test"); |
|
2665 |
//instantiate service class |
|
2666 |
CContactService* serviceHandle = CContactService::NewL(); |
|
2667 |
CleanupStack::PushL(serviceHandle); |
|
2668 |
iLog->Log( KServiceOpen ); |
|
2669 |
||
2670 |
serviceHandle->AddL(this,0,NULL,KNullDesC8,KGroup); |
|
2671 |
iLog->Log(_L("AddL called\n")); |
|
2672 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2673 |
CActiveScheduler::Start(); |
|
2674 |
||
2675 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
2676 |
iLog->Log( KServiceClose ); |
|
2677 |
/**end */ |
|
2678 |
__UHEAP_MARKEND; |
|
2679 |
if(iErr) |
|
2680 |
{ |
|
2681 |
return iErr; |
|
2682 |
} |
|
2683 |
||
2684 |
/** Check for the added group using virtual phonebook classes */ |
|
2685 |
iFindResults = iStore->ContactGroupsLC(); |
|
2686 |
TInt count(iFindResults->Count()); |
|
2687 |
while(count) |
|
2688 |
{ |
|
2689 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
2690 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
2691 |
CActiveScheduler::Start(); |
|
2692 |
||
2693 |
if(iErr) |
|
2694 |
{ |
|
2695 |
break; |
|
2696 |
} |
|
2697 |
iErr = KErrGeneral; |
|
2698 |
iGroup = iStoreContact->Group(); |
|
2699 |
if(!iGroup->GroupLabel().Compare(KGroup)) |
|
2700 |
{ |
|
2701 |
iErr = KErrNone; |
|
2702 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
2703 |
iContactToDelete->AppendL(iResult); |
|
2704 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
2705 |
CActiveScheduler::Start(); |
|
2706 |
break; |
|
2707 |
} |
|
2708 |
} |
|
2709 |
CleanupStack::Pop(); |
|
2710 |
iFindResults = NULL; |
|
2711 |
/**end */ |
|
2712 |
||
2713 |
return iErr; |
|
2714 |
||
2715 |
} |
|
2716 |
||
2717 |
||
2718 |
// ----------------------------------------------------------------------------- |
|
2719 |
// CContactsUT::DeleteL |
|
2720 |
// Example test method function. |
|
2721 |
// (other items were commented in a header). |
|
2722 |
// ----------------------------------------------------------------------------- |
|
2723 |
// |
|
2724 |
TInt CContactsUT::DeleteContactL( CStifItemParser& aItem ) |
|
2725 |
{ |
|
2726 |
||
2727 |
// Print to UI |
|
2728 |
_LIT( KContactsTest, "ContactsTest" ); |
|
2729 |
_LIT( KExample, "In Delete" ); |
|
2730 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2731 |
// Print to log file |
|
2732 |
iLog->Log( KExample ); |
|
2733 |
||
2734 |
TInt i = 0; |
|
2735 |
TPtrC string; |
|
2736 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2737 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2738 |
{ |
|
2739 |
TestModuleIf().Printf( i, KContactsTest, |
|
2740 |
KParam, i, &string ); |
|
2741 |
i++; |
|
2742 |
} |
|
2743 |
||
2744 |
iErr = KErrNone; |
|
2745 |
||
2746 |
/**Add 2 contacts using virtual phonebook*/ |
|
2747 |
||
2748 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
2749 |
CleanupStack::PushL(fieldTypeRefList); |
|
2750 |
||
2751 |
fieldTypeRefList->AppendL( |
|
2752 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
2753 |
fieldTypeRefList->AppendL( |
|
2754 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
2755 |
||
2756 |
// Create first contact |
|
2757 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2758 |
||
2759 |
// Create contact field for contact |
|
2760 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2761 |
// Set contact field data |
|
2762 |
_LIT(KFirstName,"Tenali"); |
|
2763 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
2764 |
// Add the contact field to contact |
|
2765 |
iStoreContact->AddFieldL( field ); |
|
2766 |
CleanupStack::Pop(); // field |
|
2767 |
||
2768 |
// Create contact field for contact |
|
2769 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2770 |
// Set contact field data |
|
2771 |
_LIT(KFirstNumber,"13579"); |
|
2772 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
2773 |
// Add the contact field to contact |
|
2774 |
iStoreContact->AddFieldL( field ); |
|
2775 |
CleanupStack::Pop(); // field |
|
2776 |
||
2777 |
// Commit the new created contact to contact store |
|
2778 |
iStoreContact->CommitL( *this ); |
|
2779 |
CActiveScheduler::Start(); |
|
2780 |
CleanupStack::Pop(); // iStoreContact |
|
2781 |
||
2782 |
||
2783 |
// Create second contact |
|
2784 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2785 |
||
2786 |
// Create contact field for contact |
|
2787 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2788 |
// Set contact field data |
|
2789 |
_LIT(KSecondName,"Birbal"); |
|
2790 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
2791 |
// Add the contact field to contact |
|
2792 |
iStoreContact->AddFieldL( field ); |
|
2793 |
CleanupStack::Pop(); // field |
|
2794 |
||
2795 |
// Create contact field for contact |
|
2796 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2797 |
// Set contact field data |
|
2798 |
_LIT(KSecondNumber,"13579"); |
|
2799 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
2800 |
// Add the contact field to contact |
|
2801 |
iStoreContact->AddFieldL( field ); |
|
2802 |
CleanupStack::Pop(); // field |
|
2803 |
||
2804 |
// Commit the new created contact to contact store |
|
2805 |
iStoreContact->CommitL( *this ); |
|
2806 |
CActiveScheduler::Start(); |
|
2807 |
CleanupStack::Pop(); // iStoreContact |
|
2808 |
||
2809 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
2810 |
/**end*/ |
|
2811 |
||
2812 |
/** Search for the added contacts*/ |
|
2813 |
||
2814 |
// Phone number to be searched for |
|
2815 |
_LIT( KMatchNo, "13579" ); |
|
2816 |
// Create find operation |
|
2817 |
iOp = iContactManager->MatchPhoneNumberL( |
|
2818 |
KMatchNo, KMatchNo().Length(), *this ); |
|
2819 |
||
2820 |
CActiveScheduler::Start(); |
|
2821 |
TInt count(iFindResults->Count()); |
|
2822 |
/**end*/ |
|
2823 |
||
2824 |
/**Delete using SAPI core class*/ |
|
2825 |
||
2826 |
if(count>1) |
|
2827 |
{ |
|
2828 |
__UHEAP_MARK; |
|
2829 |
RPointerArray<TDesC8> idArray; |
|
2830 |
CleanupClosePushL(idArray); |
|
2831 |
TInt num(count); |
|
2832 |
while(count) |
|
2833 |
{ |
|
2834 |
HBufC8* contactId = (const_cast<MVPbkContactLink&>(iFindResults->At(--count))).PackLC(); |
|
2835 |
idArray.AppendL(contactId); |
|
2836 |
} |
|
2837 |
||
2838 |
CContactService* serviceHandle = CContactService::NewL(); |
|
2839 |
CleanupStack::PushL(serviceHandle); |
|
2840 |
iLog->Log( KServiceOpen ); |
|
2841 |
||
2842 |
serviceHandle->DeleteL(this,0,idArray); |
|
2843 |
iLog->Log(_L("DeleteL called\n")); |
|
2844 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2845 |
CActiveScheduler::Start(); |
|
2846 |
||
2847 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
2848 |
||
2849 |
CleanupStack::PopAndDestroy(num);//destroy all contactIds |
|
2850 |
CleanupStack::PopAndDestroy(&idArray);//singleContactField |
|
2851 |
||
2852 |
iLog->Log( KServiceClose ); |
|
2853 |
__UHEAP_MARKEND; |
|
2854 |
||
2855 |
} |
|
2856 |
/**end*/ |
|
2857 |
||
2858 |
return iErr; |
|
2859 |
||
2860 |
} |
|
2861 |
||
2862 |
||
2863 |
// ----------------------------------------------------------------------------- |
|
2864 |
// CContactsUT::DeleteInvalidContactL |
|
2865 |
// Example test method function. |
|
2866 |
// (other items were commented in a header). |
|
2867 |
// ----------------------------------------------------------------------------- |
|
2868 |
// |
|
2869 |
TInt CContactsUT::DeleteSingleContactL( CStifItemParser& aItem ) |
|
2870 |
{ |
|
2871 |
||
2872 |
// Print to UI |
|
2873 |
_LIT( KContactsTest, "ContactsTest" ); |
|
2874 |
_LIT( KExample, "In Delete" ); |
|
2875 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
2876 |
// Print to log file |
|
2877 |
iLog->Log( KExample ); |
|
2878 |
||
2879 |
TInt i = 0; |
|
2880 |
TPtrC string; |
|
2881 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2882 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2883 |
{ |
|
2884 |
TestModuleIf().Printf( i, KContactsTest, |
|
2885 |
KParam, i, &string ); |
|
2886 |
i++; |
|
2887 |
} |
|
2888 |
||
2889 |
iErr = KErrNone; |
|
2890 |
||
2891 |
/**Add 2 contacts using virtual phonebook*/ |
|
2892 |
||
2893 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
2894 |
CleanupStack::PushL(fieldTypeRefList); |
|
2895 |
||
2896 |
fieldTypeRefList->AppendL( |
|
2897 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
2898 |
fieldTypeRefList->AppendL( |
|
2899 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
2900 |
||
2901 |
// Create first contact |
|
2902 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2903 |
||
2904 |
// Create contact field for contact |
|
2905 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2906 |
// Set contact field data |
|
2907 |
_LIT(KFirstName,"Tenali"); |
|
2908 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
2909 |
// Add the contact field to contact |
|
2910 |
iStoreContact->AddFieldL( field ); |
|
2911 |
CleanupStack::Pop(); // field |
|
2912 |
||
2913 |
// Create contact field for contact |
|
2914 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2915 |
// Set contact field data |
|
2916 |
_LIT(KFirstNumber,"13579"); |
|
2917 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
2918 |
// Add the contact field to contact |
|
2919 |
iStoreContact->AddFieldL( field ); |
|
2920 |
CleanupStack::Pop(); // field |
|
2921 |
||
2922 |
// Commit the new created contact to contact store |
|
2923 |
iStoreContact->CommitL( *this ); |
|
2924 |
CActiveScheduler::Start(); |
|
2925 |
CleanupStack::Pop(); // iStoreContact |
|
2926 |
||
2927 |
||
2928 |
// Create second contact |
|
2929 |
iStoreContact = iStore->CreateNewContactLC(); |
|
2930 |
||
2931 |
// Create contact field for contact |
|
2932 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
2933 |
// Set contact field data |
|
2934 |
_LIT(KSecondName,"Birbal"); |
|
2935 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
2936 |
// Add the contact field to contact |
|
2937 |
iStoreContact->AddFieldL( field ); |
|
2938 |
CleanupStack::Pop(); // field |
|
2939 |
||
2940 |
// Create contact field for contact |
|
2941 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
2942 |
// Set contact field data |
|
2943 |
_LIT(KSecondNumber,"13579"); |
|
2944 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
2945 |
// Add the contact field to contact |
|
2946 |
iStoreContact->AddFieldL( field ); |
|
2947 |
CleanupStack::Pop(); // field |
|
2948 |
||
2949 |
// Commit the new created contact to contact store |
|
2950 |
iStoreContact->CommitL( *this ); |
|
2951 |
CActiveScheduler::Start(); |
|
2952 |
CleanupStack::Pop(); // iStoreContact |
|
2953 |
||
2954 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
2955 |
/**end*/ |
|
2956 |
||
2957 |
/** Search for the added contacts*/ |
|
2958 |
||
2959 |
// Phone number to be searched for |
|
2960 |
_LIT( KMatchNo, "13579" ); |
|
2961 |
// Create find operation |
|
2962 |
iOp = iContactManager->MatchPhoneNumberL( |
|
2963 |
KMatchNo, KMatchNo().Length(), *this ); |
|
2964 |
||
2965 |
CActiveScheduler::Start(); |
|
2966 |
TInt count(iFindResults->Count()); |
|
2967 |
/**end*/ |
|
2968 |
||
2969 |
/**Delete using SAPI core class*/ |
|
2970 |
||
2971 |
if(count>1) |
|
2972 |
{ |
|
2973 |
__UHEAP_MARK; |
|
2974 |
RPointerArray<TDesC8> idArray; |
|
2975 |
CleanupClosePushL(idArray); |
|
2976 |
TInt num(1); |
|
2977 |
if(count) |
|
2978 |
{ |
|
2979 |
HBufC8* contactId = (const_cast<MVPbkContactLink&>(iFindResults->At(--count))).PackLC(); |
|
2980 |
idArray.AppendL(contactId); |
|
2981 |
} |
|
2982 |
||
2983 |
CContactService* serviceHandle = CContactService::NewL(); |
|
2984 |
CleanupStack::PushL(serviceHandle); |
|
2985 |
iLog->Log( KServiceOpen ); |
|
2986 |
||
2987 |
serviceHandle->DeleteL(this,0,idArray); |
|
2988 |
iLog->Log(_L("DeleteL called\n")); |
|
2989 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
2990 |
CActiveScheduler::Start(); |
|
2991 |
||
2992 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
2993 |
||
2994 |
CleanupStack::PopAndDestroy(num);//destroy all contactIds |
|
2995 |
CleanupStack::PopAndDestroy(&idArray);//singleContactField |
|
2996 |
||
2997 |
iLog->Log( KServiceClose ); |
|
2998 |
__UHEAP_MARKEND; |
|
2999 |
||
3000 |
} |
|
3001 |
/**end*/ |
|
3002 |
||
3003 |
return iErr; |
|
3004 |
||
3005 |
} |
|
3006 |
||
3007 |
// ----------------------------------------------------------------------------- |
|
3008 |
// CContactsUT::DeleteListL |
|
3009 |
// Example test method function. |
|
3010 |
// (other items were commented in a header). |
|
3011 |
// ----------------------------------------------------------------------------- |
|
3012 |
// |
|
3013 |
TInt CContactsUT::DeleteGroupL( CStifItemParser& aItem ) |
|
3014 |
{ |
|
3015 |
||
3016 |
// Print to UI |
|
3017 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3018 |
_LIT( KExample, "In DeleteList" ); |
|
3019 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3020 |
// Print to log file |
|
3021 |
iLog->Log( KExample ); |
|
3022 |
||
3023 |
TInt i = 0; |
|
3024 |
TPtrC string; |
|
3025 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3026 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3027 |
{ |
|
3028 |
TestModuleIf().Printf( i, KContactsTest, |
|
3029 |
KParam, i, &string ); |
|
3030 |
i++; |
|
3031 |
} |
|
3032 |
iErr = KErrNone; |
|
3033 |
||
3034 |
/**Add 2 groups using virtual phonebook */ |
|
3035 |
||
3036 |
_LIT(KGroup1,"Test1"); |
|
3037 |
_LIT(KGroup2,"Test2"); |
|
3038 |
iGroup = iStore->CreateNewContactGroupLC(); |
|
3039 |
iGroup->SetGroupLabelL(KGroup1); |
|
3040 |
iOperation = EGroup; |
|
3041 |
iGroup->CommitL(*this); |
|
3042 |
||
3043 |
CActiveScheduler::Start(); |
|
3044 |
CleanupStack::Pop(); |
|
3045 |
||
3046 |
iGroup = iStore->CreateNewContactGroupLC(); |
|
3047 |
iGroup->SetGroupLabelL(KGroup2); |
|
3048 |
iOperation = EGroup; |
|
3049 |
iGroup->CommitL(*this); |
|
3050 |
||
3051 |
CActiveScheduler::Start(); |
|
3052 |
CleanupStack::Pop(); |
|
3053 |
/**end */ |
|
3054 |
||
3055 |
if(iErr) |
|
3056 |
{ |
|
3057 |
return iErr; |
|
3058 |
} |
|
3059 |
||
3060 |
/**Delete the groups using SAPI core class */ |
|
3061 |
||
3062 |
/** Check for the added group using virtual phonebook classes */ |
|
3063 |
||
3064 |
iFindResults = iStore->ContactGroupsLC(); |
|
3065 |
TInt count(iFindResults->Count()); |
|
3066 |
if(count>1) |
|
3067 |
{ |
|
3068 |
HBufC8* groupId; |
|
3069 |
RPointerArray<TDesC8> idArray; |
|
3070 |
CleanupClosePushL(idArray); |
|
3071 |
while(count) |
|
3072 |
{ |
|
3073 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3074 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
3075 |
CActiveScheduler::Start(); |
|
3076 |
||
3077 |
iGroup = iStoreContact->Group(); |
|
3078 |
if(!iGroup->GroupLabel().Compare(KGroup1) || !iGroup->GroupLabel().Compare(KGroup2)) |
|
3079 |
{ |
|
3080 |
groupId = iResult->PackLC(); |
|
3081 |
idArray.AppendL(groupId); |
|
3082 |
} |
|
3083 |
} |
|
3084 |
TInt num(idArray.Count()); |
|
3085 |
if( num < 2) |
|
3086 |
{ |
|
3087 |
return KErrGeneral; |
|
3088 |
} |
|
3089 |
__UHEAP_MARK; |
|
3090 |
CContactService* serviceHandle = CContactService::NewL(); |
|
3091 |
CleanupStack::PushL(serviceHandle); |
|
3092 |
iLog->Log( KServiceOpen ); |
|
3093 |
||
3094 |
serviceHandle->DeleteL(this,0,idArray); |
|
3095 |
iLog->Log(_L("DeleteL called\n")); |
|
3096 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3097 |
CActiveScheduler::Start(); |
|
3098 |
||
3099 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
3100 |
__UHEAP_MARKEND; |
|
3101 |
CleanupStack::PopAndDestroy(num);//destroy all contactIds |
|
3102 |
CleanupStack::PopAndDestroy(&idArray);//singleContactField |
|
3103 |
||
3104 |
iLog->Log( KServiceClose ); |
|
3105 |
} |
|
3106 |
CleanupStack::Pop(); |
|
3107 |
iFindResults = NULL; |
|
3108 |
/**end */ |
|
3109 |
||
3110 |
return iErr; |
|
3111 |
||
3112 |
} |
|
3113 |
||
3114 |
// ----------------------------------------------------------------------------- |
|
3115 |
// CContactsUT::ModifyL |
|
3116 |
// Example test method function. |
|
3117 |
// (other items were commented in a header). |
|
3118 |
// ----------------------------------------------------------------------------- |
|
3119 |
// |
|
3120 |
TInt CContactsUT::ModifyL( CStifItemParser& aItem ) |
|
3121 |
{ |
|
3122 |
||
3123 |
||
3124 |
// Print to UI |
|
3125 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3126 |
_LIT( KExample, "In Modify" ); |
|
3127 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3128 |
// Print to log file |
|
3129 |
iLog->Log( KExample ); |
|
3130 |
||
3131 |
TInt i = 0; |
|
3132 |
TPtrC string; |
|
3133 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3134 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3135 |
{ |
|
3136 |
TestModuleIf().Printf( i, KContactsTest, |
|
3137 |
KParam, i, &string ); |
|
3138 |
i++; |
|
3139 |
} |
|
3140 |
iErr = KErrNone; |
|
3141 |
||
3142 |
DeleteAllL(); |
|
3143 |
_LIT(KFirstName,"Tenali"); |
|
3144 |
TPtrC ptr(KFirstName); |
|
3145 |
AddOneContactL(ptr); |
|
3146 |
||
3147 |
/** Retrieve contact ids and modify using SAPI core class */ |
|
3148 |
||
3149 |
// Create find operation |
|
3150 |
iOp = iContactManager->MatchPhoneNumberL( |
|
3151 |
KPhoneNumber, KPhoneNumber().Length(), *this ); |
|
3152 |
||
3153 |
CActiveScheduler::Start(); |
|
3154 |
||
3155 |
TInt count(iFindResults->Count()); |
|
3156 |
/**end*/ |
|
3157 |
||
3158 |
/**Modify using SAPI core class*/ |
|
3159 |
||
3160 |
if(count) |
|
3161 |
{ |
|
3162 |
while(count) |
|
3163 |
{ |
|
66 | 3164 |
__UHEAP_MARK; |
19 | 3165 |
iBuffer = (const_cast<MVPbkContactLink&>(iFindResults->At(--count))).PackLC(); |
3166 |
CleanupStack::Pop();//iBuffer |
|
3167 |
iServiceHandle = CContactService::NewL(); |
|
3168 |
iLog->Log( KServiceOpen ); |
|
3169 |
||
3170 |
iOperation = EContact; |
|
3171 |
iServiceHandle->GetListL(this,0,EContacts,*iBuffer); |
|
3172 |
iLog->Log(_L("GetListL called\n")); |
|
3173 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3174 |
CActiveScheduler::Start(); |
|
3175 |
||
3176 |
delete iServiceHandle;//serviceHandle |
|
3177 |
iServiceHandle = NULL; |
|
3178 |
iLog->Log( KServiceClose ); |
|
66 | 3179 |
__UHEAP_MARKEND; |
19 | 3180 |
} |
3181 |
||
3182 |
} |
|
3183 |
||
3184 |
/** ends */ |
|
3185 |
||
3186 |
return iErr; |
|
3187 |
||
3188 |
} |
|
3189 |
||
3190 |
// ----------------------------------------------------------------------------- |
|
3191 |
// CContactsUT::ModifyGroupL |
|
3192 |
// Example test method function. |
|
3193 |
// (other items were commented in a header). |
|
3194 |
// ----------------------------------------------------------------------------- |
|
3195 |
// |
|
3196 |
TInt CContactsUT::ModifyGroupL( CStifItemParser& aItem ) |
|
3197 |
{ |
|
3198 |
||
3199 |
// Print to UI |
|
3200 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3201 |
_LIT( KExample, "In ModifyGroup" ); |
|
3202 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3203 |
// Print to log file |
|
3204 |
iLog->Log( KExample ); |
|
3205 |
||
3206 |
TInt i = 0; |
|
3207 |
TPtrC string; |
|
3208 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3209 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3210 |
{ |
|
3211 |
TestModuleIf().Printf( i, KContactsTest, |
|
3212 |
KParam, i, &string ); |
|
3213 |
i++; |
|
3214 |
} |
|
3215 |
iErr = KErrNone; |
|
3216 |
/**Add 1 group using virtual phonebook */ |
|
3217 |
||
3218 |
_LIT(KGroup1,"Modify1"); |
|
3219 |
_LIT(KGroup2,"Modify2"); |
|
3220 |
iGroup = iStore->CreateNewContactGroupLC(); |
|
3221 |
iGroup->SetGroupLabelL(KGroup1); |
|
3222 |
iOperation = EGroup; |
|
3223 |
iGroup->CommitL(*this); |
|
3224 |
||
3225 |
CActiveScheduler::Start(); |
|
3226 |
CleanupStack::Pop(); |
|
3227 |
/**end */ |
|
3228 |
||
3229 |
/** Check for the added group using virtual phonebook classes */ |
|
3230 |
iFindResults = iStore->ContactGroupsLC(); |
|
3231 |
TInt count(iFindResults->Count()); |
|
3232 |
while(count) |
|
3233 |
{ |
|
3234 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3235 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
3236 |
CActiveScheduler::Start(); |
|
3237 |
||
3238 |
if(iErr) |
|
3239 |
{ |
|
3240 |
break; |
|
3241 |
} |
|
3242 |
iErr = KErrGeneral; |
|
3243 |
iGroup = iStoreContact->Group(); |
|
3244 |
if(!iGroup->GroupLabel().Compare(KGroup1)) |
|
3245 |
{ |
|
3246 |
__UHEAP_MARK; |
|
3247 |
CContactService* serviceHandle = CContactService::NewL(); |
|
3248 |
CleanupStack::PushL(serviceHandle); |
|
3249 |
iLog->Log( KServiceOpen ); |
|
3250 |
||
3251 |
serviceHandle->AddL(this,0,NULL,KNullDesC8,KGroup2); |
|
3252 |
iLog->Log(_L("ModifyGroupL called\n")); |
|
3253 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3254 |
CActiveScheduler::Start(); |
|
3255 |
||
3256 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
3257 |
iLog->Log( KServiceClose ); |
|
3258 |
__UHEAP_MARKEND; |
|
3259 |
} |
|
3260 |
} |
|
3261 |
CleanupStack::Pop(); |
|
3262 |
iFindResults = NULL; |
|
3263 |
/**end */ |
|
3264 |
||
3265 |
/** Check for the added group using virtual phonebook classes */ |
|
3266 |
iFindResults = iStore->ContactGroupsLC(); |
|
3267 |
count = iFindResults->Count(); |
|
3268 |
while(count) |
|
3269 |
{ |
|
3270 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3271 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
3272 |
CActiveScheduler::Start(); |
|
3273 |
||
3274 |
if(iErr) |
|
3275 |
{ |
|
3276 |
break; |
|
3277 |
} |
|
3278 |
iErr = KErrGeneral; |
|
3279 |
iGroup = iStoreContact->Group(); |
|
3280 |
if(!iGroup->GroupLabel().Compare(KGroup2)) |
|
3281 |
{ |
|
3282 |
iErr = KErrNone; |
|
3283 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3284 |
iContactToDelete->AppendL(iResult); |
|
3285 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
3286 |
CActiveScheduler::Start(); |
|
3287 |
break; |
|
3288 |
} |
|
3289 |
} |
|
3290 |
CleanupStack::Pop(); |
|
3291 |
iFindResults = NULL; |
|
3292 |
||
3293 |
/**end */ |
|
3294 |
return iErr; |
|
3295 |
||
3296 |
} |
|
3297 |
||
3298 |
// ----------------------------------------------------------------------------- |
|
3299 |
// CContactsUT::OrganiseAddL |
|
3300 |
// Example test method function. |
|
3301 |
// (other items were commented in a header). |
|
3302 |
// ----------------------------------------------------------------------------- |
|
3303 |
// |
|
3304 |
TInt CContactsUT::OrganiseAddL( CStifItemParser& aItem ) |
|
3305 |
{ |
|
3306 |
||
3307 |
// Print to UI |
|
3308 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3309 |
_LIT( KExample, "In OrganiseAdd" ); |
|
3310 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3311 |
// Print to log file |
|
3312 |
iLog->Log( KExample ); |
|
3313 |
||
3314 |
TInt i = 0; |
|
3315 |
TPtrC string; |
|
3316 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3317 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3318 |
{ |
|
3319 |
TestModuleIf().Printf( i, KContactsTest, |
|
3320 |
KParam, i, &string ); |
|
3321 |
i++; |
|
3322 |
} |
|
3323 |
||
3324 |
iErr = KErrNone; |
|
3325 |
||
3326 |
/** Add 1 group */ |
|
3327 |
||
3328 |
_LIT(KGroup,"OrganiseTest1"); |
|
3329 |
iGroup = iStore->CreateNewContactGroupLC(); |
|
3330 |
iGroup->SetGroupLabelL(KGroup); |
|
3331 |
iOperation = EGroup; |
|
3332 |
iGroup->CommitL(*this); |
|
3333 |
||
3334 |
CActiveScheduler::Start(); |
|
3335 |
CleanupStack::Pop(); |
|
3336 |
/** ends */ |
|
3337 |
||
3338 |
||
3339 |
if(iErr) |
|
3340 |
{ |
|
3341 |
return iErr; |
|
3342 |
} |
|
3343 |
||
3344 |
/** Retrieve the group id */ |
|
3345 |
HBufC8* groupId = NULL; |
|
3346 |
iFindResults = iStore->ContactGroupsLC(); |
|
3347 |
TInt count(iFindResults->Count()); |
|
3348 |
iErr = KErrGeneral; |
|
3349 |
while(count) |
|
3350 |
{ |
|
3351 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3352 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
3353 |
CActiveScheduler::Start(); |
|
3354 |
||
3355 |
iGroup = iStoreContact->Group(); |
|
3356 |
if(!iGroup->GroupLabel().Compare(KGroup)) |
|
3357 |
{ |
|
3358 |
groupId =iResult->PackLC(); |
|
3359 |
CleanupStack::Pop();//groupId |
|
3360 |
break; |
|
3361 |
} |
|
3362 |
} |
|
3363 |
CleanupStack::Pop();//iFindResults |
|
3364 |
CleanupStack::PushL(groupId); |
|
3365 |
iFindResults = NULL; |
|
3366 |
/** ends */ |
|
3367 |
||
3368 |
||
3369 |
/** Add 2 contacts */ |
|
3370 |
||
3371 |
DeleteAllL(); |
|
3372 |
_LIT(KFirstName,"Tenali"); |
|
3373 |
_LIT(KSecondName,"Birbal"); |
|
3374 |
||
3375 |
TPtrC ptr1(KFirstName); |
|
3376 |
TPtrC ptr2(KSecondName); |
|
3377 |
||
3378 |
AddOneContactL(ptr1); |
|
3379 |
AddOneContactL(ptr2); |
|
3380 |
||
3381 |
||
3382 |
||
3383 |
/** Retrieve the 2 contacts */ |
|
3384 |
||
3385 |
// Phone number to be searched for |
|
3386 |
// Create find operation |
|
3387 |
iOp = iContactManager->MatchPhoneNumberL( |
|
3388 |
KPhoneNumber, KPhoneNumber().Length(), *this ); |
|
3389 |
||
3390 |
CActiveScheduler::Start(); |
|
3391 |
count = iFindResults->Count(); |
|
3392 |
/**end*/ |
|
3393 |
||
3394 |
/**Organise using SAPI core class*/ |
|
3395 |
if(count>1 && groupId) |
|
3396 |
{ |
|
3397 |
RPointerArray<TDesC8> idArray; |
|
3398 |
CleanupClosePushL(idArray); |
|
3399 |
TInt num(count); |
|
3400 |
while(count) |
|
3401 |
{ |
|
3402 |
HBufC8* contactId = (const_cast<MVPbkContactLink&>(iFindResults->At(--count))).PackLC(); |
|
3403 |
idArray.AppendL(contactId); |
|
3404 |
} |
|
3405 |
__UHEAP_MARK; |
|
3406 |
CContactService* serviceHandle = CContactService::NewL(); |
|
3407 |
CleanupStack::PushL(serviceHandle); |
|
3408 |
iLog->Log( KServiceOpen ); |
|
3409 |
||
3410 |
serviceHandle->OrganiseGroupsL(this,0,*groupId,idArray,ETrue); |
|
3411 |
iLog->Log(_L("OrganiseGroupsL called\n")); |
|
3412 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3413 |
CActiveScheduler::Start(); |
|
3414 |
||
3415 |
||
3416 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
3417 |
__UHEAP_MARKEND; |
|
3418 |
CleanupStack::PopAndDestroy(num);//destroy all contactIds |
|
3419 |
CleanupStack::PopAndDestroy(&idArray);//singleContactField |
|
3420 |
||
3421 |
iLog->Log( KServiceClose ); |
|
3422 |
} |
|
3423 |
/** ends */ |
|
3424 |
||
3425 |
||
3426 |
/** Check for the group and delete*/ |
|
3427 |
iFindResults = iStore->ContactGroupsLC(); |
|
3428 |
count = iFindResults->Count(); |
|
3429 |
iErr = KErrGeneral; |
|
3430 |
while(count) |
|
3431 |
{ |
|
3432 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3433 |
if(!(iResult->PackLC())->Compare(*groupId)) |
|
3434 |
{ |
|
3435 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
3436 |
CActiveScheduler::Start(); |
|
3437 |
||
3438 |
iGroup = iStoreContact->Group(); |
|
3439 |
MVPbkContactLinkArray* linkArray = iGroup->ItemsContainedLC(); |
|
3440 |
if(linkArray->Count() == 2 ) |
|
3441 |
{ |
|
3442 |
iErr = KErrNone; |
|
3443 |
} |
|
3444 |
CleanupStack::Pop();//linkArray |
|
3445 |
||
3446 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3447 |
iContactToDelete->AppendL(iResult); |
|
3448 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
3449 |
CActiveScheduler::Start(); |
|
3450 |
} |
|
3451 |
CleanupStack::PopAndDestroy(); |
|
3452 |
} |
|
3453 |
CleanupStack::Pop(); |
|
3454 |
iFindResults = NULL; |
|
3455 |
/**end */ |
|
3456 |
CleanupStack::PopAndDestroy(groupId); |
|
3457 |
||
3458 |
return iErr; |
|
3459 |
} |
|
3460 |
||
3461 |
||
3462 |
// ----------------------------------------------------------------------------- |
|
3463 |
// CContactsUT::OrganiseDeleteL |
|
3464 |
// Example test method function. |
|
3465 |
// (other items were commented in a header). |
|
3466 |
// ----------------------------------------------------------------------------- |
|
3467 |
// |
|
3468 |
TInt CContactsUT::OrganiseDeleteL( CStifItemParser& aItem ) |
|
3469 |
{ |
|
3470 |
||
3471 |
// Print to UI |
|
3472 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3473 |
_LIT( KExample, "In OrganiseDelete" ); |
|
3474 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3475 |
// Print to log file |
|
3476 |
iLog->Log( KExample ); |
|
3477 |
||
3478 |
TInt i = 0; |
|
3479 |
TPtrC string; |
|
3480 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3481 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3482 |
{ |
|
3483 |
TestModuleIf().Printf( i, KContactsTest, |
|
3484 |
KParam, i, &string ); |
|
3485 |
i++; |
|
3486 |
} |
|
3487 |
iErr = KErrNone; |
|
3488 |
||
3489 |
/** Add 1 group */ |
|
3490 |
||
3491 |
_LIT(KGroup,"OrganiseTest1"); |
|
3492 |
iGroup = iStore->CreateNewContactGroupLC(); |
|
3493 |
iGroup->SetGroupLabelL(KGroup); |
|
3494 |
iOperation = EGroup; |
|
3495 |
iGroup->CommitL(*this); |
|
3496 |
||
3497 |
CActiveScheduler::Start(); |
|
3498 |
CleanupStack::Pop(); |
|
3499 |
/** ends */ |
|
3500 |
||
3501 |
||
3502 |
if(iErr) |
|
3503 |
{ |
|
3504 |
return iErr; |
|
3505 |
} |
|
3506 |
||
3507 |
||
3508 |
/** Add 2 contacts */ |
|
3509 |
||
3510 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
3511 |
CleanupStack::PushL(fieldTypeRefList); |
|
3512 |
||
3513 |
fieldTypeRefList->AppendL( |
|
3514 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
3515 |
fieldTypeRefList->AppendL( |
|
3516 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
3517 |
||
3518 |
// Create first contact |
|
3519 |
iStoreContact = iStore->CreateNewContactLC(); |
|
3520 |
||
3521 |
// Create contact field for contact |
|
3522 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
3523 |
// Set contact field data |
|
3524 |
_LIT(KFirstName,"Tenali"); |
|
3525 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
3526 |
// Add the contact field to contact |
|
3527 |
iStoreContact->AddFieldL( field ); |
|
3528 |
CleanupStack::Pop(); // field |
|
3529 |
||
3530 |
// Create contact field for contact |
|
3531 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
3532 |
// Set contact field data |
|
3533 |
_LIT(KFirstNumber,"97531"); |
|
3534 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
3535 |
// Add the contact field to contact |
|
3536 |
iStoreContact->AddFieldL( field ); |
|
3537 |
CleanupStack::Pop(); // field |
|
3538 |
||
3539 |
// Commit the new created contact to contact store |
|
3540 |
iStoreContact->CommitL( *this ); |
|
3541 |
CActiveScheduler::Start(); |
|
3542 |
CleanupStack::Pop(); // iStoreContact |
|
3543 |
||
3544 |
||
3545 |
// Create second contact |
|
3546 |
iStoreContact = iStore->CreateNewContactLC(); |
|
3547 |
||
3548 |
// Create contact field for contact |
|
3549 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
3550 |
// Set contact field data |
|
3551 |
_LIT(KSecondName,"Birbal"); |
|
3552 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondName ); |
|
3553 |
// Add the contact field to contact |
|
3554 |
iStoreContact->AddFieldL( field ); |
|
3555 |
CleanupStack::Pop(); // field |
|
3556 |
||
3557 |
// Create contact field for contact |
|
3558 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
3559 |
// Set contact field data |
|
3560 |
_LIT(KSecondNumber,"97531"); |
|
3561 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KSecondNumber ); |
|
3562 |
// Add the contact field to contact |
|
3563 |
iStoreContact->AddFieldL( field ); |
|
3564 |
CleanupStack::Pop(); // field |
|
3565 |
||
3566 |
// Commit the new created contact to contact store |
|
3567 |
iStoreContact->CommitL( *this ); |
|
3568 |
CActiveScheduler::Start(); |
|
3569 |
CleanupStack::Pop(); // iStoreContact |
|
3570 |
||
3571 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
3572 |
/** end */ |
|
3573 |
||
3574 |
||
3575 |
if(iErr) |
|
3576 |
{ |
|
3577 |
return iErr; |
|
3578 |
} |
|
3579 |
||
3580 |
/** Retrieve the 2 contacts */ |
|
3581 |
RPointerArray<TDesC8> idArray; |
|
3582 |
CleanupClosePushL(idArray); |
|
3583 |
// Phone number to be searched for |
|
3584 |
_LIT( KMatchNo, "97531" ); |
|
3585 |
// Create find operation |
|
3586 |
iOp = iContactManager->MatchPhoneNumberL( |
|
3587 |
KMatchNo, KMatchNo().Length(), *this ); |
|
3588 |
||
3589 |
CActiveScheduler::Start(); |
|
3590 |
TInt count = iFindResults->Count(); |
|
3591 |
TInt num(count); |
|
3592 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3593 |
while(count) |
|
3594 |
{ |
|
3595 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3596 |
iContactToDelete->AppendL(iResult); |
|
3597 |
idArray.AppendL(iResult->PackLC()); |
|
3598 |
} |
|
3599 |
/** ends */ |
|
3600 |
||
3601 |
/** Retrieve the group id */ |
|
3602 |
HBufC8* groupId = NULL; |
|
3603 |
iFindResults = iStore->ContactGroupsLC(); |
|
3604 |
count = iFindResults->Count(); |
|
3605 |
iErr = KErrGeneral; |
|
3606 |
while(count) |
|
3607 |
{ |
|
3608 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3609 |
iOp = iContactManager->RetrieveContactL(*iResult,*this); |
|
3610 |
CActiveScheduler::Start(); |
|
3611 |
||
3612 |
iGroup = iStoreContact->Group(); |
|
3613 |
if(!iGroup->GroupLabel().Compare(KGroup)) |
|
3614 |
{ |
|
3615 |
groupId =iResult->PackLC(); |
|
3616 |
TInt count(iContactToDelete->Count()); |
|
3617 |
while(count) |
|
3618 |
{ |
|
3619 |
iGroup->AddContactL(iContactToDelete->At(--count)); |
|
3620 |
} |
|
3621 |
CleanupStack::Pop(); |
|
3622 |
break; |
|
3623 |
} |
|
3624 |
} |
|
3625 |
CleanupStack::Pop(); |
|
3626 |
CleanupStack::PushL(groupId); |
|
3627 |
iFindResults = NULL; |
|
3628 |
delete iContactToDelete; |
|
3629 |
iContactToDelete = NULL; |
|
3630 |
/** ends */ |
|
3631 |
||
3632 |
/**Organise using SAPI core class*/ |
|
3633 |
if(groupId) |
|
3634 |
{ |
|
3635 |
__UHEAP_MARK; |
|
3636 |
CContactService* serviceHandle = CContactService::NewL(); |
|
3637 |
CleanupStack::PushL(serviceHandle); |
|
3638 |
iLog->Log( KServiceOpen ); |
|
3639 |
||
3640 |
serviceHandle->OrganiseGroupsL(this,0,*groupId,idArray,EFalse); |
|
3641 |
iLog->Log(_L("OrganiseGroupsL called\n")); |
|
3642 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3643 |
CActiveScheduler::Start(); |
|
3644 |
||
3645 |
||
3646 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
3647 |
||
3648 |
iLog->Log( KServiceClose ); |
|
3649 |
__UHEAP_MARKEND; |
|
3650 |
} |
|
3651 |
/** ends */ |
|
3652 |
||
3653 |
||
3654 |
/** Check for the group */ |
|
3655 |
iFindResults = iStore->ContactGroupsLC(); |
|
3656 |
count = iFindResults->Count(); |
|
3657 |
iErr = KErrGeneral; |
|
3658 |
while(count) |
|
3659 |
{ |
|
3660 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3661 |
if(!(iResult->PackLC())->Compare(*groupId)) |
|
3662 |
{ |
|
3663 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3664 |
iContactToDelete->AppendL(iResult); |
|
3665 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
3666 |
CActiveScheduler::Start(); |
|
3667 |
} |
|
3668 |
CleanupStack::PopAndDestroy(); |
|
3669 |
} |
|
3670 |
CleanupStack::Pop(); //iFindResults |
|
3671 |
iFindResults = NULL; |
|
3672 |
/**end */ |
|
3673 |
CleanupStack::PopAndDestroy(groupId); |
|
3674 |
CleanupStack::PopAndDestroy(num);//destroy all contactIds |
|
3675 |
CleanupStack::PopAndDestroy(&idArray);//singleContactField |
|
3676 |
||
3677 |
return iErr; |
|
3678 |
} |
|
3679 |
||
3680 |
// ----------------------------------------------------------------------------- |
|
3681 |
// CContactsUT::OrganiseDeleteL |
|
3682 |
// Example test method function. |
|
3683 |
// (other items were commented in a header). |
|
3684 |
// ----------------------------------------------------------------------------- |
|
3685 |
// |
|
3686 |
TInt CContactsUT::ImportL( CStifItemParser& aItem ) |
|
3687 |
{ |
|
3688 |
||
3689 |
// Print to UI |
|
3690 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3691 |
_LIT( KExample, "In Import" ); |
|
3692 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3693 |
// Print to log file |
|
3694 |
iLog->Log( KExample ); |
|
3695 |
||
3696 |
TInt i = 0; |
|
3697 |
TPtrC string; |
|
3698 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3699 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3700 |
{ |
|
3701 |
TestModuleIf().Printf( i, KContactsTest, |
|
3702 |
KParam, i, &string ); |
|
3703 |
i++; |
|
3704 |
} |
|
3705 |
iErr = KErrNone; |
|
3706 |
_LIT(KFileName,"c:\\vcardex.vcf"); |
|
3707 |
||
3708 |
/** Add 1 contact */ |
|
3709 |
CVPbkFieldTypeRefsList* fieldTypeRefList = CVPbkFieldTypeRefsList::NewL(); |
|
3710 |
CleanupStack::PushL(fieldTypeRefList); |
|
3711 |
||
3712 |
fieldTypeRefList->AppendL( |
|
3713 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_FIRSTNAME ) ); |
|
3714 |
fieldTypeRefList->AppendL( |
|
3715 |
*iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) ); |
|
3716 |
||
3717 |
// Create first contact |
|
3718 |
iStoreContact = iStore->CreateNewContactLC(); |
|
3719 |
||
3720 |
// Create contact field for contact |
|
3721 |
MVPbkStoreContactField* field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 0 ) ); |
|
3722 |
// Set contact field data |
|
3723 |
_LIT(KFirstName,"Tenali"); |
|
3724 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstName ); |
|
3725 |
// Add the contact field to contact |
|
3726 |
iStoreContact->AddFieldL( field ); |
|
3727 |
CleanupStack::Pop(); // field |
|
3728 |
||
3729 |
// Create contact field for contact |
|
3730 |
field = iStoreContact->CreateFieldLC( fieldTypeRefList->FieldTypeAt( 1 ) ); |
|
3731 |
// Set contact field data |
|
3732 |
_LIT(KFirstNumber,"45678"); |
|
3733 |
(MVPbkContactFieldTextData::Cast(field->FieldData())).SetTextL( KFirstNumber ); |
|
3734 |
// Add the contact field to contact |
|
3735 |
iStoreContact->AddFieldL( field ); |
|
3736 |
CleanupStack::Pop(); // field |
|
3737 |
||
3738 |
// Commit the new created contact to contact store |
|
3739 |
iStoreContact->CommitL( *this ); |
|
3740 |
CActiveScheduler::Start(); |
|
3741 |
CleanupStack::Pop(); // iStoreContact |
|
3742 |
||
3743 |
CleanupStack::PopAndDestroy(fieldTypeRefList); |
|
3744 |
/** end */ |
|
3745 |
||
3746 |
/** Retrieve the contact */ |
|
3747 |
||
3748 |
// Phone number to be searched for |
|
3749 |
_LIT( KMatchNo, "45678" ); |
|
3750 |
// Create find operation |
|
3751 |
iOp = iContactManager->MatchPhoneNumberL( |
|
3752 |
KMatchNo, KMatchNo().Length(), *this ); |
|
3753 |
||
3754 |
CActiveScheduler::Start(); |
|
3755 |
TInt count = iFindResults->Count(); |
|
3756 |
while(count) |
|
3757 |
{ |
|
3758 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3759 |
iVCardEngine = CVPbkVCardEng::NewL( *iContactManager ); |
|
3760 |
||
3761 |
// Create the buffer to store the contact |
|
3762 |
iBuffer = HBufC8::NewL( 1024 ); |
|
3763 |
TPtr8 bufferPtr( iBuffer->Des() ); |
|
3764 |
iDestStream.Open( bufferPtr ); |
|
3765 |
||
3766 |
iOperation = EVCard; |
|
3767 |
||
3768 |
//export the contact from MVPbkContactLink |
|
3769 |
iOp = iVCardEngine->ExportVCardL( iDestStream, *iResult, *this ); |
|
3770 |
CActiveScheduler::Start(); |
|
3771 |
||
3772 |
delete iVCardEngine; |
|
3773 |
iVCardEngine = NULL; |
|
3774 |
||
3775 |
if(iBuffer) |
|
3776 |
{ |
|
3777 |
RFile file; |
|
3778 |
CleanupClosePushL(file); |
|
3779 |
file.Replace(iRfs,KFileName,EFileWrite); |
|
3780 |
file.Write(0,*iBuffer); |
|
3781 |
CleanupStack::PopAndDestroy(&file); |
|
3782 |
delete iBuffer; |
|
3783 |
iBuffer = NULL; |
|
3784 |
} |
|
3785 |
||
3786 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3787 |
iContactToDelete->AppendL(iResult); |
|
3788 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
3789 |
CActiveScheduler::Start(); |
|
3790 |
} |
|
3791 |
iFindResults = NULL; |
|
3792 |
__UHEAP_MARK; |
|
3793 |
//using sapi |
|
3794 |
CContactService* serviceHandle = CContactService::NewL(); |
|
3795 |
CleanupStack::PushL(serviceHandle); |
|
3796 |
iLog->Log( KServiceOpen ); |
|
3797 |
||
3798 |
TFileName file(KFileName); |
|
3799 |
||
3800 |
serviceHandle->ImportVCardToStoreL(this,0,file); |
|
3801 |
iLog->Log(_L("ImportVCardToStoreL called\n")); |
|
3802 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3803 |
CActiveScheduler::Start(); |
|
3804 |
||
3805 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
3806 |
iLog->Log( KServiceClose ); |
|
3807 |
__UHEAP_MARKEND; |
|
3808 |
/**Delete using virtual Phonebook */ |
|
3809 |
||
3810 |
||
3811 |
// Create find operation |
|
3812 |
iOp = iContactManager->MatchPhoneNumberL( |
|
3813 |
KMatchNo, KMatchNo().Length(), *this ); |
|
3814 |
CActiveScheduler::Start(); |
|
3815 |
iErr = KErrGeneral; |
|
3816 |
count = iFindResults->Count(); |
|
3817 |
while(count) |
|
3818 |
{ |
|
3819 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3820 |
iContactToDelete->AppendL(&(const_cast<MVPbkContactLink&>(iFindResults->At(--count)))); |
|
3821 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
3822 |
CActiveScheduler::Start(); |
|
3823 |
} |
|
3824 |
/**end */ |
|
3825 |
||
3826 |
return iErr; |
|
3827 |
} |
|
3828 |
// ----------------------------------------------------------------------------- |
|
3829 |
// CContactsUT::OrganiseDeleteL |
|
3830 |
// Example test method function. |
|
3831 |
// (other items were commented in a header). |
|
3832 |
// ----------------------------------------------------------------------------- |
|
3833 |
// |
|
3834 |
TInt CContactsUT::ExportL( CStifItemParser& aItem ) |
|
3835 |
{ |
|
3836 |
||
3837 |
// Print to UI |
|
3838 |
_LIT( KContactsTest, "ContactsTest" ); |
|
3839 |
_LIT( KExample, "In Import" ); |
|
3840 |
TestModuleIf().Printf( 0, KContactsTest, KExample ); |
|
3841 |
// Print to log file |
|
3842 |
iLog->Log( KExample ); |
|
3843 |
||
3844 |
TInt i = 0; |
|
3845 |
TPtrC string; |
|
3846 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3847 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3848 |
{ |
|
3849 |
TestModuleIf().Printf( i, KContactsTest, |
|
3850 |
KParam, i, &string ); |
|
3851 |
i++; |
|
3852 |
} |
|
3853 |
iErr = KErrNone; |
|
3854 |
_LIT(KFileName,"c:\\vcardim.vcf"); |
|
3855 |
RFs fs; |
|
3856 |
CleanupClosePushL(fs); |
|
3857 |
User::LeaveIfError(fs.Connect()); |
|
3858 |
RFile file; |
|
3859 |
if(!file.Open(fs,KFileName,EFileRead)) |
|
3860 |
{ |
|
3861 |
file.Close(); |
|
3862 |
fs.Delete(KFileName); |
|
3863 |
} |
|
3864 |
CleanupStack::PopAndDestroy(&fs); |
|
3865 |
||
3866 |
DeleteAllL(); |
|
3867 |
_LIT(KFirstName,"Akbar"); |
|
3868 |
TPtrC ptr(KFirstName); |
|
3869 |
AddOneContactL(ptr); |
|
3870 |
||
3871 |
/** Retrieve the contact */ |
|
3872 |
||
3873 |
// Phone number to be searched for |
|
3874 |
// Create find operation |
|
3875 |
iOp = iContactManager->MatchPhoneNumberL( |
|
3876 |
KPhoneNumber, KPhoneNumber().Length(), *this ); |
|
3877 |
||
3878 |
CActiveScheduler::Start(); |
|
3879 |
TInt count = iFindResults->Count(); |
|
3880 |
while(count) |
|
3881 |
{ |
|
3882 |
iResult = &(const_cast<MVPbkContactLink&>(iFindResults->At(--count))); |
|
3883 |
iBuffer = iResult->PackLC(); |
|
3884 |
CleanupStack::Pop(); |
|
3885 |
||
3886 |
// __UHEAP_MARK; |
|
3887 |
//using sapi |
|
3888 |
CContactService* serviceHandle = CContactService::NewL(); |
|
3889 |
CleanupStack::PushL(serviceHandle); |
|
3890 |
iLog->Log( KServiceOpen ); |
|
3891 |
||
3892 |
TFileName file(KFileName); |
|
3893 |
serviceHandle->ExportVCardL(this,0,file,*iBuffer); |
|
3894 |
iLog->Log(_L("ExportVCardL called\n")); |
|
3895 |
iLog->Log(_L("Start Active Scheduler\n")); |
|
3896 |
CActiveScheduler::Start(); |
|
3897 |
||
3898 |
CleanupStack::PopAndDestroy(serviceHandle);//serviceHandle |
|
3899 |
iLog->Log( KServiceClose ); |
|
3900 |
// __UHEAP_MARKEND; |
|
3901 |
||
3902 |
iContactToDelete = CVPbkContactLinkArray::NewL(); |
|
3903 |
iContactToDelete->AppendL(iResult); |
|
3904 |
iOp = iContactManager->DeleteContactsL( *iContactToDelete, *this ); |
|
3905 |
CActiveScheduler::Start(); |
|
3906 |
||
3907 |
delete iBuffer; |
|
3908 |
iBuffer = NULL; |
|
3909 |
||
3910 |
RPointerArray< MVPbkStoreContact > importedContacts; |
|
3911 |
CleanupClosePushL(importedContacts); |
|
3912 |
||
3913 |
iVCardEngine = CVPbkVCardEng::NewL( *iContactManager ); |
|
3914 |
||
3915 |
// Open the RFileReadStream that holds the vCard content |
|
3916 |
iErr = iSource.Open( iRfs, KFileName, EFileRead ); |
|
3917 |
||
3918 |
// Import the contact from RFileReadStream asynchronously |
|
3919 |
// The operation status is reported via MVPbkSingleContactOperationObserver. |
|
3920 |
iOp = iVCardEngine->ImportVCardL( importedContacts, *iStore, iSource, *this ); |
|
3921 |
CActiveScheduler::Start(); |
|
3922 |
||
3923 |
if(!importedContacts.Count()) |
|
3924 |
{ |
|
3925 |
return KErrGeneral; |
|
3926 |
||
3927 |
} |
|
3928 |
||
3929 |
// Close iImportedContacts |
|
3930 |
// |
|
3931 |
importedContacts.ResetAndDestroy(); |
|
3932 |
CleanupStack::PopAndDestroy(&importedContacts); |
|
3933 |
} |
|
3934 |
iFindResults = NULL; |
|
3935 |
||
3936 |
||
3937 |
return iErr; |
|
3938 |
} |
|
3939 |
||
3940 |
||
3941 |
TInt CContactsUT::GetListCancelL( CStifItemParser& /*aItem*/) |
|
3942 |
{ |
|
3943 |
||
3944 |
int ret=0; |
|
3945 |
ret = getlist_cancel(0, NULL); |
|
3946 |
||
3947 |
if(ret==0) |
|
3948 |
return KErrNone; |
|
3949 |
else |
|
3950 |
return KErrGeneral; |
|
3951 |
} |
|
3952 |
||
3953 |
||
3954 |
TInt CContactsUT::GetListSrchCancelL( CStifItemParser& /*aItem*/) |
|
3955 |
{ |
|
3956 |
||
3957 |
int ret=0; |
|
3958 |
ret = getlistsrh_cancel(0, NULL); |
|
3959 |
||
3960 |
if(ret==0) |
|
3961 |
return KErrNone; |
|
3962 |
else |
|
3963 |
return KErrGeneral; |
|
3964 |
} |
|
3965 |
||
3966 |
||
3967 |
||
3968 |
TInt CContactsUT::ExportCancelL( CStifItemParser& /*aItem*/) |
|
3969 |
{ |
|
3970 |
||
3971 |
int ret=0; |
|
3972 |
ret = export_cancel(0, NULL); |
|
3973 |
||
3974 |
if(ret==0) |
|
3975 |
return KErrNone; |
|
3976 |
else |
|
3977 |
return KErrGeneral; |
|
3978 |
||
3979 |
||
3980 |
} |
|
3981 |
||
3982 |
TInt CContactsUT::AddCancelL( CStifItemParser& /*aItem*/ ) |
|
3983 |
{ |
|
3984 |
int ret=0; |
|
3985 |
ret = add_cancel(0, NULL); |
|
3986 |
||
3987 |
if(ret==0) |
|
3988 |
return KErrNone; |
|
3989 |
else |
|
3990 |
return KErrGeneral; |
|
3991 |
} |
|
3992 |
||
3993 |
TInt CContactsUT::ImportCancelL( CStifItemParser& /*aItem*/) |
|
3994 |
{ |
|
3995 |
||
3996 |
int ret=0; |
|
3997 |
ret = import_cancel(0, NULL); |
|
3998 |
||
3999 |
if(ret==0) |
|
4000 |
return KErrNone; |
|
4001 |
else |
|
4002 |
return KErrGeneral; |
|
4003 |
||
4004 |
||
4005 |
} |
|
4006 |
||
4007 |
TInt CContactsUT::DeleteCancelL( CStifItemParser& /*aItem*/) |
|
4008 |
{ |
|
4009 |
||
4010 |
int ret=0; |
|
4011 |
ret = delete_cancel(0, NULL); |
|
4012 |
||
4013 |
if(ret==0) |
|
4014 |
return KErrNone; |
|
4015 |
else |
|
4016 |
return KErrGeneral; |
|
4017 |
||
4018 |
} |
|
4019 |
TInt CContactsUT::OrganiseCancelL( CStifItemParser& /*aItem*/) |
|
4020 |
{ |
|
4021 |
||
4022 |
int ret=0; |
|
4023 |
ret = organise_cancel(0, NULL); |
|
4024 |
||
4025 |
if(ret==0) |
|
4026 |
return KErrNone; |
|
4027 |
else |
|
4028 |
return KErrGeneral; |
|
4029 |
||
4030 |
} |
|
4031 |
//End of file |