author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 11 May 2010 17:01:36 +0300 | |
branch | RCL_3 |
changeset 58 | ea43c23d28d2 |
parent 33 | 50974a8b132e |
child 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> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
25 |
#include "tcontact_export.h" |
19 | 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; |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
80 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
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:
19
diff
changeset
|
82 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
83 |
CActiveScheduler::Stop(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
84 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
85 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
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:
19
diff
changeset
|
87 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
88 |
CActiveScheduler::Stop(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
89 |
} |
19 | 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 */ \ |
|
58
ea43c23d28d2
Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
200 |
TInt err1 = 0; |
ea43c23d28d2
Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
201 |
TInt err2 = 0; |
19 | 202 |
TRAP(err1,icontactservice->GetListL(icallback,1,EContacts,KNullDesC8)); |
203 |
CActiveScheduler::Start(); |
|
204 |
||
205 |
/*call export */ |
|
206 |
||
207 |
TRAP(err1,icontactservice->ExportVCardL(icallback,2,string1,KNullDesC8)); |
|
208 |
if(err1 || err2) |
|
209 |
return KErrNone; |
|
210 |
CActiveScheduler::Start(); |
|
211 |
||
212 |
||
213 |
/* verify whther export returns the expected error */ |
|
214 |
aItem.GetNextInt(flag) ; |
|
215 |
if(icallback->iError) |
|
58
ea43c23d28d2
Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
216 |
return KErrNone; |
19 | 217 |
if(icallback->iError == flag) |
58
ea43c23d28d2
Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
218 |
return KErrNone; |
19 | 219 |
|
58
ea43c23d28d2
Revision: 201016
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
220 |
return 0; |
19 | 221 |
} |
222 |
||
223 |
/* exporting 2 contacts */ |
|
224 |
TInt Cteximport::Export_Test2L( CStifItemParser& aItem ) |
|
225 |
{ |
|
226 |
||
227 |
// Print to UI |
|
228 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
229 |
_LIT( KExample, "In Import_InvL" ); |
|
230 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
231 |
// Print to log file |
|
232 |
iLog->Log( KExample ); |
|
233 |
||
234 |
||
235 |
TPtrC String; |
|
236 |
||
237 |
||
238 |
/* get the filename for export */ |
|
239 |
if(aItem.GetNextString(String) != KErrNone ) |
|
240 |
{ |
|
241 |
_LIT(Kerr , "Failed to read input file name") ; |
|
242 |
iLog->Log(Kerr) ; |
|
243 |
return KErrGeneral ; |
|
244 |
} |
|
245 |
||
246 |
TBuf<256> string1,string2,string3; |
|
247 |
string1.Copy(String); |
|
248 |
||
249 |
if(aItem.GetNextString(String) != KErrNone ) |
|
250 |
{ |
|
251 |
_LIT(Kerr , "Failed to read input file name") ; |
|
252 |
iLog->Log(Kerr) ; |
|
253 |
return KErrGeneral ; |
|
254 |
} |
|
255 |
||
256 |
string2.Copy(String); |
|
257 |
||
258 |
if(aItem.GetNextString(String) != KErrNone ) |
|
259 |
{ |
|
260 |
_LIT(Kerr , "Failed to read input file name") ; |
|
261 |
iLog->Log(Kerr) ; |
|
262 |
return KErrGeneral ; |
|
263 |
} |
|
264 |
||
265 |
string3.Copy(String); |
|
266 |
TInt flag=0,cnt=0; |
|
267 |
||
268 |
||
269 |
icontactservice->ImportVCardToStoreL(icallback,1,string3); |
|
270 |
CActiveScheduler::Start(); |
|
271 |
||
272 |
/*call getlist to get the contactid for export */ |
|
273 |
icontactservice->GetListL(icallback,1,EContacts) ; |
|
274 |
CActiveScheduler::Start(); |
|
275 |
||
276 |
/*call export */ |
|
277 |
icontactservice->ExportVCardL(icallback,1,string1,*contactid); |
|
278 |
CActiveScheduler::Start(); |
|
279 |
||
280 |
icontactservice->ExportVCardL(icallback,2,string2,*contactid); |
|
281 |
CActiveScheduler::Start(); |
|
282 |
||
283 |
||
284 |
/* verify whther export returns the expected error */ |
|
285 |
aItem.GetNextInt(flag) ; |
|
286 |
if(icallback->iError == flag) |
|
287 |
return KErrNone; |
|
288 |
||
289 |
return KErrGeneral; |
|
290 |
||
291 |
||
292 |
} |
|
293 |
||
294 |
||
295 |
/* exporting non existent contact */ |
|
296 |
TInt Cteximport::Export_Test3L( CStifItemParser& aItem ) |
|
297 |
{ |
|
298 |
||
299 |
// Print to UI |
|
300 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
301 |
_LIT( KExample, "In Import_InvL" ); |
|
302 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
303 |
// Print to log file |
|
304 |
iLog->Log( KExample ); |
|
305 |
||
306 |
||
307 |
TPtrC String; |
|
308 |
||
309 |
||
310 |
||
311 |
/* get the filename for export */ |
|
312 |
if(aItem.GetNextString(String) != KErrNone ) |
|
313 |
{ |
|
314 |
_LIT(Kerr , "Failed to read input file name") ; |
|
315 |
iLog->Log(Kerr) ; |
|
316 |
return KErrGeneral ; |
|
317 |
} |
|
318 |
||
319 |
TBuf<256> string1; |
|
320 |
string1.Copy(String); |
|
321 |
||
322 |
||
323 |
TInt flag=0,cnt=0; |
|
324 |
||
325 |
||
326 |
_LIT8(KFirstName,"FirstName"); |
|
327 |
_LIT(KName,"Goat"); |
|
328 |
//instantiate service class object |
|
329 |
||
330 |
/* create contactitem to add */ |
|
331 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
332 |
CSingleContactField* singleContactField = CSingleContactField::NewL(); |
|
333 |
||
334 |
||
335 |
singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
336 |
singleContact->AddFieldToContactL(singleContactField); |
|
337 |
||
338 |
||
339 |
||
340 |
||
341 |
/* Add the contactitem */ |
|
342 |
icontactservice->AddL(icallback,0,singleContact); |
|
343 |
CActiveScheduler::Start(); |
|
344 |
||
345 |
||
346 |
/*call getlist to get the contactid for export */ |
|
347 |
icontactservice->GetListL(icallback,1,EContacts) ; |
|
348 |
CActiveScheduler::Start(); |
|
349 |
||
350 |
||
351 |
RPointerArray<TDesC8> ptr ; //= new (ELeave) CArrayFixFlat<TDesC8>(1); |
|
352 |
ptr.Append(contactid); |
|
353 |
||
354 |
icontactservice->DeleteL(icallback,2,ptr); |
|
355 |
||
356 |
CActiveScheduler::Start(); |
|
357 |
||
358 |
/*call export */ |
|
359 |
icontactservice->ExportVCardL(icallback,2,string1,*contactid); |
|
360 |
CActiveScheduler::Start(); |
|
361 |
||
362 |
/* verify whther export returns the expected error */ |
|
363 |
aItem.GetNextInt(flag) ; |
|
364 |
if(icallback->iError) |
|
365 |
return KErrNone; |
|
366 |
||
367 |
||
368 |
return KErrGeneral; |
|
369 |
||
370 |
||
371 |
||
372 |
} |
|
373 |
||
374 |
/*Exporting single contact to a file with existing filename */ |
|
375 |
TInt Cteximport::Export_Test4L( CStifItemParser& aItem ) |
|
376 |
{ |
|
377 |
||
378 |
// Print to UI |
|
379 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
380 |
_LIT( KExample, "In Import_InvL" ); |
|
381 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
382 |
// Print to log file |
|
383 |
iLog->Log( KExample ); |
|
384 |
||
385 |
||
386 |
TPtrC String; |
|
387 |
||
388 |
// TPtrC db1(_L("cntdb://c:testcontacts2.cdb")); |
|
389 |
||
390 |
/* get the filename for export */ |
|
391 |
if(aItem.GetNextString(String) != KErrNone ) |
|
392 |
{ |
|
393 |
_LIT(Kerr ,"Failed to read input file name") ; |
|
394 |
iLog->Log(Kerr) ; |
|
395 |
return KErrGeneral ; |
|
396 |
} |
|
397 |
||
398 |
TBuf<256> string1; |
|
399 |
string1.Copy(String); |
|
400 |
||
401 |
||
402 |
TInt flag=0,cnt=0; |
|
403 |
||
404 |
_LIT8(KFirstName,"FirstName"); |
|
405 |
_LIT(KName,"Nokia"); |
|
406 |
//instantiate service class object |
|
407 |
||
408 |
/* create contactitem to add */ |
|
409 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
410 |
CSingleContactField* singleContactField = CSingleContactField::NewL(); |
|
411 |
||
412 |
||
413 |
singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
414 |
singleContact->AddFieldToContactL(singleContactField); |
|
415 |
||
416 |
||
417 |
||
418 |
||
419 |
/* Add the contactitem */ |
|
420 |
icontactservice->AddL(icallback,0,singleContact); |
|
421 |
CActiveScheduler::Start(); |
|
422 |
||
423 |
/*call getlist to get the contactid for export */ |
|
424 |
icontactservice->GetListL(icallback,1,EContacts,KNullDesC8) ; |
|
425 |
CActiveScheduler::Start(); |
|
426 |
||
427 |
||
428 |
icontactservice->ExportVCardL(icallback,2,string1,*contactid); |
|
429 |
CActiveScheduler::Start(); |
|
430 |
||
431 |
icontactservice->ExportVCardL(icallback,2,string1,*contactid); |
|
432 |
CActiveScheduler::Start(); |
|
433 |
||
434 |
||
435 |
/* verify whther export returns the expected error */ |
|
436 |
aItem.GetNextInt(flag) ; |
|
437 |
if(icallback->iError==flag) |
|
438 |
return KErrNone; |
|
439 |
||
440 |
||
441 |
return KErrGeneral; |
|
442 |
||
443 |
||
444 |
} |
|
445 |
||
446 |
/* Negative testcase when the file name to be exported is not specified*/ |
|
447 |
||
448 |
TInt Cteximport::Export_Test5L( CStifItemParser& aItem ) |
|
449 |
{ |
|
450 |
||
451 |
// Print to UI |
|
452 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
453 |
_LIT( KExample, "In Import_InvL" ); |
|
454 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
455 |
// Print to log file |
|
456 |
iLog->Log( KExample ); |
|
457 |
||
458 |
TBuf<256> string2; |
|
459 |
||
460 |
TInt flag=0,cnt=0; |
|
461 |
||
462 |
/*call getlist to get the contactid for export */ |
|
463 |
icontactservice->GetListL(icallback,1,EContacts,KNullDesC8) ; |
|
464 |
CActiveScheduler::Start(); |
|
465 |
||
466 |
/*call export */ |
|
467 |
icontactservice->ExportVCardL(icallback,2,string2,*contactid); |
|
468 |
CActiveScheduler::Start(); |
|
469 |
||
470 |
||
471 |
/* verify whther export returns the expected error */ |
|
472 |
||
473 |
if(icallback->iError !=0) |
|
474 |
return KErrNone; |
|
475 |
||
476 |
||
477 |
return KErrGeneral; |
|
478 |
||
479 |
||
480 |
} |
|
481 |
||
482 |
/* exporting from a different database*/ |
|
483 |
||
484 |
TInt Cteximport::Export_Test6L( CStifItemParser& aItem ) |
|
485 |
{ |
|
486 |
||
487 |
// Print to UI |
|
488 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
489 |
_LIT( KExample, "In Import_InvL" ); |
|
490 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
491 |
// Print to log file |
|
492 |
iLog->Log( KExample ); |
|
493 |
||
494 |
TPtrC String; |
|
495 |
||
496 |
||
497 |
/* get the filename for export */ |
|
498 |
if(aItem.GetNextString(String) != KErrNone ) |
|
499 |
{ |
|
500 |
_LIT(Kerr ,"Failed to read input file name") ; |
|
501 |
iLog->Log(Kerr) ; |
|
502 |
return KErrGeneral ; |
|
503 |
} |
|
504 |
||
505 |
TBuf<256> string1; |
|
506 |
string1.Copy(String); |
|
507 |
||
508 |
TPtrC db1(_L("cntdb://c:temp.cdb")); |
|
509 |
TInt flag=0,cnt=0; |
|
510 |
||
511 |
_LIT8(KFirstName,"FirstName"); |
|
512 |
_LIT(KName,"Goat"); |
|
513 |
//instantiate service class object |
|
514 |
||
515 |
/* create contactitem to add */ |
|
516 |
CSingleContact* singleContact = CSingleContact::NewL(); |
|
517 |
CSingleContactField* singleContactField = CSingleContactField::NewL(); |
|
518 |
||
519 |
||
520 |
singleContactField->SetFieldParamsL(KFirstName,KNullDesC,KName); |
|
521 |
singleContact->AddFieldToContactL(singleContactField); |
|
522 |
||
523 |
||
524 |
||
525 |
||
526 |
/* Add the contactitem */ |
|
527 |
icontactservice->AddL(icallback,0,singleContact,KNullDesC8,KNullDesC,db1); |
|
528 |
CActiveScheduler::Start(); |
|
529 |
/*call getlist to get the contactid for export */ |
|
530 |
icontactservice->GetListL(icallback,1,EContacts,KNullDesC8,KNullDesC,NULL,EAsc,db1) ; |
|
531 |
CActiveScheduler::Start(); |
|
532 |
||
533 |
/*call export */ |
|
534 |
icontactservice->ExportVCardL(icallback,2,string1,*contactid,db1); |
|
535 |
CActiveScheduler::Start(); |
|
536 |
||
537 |
||
538 |
/* verify whther export returns the expected error */ |
|
539 |
aItem.GetNextInt(flag) ; |
|
540 |
if(icallback->iError == flag) |
|
541 |
return KErrNone; |
|
542 |
||
543 |
||
544 |
return KErrGeneral; |
|
545 |
||
546 |
||
547 |
} |
|
548 |
||
549 |
||
550 |
||
551 |
||
552 |
||
553 |
TInt Cteximport::Export_Test7L( CStifItemParser& aItem ) |
|
554 |
{ |
|
555 |
||
556 |
// Print to UI |
|
557 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
558 |
_LIT( KExample, "In Import_InvL" ); |
|
559 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
560 |
// Print to log file |
|
561 |
iLog->Log( KExample ); |
|
562 |
||
563 |
TPtrC String; |
|
564 |
||
565 |
||
566 |
/* get the filename for export */ |
|
567 |
if(aItem.GetNextString(String) != KErrNone ) |
|
568 |
{ |
|
569 |
_LIT(Kerr ,"Failed to read input file name") ; |
|
570 |
iLog->Log(Kerr) ; |
|
571 |
return KErrGeneral ; |
|
572 |
} |
|
573 |
||
574 |
TBuf<256> string1; |
|
575 |
string1.Copy(String); |
|
576 |
||
577 |
TPtrC db1(_L("cntdb://c:temp.cdb")); |
|
578 |
TInt flag=0,cnt=0; |
|
579 |
||
580 |
_LIT(KGroup,"Group10") ; |
|
581 |
||
582 |
||
583 |
/*Add group1 to phonebook */ |
|
584 |
icontactservice->AddL(icallback,0,NULL,KNullDesC8,KGroup); |
|
585 |
CActiveScheduler::Start(); |
|
586 |
||
587 |
/*call getlist to get the contactid for export */ |
|
588 |
icontactservice->GetListL(icallback,1,EGroups,KNullDesC8) ; |
|
589 |
CActiveScheduler::Start(); |
|
590 |
||
591 |
/*call export */ |
|
592 |
TInt err1; |
|
593 |
TRAP(err1,icontactservice->ExportVCardL(icallback,2,string1,*contactid)); |
|
594 |
if(!err1) |
|
595 |
CActiveScheduler::Start(); |
|
596 |
||
597 |
||
598 |
/* verify whther export returns the expected error */ |
|
599 |
aItem.GetNextInt(flag) ; |
|
600 |
if(!icallback->iError) |
|
601 |
return KErrNone; |
|
602 |
||
603 |
||
604 |
return KErrGeneral; |
|
605 |
||
606 |
||
607 |
} |
|
608 |
||
609 |
/* exporting of a database*/ |
|
610 |
||
611 |
TInt Cteximport::Export_Test8L( CStifItemParser& aItem ) |
|
612 |
{ |
|
613 |
||
614 |
// Print to UI |
|
615 |
_LIT( Ktsapicontacts, "tsapicontacts" ); |
|
616 |
_LIT( KExample, "In Import_InvL" ); |
|
617 |
TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
618 |
// Print to log file |
|
619 |
iLog->Log( KExample ); |
|
620 |
||
621 |
TPtrC String; |
|
622 |
||
623 |
||
624 |
/* get the filename for export */ |
|
625 |
if(aItem.GetNextString(String) != KErrNone ) |
|
626 |
{ |
|
627 |
_LIT(Kerr ,"Failed to read input file name") ; |
|
628 |
iLog->Log(Kerr) ; |
|
629 |
return KErrGeneral ; |
|
630 |
} |
|
631 |
||
632 |
TBuf<256> string1; |
|
633 |
string1.Copy(String); |
|
634 |
||
635 |
TPtrC db1(_L("cntdb://c:temp.cdb")); |
|
636 |
TInt flag=0,cnt=0; |
|
637 |
||
638 |
||
639 |
/*call getlist to get the contactid for export */ |
|
640 |
int err; |
|
641 |
TRAP(err,icontactservice->GetListL(icallback,1,EDatabase,KNullDesC8)) ; |
|
642 |
if(err) |
|
643 |
return KErrNone; |
|
644 |
||
645 |
CActiveScheduler::Start(); |
|
646 |
||
647 |
/*call export */ |
|
648 |
icontactservice->ExportVCardL(icallback,2,string1,*contactid); |
|
649 |
CActiveScheduler::Start(); |
|
650 |
||
651 |
||
652 |
/* verify whther export returns the expected error */ |
|
653 |
aItem.GetNextInt(flag) ; |
|
654 |
if(icallback->iError == flag) |
|
655 |
return KErrNone; |
|
656 |
||
657 |
||
658 |
return KErrGeneral; |
|
659 |
||
660 |
||
661 |
} |
|
662 |
||
663 |
/* importing and exporting thumbnail */ |
|
664 |
//TInt Cteximport::Export_Test9L( CStifItemParser& aItem ) |
|
665 |
// { |
|
666 |
||
667 |
// _LIT(KCntDbUri, "cntdb://c:contacts.cdb"); |
|
668 |
// _LIT( Ktsapicontacts, "tsapicontacts" ); |
|
669 |
// _LIT( KExample, "In Import_ValL" ); |
|
670 |
// TestModuleIf().Printf( 0, Ktsapicontacts, KExample ); |
|
671 |
// // Print to log file |
|
672 |
// iLog->Log( KExample ); |
|
673 |
||
674 |
||
675 |
||
676 |
// TPtrC String; |
|
677 |
/* get the filename for import */ |
|
678 |
// if(aItem.GetNextString(String) != KErrNone ) |
|
679 |
// { |
|
680 |
// _LIT(Kerr , "Failed to read input file name"); |
|
681 |
// iLog->Log(Kerr) ; |
|
682 |
// return KErrGeneral ; |
|
683 |
// } |
|
684 |
||
685 |
||
686 |
// TBuf<256> string1; |
|
687 |
// string1.Copy(String); |
|
688 |
// TInt flag=0; |
|
689 |
||
690 |
/*call import */ |
|
691 |
// icontactservice->ImportVCardToStoreL(icallback,1,string1); |
|
692 |
// CActiveScheduler::Start(); |
|
693 |
||
694 |
// TBuf8<15> fstname(_L8("ThumbNailPic")); |
|
695 |
// CSearchFields *srchfield =CSearchFields :: NewL(icontactservice); |
|
696 |
// srchfield->AppendL(fstname); |
|
697 |
// icontactservice->GetListL(icallback,0,EContacts,KNullDesC8,KCntDbUri,KNullDesC,srchfield); |
|
698 |
// CActiveScheduler::Start(); |
|
699 |
||
700 |
||
701 |
/* get the filename for export */ |
|
702 |
// if(aItem.GetNextString(String) != KErrNone ) |
|
703 |
// { |
|
704 |
// _LIT(Kerr ,"Failed to read input file name") ; |
|
705 |
// iLog->Log(Kerr) ; |
|
706 |
// return KErrGeneral ; |
|
707 |
// } |
|
708 |
||
709 |
// string1.Copy(String); |
|
710 |
||
711 |
// icontactservice->ExportVCardL(icallback,1,string1,*contactid); |
|
712 |
// CActiveScheduler::Start(); |
|
713 |
||
714 |
// aItem.GetNextInt(flag) ; |
|
715 |
// if(icallback->iError == flag) |
|
716 |
// return KErrNone; |
|
717 |
||
718 |
||
719 |
// return KErrGeneral; |
|
720 |
||
721 |
||
722 |
||
723 |
// } |
|
724 |
||
725 |
||
726 |
// ----------------------------------------------------------------------------- |
|
727 |
// Cteximport::?member_function |
|
728 |
// ?implementation_description |
|
729 |
// (other items were commented in a header). |
|
730 |
// ----------------------------------------------------------------------------- |
|
731 |
// |
|
732 |
/* |
|
733 |
TInt Cteximport::?member_function( |
|
734 |
CItemParser& aItem ) |
|
735 |
{ |
|
736 |
||
737 |
?code |
|
738 |
||
739 |
} |
|
740 |
*/ |
|
741 |
||
742 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
743 |
// None |
|
744 |
||
745 |
// End of File |