author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:06:03 +0300 | |
branch | RCL_3 |
changeset 44 | 0b68a1b0c15e |
parent 38 | ea43c23d28d2 |
child 45 | a9c0808a1095 |
permissions | -rw-r--r-- |
5 | 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> |
|
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
24 |
#include <StifTestInterface.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
25 |
#include "tcontact_export.h" |
5 | 26 |
|
27 |
// EXTERNAL DATA STRUCTURES |
|
28 |
//extern ?external_data; |
|
29 |
||
30 |
// EXTERNAL FUNCTION PROTOTYPES |
|
31 |
//extern ?external_function( ?arg_type,?arg_type ); |
|
32 |
||
33 |
// CONSTANTS |
|
34 |
//const ?type ?constant_var = ?constant; |
|
35 |
||
36 |
// MACROS |
|
37 |
//#define ?macro ?macro_def |
|
38 |
||
39 |
// LOCAL CONSTANTS AND MACROS |
|
40 |
//const ?type ?constant_var = ?constant; |
|
41 |
//#define ?macro_name ?macro_def |
|
42 |
||
43 |
// MODULE DATA STRUCTURES |
|
44 |
//enum ?declaration |
|
45 |
//typedef ?declaration |
|
46 |
||
47 |
// LOCAL FUNCTION PROTOTYPES |
|
48 |
//?type ?function_name( ?arg_type, ?arg_type ); |
|
49 |
||
50 |
// FORWARD DECLARATIONS |
|
51 |
//class ?FORWARD_CLASSNAME; |
|
52 |
||
53 |
// ============================= LOCAL FUNCTIONS =============================== |
|
54 |
||
55 |
// ----------------------------------------------------------------------------- |
|
56 |
// ?function_name ?description. |
|
57 |
// ?description |
|
58 |
// Returns: ?value_1: ?description |
|
59 |
// ?value_n: ?description_line1 |
|
60 |
// ?description_line2 |
|
61 |
// ----------------------------------------------------------------------------- |
|
62 |
// |
|
63 |
/* |
|
64 |
?type ?function_name( |
|
65 |
?arg_type arg, // ?description |
|
66 |
?arg_type arg) // ?description |
|
67 |
{ |
|
68 |
||
69 |
?code // ?comment |
|
70 |
||
71 |
// ?comment |
|
72 |
?code |
|
73 |
} |
|
74 |
*/ |
|
75 |
||
76 |
TInt handlerror_cnt,handleiter_cnt; |
|
77 |
||
78 |
HBufC8* contactid=NULL; |
|
79 |
CSingleContact* myContact=NULL; |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
80 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
81 |
void CContactCallback::HandleReturnArray(const TInt& aError, RPointerArray<HBufC8>& aArray, TInt aTransId ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
82 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
83 |
CActiveScheduler::Stop(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
84 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
85 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
86 |
void CContactCallback::HandleReturnId( const TInt& aError, HBufC8* acntId, TInt aTransId ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
87 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
88 |
CActiveScheduler::Stop(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
89 |
} |
5 | 90 |
|
91 |
void CContactCallback::HandleReturnValue( TOperationEvent aEventId, const TInt& aError, TInt aTransId ) |
|
92 |
{ |
|
93 |
iError= aError; |
|
94 |
CActiveScheduler::Stop(); |
|
95 |
} |
|
96 |
||
97 |
||
98 |
void CContactCallback:: HandleReturnIter( const TInt& aError, CContactIter* aIter, TInt aTransId ) |
|
99 |
{ |
|
100 |
CActiveScheduler::Stop(); |
|
101 |
CSingleContactField* field = NULL; |
|
102 |
HBufC8* buf = NULL; |
|
103 |
TBuf8<100> buf1; |
|
104 |
TBuf<100> buf2; |
|
105 |
TBuf<100> buf3; |
|
106 |
TInt count=0 ; |
|
107 |
||
108 |
||
109 |
if(aError==KErrNone) |
|
110 |
{ |
|
111 |
aIter->NextL(myContact,contactid); |
|
112 |
} |
|
113 |
||
114 |
delete aIter; |
|
115 |
} |
|
116 |
||
117 |
// ============================ MEMBER FUNCTIONS =============================== |
|
118 |
||
119 |
// ----------------------------------------------------------------------------- |
|
120 |
// Cteximport::Delete |
|
121 |
// Delete here all resources allocated and opened from test methods. |
|
122 |
// Called from destructor. |
|
123 |
// ----------------------------------------------------------------------------- |
|
124 |
// |
|
125 |
void Cteximport::Delete() |
|
126 |
{ |
|
127 |
||
128 |
} |
|
129 |
||
130 |
// ----------------------------------------------------------------------------- |
|
131 |
// Cteximport::RunMethodL |
|
132 |
// Run specified method. Contains also table of test mothods and their names. |
|
133 |
// ----------------------------------------------------------------------------- |
|
134 |
// |
|
135 |
TInt Cteximport::RunMethodL( |
|
136 |
CStifItemParser& aItem ) |
|
137 |
{ |
|
138 |
||
139 |
static TStifFunctionInfo const KFunctions[] = |
|
140 |
{ |
|
141 |
// Copy this line for every implemented function. |
|
142 |
// First string is the function name used in TestScripter script file. |
|
143 |
// Second is the actual implementation member function. |
|
144 |
||
145 |
ENTRY( "Export_Test1", Cteximport::Export_Test1L ), |
|
146 |
ENTRY( "Export_Test2", Cteximport::Export_Test2L ), |
|
147 |
ENTRY( "Export_Test3", Cteximport::Export_Test3L ), |
|
148 |
ENTRY( "Export_Test4", Cteximport::Export_Test4L ), |
|
149 |
ENTRY( "Export_Test5", Cteximport::Export_Test5L ), |
|
150 |
ENTRY( "Export_Test6", Cteximport::Export_Test6L ), |
|
151 |
ENTRY( "Export_Test7", Cteximport::Export_Test7L ), |
|
152 |
ENTRY( "Export_Test8", Cteximport::Export_Test8L ), |
|
153 |
//ENTRY( "Export_Test9", Cteximport::Export_Test9L ), |
|
154 |
}; |
|
155 |
||
156 |
const TInt count = sizeof( KFunctions ) / |
|
157 |
sizeof( TStifFunctionInfo ); |
|
158 |
||
159 |
return RunInternalL( KFunctions, count, aItem ); |
|
160 |
||
161 |
} |
|
162 |
||
163 |
// ----------------------------------------------------------------------------- |
|
164 |
// Cteximport::ExampleL |
|
165 |
// Example test method function. |
|
166 |
// (other items were commented in a header). |
|
167 |
// ----------------------------------------------------------------------------- |
|
168 |
// |
|
169 |
||
170 |
/* export a single contact to a new file ; only filename specified */ |
|
171 |
TInt Cteximport::Export_Test1L( CStifItemParser& aItem ) |
|
172 |
{ |
|
173 |
||
174 |
// Print to UI |
|
175 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
176 |
_LIT( KExample, "In Import_InvL" ); |
|
177 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
178 |
// Print to log file |
|
179 |
iLog->Log( KExample ); |
|
180 |
||
181 |
||
182 |
TPtrC String; |
|
183 |
||
184 |
||
185 |
/* get the filename for export */ |
|
186 |
if(aItem.GetNextString(String) != KErrNone ) |
|
187 |
{ |
|
188 |
_LIT(Kerr ,"Failed to read input file name") ; |
|
189 |
iLog->Log(Kerr) ; |
|
190 |
return KErrGeneral ; |
|
191 |
} |
|
192 |
||
193 |
TBuf<256> string1; |
|
194 |
string1.Copy(String); |
|
195 |
||
196 |
||
197 |
TInt flag=0,cnt=0; |
|
198 |
||
199 |
/*call getlist to get the contactid for export */ \ |
|
44
0b68a1b0c15e
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
38
diff
changeset
|
200 |
TInt err1, err2; |
5 | 201 |
TRAP(err1,icontactservice->GetListL(icallback,1,EContacts,KNullDesC8)); |
202 |
CActiveScheduler::Start(); |
|
203 |
||
204 |
/*call export */ |
|
205 |
||
206 |
TRAP(err1,icontactservice->ExportVCardL(icallback,2,string1,KNullDesC8)); |
|
207 |
if(err1 || err2) |
|
208 |
return KErrNone; |
|
209 |
CActiveScheduler::Start(); |
|
210 |
||
211 |
||
212 |
/* verify whther export returns the expected error */ |
|
213 |
aItem.GetNextInt(flag) ; |
|
214 |
if(icallback->iError) |
|
44
0b68a1b0c15e
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
38
diff
changeset
|
215 |
return KErrNone; |
5 | 216 |
if(icallback->iError == flag) |
44
0b68a1b0c15e
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
38
diff
changeset
|
217 |
return KErrNone; |
5 | 218 |
|
219 |
} |
|
220 |
||
221 |
/* exporting 2 contacts */ |
|
222 |
TInt Cteximport::Export_Test2L( CStifItemParser& aItem ) |
|
223 |
{ |
|
224 |
||
225 |
// Print to UI |
|
226 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
227 |
_LIT( KExample, "In Import_InvL" ); |
|
228 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
229 |
// Print to log file |
|
230 |
iLog->Log( KExample ); |
|
231 |
||
232 |
||
233 |
TPtrC String; |
|
234 |
||
235 |
||
236 |
/* get the filename for export */ |
|
237 |
if(aItem.GetNextString(String) != KErrNone ) |
|
238 |
{ |
|
239 |
_LIT(Kerr , "Failed to read input file name") ; |
|
240 |
iLog->Log(Kerr) ; |
|
241 |
return KErrGeneral ; |
|
242 |
} |
|
243 |
||
244 |
TBuf<256> string1,string2,string3; |
|
245 |
string1.Copy(String); |
|
246 |
||
247 |
if(aItem.GetNextString(String) != KErrNone ) |
|
248 |
{ |
|
249 |
_LIT(Kerr , "Failed to read input file name") ; |
|
250 |
iLog->Log(Kerr) ; |
|
251 |
return KErrGeneral ; |
|
252 |
} |
|
253 |
||
254 |
string2.Copy(String); |
|
255 |
||
256 |
if(aItem.GetNextString(String) != KErrNone ) |
|
257 |
{ |
|
258 |
_LIT(Kerr , "Failed to read input file name") ; |
|
259 |
iLog->Log(Kerr) ; |
|
260 |
return KErrGeneral ; |
|
261 |
} |
|
262 |
||
263 |
string3.Copy(String); |
|
264 |
TInt flag=0,cnt=0; |
|
265 |
||
266 |
||
267 |
icontactservice->ImportVCardToStoreL(icallback,1,string3); |
|
268 |
CActiveScheduler::Start(); |
|
269 |
||
270 |
/*call getlist to get the contactid for export */ |
|
271 |
icontactservice->GetListL(icallback,1,EContacts) ; |
|
272 |
CActiveScheduler::Start(); |
|
273 |
||
274 |
/*call export */ |
|
275 |
icontactservice->ExportVCardL(icallback,1,string1,*contactid); |
|
276 |
CActiveScheduler::Start(); |
|
277 |
||
278 |
icontactservice->ExportVCardL(icallback,2,string2,*contactid); |
|
279 |
CActiveScheduler::Start(); |
|
280 |
||
281 |
||
282 |
/* verify whther export returns the expected error */ |
|
283 |
aItem.GetNextInt(flag) ; |
|
284 |
if(icallback->iError == flag) |
|
285 |
return KErrNone; |
|
286 |
||
287 |
return KErrGeneral; |
|
288 |
||
289 |
||
290 |
} |
|
291 |
||
292 |
||
293 |
/* exporting non existent contact */ |
|
294 |
TInt Cteximport::Export_Test3L( CStifItemParser& aItem ) |
|
295 |
{ |
|
296 |
||
297 |
// Print to UI |
|
298 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
299 |
_LIT( KExample, "In Import_InvL" ); |
|
300 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
301 |
// Print to log file |
|
302 |
iLog->Log( KExample ); |
|
303 |
||
304 |
||
305 |
TPtrC String; |
|
306 |
||
307 |
||
308 |
||
309 |
/* get the filename for export */ |
|
310 |
if(aItem.GetNextString(String) != KErrNone ) |
|
311 |
{ |
|
312 |
_LIT(Kerr , "Failed to read input file name") ; |
|
313 |
iLog->Log(Kerr) ; |
|
314 |
return KErrGeneral ; |
|
315 |
} |
|
316 |
||
317 |
TBuf<256> string1; |
|
318 |
string1.Copy(String); |
|
319 |
||
320 |
||
321 |
TInt flag=0,cnt=0; |
|
322 |
||
323 |
||
324 |
_LIT8(KFirstName,"FirstName"); |
|
325 |
_LIT(KName,"Goat"); |
|
326 |
//instantiate service class object |
|
327 |
||
328 |
/* create contactitem to add */ |
|
329 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
330 |
CSingleContactField* singleContactField = CSingleContactField::NewL(); |
|
331 |
||
332 |
||
333 |
singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
334 |
singleContact->AddFieldToContactL(singleContactField); |
|
335 |
||
336 |
||
337 |
||
338 |
||
339 |
/* Add the contactitem */ |
|
340 |
icontactservice->AddL(icallback,0,singleContact); |
|
341 |
CActiveScheduler::Start(); |
|
342 |
||
343 |
||
344 |
/*call getlist to get the contactid for export */ |
|
345 |
icontactservice->GetListL(icallback,1,EContacts) ; |
|
346 |
CActiveScheduler::Start(); |
|
347 |
||
348 |
||
349 |
RPointerArray<TDesC8> ptr ; //= new (ELeave) CArrayFixFlat<TDesC8>(1); |
|
350 |
ptr.Append(contactid); |
|
351 |
||
352 |
icontactservice->DeleteL(icallback,2,ptr); |
|
353 |
||
354 |
CActiveScheduler::Start(); |
|
355 |
||
356 |
/*call export */ |
|
357 |
icontactservice->ExportVCardL(icallback,2,string1,*contactid); |
|
358 |
CActiveScheduler::Start(); |
|
359 |
||
360 |
/* verify whther export returns the expected error */ |
|
361 |
aItem.GetNextInt(flag) ; |
|
362 |
if(icallback->iError) |
|
363 |
return KErrNone; |
|
364 |
||
365 |
||
366 |
return KErrGeneral; |
|
367 |
||
368 |
||
369 |
||
370 |
} |
|
371 |
||
372 |
/*Exporting single contact to a file with existing filename */ |
|
373 |
TInt Cteximport::Export_Test4L( CStifItemParser& aItem ) |
|
374 |
{ |
|
375 |
||
376 |
// Print to UI |
|
377 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
378 |
_LIT( KExample, "In Import_InvL" ); |
|
379 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
380 |
// Print to log file |
|
381 |
iLog->Log( KExample ); |
|
382 |
||
383 |
||
384 |
TPtrC String; |
|
385 |
||
386 |
// TPtrC db1(_L("cntdb://c:testcontacts2.cdb")); |
|
387 |
||
388 |
/* get the filename for export */ |
|
389 |
if(aItem.GetNextString(String) != KErrNone ) |
|
390 |
{ |
|
391 |
_LIT(Kerr ,"Failed to read input file name") ; |
|
392 |
iLog->Log(Kerr) ; |
|
393 |
return KErrGeneral ; |
|
394 |
} |
|
395 |
||
396 |
TBuf<256> string1; |
|
397 |
string1.Copy(String); |
|
398 |
||
399 |
||
400 |
TInt flag=0,cnt=0; |
|
401 |
||
402 |
_LIT8(KFirstName,"FirstName"); |
|
403 |
_LIT(KName,"Nokia"); |
|
404 |
//instantiate service class object |
|
405 |
||
406 |
/* create contactitem to add */ |
|
407 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
408 |
CSingleContactField* singleContactField = CSingleContactField::NewL(); |
|
409 |
||
410 |
||
411 |
singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
412 |
singleContact->AddFieldToContactL(singleContactField); |
|
413 |
||
414 |
||
415 |
||
416 |
||
417 |
/* Add the contactitem */ |
|
418 |
icontactservice->AddL(icallback,0,singleContact); |
|
419 |
CActiveScheduler::Start(); |
|
420 |
||
421 |
/*call getlist to get the contactid for export */ |
|
422 |
icontactservice->GetListL(icallback,1,EContacts,KNullDesC8) ; |
|
423 |
CActiveScheduler::Start(); |
|
424 |
||
425 |
||
426 |
icontactservice->ExportVCardL(icallback,2,string1,*contactid); |
|
427 |
CActiveScheduler::Start(); |
|
428 |
||
429 |
icontactservice->ExportVCardL(icallback,2,string1,*contactid); |
|
430 |
CActiveScheduler::Start(); |
|
431 |
||
432 |
||
433 |
/* verify whther export returns the expected error */ |
|
434 |
aItem.GetNextInt(flag) ; |
|
435 |
if(icallback->iError==flag) |
|
436 |
return KErrNone; |
|
437 |
||
438 |
||
439 |
return KErrGeneral; |
|
440 |
||
441 |
||
442 |
} |
|
443 |
||
444 |
/* Negative testcase when the file name to be exported is not specified*/ |
|
445 |
||
446 |
TInt Cteximport::Export_Test5L( CStifItemParser& aItem ) |
|
447 |
{ |
|
448 |
||
449 |
// Print to UI |
|
450 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
451 |
_LIT( KExample, "In Import_InvL" ); |
|
452 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
453 |
// Print to log file |
|
454 |
iLog->Log( KExample ); |
|
455 |
||
456 |
TBuf<256> string2; |
|
457 |
||
458 |
TInt flag=0,cnt=0; |
|
459 |
||
460 |
/*call getlist to get the contactid for export */ |
|
461 |
icontactservice->GetListL(icallback,1,EContacts,KNullDesC8) ; |
|
462 |
CActiveScheduler::Start(); |
|
463 |
||
464 |
/*call export */ |
|
465 |
icontactservice->ExportVCardL(icallback,2,string2,*contactid); |
|
466 |
CActiveScheduler::Start(); |
|
467 |
||
468 |
||
469 |
/* verify whther export returns the expected error */ |
|
470 |
||
471 |
if(icallback->iError !=0) |
|
472 |
return KErrNone; |
|
473 |
||
474 |
||
475 |
return KErrGeneral; |
|
476 |
||
477 |
||
478 |
} |
|
479 |
||
480 |
/* exporting from a different database*/ |
|
481 |
||
482 |
TInt Cteximport::Export_Test6L( CStifItemParser& aItem ) |
|
483 |
{ |
|
484 |
||
485 |
// Print to UI |
|
486 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
487 |
_LIT( KExample, "In Import_InvL" ); |
|
488 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
489 |
// Print to log file |
|
490 |
iLog->Log( KExample ); |
|
491 |
||
492 |
TPtrC String; |
|
493 |
||
494 |
||
495 |
/* get the filename for export */ |
|
496 |
if(aItem.GetNextString(String) != KErrNone ) |
|
497 |
{ |
|
498 |
_LIT(Kerr ,"Failed to read input file name") ; |
|
499 |
iLog->Log(Kerr) ; |
|
500 |
return KErrGeneral ; |
|
501 |
} |
|
502 |
||
503 |
TBuf<256> string1; |
|
504 |
string1.Copy(String); |
|
505 |
||
506 |
TPtrC db1(_L("cntdb://c:temp.cdb")); |
|
507 |
TInt flag=0,cnt=0; |
|
508 |
||
509 |
_LIT8(KFirstName,"FirstName"); |
|
510 |
_LIT(KName,"Goat"); |
|
511 |
//instantiate service class object |
|
512 |
||
513 |
/* create contactitem to add */ |
|
514 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
515 |
CSingleContactField* singleContactField = CSingleContactField::NewL(); |
|
516 |
||
517 |
||
518 |
singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
519 |
singleContact->AddFieldToContactL(singleContactField); |
|
520 |
||
521 |
||
522 |
||
523 |
||
524 |
/* Add the contactitem */ |
|
525 |
icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KNullDesC,db1); |
|
526 |
CActiveScheduler::Start(); |
|
527 |
/*call getlist to get the contactid for export */ |
|
528 |
icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc,db1) ; |
|
529 |
CActiveScheduler::Start(); |
|
530 |
||
531 |
/*call export */ |
|
532 |
icontactservice->ExportVCardL(icallback,2,string1,*contactid,db1); |
|
533 |
CActiveScheduler::Start(); |
|
534 |
||
535 |
||
536 |
/* verify whther export returns the expected error */ |
|
537 |
aItem.GetNextInt(flag) ; |
|
538 |
if(icallback->iError == flag) |
|
539 |
return KErrNone; |
|
540 |
||
541 |
||
542 |
return KErrGeneral; |
|
543 |
||
544 |
||
545 |
} |
|
546 |
||
547 |
||
548 |
||
549 |
||
550 |
||
551 |
TInt Cteximport::Export_Test7L( CStifItemParser& aItem ) |
|
552 |
{ |
|
553 |
||
554 |
// Print to UI |
|
555 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
556 |
_LIT( KExample, "In Import_InvL" ); |
|
557 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
558 |
// Print to log file |
|
559 |
iLog->Log( KExample ); |
|
560 |
||
561 |
TPtrC String; |
|
562 |
||
563 |
||
564 |
/* get the filename for export */ |
|
565 |
if(aItem.GetNextString(String) != KErrNone ) |
|
566 |
{ |
|
567 |
_LIT(Kerr ,"Failed to read input file name") ; |
|
568 |
iLog->Log(Kerr) ; |
|
569 |
return KErrGeneral ; |
|
570 |
} |
|
571 |
||
572 |
TBuf<256> string1; |
|
573 |
string1.Copy(String); |
|
574 |
||
575 |
TPtrC db1(_L("cntdb://c:temp.cdb")); |
|
576 |
TInt flag=0,cnt=0; |
|
577 |
||
578 |
_LIT(KGroup,"Group10") ; |
|
579 |
||
580 |
||
581 |
/*Add group1 to phonebook */ |
|
582 |
icontactservice->AddL(icallback,0,NULL,KNullDesC8,KGroup); |
|
583 |
CActiveScheduler::Start(); |
|
584 |
||
585 |
/*call getlist to get the contactid for export */ |
|
586 |
icontactservice->GetListL(icallback,1,EGroups,KNullDesC8) ; |
|
587 |
CActiveScheduler::Start(); |
|
588 |
||
589 |
/*call export */ |
|
590 |
TInt err1; |
|
591 |
TRAP(err1,icontactservice->ExportVCardL(icallback,2,string1,*contactid)); |
|
592 |
if(!err1) |
|
593 |
CActiveScheduler::Start(); |
|
594 |
||
595 |
||
596 |
/* verify whther export returns the expected error */ |
|
597 |
aItem.GetNextInt(flag) ; |
|
598 |
if(!icallback->iError) |
|
599 |
return KErrNone; |
|
600 |
||
601 |
||
602 |
return KErrGeneral; |
|
603 |
||
604 |
||
605 |
} |
|
606 |
||
607 |
/* exporting of a database*/ |
|
608 |
||
609 |
TInt Cteximport::Export_Test8L( CStifItemParser& aItem ) |
|
610 |
{ |
|
611 |
||
612 |
// Print to UI |
|
613 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
614 |
_LIT( KExample, "In Import_InvL" ); |
|
615 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
616 |
// Print to log file |
|
617 |
iLog->Log( KExample ); |
|
618 |
||
619 |
TPtrC String; |
|
620 |
||
621 |
||
622 |
/* get the filename for export */ |
|
623 |
if(aItem.GetNextString(String) != KErrNone ) |
|
624 |
{ |
|
625 |
_LIT(Kerr ,"Failed to read input file name") ; |
|
626 |
iLog->Log(Kerr) ; |
|
627 |
return KErrGeneral ; |
|
628 |
} |
|
629 |
||
630 |
TBuf<256> string1; |
|
631 |
string1.Copy(String); |
|
632 |
||
633 |
TPtrC db1(_L("cntdb://c:temp.cdb")); |
|
634 |
TInt flag=0,cnt=0; |
|
635 |
||
636 |
||
637 |
/*call getlist to get the contactid for export */ |
|
638 |
int err; |
|
639 |
TRAP(err,icontactservice->GetListL(icallback,1,EDatabase,KNullDesC8)) ; |
|
640 |
if(err) |
|
641 |
return KErrNone; |
|
642 |
||
643 |
CActiveScheduler::Start(); |
|
644 |
||
645 |
/*call export */ |
|
646 |
icontactservice->ExportVCardL(icallback,2,string1,*contactid); |
|
647 |
CActiveScheduler::Start(); |
|
648 |
||
649 |
||
650 |
/* verify whther export returns the expected error */ |
|
651 |
aItem.GetNextInt(flag) ; |
|
652 |
if(icallback->iError == flag) |
|
653 |
return KErrNone; |
|
654 |
||
655 |
||
656 |
return KErrGeneral; |
|
657 |
||
658 |
||
659 |
} |
|
660 |
||
661 |
/* importing and exporting thumbnail */ |
|
662 |
//TInt Cteximport::Export_Test9L( CStifItemParser& aItem ) |
|
663 |
// { |
|
664 |
||
665 |
// _LIT(KCntDbUri, "cntdb://c:contacts.cdb"); |
|
666 |
// _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
667 |
// _LIT( KExample, "In Import_ValL" ); |
|
668 |
// TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
669 |
// // Print to log file |
|
670 |
// iLog->Log( KExample ); |
|
671 |
||
672 |
||
673 |
||
674 |
// TPtrC String; |
|
675 |
/* get the filename for import */ |
|
676 |
// if(aItem.GetNextString(String) != KErrNone ) |
|
677 |
// { |
|
678 |
// _LIT(Kerr , "Failed to read input file name"); |
|
679 |
// iLog->Log(Kerr) ; |
|
680 |
// return KErrGeneral ; |
|
681 |
// } |
|
682 |
||
683 |
||
684 |
// TBuf<256> string1; |
|
685 |
// string1.Copy(String); |
|
686 |
// TInt flag=0; |
|
687 |
||
688 |
/*call import */ |
|
689 |
// icontactservice->ImportVCardToStoreL(icallback,1,string1); |
|
690 |
// CActiveScheduler::Start(); |
|
691 |
||
692 |
// TBuf8<15> fstname(_L8("ThumbNailPic")); |
|
693 |
// CSearchFields *srchfield =CSearchFields :: NewL(icontactservice); |
|
694 |
// srchfield->AppendL(fstname); |
|
695 |
// icontactservice->GetListL(icallback,0,EContacts,KNullDesC8,KCntDbUri,KNullDesC,srchfield); |
|
696 |
// CActiveScheduler::Start(); |
|
697 |
||
698 |
||
699 |
/* get the filename for export */ |
|
700 |
// if(aItem.GetNextString(String) != KErrNone ) |
|
701 |
// { |
|
702 |
// _LIT(Kerr ,"Failed to read input file name") ; |
|
703 |
// iLog->Log(Kerr) ; |
|
704 |
// return KErrGeneral ; |
|
705 |
// } |
|
706 |
||
707 |
// string1.Copy(String); |
|
708 |
||
709 |
// icontactservice->ExportVCardL(icallback,1,string1,*contactid); |
|
710 |
// CActiveScheduler::Start(); |
|
711 |
||
712 |
// aItem.GetNextInt(flag) ; |
|
713 |
// if(icallback->iError == flag) |
|
714 |
// return KErrNone; |
|
715 |
||
716 |
||
717 |
// return KErrGeneral; |
|
718 |
||
719 |
||
720 |
||
721 |
// } |
|
722 |
||
723 |
||
724 |
// ----------------------------------------------------------------------------- |
|
725 |
// Cteximport::?member_function |
|
726 |
// ?implementation_description |
|
727 |
// (other items were commented in a header). |
|
728 |
// ----------------------------------------------------------------------------- |
|
729 |
// |
|
730 |
/* |
|
731 |
TInt Cteximport::?member_function( |
|
732 |
CItemParser& aItem ) |
|
733 |
{ |
|
734 |
||
735 |
?code |
|
736 |
||
737 |
} |
|
738 |
*/ |
|
739 |
||
740 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
741 |
// None |
|
742 |
||
743 |
// End of File |