author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2002 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 <SAPI_TEST\testprg.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
25 |
#include <StifTestInterface.h> |
19 | 26 |
|
27 |
#include <badesca.h> |
|
28 |
||
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
29 |
#include<liwservicehandler.h> |
19 | 30 |
|
31 |
#include "tcalendarexporttest.h" |
|
32 |
#include "teststartconsolealarmserver2.h" |
|
33 |
TDesC& GetEntry(MLiwInterface* interface, CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, TPtrC globaluid, const TDesC& calname); |
|
34 |
_LIT(KCalNameExportTestDirect, "ExportTothisatProvider"); |
|
35 |
TInt AddProvAppointmentDailyRepeat(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUIDSet*& uidset); |
|
36 |
||
37 |
class CCalCallback : public MLiwNotifyCallback |
|
38 |
{ |
|
39 |
public: |
|
40 |
||
41 |
static CCalCallback* NewL(CActiveSchedulerWait* aWaitSchedular, TInt& aResult ); |
|
42 |
||
43 |
virtual ~CCalCallback(){} |
|
44 |
||
45 |
TInt HandleNotifyL(TInt aCmdId, |
|
46 |
TInt aEventId, |
|
47 |
CLiwGenericParamList& aEventParamList, |
|
48 |
const CLiwGenericParamList& aInParamList); |
|
49 |
TInt iEntryAdded; |
|
50 |
||
51 |
private: |
|
52 |
||
53 |
CCalCallback(CActiveSchedulerWait* aWaitSchedular, TInt& aResult ):iWaitSchedular(aWaitSchedular), iResult(aResult){ } |
|
54 |
||
55 |
CActiveSchedulerWait* iWaitSchedular; |
|
56 |
TInt& iResult; |
|
57 |
||
58 |
||
59 |
}; |
|
60 |
||
61 |
class CTestAsync : public CActive |
|
62 |
{ |
|
63 |
public: |
|
64 |
static CTestAsync* NewL(); |
|
65 |
~CTestAsync(); |
|
66 |
void Start(TInt flag, TInt option, TBool aICalFormat = EFalse, TBool aAsync = EFalse, TBool aPosBased = EFalse, TBool aInvalidFormat = EFalse); |
|
67 |
void CancelNotification(); |
|
68 |
||
69 |
TInt Result(); |
|
70 |
||
71 |
private: |
|
72 |
void ConstructL(); |
|
73 |
CTestAsync(); |
|
74 |
||
75 |
virtual void DoCancel(); |
|
76 |
virtual void RunL(); |
|
77 |
||
78 |
void TestFunc(); |
|
79 |
||
80 |
||
81 |
private: |
|
82 |
CLiwServiceHandler* iServiceHandler; |
|
83 |
CActiveSchedulerWait* iWaitSchedular; |
|
84 |
TInt iResult; |
|
85 |
TInt iEntryAdded; |
|
86 |
CCalCallback* iCallback; |
|
87 |
MLiwInterface* interface; |
|
88 |
TInt32 iTransactionId; |
|
89 |
TBool iICalFormat; |
|
90 |
TBool iAsync; |
|
91 |
TInt iOption; |
|
92 |
TInt iFunc; |
|
93 |
TBool iPosBased; |
|
94 |
TBool iInvalidFormat; |
|
95 |
}; |
|
96 |
||
97 |
_LIT8(KTestInterface, "IDataSource"); |
|
98 |
_LIT8(KTestContent, "Service.Calendar"); |
|
99 |
_LIT8(KCmd, "RequestNotification"); |
|
100 |
||
101 |
||
102 |
_LIT(KEntryTypeMeeting, "Meeting"); |
|
103 |
_LIT(KCalTestImportSync1, "C:CalendarExportFile1"); |
|
104 |
_LIT(KCalTestImportSync2, "C:CalendarExportFile2"); |
|
105 |
||
106 |
TInt RemoveProvCalendar(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar); |
|
107 |
TInt AddProvCalendar(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar); |
|
108 |
TInt AddProvAppointmentDailyRepeat(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUint& localuid); |
|
109 |
||
110 |
// ============================ MEMBER FUNCTIONS =============================== |
|
111 |
||
112 |
// ----------------------------------------------------------------------------- |
|
113 |
// CTChangeStatusTest::Delete |
|
114 |
// Delete here all resources allocated and opened from test methods. |
|
115 |
// Called from destructor. |
|
116 |
// ----------------------------------------------------------------------------- |
|
117 |
// |
|
118 |
void CTCalendarExportTest::Delete() |
|
119 |
{ |
|
120 |
||
121 |
} |
|
122 |
||
123 |
// ----------------------------------------------------------------------------- |
|
124 |
// CTChangeStatusTest::RunMethodL |
|
125 |
// Run specified method. Contains also table of test mothods and their names. |
|
126 |
// ----------------------------------------------------------------------------- |
|
127 |
// |
|
128 |
TInt CTCalendarExportTest::RunMethodL( |
|
129 |
CStifItemParser& aItem ) |
|
130 |
{ |
|
131 |
||
132 |
static TStifFunctionInfo const KFunctions[] = |
|
133 |
{ |
|
134 |
// Copy this line for every implemented function. |
|
135 |
// First string is the function name used in TestScripter script file. |
|
136 |
// Second is the actual implementation member function. |
|
137 |
//TRY( "SendMessage", CTDeleteMessageTest::SendMessage ), |
|
138 |
||
139 |
ENTRY( "ExportAllProviderIter3", CTCalendarExportTest::ExportAll ), |
|
140 |
ENTRY( "ExportProviderIter3InvalidFormat", CTCalendarExportTest::ExportProviderIter3InvalidFormat ), |
|
141 |
ENTRY( "ExportAllProviderIter3PosBased", CTCalendarExportTest::ExportAllPosBased ), |
|
142 |
ENTRY( "ExportAllAsyncProviderIter3", CTCalendarExportTest::ExportAllAsync ), |
|
143 |
ENTRY( "ExportForGuidsProviderIter3", CTCalendarExportTest::ExportForGuids ), |
|
144 |
ENTRY( "ExportForGuidsAsyncProviderIter3", CTCalendarExportTest::ExportForGuidsAsync ), |
|
145 |
ENTRY( "ExportForLuidsProviderIter3", CTCalendarExportTest::ExportForLuids ), |
|
146 |
ENTRY( "ExportForLuidsAsyncProviderIter3", CTCalendarExportTest::ExportForLuidsAsync ), |
|
147 |
ENTRY( "ICALExportProviderIter3", CTCalendarExportTest::ICALExport ), |
|
148 |
ENTRY( "ICALExportAsyncProviderIter3", CTCalendarExportTest::ICALExportAsync ), |
|
149 |
ENTRY( "ExportAllProviderFileIter3", CTCalendarExportTest::ExportAllFile ), |
|
150 |
ENTRY( "ExportAllAsyncProviderFileIter3", CTCalendarExportTest::ExportAllAsyncFile ), |
|
151 |
ENTRY( "ExportForGuidsProviderFileIter3", CTCalendarExportTest::ExportForGuidsFile ), |
|
152 |
ENTRY( "ExportForGuidsAsyncProviderFileIter3", CTCalendarExportTest::ExportForGuidsAsyncFile ), |
|
153 |
ENTRY( "ExportForLuidsProviderFileIter3", CTCalendarExportTest::ExportForLuidsFile ), |
|
154 |
ENTRY( "ExportForLuidsAsyncProviderFileIter3", CTCalendarExportTest::ExportForLuidsAsyncFile ), |
|
155 |
ENTRY( "ICALExportProviderFileIter3", CTCalendarExportTest::ICALExportFile ), |
|
156 |
ENTRY( "ICALExportAsyncProviderFileIter3", CTCalendarExportTest::ICALExportAsyncFile ), |
|
157 |
||
158 |
}; |
|
159 |
||
160 |
const TInt count = sizeof( KFunctions ) / |
|
161 |
sizeof( TStifFunctionInfo ); |
|
162 |
||
163 |
return RunInternalL( KFunctions, count, aItem ); |
|
164 |
||
165 |
} |
|
166 |
||
167 |
CCalCallback* CCalCallback::NewL(CActiveSchedulerWait* aWaitSchedular, TInt& aResult) |
|
168 |
{ |
|
169 |
return new (ELeave) CCalCallback(aWaitSchedular, aResult); |
|
170 |
} |
|
171 |
||
172 |
TInt CCalCallback::HandleNotifyL(TInt aCmdId, |
|
173 |
TInt aEventId, |
|
174 |
CLiwGenericParamList& aEventParamList, |
|
175 |
const CLiwGenericParamList& aInParamList) |
|
176 |
{ |
|
177 |
TInt pos = 0; |
|
178 |
TInt result = KErrNone; |
|
179 |
const TLiwGenericParam* output = aEventParamList.FindFirst( pos,_L8("ReturnValue")); |
|
180 |
||
181 |
if(output) |
|
182 |
{ |
|
183 |
CLiwIterable* iterlist = output->Value().AsIterable(); |
|
184 |
||
185 |
TInt returnItems = 0; |
|
186 |
||
187 |
if(iterlist) |
|
188 |
{ |
|
189 |
TLiwVariant data; |
|
190 |
||
191 |
while ( iterlist->NextL(data) ) |
|
192 |
returnItems++; |
|
193 |
||
194 |
data.Reset(); |
|
195 |
} |
|
196 |
||
197 |
if(iEntryAdded == returnItems) |
|
198 |
iResult = KErrNone; |
|
199 |
else |
|
200 |
iResult = KErrGeneral; |
|
201 |
} |
|
202 |
||
203 |
if ( iWaitSchedular && iWaitSchedular->IsStarted()) |
|
204 |
{ |
|
205 |
iWaitSchedular->AsyncStop(); |
|
206 |
} |
|
207 |
return 0; |
|
208 |
} |
|
209 |
||
210 |
CTestAsync* CTestAsync::NewL() |
|
211 |
{ |
|
212 |
CTestAsync* self = new (ELeave) CTestAsync(); |
|
213 |
self->ConstructL(); |
|
214 |
return self; |
|
215 |
} |
|
216 |
||
217 |
CTestAsync::~CTestAsync() |
|
218 |
{ |
|
219 |
Cancel(); |
|
220 |
||
221 |
interface->Close(); |
|
222 |
||
223 |
delete iServiceHandler; |
|
224 |
||
225 |
delete iCallback; |
|
226 |
||
227 |
if(iWaitSchedular->IsStarted()) |
|
228 |
iWaitSchedular->AsyncStop(); |
|
229 |
||
230 |
delete iWaitSchedular; |
|
231 |
} |
|
232 |
||
233 |
||
234 |
void CTestAsync::ConstructL() |
|
235 |
{ |
|
236 |
CActiveScheduler::Add(this); |
|
237 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
238 |
} |
|
239 |
||
240 |
||
241 |
CTestAsync::CTestAsync() : |
|
242 |
CActive(EPriorityStandard) |
|
243 |
{ |
|
244 |
interface = NULL ; |
|
245 |
iResult = KErrGeneral; |
|
246 |
} |
|
247 |
||
248 |
void CTestAsync::DoCancel() |
|
249 |
{ |
|
250 |
||
251 |
} |
|
252 |
||
253 |
void CTestAsync::RunL() |
|
254 |
{ |
|
255 |
TestFunc(); |
|
256 |
} |
|
257 |
||
258 |
TInt CTestAsync::Result() |
|
259 |
{ |
|
260 |
return iResult; |
|
261 |
} |
|
262 |
||
263 |
void CTestAsync::Start(TInt flag, TInt option, TBool aICalFormat, TBool aAsync, TBool aPosBased, TBool aInvalidFormat) |
|
264 |
{ |
|
265 |
iICalFormat = aICalFormat; |
|
266 |
iAsync = aAsync; |
|
267 |
iOption = flag; |
|
268 |
iFunc = option; |
|
269 |
iPosBased = aPosBased; |
|
270 |
iInvalidFormat = aInvalidFormat; |
|
271 |
if( iAsync ) |
|
272 |
{ |
|
273 |
SetActive(); |
|
274 |
TRequestStatus* temp = &iStatus; |
|
275 |
User::RequestComplete(temp, KErrNone); |
|
276 |
iWaitSchedular->Start(); |
|
277 |
} |
|
278 |
else |
|
279 |
{ |
|
280 |
TestFunc(); |
|
281 |
} |
|
282 |
} |
|
283 |
||
284 |
void CTestAsync::CancelNotification() |
|
285 |
{ |
|
286 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
287 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
288 |
||
289 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
290 |
CleanupStack::PushL(map); |
|
291 |
||
292 |
TLiwGenericParam element1; |
|
293 |
element1.SetNameAndValueL(_L8("Type"),TLiwVariant(_L("CalendarEntry"))); |
|
294 |
inparam->AppendL(element1); |
|
295 |
element1.Reset(); |
|
296 |
||
297 |
TLiwGenericParam element2; |
|
298 |
element2.SetNameAndValueL(_L8("TransactionID"), TLiwVariant(iTransactionId)); |
|
299 |
inparam->AppendL(element2); |
|
300 |
element2.Reset(); |
|
301 |
||
302 |
||
303 |
TLiwVariant filterparam(map); |
|
304 |
TLiwGenericParam element ; |
|
305 |
element.SetNameAndValueL(_L8("Item"),filterparam); |
|
306 |
filterparam.Reset(); |
|
307 |
||
308 |
inparam->AppendL(element); |
|
309 |
element.Reset(); |
|
310 |
map->DecRef(); |
|
311 |
CleanupStack::Pop(map); |
|
312 |
||
313 |
TRAPD(err1, interface->ExecuteCmdL(KCmdCancel, *inparam, *outparam, KLiwOptCancel )); |
|
314 |
inparam->Reset(); |
|
315 |
outparam->Reset(); |
|
316 |
} |
|
317 |
||
318 |
TInt CTCalendarExportTest::ExportAll(CStifItemParser& /*aItem*/) |
|
319 |
{ |
|
320 |
TInt result=KErrNone; |
|
321 |
||
322 |
if( result == KErrNone ) |
|
323 |
{ |
|
324 |
__UHEAP_MARK; |
|
325 |
CTestAsync* test = CTestAsync::NewL(); |
|
326 |
int flag = 0; |
|
327 |
int option = 1; |
|
328 |
test->Start(flag, option, EFalse ); |
|
329 |
result = test->Result(); |
|
330 |
delete test; |
|
331 |
__UHEAP_MARKEND; |
|
332 |
} |
|
333 |
return result; |
|
334 |
} |
|
335 |
||
336 |
TInt CTCalendarExportTest::ExportProviderIter3InvalidFormat(CStifItemParser& /*aItem*/) |
|
337 |
{ |
|
338 |
TInt result=KErrNone; |
|
339 |
||
340 |
{ |
|
341 |
__UHEAP_MARK; |
|
342 |
CTestAsync* test = CTestAsync::NewL(); |
|
343 |
int flag = 1; |
|
344 |
int option = 1; |
|
345 |
test->Start(flag, option, EFalse, EFalse, EFalse, ETrue ); |
|
346 |
result = test->Result(); |
|
347 |
if(result == 1004) |
|
348 |
result = KErrNone; |
|
349 |
delete test; |
|
350 |
__UHEAP_MARKEND; |
|
351 |
} |
|
352 |
||
353 |
return result; |
|
354 |
} |
|
355 |
||
356 |
||
357 |
||
358 |
TInt CTCalendarExportTest::ExportAllPosBased(CStifItemParser& /*aItem*/) |
|
359 |
{ |
|
360 |
TInt result=KErrNone; |
|
361 |
||
362 |
if( result == KErrNone ) |
|
363 |
{ |
|
364 |
__UHEAP_MARK; |
|
365 |
CTestAsync* test = CTestAsync::NewL(); |
|
366 |
int flag = 0; |
|
367 |
int option = 1; |
|
368 |
test->Start(flag, option, EFalse, EFalse, ETrue); |
|
369 |
result = test->Result(); |
|
370 |
delete test; |
|
371 |
__UHEAP_MARKEND; |
|
372 |
} |
|
373 |
return result; |
|
374 |
} |
|
375 |
||
376 |
TInt CTCalendarExportTest::ExportAllAsync(CStifItemParser& /*aItem*/) |
|
377 |
{ |
|
378 |
TInt result=KErrNone; |
|
379 |
||
380 |
if( result == KErrNone ) |
|
381 |
{ |
|
382 |
__UHEAP_MARK; |
|
383 |
CTestAsync* test = CTestAsync::NewL(); |
|
384 |
int flag = 0; |
|
385 |
int option = 1; |
|
386 |
test->Start(flag, option, EFalse, ETrue); |
|
387 |
result = test->Result(); |
|
388 |
delete test; |
|
389 |
__UHEAP_MARKEND; |
|
390 |
} |
|
391 |
return result; |
|
392 |
} |
|
393 |
||
394 |
TInt CTCalendarExportTest::ExportForGuids(CStifItemParser& /*aItem*/) |
|
395 |
{ |
|
396 |
TInt result=KErrNone; |
|
397 |
||
398 |
if( result == KErrNone ) |
|
399 |
{ |
|
400 |
__UHEAP_MARK; |
|
401 |
CTestAsync* test = CTestAsync::NewL(); |
|
402 |
int flag = 0; |
|
403 |
int option = 2; |
|
404 |
test->Start(flag, option, EFalse); |
|
405 |
result = test->Result(); |
|
406 |
delete test; |
|
407 |
__UHEAP_MARKEND; |
|
408 |
} |
|
409 |
return result; |
|
410 |
} |
|
411 |
||
412 |
TInt CTCalendarExportTest::ExportForGuidsAsync(CStifItemParser& /*aItem*/) |
|
413 |
{ |
|
414 |
TInt result=KErrNone; |
|
415 |
||
416 |
if( result == KErrNone ) |
|
417 |
{ |
|
418 |
__UHEAP_MARK; |
|
419 |
CTestAsync* test = CTestAsync::NewL(); |
|
420 |
int flag = 0; |
|
421 |
int option = 2; |
|
422 |
test->Start(flag,option,EFalse, ETrue); |
|
423 |
result = test->Result(); |
|
424 |
delete test; |
|
425 |
__UHEAP_MARKEND; |
|
426 |
} |
|
427 |
return result; |
|
428 |
} |
|
429 |
||
430 |
TInt CTCalendarExportTest::ExportForLuids(CStifItemParser& /*aItem*/) |
|
431 |
{ |
|
432 |
TInt result=KErrNone; |
|
433 |
||
434 |
if( result == KErrNone ) |
|
435 |
{ |
|
436 |
__UHEAP_MARK; |
|
437 |
CTestAsync* test = CTestAsync::NewL(); |
|
438 |
int flag = 0; |
|
439 |
int option = 3; |
|
440 |
test->Start(flag, option,EFalse); |
|
441 |
result = test->Result(); |
|
442 |
delete test; |
|
443 |
__UHEAP_MARKEND; |
|
444 |
} |
|
445 |
return result; |
|
446 |
} |
|
447 |
||
448 |
TInt CTCalendarExportTest::ExportForLuidsAsync(CStifItemParser& /*aItem*/) |
|
449 |
{ |
|
450 |
TInt result=KErrNone; |
|
451 |
||
452 |
if( result == KErrNone ) |
|
453 |
{ |
|
454 |
__UHEAP_MARK; |
|
455 |
CTestAsync* test = CTestAsync::NewL(); |
|
456 |
int flag = 0; |
|
457 |
int option = 3; |
|
458 |
test->Start(flag, option,EFalse, ETrue); |
|
459 |
result = test->Result(); |
|
460 |
delete test; |
|
461 |
__UHEAP_MARKEND; |
|
462 |
} |
|
463 |
return result; |
|
464 |
} |
|
465 |
||
466 |
TInt CTCalendarExportTest::ICALExport(CStifItemParser& /*aItem*/) |
|
467 |
{ |
|
468 |
TInt result=KErrNone; |
|
469 |
||
470 |
if( result == KErrNone ) |
|
471 |
{ |
|
472 |
__UHEAP_MARK; |
|
473 |
CTestAsync* test = CTestAsync::NewL(); |
|
474 |
int flag = 0; |
|
475 |
int option =1; |
|
476 |
test->Start(flag,option, ETrue); |
|
477 |
result = test->Result(); |
|
478 |
delete test; |
|
479 |
__UHEAP_MARKEND; |
|
480 |
} |
|
481 |
return result; |
|
482 |
} |
|
483 |
void Start(TInt flag, TInt option, TBool aICalFormat = EFalse, TBool aAsync = EFalse); |
|
484 |
TInt CTCalendarExportTest::ICALExportAsync(CStifItemParser& /*aItem*/) |
|
485 |
{ |
|
486 |
TInt result=KErrNone; |
|
487 |
||
488 |
if( result == KErrNone ) |
|
489 |
{ |
|
490 |
__UHEAP_MARK; |
|
491 |
CTestAsync* test = CTestAsync::NewL(); |
|
492 |
int flag = 0; |
|
493 |
int option = 1; |
|
494 |
test->Start(flag,option, ETrue, ETrue); |
|
495 |
result = test->Result(); |
|
496 |
delete test; |
|
497 |
__UHEAP_MARKEND; |
|
498 |
} |
|
499 |
return result; |
|
500 |
} |
|
501 |
TInt CTCalendarExportTest::ExportAllFile(CStifItemParser& /*aItem*/) |
|
502 |
{ |
|
503 |
TInt result=KErrNone; |
|
504 |
||
505 |
if( result == KErrNone ) |
|
506 |
{ |
|
507 |
__UHEAP_MARK; |
|
508 |
CTestAsync* test = CTestAsync::NewL(); |
|
509 |
int flag = 0; |
|
510 |
int option =1; |
|
511 |
test->Start(flag,option); |
|
512 |
result = test->Result(); |
|
513 |
delete test; |
|
514 |
__UHEAP_MARKEND; |
|
515 |
} |
|
516 |
return result; |
|
517 |
} |
|
518 |
||
519 |
TInt CTCalendarExportTest::ExportAllAsyncFile(CStifItemParser& /*aItem*/) |
|
520 |
{ |
|
521 |
TInt result=KErrNone; |
|
522 |
||
523 |
if( result == KErrNone ) |
|
524 |
{ |
|
525 |
__UHEAP_MARK; |
|
526 |
CTestAsync* test = CTestAsync::NewL(); |
|
527 |
int flag = 1; |
|
528 |
int option =1; |
|
529 |
test->Start(flag,option, EFalse, ETrue); |
|
530 |
result = test->Result(); |
|
531 |
delete test; |
|
532 |
__UHEAP_MARKEND; |
|
533 |
} |
|
534 |
return result; |
|
535 |
} |
|
536 |
||
537 |
TInt CTCalendarExportTest::ExportForGuidsFile(CStifItemParser& /*aItem*/) |
|
538 |
{ |
|
539 |
TInt result=KErrNone; |
|
540 |
||
541 |
if( result == KErrNone ) |
|
542 |
{ |
|
543 |
__UHEAP_MARK; |
|
544 |
CTestAsync* test = CTestAsync::NewL(); |
|
545 |
int flag = 1; |
|
546 |
int option =2; |
|
547 |
test->Start(flag,option); |
|
548 |
result = test->Result(); |
|
549 |
delete test; |
|
550 |
__UHEAP_MARKEND; |
|
551 |
} |
|
552 |
return result; |
|
553 |
} |
|
554 |
||
555 |
TInt CTCalendarExportTest::ExportForGuidsAsyncFile(CStifItemParser& /*aItem*/) |
|
556 |
{ |
|
557 |
TInt result=KErrNone; |
|
558 |
||
559 |
if( result == KErrNone ) |
|
560 |
{ |
|
561 |
__UHEAP_MARK; |
|
562 |
CTestAsync* test = CTestAsync::NewL(); |
|
563 |
int flag = 1; |
|
564 |
int option =2; |
|
565 |
test->Start(flag,option, EFalse, ETrue); |
|
566 |
result = test->Result(); |
|
567 |
delete test; |
|
568 |
__UHEAP_MARKEND; |
|
569 |
} |
|
570 |
return result; |
|
571 |
} |
|
572 |
||
573 |
TInt CTCalendarExportTest::ExportForLuidsFile(CStifItemParser& /*aItem*/) |
|
574 |
{ |
|
575 |
TInt result=KErrNone; |
|
576 |
||
577 |
if( result == KErrNone ) |
|
578 |
{ |
|
579 |
__UHEAP_MARK; |
|
580 |
CTestAsync* test = CTestAsync::NewL(); |
|
581 |
int flag = 1; |
|
582 |
int option =3; |
|
583 |
test->Start(flag,option); |
|
584 |
result = test->Result(); |
|
585 |
delete test; |
|
586 |
__UHEAP_MARKEND; |
|
587 |
} |
|
588 |
return result; |
|
589 |
} |
|
590 |
||
591 |
TInt CTCalendarExportTest::ExportForLuidsAsyncFile(CStifItemParser& /*aItem*/) |
|
592 |
{ |
|
593 |
TInt result=KErrNone; |
|
594 |
||
595 |
if( result == KErrNone ) |
|
596 |
{ |
|
597 |
__UHEAP_MARK; |
|
598 |
CTestAsync* test = CTestAsync::NewL(); |
|
599 |
int flag = 1; |
|
600 |
int option =3; |
|
601 |
test->Start(flag,option, EFalse, ETrue); |
|
602 |
result = test->Result(); |
|
603 |
delete test; |
|
604 |
__UHEAP_MARKEND; |
|
605 |
} |
|
606 |
return result; |
|
607 |
} |
|
608 |
||
609 |
TInt CTCalendarExportTest::ICALExportFile(CStifItemParser& /*aItem*/) |
|
610 |
{ |
|
611 |
TInt result=KErrNone; |
|
612 |
||
613 |
if( result == KErrNone ) |
|
614 |
{ |
|
615 |
__UHEAP_MARK; |
|
616 |
CTestAsync* test = CTestAsync::NewL(); |
|
617 |
int flag = 1; |
|
618 |
int option =1; |
|
619 |
test->Start(flag,option, ETrue); |
|
620 |
result = test->Result(); |
|
621 |
delete test; |
|
622 |
__UHEAP_MARKEND; |
|
623 |
} |
|
624 |
return result; |
|
625 |
} |
|
626 |
||
627 |
TInt CTCalendarExportTest::ICALExportAsyncFile(CStifItemParser& /*aItem*/) |
|
628 |
{ |
|
629 |
TInt result=KErrNone; |
|
630 |
||
631 |
if( result == KErrNone ) |
|
632 |
{ |
|
633 |
__UHEAP_MARK; |
|
634 |
CTestAsync* test = CTestAsync::NewL(); |
|
635 |
int flag = 1; |
|
636 |
int option =1; |
|
637 |
test->Start(flag,option, ETrue, ETrue); |
|
638 |
result = test->Result(); |
|
639 |
delete test; |
|
640 |
__UHEAP_MARKEND; |
|
641 |
} |
|
642 |
return result; |
|
643 |
} |
|
644 |
||
645 |
void CTestAsync::TestFunc() |
|
646 |
{ |
|
647 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
648 |
||
649 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
650 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
651 |
||
652 |
||
653 |
TInt err; |
|
654 |
||
655 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KTestInterface,KTestContent); |
|
656 |
||
657 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
658 |
||
659 |
RCriteriaArray a; |
|
660 |
a.AppendL(crit); |
|
661 |
||
662 |
iServiceHandler->AttachL(a); |
|
663 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
664 |
||
665 |
a.Reset(); |
|
666 |
delete crit; |
|
667 |
||
668 |
TInt pos = 0; |
|
669 |
||
670 |
outparam->FindFirst( pos, KTestInterface ); |
|
671 |
if(pos != KErrNotFound) |
|
672 |
{ |
|
673 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
674 |
} |
|
675 |
||
676 |
outparam->Reset(); |
|
677 |
inparam->Reset(); |
|
678 |
||
679 |
||
680 |
RemoveProvCalendar(inparam, outparam, interface, KCalTestImportSync1); |
|
681 |
RemoveProvCalendar(inparam, outparam, interface, KCalTestImportSync2); |
|
682 |
||
683 |
if( AddProvCalendar(inparam, outparam, interface, KCalTestImportSync1) != KErrNone) |
|
684 |
{ |
|
685 |
if(iWaitSchedular->IsStarted()) |
|
686 |
iWaitSchedular->AsyncStop(); |
|
687 |
inparam->Reset(); |
|
688 |
outparam->Reset(); |
|
689 |
return; |
|
690 |
}; |
|
691 |
||
692 |
if( AddProvCalendar(inparam, outparam, interface, KCalTestImportSync2) != KErrNone) |
|
693 |
{ |
|
694 |
if(iWaitSchedular->IsStarted()) |
|
695 |
iWaitSchedular->AsyncStop(); |
|
696 |
inparam->Reset(); |
|
697 |
outparam->Reset(); |
|
698 |
return; |
|
699 |
}; |
|
700 |
||
701 |
||
702 |
TUint localUid; |
|
703 |
TInt entryAdded = 0; |
|
704 |
TUIDSet* uidset1; |
|
705 |
TUIDSet* uidset2; |
|
706 |
if( AddProvAppointmentDailyRepeat(inparam, outparam, interface, KCalTestImportSync1 ,uidset1) != KErrNone ) |
|
707 |
{ |
|
708 |
if(iWaitSchedular->IsStarted()) |
|
709 |
iWaitSchedular->AsyncStop(); |
|
710 |
inparam->Reset(); |
|
711 |
outparam->Reset(); |
|
712 |
iResult = KErrGeneral; |
|
713 |
delete uidset1; |
|
714 |
return; |
|
715 |
}; |
|
716 |
iEntryAdded++; |
|
717 |
||
718 |
inparam->Reset(); |
|
719 |
outparam->Reset(); |
|
720 |
||
721 |
if( AddProvAppointmentDailyRepeat(inparam, outparam, interface, KCalTestImportSync1, uidset2 ) != KErrNone ) |
|
722 |
{ |
|
723 |
if(iWaitSchedular->IsStarted()) |
|
724 |
iWaitSchedular->AsyncStop(); |
|
725 |
inparam->Reset(); |
|
726 |
outparam->Reset(); |
|
727 |
iResult = KErrGeneral; |
|
728 |
delete uidset2; |
|
729 |
return; |
|
730 |
}; |
|
731 |
iEntryAdded++; |
|
732 |
||
733 |
inparam->Reset(); |
|
734 |
outparam->Reset(); |
|
735 |
||
736 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
737 |
CleanupStack::PushL(map); |
|
738 |
||
739 |
TLiwGenericParam element1; |
|
740 |
||
741 |
if ( iPosBased ) |
|
742 |
element1.SetNameAndValueL(KNullDesC8,TLiwVariant(_L("CalendarEntry"))); |
|
743 |
else |
|
744 |
element1.SetNameAndValueL(_L8("Type"),TLiwVariant(_L("CalendarEntry"))); |
|
745 |
||
746 |
||
747 |
map->InsertL(_L8("CalendarName"), TLiwVariant(KCalTestImportSync1) ); |
|
748 |
||
749 |
if(iInvalidFormat) |
|
750 |
map->InsertL(_L8("Format"), TLiwVariant(_L("InvalidFormat")) ); |
|
751 |
else if(iICalFormat) |
|
752 |
map->InsertL(_L8("Format"), TLiwVariant(_L("ICal")) ); |
|
753 |
else |
|
754 |
map->InsertL(_L8("Format"), TLiwVariant(_L("VCal")) ); |
|
755 |
||
756 |
if( iOption == 1 ) |
|
757 |
{ |
|
758 |
map->InsertL(_L8("FileName"), TLiwVariant(_L("c:\\exportall.txt"))); |
|
759 |
} |
|
760 |
||
761 |
if( iFunc == 2 ) |
|
762 |
{ |
|
763 |
CLiwDefaultList *uidlist = CLiwDefaultList::NewL(); |
|
764 |
TBuf<10> localuid; |
|
765 |
TBuf<50> globaluid; |
|
766 |
globaluid.Copy(uidset1->iGlobalUID->Des()); |
|
767 |
localuid = GetEntry( interface, inparam, outparam, globaluid, KCalTestImportSync1); |
|
768 |
||
769 |
//localuid.Num(TInt64(uidset1->iLocalUID)); |
|
770 |
uidlist->AppendL(TLiwVariant(localuid)); |
|
771 |
globaluid.Copy(uidset2->iGlobalUID->Des()); |
|
772 |
localuid = GetEntry( interface, inparam, outparam, globaluid, KCalTestImportSync1); |
|
773 |
||
774 |
//localuid.Num(TInt64(uidset2->iLocalUID)); |
|
775 |
uidlist->AppendL(TLiwVariant(localuid)); |
|
776 |
map->InsertL(_L8("LocalIdList"), TLiwVariant(uidlist)); |
|
777 |
uidlist->DecRef(); |
|
778 |
} |
|
779 |
||
780 |
if( iFunc == 3 ) |
|
781 |
{ |
|
782 |
CLiwDefaultList *uidlist = CLiwDefaultList::NewL(); |
|
783 |
TBuf<50> guid; |
|
784 |
guid.Copy(uidset1->iGlobalUID->Des()); |
|
785 |
uidlist->AppendL(TLiwVariant(guid)); |
|
786 |
guid.Copy(uidset2->iGlobalUID->Des()); |
|
787 |
uidlist->AppendL(TLiwVariant(guid)); |
|
788 |
map->InsertL(_L8("IdList"), TLiwVariant(uidlist)); |
|
789 |
uidlist->DecRef(); |
|
790 |
} |
|
791 |
||
792 |
inparam->AppendL(element1); |
|
793 |
element1.Reset(); |
|
794 |
||
795 |
||
796 |
TLiwVariant filterparam(map); |
|
797 |
TLiwGenericParam element ; |
|
798 |
||
799 |
if ( iPosBased ) |
|
800 |
element.SetNameAndValueL(KNullDesC8,filterparam); |
|
801 |
else |
|
802 |
element.SetNameAndValueL(_L8("Data"),filterparam); |
|
803 |
||
804 |
filterparam.Reset(); |
|
805 |
||
806 |
inparam->AppendL(element); |
|
807 |
element.Reset(); |
|
808 |
map->DecRef(); |
|
809 |
CleanupStack::Pop(map); |
|
810 |
||
811 |
TRAPD(err1, interface->ExecuteCmdL(KCmdExport, *inparam, *outparam )); |
|
812 |
||
813 |
pos = 0; |
|
814 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
815 |
||
816 |
HBufC8* exportBuffer = NULL; |
|
817 |
delete uidset1; |
|
818 |
delete uidset2; |
|
819 |
||
820 |
if( iOption == 0) |
|
821 |
{ |
|
822 |
if(output) |
|
823 |
{ |
|
824 |
err = output->Value().AsTInt32(); |
|
825 |
if(err == KErrNone) |
|
826 |
{ |
|
827 |
pos = 0; |
|
828 |
output = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
829 |
if ( output ) |
|
830 |
{ |
|
831 |
exportBuffer = output->Value().AsData().AllocL(); |
|
832 |
} |
|
833 |
} |
|
834 |
else |
|
835 |
{ |
|
836 |
if(iWaitSchedular->IsStarted()) |
|
837 |
iWaitSchedular->AsyncStop(); |
|
838 |
} |
|
839 |
||
840 |
} |
|
841 |
inparam->Reset(); |
|
842 |
outparam->Reset(); |
|
843 |
||
844 |
if ( exportBuffer ) |
|
845 |
{ |
|
846 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
847 |
CleanupStack::PushL(map); |
|
848 |
||
849 |
TLiwGenericParam element1; |
|
850 |
element1.SetNameAndValueL(_L8("Type"),TLiwVariant(_L("CalendarEntry"))); |
|
851 |
inparam->AppendL(element1); |
|
852 |
element1.Reset(); |
|
853 |
||
854 |
map->InsertL(_L8("CalendarName"), TLiwVariant(KCalTestImportSync2) ); |
|
855 |
||
856 |
if(iICalFormat) |
|
857 |
map->InsertL(_L8("Format"), TLiwVariant(_L("ICal")) ); |
|
858 |
else |
|
859 |
map->InsertL(_L8("Format"), TLiwVariant(_L("VCal")) ); |
|
860 |
||
861 |
map->InsertL(_L8("Buffer"), TLiwVariant( exportBuffer->Des() ) ); |
|
862 |
||
863 |
TLiwVariant filterparam(map); |
|
864 |
TLiwGenericParam element ; |
|
865 |
element.SetNameAndValueL(_L8("Data"),filterparam); |
|
866 |
filterparam.Reset(); |
|
867 |
||
868 |
inparam->AppendL(element); |
|
869 |
element.Reset(); |
|
870 |
map->DecRef(); |
|
871 |
CleanupStack::Pop(map); |
|
872 |
||
873 |
if(iAsync) |
|
874 |
{ |
|
875 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
876 |
||
877 |
iCallback->iEntryAdded = iEntryAdded; |
|
878 |
||
879 |
TRAPD(err1, interface->ExecuteCmdL(KCmdImport, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
880 |
||
881 |
pos = 0; |
|
882 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
883 |
||
884 |
if(output) |
|
885 |
{ |
|
886 |
iTransactionId = output->Value().AsTInt32(); |
|
887 |
} |
|
888 |
else |
|
889 |
{ |
|
890 |
if(iWaitSchedular->IsStarted()) |
|
891 |
iWaitSchedular->AsyncStop(); |
|
892 |
} |
|
893 |
inparam->Reset(); |
|
894 |
outparam->Reset(); |
|
895 |
} |
|
896 |
else |
|
897 |
{ |
|
898 |
TRAPD(err1, interface->ExecuteCmdL(KCmdImport, *inparam, *outparam )); |
|
899 |
pos = 0; |
|
900 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
901 |
||
902 |
if(output) |
|
903 |
{ |
|
904 |
err = output->Value().AsTInt32(); |
|
905 |
if(err == KErrNone) |
|
906 |
{ |
|
907 |
pos = 0; |
|
908 |
output = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
909 |
if ( output ) |
|
910 |
{ |
|
911 |
CLiwIterable* iterlist = output->Value().AsIterable(); |
|
912 |
||
913 |
TInt returnItems = 0; |
|
914 |
||
915 |
if(iterlist) |
|
916 |
{ |
|
917 |
TLiwVariant data; |
|
918 |
||
919 |
while ( iterlist->NextL(data) ) |
|
920 |
returnItems++; |
|
921 |
||
922 |
data.Reset(); |
|
923 |
} |
|
924 |
||
925 |
if(iEntryAdded == returnItems) |
|
926 |
iResult = KErrNone; |
|
927 |
} |
|
928 |
} |
|
929 |
else |
|
930 |
{ |
|
931 |
iResult = err; |
|
932 |
} |
|
933 |
||
934 |
} |
|
935 |
} |
|
936 |
} |
|
937 |
delete exportBuffer; |
|
938 |
} |
|
939 |
else |
|
940 |
{ |
|
941 |
if(output) |
|
942 |
{ |
|
943 |
err = output->Value().AsTInt32(); |
|
944 |
inparam->Reset(); |
|
945 |
outparam->Reset(); |
|
946 |
||
947 |
if(err == KErrNone) |
|
948 |
{ |
|
949 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
950 |
CleanupStack::PushL(map); |
|
951 |
||
952 |
TLiwGenericParam element1; |
|
953 |
element1.SetNameAndValueL(_L8("Type"),TLiwVariant(_L("CalendarEntry"))); |
|
954 |
inparam->AppendL(element1); |
|
955 |
element1.Reset(); |
|
956 |
||
957 |
map->InsertL(_L8("CalendarName"), TLiwVariant(KCalTestImportSync2) ); |
|
958 |
||
959 |
if(iICalFormat) |
|
960 |
map->InsertL(_L8("Format"), TLiwVariant(_L("ICal")) ); |
|
961 |
else |
|
962 |
map->InsertL(_L8("Format"), TLiwVariant(_L("VCal")) ); |
|
963 |
||
964 |
map->InsertL(_L8("FileName"), TLiwVariant( _L("c:\\exportall.txt") ) ); |
|
965 |
||
966 |
TLiwVariant filterparam(map); |
|
967 |
TLiwGenericParam element ; |
|
968 |
element.SetNameAndValueL(_L8("Data"),filterparam); |
|
969 |
filterparam.Reset(); |
|
970 |
||
971 |
inparam->AppendL(element); |
|
972 |
element.Reset(); |
|
973 |
map->DecRef(); |
|
974 |
CleanupStack::Pop(map); |
|
975 |
if(iAsync) |
|
976 |
{ |
|
977 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
978 |
||
979 |
iCallback->iEntryAdded = iEntryAdded; |
|
980 |
||
981 |
TRAPD(err1, interface->ExecuteCmdL(KCmdImport, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
982 |
||
983 |
pos = 0; |
|
984 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
985 |
||
986 |
if(output) |
|
987 |
{ |
|
988 |
iTransactionId = output->Value().AsTInt32(); |
|
989 |
} |
|
990 |
else |
|
991 |
{ |
|
992 |
if(iWaitSchedular->IsStarted()) |
|
993 |
iWaitSchedular->AsyncStop(); |
|
994 |
} |
|
995 |
||
996 |
||
997 |
inparam->Reset(); |
|
998 |
outparam->Reset(); |
|
999 |
} |
|
1000 |
else |
|
1001 |
{ |
|
1002 |
TRAPD(err1, interface->ExecuteCmdL(KCmdImport, *inparam, *outparam )); |
|
1003 |
pos = 0; |
|
1004 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
1005 |
||
1006 |
if(output) |
|
1007 |
{ |
|
1008 |
err = output->Value().AsTInt32(); |
|
1009 |
if(err == KErrNone) |
|
1010 |
{ |
|
1011 |
pos = 0; |
|
1012 |
output = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
1013 |
if ( output ) |
|
1014 |
{ |
|
1015 |
CLiwIterable* iterlist = output->Value().AsIterable(); |
|
1016 |
||
1017 |
TInt returnItems = 0; |
|
1018 |
||
1019 |
if(iterlist) |
|
1020 |
{ |
|
1021 |
TLiwVariant data; |
|
1022 |
||
1023 |
while ( iterlist->NextL(data) ) |
|
1024 |
returnItems++; |
|
1025 |
||
1026 |
data.Reset(); |
|
1027 |
} |
|
1028 |
||
1029 |
if(iEntryAdded == returnItems) |
|
1030 |
iResult = KErrNone; |
|
1031 |
} |
|
1032 |
} |
|
1033 |
else |
|
1034 |
{ |
|
1035 |
iResult = err; |
|
1036 |
} |
|
1037 |
} |
|
1038 |
} |
|
1039 |
} |
|
1040 |
else |
|
1041 |
{ |
|
1042 |
iResult = err; |
|
1043 |
if(iWaitSchedular->IsStarted()) |
|
1044 |
iWaitSchedular->AsyncStop(); |
|
1045 |
} |
|
1046 |
} |
|
1047 |
} |
|
1048 |
inparam->Reset(); |
|
1049 |
outparam->Reset(); |
|
1050 |
} |