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