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 |
||
28 |
#include <badesca.h> |
|
29 |
//#include "teststartconsolealarmserver3.h" |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
30 |
#include<liwservicehandler.h> |
19 | 31 |
|
32 |
||
33 |
#include "tcalendarimporttest.h" |
|
34 |
#include "startconsolealarmserver.h" |
|
35 |
||
36 |
class CCalCallback : public MLiwNotifyCallback |
|
37 |
{ |
|
38 |
public: |
|
39 |
||
40 |
static CCalCallback* NewL(CActiveSchedulerWait* aWaitSchedular, TInt& aResult ); |
|
41 |
||
42 |
virtual ~CCalCallback(){} |
|
43 |
||
44 |
TInt HandleNotifyL(TInt aCmdId, |
|
45 |
TInt aEventId, |
|
46 |
CLiwGenericParamList& aEventParamList, |
|
47 |
const CLiwGenericParamList& aInParamList); |
|
48 |
TInt iEntryAdded; |
|
49 |
||
50 |
private: |
|
51 |
||
52 |
CCalCallback(CActiveSchedulerWait* aWaitSchedular, TInt& aResult ):iWaitSchedular(aWaitSchedular), iResult(aResult){ } |
|
53 |
||
54 |
CActiveSchedulerWait* iWaitSchedular; |
|
55 |
TInt& iResult; |
|
56 |
||
57 |
||
58 |
}; |
|
59 |
||
60 |
class CTestAsync : public CActive |
|
61 |
{ |
|
62 |
public: |
|
63 |
static CTestAsync* NewL(); |
|
64 |
~CTestAsync(); |
|
65 |
void Start(TInt flag, TBool aICalFormat = EFalse, TBool aAsync = EFalse, TBool aWrong = EFalse, TBool aPosBased = EFalse, TBool aInvalidFormat = EFalse ); |
|
66 |
void CancelNotification(); |
|
67 |
void ImportInvalidFile(); |
|
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 |
TBool iWrongCal; |
|
93 |
TBool iPosBased; |
|
94 |
TBool iInvalidFormat; |
|
95 |
}; |
|
96 |
||
97 |
_LIT8(KTestInterface, "IDataSource"); |
|
98 |
_LIT8(KTestContent, "Service.Calendar"); |
|
99 |
_LIT8(KCmd, "RequestNotification"); |
|
100 |
_LIT8(KCmdAdd, "Add"); |
|
101 |
_LIT8(KCmdDelete, "Delete"); |
|
102 |
_LIT8(KCmdCancel, "Cancel"); |
|
103 |
_LIT8(KCmdExport, "Export"); |
|
104 |
_LIT8(KCmdImport, "Import"); |
|
105 |
||
106 |
_LIT8(KFilter, "Filter"); |
|
107 |
_LIT8(KItem, "Item"); |
|
108 |
_LIT8(KCalendarName, "CalendarName"); |
|
109 |
||
110 |
_LIT(KEntryTypeMeeting, "Meeting"); |
|
111 |
||
112 |
const TChar KUidSeparator = ':'; |
|
113 |
||
114 |
TInt RemoveProvCalendar(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar); |
|
115 |
TInt AddProvCalendar(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar); |
|
116 |
TInt AddProvAppointmentDailyRepeat(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUint& localuid); |
|
117 |
||
118 |
// ============================ MEMBER FUNCTIONS =============================== |
|
119 |
||
120 |
// ----------------------------------------------------------------------------- |
|
121 |
// CTChangeStatusTest::Delete |
|
122 |
// Delete here all resources allocated and opened from test methods. |
|
123 |
// Called from destructor. |
|
124 |
// ----------------------------------------------------------------------------- |
|
125 |
// |
|
126 |
void CTCalendarImportTest::Delete() |
|
127 |
{ |
|
128 |
||
129 |
} |
|
130 |
||
131 |
// ----------------------------------------------------------------------------- |
|
132 |
// CTChangeStatusTest::RunMethodL |
|
133 |
// Run specified method. Contains also table of test mothods and their names. |
|
134 |
// ----------------------------------------------------------------------------- |
|
135 |
// |
|
136 |
TInt CTCalendarImportTest::RunMethodL( |
|
137 |
CStifItemParser& aItem ) |
|
138 |
{ |
|
139 |
||
140 |
static TStifFunctionInfo const KFunctions[] = |
|
141 |
{ |
|
142 |
// Copy this line for every implemented function. |
|
143 |
// First string is the function name used in TestScripter script file. |
|
144 |
// Second is the actual implementation member function. |
|
145 |
//TRY( "SendMessage", CTDeleteMessageTest::SendMessage ), |
|
146 |
||
147 |
ENTRY( "ImportProviderIter3", CTCalendarImportTest::Import ), |
|
148 |
ENTRY( "ImportProviderIter3File", CTCalendarImportTest::ImportProviderIter3File ), |
|
149 |
ENTRY( "ImportAsyncProviderIter3File", CTCalendarImportTest::ImportAsyncProviderIter3File ), |
|
150 |
ENTRY( "ImportAsyncProviderIter3", CTCalendarImportTest::ImportAsync ), |
|
151 |
ENTRY( "ICALImportProviderIter3", CTCalendarImportTest::ICALImport ), |
|
152 |
ENTRY( "ICALImportAsyncProviderIter3",CTCalendarImportTest::ICALImportAsync ), |
|
153 |
ENTRY( "ICALImportProviderIter3File", CTCalendarImportTest::ICALImportProviderIter3File ), |
|
154 |
ENTRY( "ICALImportAsyncProviderIter3File",CTCalendarImportTest::ICALImportAsyncProviderIter3File ), |
|
155 |
ENTRY( "ImportProviderIter3WrongCal",CTCalendarImportTest::ImportProviderIter3WrongCal ), |
|
156 |
ENTRY( "ImportProviderIter3PositionBased",CTCalendarImportTest::ImportProviderIter3PositionBased ), |
|
157 |
ENTRY( "ImportProviderIter3InvalidFile",CTCalendarImportTest::ImportProviderIter3InvalidFile ), |
|
158 |
ENTRY( "ImportProviderIter3InvalidFormat",CTCalendarImportTest::ImportProviderIter3InvalidFormat ), |
|
159 |
}; |
|
160 |
||
161 |
const TInt count = sizeof( KFunctions ) / |
|
162 |
sizeof( TStifFunctionInfo ); |
|
163 |
||
164 |
return RunInternalL( KFunctions, count, aItem ); |
|
165 |
||
166 |
} |
|
167 |
||
168 |
||
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
169 |
#include<liwcommon.h> |
19 | 170 |
|
171 |
class CTestAsync; |
|
172 |
||
173 |
// ----------------------------------------------------------------------------- |
|
174 |
// CTCalendarImportTest::Import |
|
175 |
// Test Method to test the Import(Synchronous) |
|
176 |
// Functionality of CalenderService |
|
177 |
// ----------------------------------------------------------------------------- |
|
178 |
// |
|
179 |
TInt CTCalendarImportTest::Import(CStifItemParser& /*aItem*/) |
|
180 |
{ |
|
181 |
TInt result=KErrNone; |
|
182 |
||
183 |
{ |
|
184 |
__UHEAP_MARK; |
|
185 |
CTestAsync* test = CTestAsync::NewL(); |
|
186 |
TInt flag = 0; |
|
187 |
test->Start(flag); |
|
188 |
result = test->Result(); |
|
189 |
delete test; |
|
190 |
__UHEAP_MARKEND; |
|
191 |
} |
|
192 |
||
193 |
return result; |
|
194 |
} |
|
195 |
||
196 |
TInt CTCalendarImportTest::ImportProviderIter3File(CStifItemParser& /*aItem*/) |
|
197 |
{ |
|
198 |
TInt result=KErrNone; |
|
199 |
||
200 |
{ |
|
201 |
__UHEAP_MARK; |
|
202 |
CTestAsync* test = CTestAsync::NewL(); |
|
203 |
TInt flag = 1; |
|
204 |
test->Start(flag); |
|
205 |
result = test->Result(); |
|
206 |
delete test; |
|
207 |
__UHEAP_MARKEND; |
|
208 |
} |
|
209 |
||
210 |
return result; |
|
211 |
} |
|
212 |
// ----------------------------------------------------------------------------- |
|
213 |
// CTCalendarImportTest::ImportAsync |
|
214 |
// Test Method to test the ImportAsync(ASynchronous) |
|
215 |
// Functionality of CalenderService |
|
216 |
// ----------------------------------------------------------------------------- |
|
217 |
// |
|
218 |
TInt CTCalendarImportTest::ImportAsync(CStifItemParser& /*aItem*/) |
|
219 |
{ |
|
220 |
TInt result=KErrNone; |
|
221 |
||
222 |
{ |
|
223 |
__UHEAP_MARK; |
|
224 |
CTestAsync* test = CTestAsync::NewL(); |
|
225 |
int flag = 0; |
|
226 |
test->Start(flag, EFalse, ETrue); |
|
227 |
result = test->Result(); |
|
228 |
delete test; |
|
229 |
__UHEAP_MARKEND; |
|
230 |
} |
|
231 |
||
232 |
return result; |
|
233 |
} |
|
234 |
||
235 |
TInt CTCalendarImportTest::ImportAsyncProviderIter3File(CStifItemParser& /*aItem*/) |
|
236 |
{ |
|
237 |
TInt result=KErrNone; |
|
238 |
||
239 |
{ |
|
240 |
__UHEAP_MARK; |
|
241 |
CTestAsync* test = CTestAsync::NewL(); |
|
242 |
TInt flag = 1; |
|
243 |
test->Start(flag, EFalse, ETrue); |
|
244 |
result = test->Result(); |
|
245 |
delete test; |
|
246 |
__UHEAP_MARKEND; |
|
247 |
} |
|
248 |
||
249 |
return result; |
|
250 |
} |
|
251 |
// ----------------------------------------------------------------------------- |
|
252 |
// CTCalendarImportTest::ICALImport |
|
253 |
// Test Method to test the ICALImport(Synchronous) |
|
254 |
// Functionality of CalenderService |
|
255 |
// ----------------------------------------------------------------------------- |
|
256 |
// |
|
257 |
TInt CTCalendarImportTest::ICALImport(CStifItemParser& /*aItem*/) |
|
258 |
{ |
|
259 |
TInt result=KErrNone; |
|
260 |
||
261 |
{ |
|
262 |
__UHEAP_MARK; |
|
263 |
CTestAsync* test = CTestAsync::NewL(); |
|
264 |
int flag = 0; |
|
265 |
test->Start( flag , ETrue ); |
|
266 |
result = test->Result(); |
|
267 |
delete test; |
|
268 |
__UHEAP_MARKEND; |
|
269 |
} |
|
270 |
||
271 |
return result; |
|
272 |
} |
|
273 |
||
274 |
TInt CTCalendarImportTest::ICALImportProviderIter3File(CStifItemParser& /*aItem*/) |
|
275 |
{ |
|
276 |
TInt result=KErrNone; |
|
277 |
||
278 |
{ |
|
279 |
__UHEAP_MARK; |
|
280 |
int flag = 1; |
|
281 |
CTestAsync* test = CTestAsync::NewL(); |
|
282 |
test->Start( flag , ETrue ); |
|
283 |
result = test->Result(); |
|
284 |
delete test; |
|
285 |
__UHEAP_MARKEND; |
|
286 |
} |
|
287 |
||
288 |
return result; |
|
289 |
} |
|
290 |
||
291 |
||
292 |
// ----------------------------------------------------------------------------- |
|
293 |
// CTCalendarImportTest::ICALImportAsync |
|
294 |
// Test Method to test the ICALImportAsync(ASynchronous) |
|
295 |
// Functionality of CalenderService |
|
296 |
// ----------------------------------------------------------------------------- |
|
297 |
// |
|
298 |
TInt CTCalendarImportTest::ICALImportAsync(CStifItemParser& /*aItem*/) |
|
299 |
{ |
|
300 |
TInt result=KErrNone; |
|
301 |
||
302 |
{ |
|
303 |
__UHEAP_MARK; |
|
304 |
CTestAsync* test = CTestAsync::NewL(); |
|
305 |
int flag = 0; |
|
306 |
test->Start( flag, ETrue, ETrue ); |
|
307 |
result = test->Result(); |
|
308 |
delete test; |
|
309 |
__UHEAP_MARKEND; |
|
310 |
} |
|
311 |
||
312 |
return result; |
|
313 |
} |
|
314 |
||
315 |
TInt CTCalendarImportTest::ICALImportAsyncProviderIter3File(CStifItemParser& /*aItem*/) |
|
316 |
{ |
|
317 |
TInt result=KErrNone; |
|
318 |
||
319 |
{ |
|
320 |
__UHEAP_MARK; |
|
321 |
CTestAsync* test = CTestAsync::NewL(); |
|
322 |
int flag = 1; |
|
323 |
test->Start( flag, ETrue, ETrue ); |
|
324 |
result = test->Result(); |
|
325 |
delete test; |
|
326 |
__UHEAP_MARKEND; |
|
327 |
} |
|
328 |
||
329 |
return result; |
|
330 |
} |
|
331 |
||
332 |
TInt CTCalendarImportTest::ImportProviderIter3WrongCal(CStifItemParser& /*aItem*/) |
|
333 |
{ |
|
334 |
TInt result=KErrNone; |
|
335 |
||
336 |
{ |
|
337 |
__UHEAP_MARK; |
|
338 |
CTestAsync* test = CTestAsync::NewL(); |
|
339 |
int flag = 0; |
|
340 |
test->Start( flag, EFalse, EFalse, ETrue ); |
|
341 |
result = test->Result(); |
|
342 |
if(result > 0 ) |
|
343 |
result = KErrNone; |
|
344 |
delete test; |
|
345 |
__UHEAP_MARKEND; |
|
346 |
} |
|
347 |
||
348 |
return result; |
|
349 |
} |
|
350 |
||
351 |
TInt CTCalendarImportTest::ImportProviderIter3PositionBased(CStifItemParser& /*aItem*/ ) |
|
352 |
{ |
|
353 |
TInt result=KErrNone; |
|
354 |
||
355 |
{ |
|
356 |
__UHEAP_MARK; |
|
357 |
CTestAsync* test = CTestAsync::NewL(); |
|
358 |
int flag = 0; |
|
359 |
test->Start( flag, EFalse, EFalse, EFalse, ETrue ); |
|
360 |
result = test->Result(); |
|
361 |
delete test; |
|
362 |
__UHEAP_MARKEND; |
|
363 |
} |
|
364 |
return result; |
|
365 |
} |
|
366 |
||
367 |
TInt CTCalendarImportTest::ImportProviderIter3InvalidFile(CStifItemParser& /*aItem*/ ) |
|
368 |
{ |
|
369 |
TInt result=KErrNone; |
|
370 |
||
371 |
{ |
|
372 |
__UHEAP_MARK; |
|
373 |
CTestAsync* test = CTestAsync::NewL(); |
|
374 |
int flag = 0; |
|
375 |
test->ImportInvalidFile(); |
|
376 |
result = test->Result(); |
|
377 |
delete test; |
|
378 |
__UHEAP_MARKEND; |
|
379 |
} |
|
380 |
||
381 |
return result; |
|
382 |
} |
|
383 |
||
384 |
TInt CTCalendarImportTest::ImportProviderIter3InvalidFormat(CStifItemParser& /*aItem*/ ) |
|
385 |
{ |
|
386 |
TInt result=KErrNone; |
|
387 |
||
388 |
{ |
|
389 |
__UHEAP_MARK; |
|
390 |
CTestAsync* test = CTestAsync::NewL(); |
|
391 |
int flag = 0; |
|
392 |
test->Start( flag, EFalse, EFalse, EFalse, EFalse, ETrue ); |
|
393 |
result = test->Result(); |
|
394 |
if(result == 1004 ) |
|
395 |
result = KErrNone; |
|
396 |
else if(result == KErrNone) |
|
397 |
result = KErrGeneral; |
|
398 |
||
399 |
delete test; |
|
400 |
__UHEAP_MARKEND; |
|
401 |
} |
|
402 |
||
403 |
return result; |
|
404 |
} |
|
405 |
||
406 |
||
407 |
||
408 |
/*TInt CTCalendarImportTest::ImportInvalidParamTest(CStifItemParser& aItem) |
|
409 |
{ |
|
410 |
||
411 |
}*/ |
|
412 |
||
413 |
_LIT(KCalTestImportSync1, "c:importsynctestcal1"); |
|
414 |
_LIT(KCalTestImportSync2, "c:importsynctestcal2"); |
|
415 |
||
416 |
||
417 |
/** |
|
418 |
* Callback class for asynchronous SAPI message header |
|
419 |
*/ |
|
420 |
CCalCallback* CCalCallback::NewL(CActiveSchedulerWait* aWaitSchedular, TInt& aResult) |
|
421 |
{ |
|
422 |
return new (ELeave) CCalCallback(aWaitSchedular, aResult); |
|
423 |
} |
|
424 |
||
425 |
TInt CCalCallback::HandleNotifyL(TInt aCmdId, |
|
426 |
TInt aEventId, |
|
427 |
CLiwGenericParamList& aEventParamList, |
|
428 |
const CLiwGenericParamList& aInParamList) |
|
429 |
{ |
|
430 |
TInt pos = 0; |
|
431 |
TInt result = KErrNone; |
|
432 |
const TLiwGenericParam* output = aEventParamList.FindFirst( pos,_L8("ReturnValue")); |
|
433 |
||
434 |
if(output) |
|
435 |
{ |
|
436 |
CLiwIterable* iterlist = output->Value().AsIterable(); |
|
437 |
||
438 |
TInt returnItems = 0; |
|
439 |
||
440 |
if(iterlist) |
|
441 |
{ |
|
442 |
TLiwVariant data; |
|
443 |
||
444 |
while ( iterlist->NextL(data) ) |
|
445 |
returnItems++; |
|
446 |
||
447 |
data.Reset(); |
|
448 |
} |
|
449 |
||
450 |
if(iEntryAdded == returnItems) |
|
451 |
iResult = KErrNone; |
|
452 |
else |
|
453 |
iResult = KErrGeneral; |
|
454 |
} |
|
455 |
||
456 |
if ( iWaitSchedular && iWaitSchedular->IsStarted()) |
|
457 |
{ |
|
458 |
iWaitSchedular->AsyncStop(); |
|
459 |
} |
|
460 |
return 0; |
|
461 |
} |
|
462 |
||
463 |
CTestAsync* CTestAsync::NewL() |
|
464 |
{ |
|
465 |
CTestAsync* self = new (ELeave) CTestAsync(); |
|
466 |
self->ConstructL(); |
|
467 |
return self; |
|
468 |
} |
|
469 |
||
470 |
CTestAsync::~CTestAsync() |
|
471 |
{ |
|
472 |
Cancel(); |
|
473 |
||
474 |
interface->Close(); |
|
475 |
||
476 |
delete iServiceHandler; |
|
477 |
||
478 |
delete iCallback; |
|
479 |
||
480 |
if(iWaitSchedular->IsStarted()) |
|
481 |
iWaitSchedular->AsyncStop(); |
|
482 |
||
483 |
delete iWaitSchedular; |
|
484 |
} |
|
485 |
||
486 |
||
487 |
void CTestAsync::ConstructL() |
|
488 |
{ |
|
489 |
CActiveScheduler::Add(this); |
|
490 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
491 |
} |
|
492 |
||
493 |
||
494 |
CTestAsync::CTestAsync() : |
|
495 |
CActive(EPriorityStandard) |
|
496 |
{ |
|
497 |
interface = NULL ; |
|
498 |
iResult = KErrGeneral; |
|
499 |
} |
|
500 |
||
501 |
void CTestAsync::DoCancel() |
|
502 |
{ |
|
503 |
||
504 |
} |
|
505 |
||
506 |
void CTestAsync::RunL() |
|
507 |
{ |
|
508 |
TestFunc(); |
|
509 |
} |
|
510 |
||
511 |
TInt CTestAsync::Result() |
|
512 |
{ |
|
513 |
return iResult; |
|
514 |
} |
|
515 |
||
516 |
void CTestAsync::Start(TInt flag, TBool aICalFormat, TBool aAsync, TBool aWrongCal, TBool aPosBased, TBool aInvalidFormat ) |
|
517 |
{ |
|
518 |
iICalFormat = aICalFormat; |
|
519 |
iAsync = aAsync; |
|
520 |
iOption = flag; |
|
521 |
iWrongCal = aWrongCal; |
|
522 |
iPosBased = aPosBased; |
|
523 |
iInvalidFormat = aInvalidFormat; |
|
524 |
if( iAsync ) |
|
525 |
{ |
|
526 |
SetActive(); |
|
527 |
TRequestStatus* temp = &iStatus; |
|
528 |
User::RequestComplete(temp, KErrNone); |
|
529 |
iWaitSchedular->Start(); |
|
530 |
} |
|
531 |
else |
|
532 |
{ |
|
533 |
TestFunc(); |
|
534 |
} |
|
535 |
} |
|
536 |
||
537 |
void CTestAsync::CancelNotification() |
|
538 |
{ |
|
539 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
540 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
541 |
||
542 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
543 |
CleanupStack::PushL(map); |
|
544 |
||
545 |
TLiwGenericParam element1; |
|
546 |
element1.SetNameAndValueL(_L8("Type"),TLiwVariant(_L("CalendarEntry"))); |
|
547 |
inparam->AppendL(element1); |
|
548 |
element1.Reset(); |
|
549 |
||
550 |
TLiwGenericParam element2; |
|
551 |
element2.SetNameAndValueL(_L8("TransactionID"), TLiwVariant(iTransactionId)); |
|
552 |
inparam->AppendL(element2); |
|
553 |
element2.Reset(); |
|
554 |
||
555 |
||
556 |
TLiwVariant filterparam(map); |
|
557 |
TLiwGenericParam element ; |
|
558 |
element.SetNameAndValueL(_L8("Item"),filterparam); |
|
559 |
filterparam.Reset(); |
|
560 |
||
561 |
inparam->AppendL(element); |
|
562 |
element.Reset(); |
|
563 |
map->DecRef(); |
|
564 |
CleanupStack::Pop(map); |
|
565 |
||
566 |
TRAPD(err1, interface->ExecuteCmdL(KCmdCancel, *inparam, *outparam, KLiwOptCancel )); |
|
567 |
inparam->Reset(); |
|
568 |
outparam->Reset(); |
|
569 |
} |
|
570 |
||
571 |
void CTestAsync::TestFunc() |
|
572 |
{ |
|
573 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
574 |
||
575 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
576 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
577 |
||
578 |
||
579 |
TInt err; |
|
580 |
||
581 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KTestInterface,KTestContent); |
|
582 |
||
583 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
584 |
||
585 |
RCriteriaArray a; |
|
586 |
a.AppendL(crit); |
|
587 |
||
588 |
iServiceHandler->AttachL(a); |
|
589 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
590 |
||
591 |
a.Reset(); |
|
592 |
delete crit; |
|
593 |
||
594 |
TInt pos = 0; |
|
595 |
||
596 |
outparam->FindFirst( pos, KTestInterface ); |
|
597 |
if(pos != KErrNotFound) |
|
598 |
{ |
|
599 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
600 |
} |
|
601 |
||
602 |
outparam->Reset(); |
|
603 |
inparam->Reset(); |
|
604 |
||
605 |
||
606 |
RemoveProvCalendar(inparam, outparam, interface, KCalTestImportSync1); |
|
607 |
RemoveProvCalendar(inparam, outparam, interface, KCalTestImportSync2); |
|
608 |
||
609 |
if( AddProvCalendar(inparam, outparam, interface, KCalTestImportSync1) != KErrNone) |
|
610 |
{ |
|
611 |
if(iWaitSchedular->IsStarted()) |
|
612 |
iWaitSchedular->AsyncStop(); |
|
613 |
inparam->Reset(); |
|
614 |
outparam->Reset(); |
|
615 |
return; |
|
616 |
}; |
|
617 |
||
618 |
if(!iWrongCal) |
|
619 |
{ |
|
620 |
if( AddProvCalendar(inparam, outparam, interface, KCalTestImportSync2) != KErrNone) |
|
621 |
{ |
|
622 |
if(iWaitSchedular->IsStarted()) |
|
623 |
iWaitSchedular->AsyncStop(); |
|
624 |
inparam->Reset(); |
|
625 |
outparam->Reset(); |
|
626 |
return; |
|
627 |
}; |
|
628 |
} |
|
629 |
||
630 |
||
631 |
TUint localUid; |
|
632 |
TInt entryAdded = 0; |
|
633 |
if( AddProvAppointmentDailyRepeat(inparam, outparam, interface, KCalTestImportSync1, localUid ) != KErrNone ) |
|
634 |
{ |
|
635 |
if(iWaitSchedular->IsStarted()) |
|
636 |
iWaitSchedular->AsyncStop(); |
|
637 |
inparam->Reset(); |
|
638 |
outparam->Reset(); |
|
639 |
return; |
|
640 |
}; |
|
641 |
iEntryAdded++; |
|
642 |
||
643 |
inparam->Reset(); |
|
644 |
outparam->Reset(); |
|
645 |
||
646 |
if( AddProvAppointmentDailyRepeat(inparam, outparam, interface, KCalTestImportSync1, localUid ) != KErrNone ) |
|
647 |
{ |
|
648 |
if(iWaitSchedular->IsStarted()) |
|
649 |
iWaitSchedular->AsyncStop(); |
|
650 |
inparam->Reset(); |
|
651 |
outparam->Reset(); |
|
652 |
return; |
|
653 |
}; |
|
654 |
iEntryAdded++; |
|
655 |
||
656 |
inparam->Reset(); |
|
657 |
outparam->Reset(); |
|
658 |
||
659 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
660 |
CleanupStack::PushL(map); |
|
661 |
||
662 |
TLiwGenericParam element1; |
|
663 |
element1.SetNameAndValueL(_L8("Type"),TLiwVariant(_L("CalendarEntry"))); |
|
664 |
inparam->AppendL(element1); |
|
665 |
element1.Reset(); |
|
666 |
||
667 |
map->InsertL(_L8("CalendarName"), TLiwVariant(KCalTestImportSync1) ); |
|
668 |
||
669 |
if(iICalFormat) |
|
670 |
map->InsertL(_L8("Format"), TLiwVariant(_L("ICal")) ); |
|
671 |
else |
|
672 |
map->InsertL(_L8("Format"), TLiwVariant(_L("VCal")) ); |
|
673 |
||
674 |
if( iOption == 1 ) |
|
675 |
{ |
|
676 |
map->InsertL(_L8("FileName"), TLiwVariant(_L("c:\\exportall.txt"))); |
|
677 |
} |
|
678 |
||
679 |
TLiwVariant filterparam(map); |
|
680 |
TLiwGenericParam element ; |
|
681 |
element.SetNameAndValueL(_L8("Data"),filterparam); |
|
682 |
filterparam.Reset(); |
|
683 |
||
684 |
inparam->AppendL(element); |
|
685 |
element.Reset(); |
|
686 |
map->DecRef(); |
|
687 |
CleanupStack::Pop(map); |
|
688 |
||
689 |
TRAPD(err1, interface->ExecuteCmdL(KCmdExport, *inparam, *outparam )); |
|
690 |
||
691 |
pos = 0; |
|
692 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
693 |
||
694 |
HBufC8* exportBuffer = NULL; |
|
695 |
||
696 |
if( iOption == 0) |
|
697 |
{ |
|
698 |
if(output) |
|
699 |
{ |
|
700 |
err = output->Value().AsTInt32(); |
|
701 |
if(err == KErrNone) |
|
702 |
{ |
|
703 |
pos = 0; |
|
704 |
output = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
705 |
if ( output ) |
|
706 |
{ |
|
707 |
exportBuffer = output->Value().AsData().AllocL(); |
|
708 |
} |
|
709 |
} |
|
710 |
else |
|
711 |
{ |
|
712 |
if(iWaitSchedular->IsStarted()) |
|
713 |
iWaitSchedular->AsyncStop(); |
|
714 |
} |
|
715 |
||
716 |
} |
|
717 |
||
718 |
inparam->Reset(); |
|
719 |
outparam->Reset(); |
|
720 |
||
721 |
if ( exportBuffer ) |
|
722 |
{ |
|
723 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
724 |
CleanupStack::PushL(map); |
|
725 |
||
726 |
TLiwGenericParam element1; |
|
727 |
||
728 |
if(iPosBased) |
|
729 |
element1.SetNameAndValueL( KNullDesC8, TLiwVariant(_L("CalendarEntry"))); |
|
730 |
else |
|
731 |
element1.SetNameAndValueL( _L8("Type"),TLiwVariant(_L("CalendarEntry"))); |
|
732 |
||
733 |
||
734 |
inparam->AppendL(element1); |
|
735 |
element1.Reset(); |
|
736 |
||
737 |
map->InsertL(_L8("CalendarName"), TLiwVariant(KCalTestImportSync2) ); |
|
738 |
||
739 |
if(iInvalidFormat) |
|
740 |
map->InsertL(_L8("Format"), TLiwVariant(_L("InvalidFormat")) ); |
|
741 |
else if(iICalFormat) |
|
742 |
map->InsertL(_L8("Format"), TLiwVariant(_L("ICal")) ); |
|
743 |
else |
|
744 |
map->InsertL(_L8("Format"), TLiwVariant(_L("VCal")) ); |
|
745 |
||
746 |
map->InsertL(_L8("Buffer"), TLiwVariant( exportBuffer->Des() ) ); |
|
747 |
||
748 |
TLiwVariant filterparam(map); |
|
749 |
TLiwGenericParam element ; |
|
750 |
||
751 |
if(iPosBased) |
|
752 |
element.SetNameAndValueL( KNullDesC8, filterparam ); |
|
753 |
else |
|
754 |
element.SetNameAndValueL( _L8("Data"), filterparam); |
|
755 |
||
756 |
||
757 |
filterparam.Reset(); |
|
758 |
||
759 |
inparam->AppendL(element); |
|
760 |
element.Reset(); |
|
761 |
map->DecRef(); |
|
762 |
CleanupStack::Pop(map); |
|
763 |
||
764 |
if(iAsync) |
|
765 |
{ |
|
766 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
767 |
||
768 |
iCallback->iEntryAdded = iEntryAdded; |
|
769 |
||
770 |
TRAPD(err1, interface->ExecuteCmdL(KCmdImport, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
771 |
||
772 |
pos = 0; |
|
773 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
774 |
||
775 |
if(output) |
|
776 |
{ |
|
777 |
iTransactionId = output->Value().AsTInt32(); |
|
778 |
} |
|
779 |
else |
|
780 |
{ |
|
781 |
if(iWaitSchedular->IsStarted()) |
|
782 |
iWaitSchedular->AsyncStop(); |
|
783 |
} |
|
784 |
inparam->Reset(); |
|
785 |
outparam->Reset(); |
|
786 |
} |
|
787 |
else |
|
788 |
{ |
|
789 |
TRAPD(err1, interface->ExecuteCmdL(KCmdImport, *inparam, *outparam )); |
|
790 |
pos = 0; |
|
791 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
792 |
||
793 |
if(output) |
|
794 |
{ |
|
795 |
err = output->Value().AsTInt32(); |
|
796 |
if(err == KErrNone) |
|
797 |
{ |
|
798 |
pos = 0; |
|
799 |
output = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
800 |
if ( output ) |
|
801 |
{ |
|
802 |
CLiwIterable* iterlist = output->Value().AsIterable(); |
|
803 |
||
804 |
TInt returnItems = 0; |
|
805 |
||
806 |
if(iterlist) |
|
807 |
{ |
|
808 |
TLiwVariant data; |
|
809 |
||
810 |
while ( iterlist->NextL(data) ) |
|
811 |
returnItems++; |
|
812 |
||
813 |
data.Reset(); |
|
814 |
} |
|
815 |
||
816 |
if(iEntryAdded == returnItems) |
|
817 |
iResult = KErrNone; |
|
818 |
} |
|
819 |
} |
|
820 |
else |
|
821 |
{ |
|
822 |
iResult = err; |
|
823 |
} |
|
824 |
||
825 |
} |
|
826 |
} |
|
827 |
} |
|
828 |
delete exportBuffer; |
|
829 |
} |
|
830 |
else |
|
831 |
{ |
|
832 |
if(output) |
|
833 |
{ |
|
834 |
err = output->Value().AsTInt32(); |
|
835 |
inparam->Reset(); |
|
836 |
outparam->Reset(); |
|
837 |
||
838 |
if(err == KErrNone) |
|
839 |
{ |
|
840 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
841 |
CleanupStack::PushL(map); |
|
842 |
||
843 |
TLiwGenericParam element1; |
|
844 |
element1.SetNameAndValueL(_L8("Type"),TLiwVariant(_L("CalendarEntry"))); |
|
845 |
inparam->AppendL(element1); |
|
846 |
element1.Reset(); |
|
847 |
||
848 |
map->InsertL(_L8("CalendarName"), TLiwVariant(KCalTestImportSync2) ); |
|
849 |
||
850 |
if(iICalFormat) |
|
851 |
map->InsertL(_L8("Format"), TLiwVariant(_L("ICal")) ); |
|
852 |
else |
|
853 |
map->InsertL(_L8("Format"), TLiwVariant(_L("VCal")) ); |
|
854 |
||
855 |
map->InsertL(_L8("FileName"), TLiwVariant( _L("c:\\exportall.txt") ) ); |
|
856 |
||
857 |
TLiwVariant filterparam(map); |
|
858 |
TLiwGenericParam element ; |
|
859 |
element.SetNameAndValueL(_L8("Data"),filterparam); |
|
860 |
filterparam.Reset(); |
|
861 |
||
862 |
inparam->AppendL(element); |
|
863 |
element.Reset(); |
|
864 |
map->DecRef(); |
|
865 |
CleanupStack::Pop(map); |
|
866 |
if(iAsync) |
|
867 |
{ |
|
868 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
869 |
||
870 |
iCallback->iEntryAdded = iEntryAdded; |
|
871 |
||
872 |
TRAPD(err1, interface->ExecuteCmdL(KCmdImport, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
873 |
||
874 |
pos = 0; |
|
875 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
876 |
||
877 |
if(output) |
|
878 |
{ |
|
879 |
iTransactionId = output->Value().AsTInt32(); |
|
880 |
} |
|
881 |
else |
|
882 |
{ |
|
883 |
if(iWaitSchedular->IsStarted()) |
|
884 |
iWaitSchedular->AsyncStop(); |
|
885 |
} |
|
886 |
||
887 |
||
888 |
inparam->Reset(); |
|
889 |
outparam->Reset(); |
|
890 |
} |
|
891 |
else |
|
892 |
{ |
|
893 |
TRAPD(err1, interface->ExecuteCmdL(KCmdImport, *inparam, *outparam )); |
|
894 |
pos = 0; |
|
895 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
896 |
||
897 |
if(output) |
|
898 |
{ |
|
899 |
err = output->Value().AsTInt32(); |
|
900 |
if(err == KErrNone) |
|
901 |
{ |
|
902 |
pos = 0; |
|
903 |
output = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
904 |
if ( output ) |
|
905 |
{ |
|
906 |
CLiwIterable* iterlist = output->Value().AsIterable(); |
|
907 |
||
908 |
TInt returnItems = 0; |
|
909 |
||
910 |
if(iterlist) |
|
911 |
{ |
|
912 |
TLiwVariant data; |
|
913 |
||
914 |
while ( iterlist->NextL(data) ) |
|
915 |
returnItems++; |
|
916 |
||
917 |
data.Reset(); |
|
918 |
} |
|
919 |
||
920 |
if(iEntryAdded == returnItems) |
|
921 |
iResult = KErrNone; |
|
922 |
} |
|
923 |
} |
|
924 |
else |
|
925 |
{ |
|
926 |
iResult = err; |
|
927 |
} |
|
928 |
} |
|
929 |
} |
|
930 |
} |
|
931 |
else |
|
932 |
{ |
|
933 |
if(iWaitSchedular->IsStarted()) |
|
934 |
iWaitSchedular->AsyncStop(); |
|
935 |
} |
|
936 |
} |
|
937 |
} |
|
938 |
inparam->Reset(); |
|
939 |
outparam->Reset(); |
|
940 |
} |
|
941 |
||
942 |
void CTestAsync::ImportInvalidFile() |
|
943 |
{ |
|
944 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
945 |
||
946 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
947 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
948 |
||
949 |
TInt err; |
|
950 |
||
951 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KTestInterface,KTestContent); |
|
952 |
||
953 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
954 |
||
955 |
RCriteriaArray a; |
|
956 |
a.AppendL(crit); |
|
957 |
||
958 |
iServiceHandler->AttachL(a); |
|
959 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
960 |
||
961 |
a.Reset(); |
|
962 |
delete crit; |
|
963 |
||
964 |
TInt pos = 0; |
|
965 |
||
966 |
outparam->FindFirst( pos, KTestInterface ); |
|
967 |
if(pos != KErrNotFound) |
|
968 |
{ |
|
969 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
970 |
} |
|
971 |
||
972 |
outparam->Reset(); |
|
973 |
inparam->Reset(); |
|
974 |
||
975 |
||
976 |
RemoveProvCalendar(inparam, outparam, interface, KCalTestImportSync1); |
|
977 |
||
978 |
if( AddProvCalendar(inparam, outparam, interface, KCalTestImportSync1) != KErrNone) |
|
979 |
{ |
|
980 |
if(iWaitSchedular->IsStarted()) |
|
981 |
iWaitSchedular->AsyncStop(); |
|
982 |
inparam->Reset(); |
|
983 |
outparam->Reset(); |
|
984 |
return; |
|
985 |
}; |
|
986 |
||
987 |
inparam->Reset(); |
|
988 |
outparam->Reset(); |
|
989 |
||
990 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
991 |
CleanupStack::PushL(map); |
|
992 |
||
993 |
TLiwGenericParam element1; |
|
994 |
element1.SetNameAndValueL(_L8("Type"),TLiwVariant(_L("CalendarEntry"))); |
|
995 |
inparam->AppendL(element1); |
|
996 |
element1.Reset(); |
|
997 |
||
998 |
map->InsertL(_L8("CalendarName"), TLiwVariant(KCalTestImportSync1) ); |
|
999 |
||
1000 |
if(iICalFormat) |
|
1001 |
map->InsertL(_L8("Format"), TLiwVariant(_L("ICal")) ); |
|
1002 |
else |
|
1003 |
map->InsertL(_L8("Format"), TLiwVariant(_L("VCal")) ); |
|
1004 |
||
1005 |
map->InsertL(_L8("FileName"), TLiwVariant(_L("c:\\importfrominvalid.txt"))); |
|
1006 |
||
1007 |
||
1008 |
TLiwVariant filterparam(map); |
|
1009 |
TLiwGenericParam element ; |
|
1010 |
element.SetNameAndValueL(_L8("Data"),filterparam); |
|
1011 |
filterparam.Reset(); |
|
1012 |
||
1013 |
inparam->AppendL(element); |
|
1014 |
element.Reset(); |
|
1015 |
map->DecRef(); |
|
1016 |
CleanupStack::Pop(map); |
|
1017 |
||
1018 |
||
1019 |
TRAPD(err1, interface->ExecuteCmdL(KCmdImport, *inparam, *outparam )); |
|
1020 |
pos = 0; |
|
1021 |
||
1022 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
1023 |
||
1024 |
if(output) |
|
1025 |
{ |
|
1026 |
err = output->Value().AsTInt32(); |
|
1027 |
if(err == 1012) |
|
1028 |
{ |
|
1029 |
iResult = KErrNone; |
|
1030 |
} |
|
1031 |
else |
|
1032 |
{ |
|
1033 |
iResult = err; |
|
1034 |
} |
|
1035 |
} |
|
1036 |
else |
|
1037 |
{ |
|
1038 |
iResult = err1; |
|
1039 |
} |
|
1040 |
||
1041 |
RemoveProvCalendar(inparam, outparam, interface, KCalTestImportSync1); |
|
1042 |
||
1043 |
inparam->Reset(); |
|
1044 |
outparam->Reset(); |
|
1045 |
} |
|
1046 |
||
1047 |
TInt RemoveProvCalendar(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar) |
|
1048 |
{ |
|
1049 |
inparam->Reset(); |
|
1050 |
outparam->Reset(); |
|
1051 |
||
1052 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
1053 |
CleanupStack::PushL(map); |
|
1054 |
||
1055 |
TLiwVariant content(_L("Calendar")); |
|
1056 |
TLiwGenericParam element1; |
|
1057 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
1058 |
inparam->AppendL(element1); |
|
1059 |
content.Reset(); |
|
1060 |
element1.Reset(); |
|
1061 |
||
1062 |
||
1063 |
map->InsertL(_L8("CalendarName"), TLiwVariant(aCalendar)); |
|
1064 |
||
1065 |
TLiwVariant filterparam(map); |
|
1066 |
TLiwGenericParam element ; |
|
1067 |
element.SetNameAndValueL(_L8("Data"),filterparam); |
|
1068 |
filterparam.Reset(); |
|
1069 |
||
1070 |
inparam->AppendL(element); |
|
1071 |
element.Reset(); |
|
1072 |
map->DecRef(); |
|
1073 |
CleanupStack::Pop(map); |
|
1074 |
||
1075 |
TRAPD(err, interface->ExecuteCmdL( KCmdDelete ,*inparam,*outparam )); |
|
1076 |
TInt pos = 0 ; |
|
1077 |
||
1078 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
1079 |
||
1080 |
if(output) |
|
1081 |
{ |
|
1082 |
err = output->Value().AsTInt32(); |
|
1083 |
} |
|
1084 |
||
1085 |
inparam->Reset(); |
|
1086 |
outparam->Reset(); |
|
1087 |
||
1088 |
return err; |
|
1089 |
} |
|
1090 |
||
1091 |
TInt AddProvCalendar(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar) |
|
1092 |
{ |
|
1093 |
inparam->Reset(); |
|
1094 |
outparam->Reset(); |
|
1095 |
||
1096 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
1097 |
CleanupStack::PushL(map); |
|
1098 |
||
1099 |
TLiwVariant content(_L("Calendar")); |
|
1100 |
TLiwGenericParam element1; |
|
1101 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
1102 |
inparam->AppendL(element1); |
|
1103 |
content.Reset(); |
|
1104 |
element1.Reset(); |
|
1105 |
||
1106 |
||
1107 |
map->InsertL(_L8("CalendarName"), TLiwVariant(aCalendar) ); |
|
1108 |
||
1109 |
TLiwGenericParam element; |
|
1110 |
element.SetNameAndValueL(_L8("Item"),TLiwVariant(map)); |
|
1111 |
||
1112 |
inparam->AppendL(element); |
|
1113 |
element.Reset(); |
|
1114 |
map->DecRef(); |
|
1115 |
CleanupStack::Pop(map); |
|
1116 |
||
1117 |
TRAPD(err, interface->ExecuteCmdL( KCmdAdd, *inparam,*outparam )); |
|
1118 |
TInt pos = 0 ; |
|
1119 |
||
1120 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
1121 |
||
1122 |
if(output) |
|
1123 |
{ |
|
1124 |
err = output->Value().AsTInt32(); |
|
1125 |
} |
|
1126 |
||
1127 |
inparam->Reset(); |
|
1128 |
outparam->Reset(); |
|
1129 |
||
1130 |
return err; |
|
1131 |
}; |
|
1132 |
||
1133 |
void GetLocalUid( const TDesC& aLocalUid, TUint& aOutLocalUid ) |
|
1134 |
{ |
|
1135 |
aOutLocalUid = 0; |
|
1136 |
if( aLocalUid.Length() ) |
|
1137 |
{ |
|
1138 |
TInt sepPos = aLocalUid.Locate( KUidSeparator ); |
|
1139 |
TPtrC temp; |
|
1140 |
if( sepPos == KErrNotFound ) |
|
1141 |
{ |
|
1142 |
temp.Set(aLocalUid.Mid(0)); |
|
1143 |
} |
|
1144 |
else |
|
1145 |
{ |
|
1146 |
temp.Set(aLocalUid.Mid(0, sepPos)); |
|
1147 |
} |
|
1148 |
||
1149 |
TLex lex(temp); |
|
1150 |
TInt32 num; |
|
1151 |
||
1152 |
if(lex.Val(num) == KErrNone) |
|
1153 |
aOutLocalUid = TUint(num); |
|
1154 |
} |
|
1155 |
} |
|
1156 |
||
1157 |
TInt AddProvAppointmentDailyRepeat(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUint& localuid) |
|
1158 |
{ |
|
1159 |
inparam->Reset(); |
|
1160 |
outparam->Reset(); |
|
1161 |
TInt cells = User::CountAllocCells(); |
|
1162 |
// __UHEAP_MARK; |
|
1163 |
||
1164 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
1165 |
CleanupStack::PushL(map); |
|
1166 |
||
1167 |
TLiwVariant content(_L("CalendarEntry")); |
|
1168 |
TLiwGenericParam element1; |
|
1169 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
1170 |
inparam->AppendL(element1); |
|
1171 |
content.Reset(); |
|
1172 |
element1.Reset(); |
|
1173 |
||
1174 |
||
1175 |
map->InsertL(_L8("CalendarName"), TLiwVariant(aCalendar) ); |
|
1176 |
map->InsertL(_L8("Type"), TLiwVariant( KEntryTypeMeeting )); |
|
1177 |
map->InsertL(_L8("StartTime"), TLiwVariant(TTime(TDateTime(2007,EOctober,23,10,0,0,0)))); |
|
1178 |
map->InsertL(_L8("EndTime"), TLiwVariant(TTime(TDateTime(2007,EOctober,23,10,30,0,0)))); |
|
1179 |
map->InsertL(_L8("Replication"), TLiwVariant(_L("Open"))); |
|
1180 |
map->InsertL(_L8("Description"), TLiwVariant(_L("Meeting"))); |
|
1181 |
map->InsertL(_L8("Status"), TLiwVariant(_L("Confirmed"))); |
|
1182 |
map->InsertL(_L8("Method"), TLiwVariant(_L("None"))); |
|
1183 |
||
1184 |
CLiwDefaultMap* repeatmap = CLiwDefaultMap::NewL(); |
|
1185 |
CleanupStack::PushL(repeatmap); |
|
1186 |
repeatmap->InsertL(_L8("Type"), TLiwVariant(TInt32(1))); |
|
1187 |
repeatmap->InsertL(_L8("StartDate"), TLiwVariant(TTime(TDateTime(2007,EOctober,23,10,0,0,0)))); |
|
1188 |
repeatmap->InsertL(_L8("UntilDate"), TLiwVariant(TTime(TDateTime(2007,EOctober,30,10,0,0,0)))); |
|
1189 |
map->InsertL(_L8("RepeatRule"), TLiwVariant(repeatmap)); |
|
1190 |
CleanupStack::Pop(repeatmap); |
|
1191 |
repeatmap->DecRef(); |
|
1192 |
||
1193 |
||
1194 |
TLiwGenericParam element; |
|
1195 |
element.SetNameAndValueL(_L8("Item"),TLiwVariant(map)); |
|
1196 |
||
1197 |
inparam->AppendL(element); |
|
1198 |
element.Reset(); |
|
1199 |
map->DecRef(); |
|
1200 |
CleanupStack::Pop(map); |
|
1201 |
||
1202 |
cells = User::CountAllocCells(); |
|
1203 |
||
1204 |
//TInt err; |
|
1205 |
TRAPD(err, interface->ExecuteCmdL( KCmdAdd, *inparam,*outparam )); |
|
1206 |
TInt pos = 0 ; |
|
1207 |
||
1208 |
cells = User::CountAllocCells(); |
|
1209 |
||
1210 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
1211 |
||
1212 |
cells = User::CountAllocCells(); |
|
1213 |
||
1214 |
if(output) |
|
1215 |
{ |
|
1216 |
err = output->Value().AsTInt32(); |
|
1217 |
if ( err == KErrNone ) |
|
1218 |
{ |
|
1219 |
pos = 0; |
|
1220 |
output = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
1221 |
if(output) |
|
1222 |
{ |
|
1223 |
TPtrC uidval = (TPtrC)(output->Value().AsDes()); |
|
1224 |
GetLocalUid( uidval, localuid ); |
|
1225 |
/*const CLiwMap* res = output->Value().AsMap(); |
|
1226 |
if ( res ) |
|
1227 |
{ |
|
1228 |
TLiwVariant luid; |
|
1229 |
if(res->FindL(_L8("LocalUid"), luid)) |
|
1230 |
{ |
|
1231 |
TLex lex(luid.AsDes()); |
|
1232 |
TInt32 num; |
|
1233 |
lex.Val(num); |
|
1234 |
||
1235 |
TUint localuid = 0; |
|
1236 |
localuid = TUint(num); |
|
1237 |
} |
|
1238 |
else |
|
1239 |
err = -1; |
|
1240 |
luid.Reset(); |
|
1241 |
} |
|
1242 |
else |
|
1243 |
err = -1;*/ |
|
1244 |
} |
|
1245 |
else |
|
1246 |
err = -1; |
|
1247 |
} |
|
1248 |
} |
|
1249 |
cells = User::CountAllocCells(); |
|
1250 |
inparam->Reset(); |
|
1251 |
outparam->Reset(); |
|
1252 |
cells = User::CountAllocCells(); |
|
1253 |
// __UHEAP_MARKEND; |
|
1254 |
||
1255 |
return err; |
|
1256 |
}; |