author | Pat Downey <patd@symbian.org> |
Wed, 01 Sep 2010 12:28:47 +0100 | |
branch | RCL_3 |
changeset 45 | a9c0808a1095 |
parent 44 | 0b68a1b0c15e |
permissions | -rw-r--r-- |
5 | 1 |
/* |
2 |
* Copyright (c) 2009 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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
19 |
#include<liwcommon.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
20 |
#include<liwvariant.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
21 |
#include<liwservicehandler.h> |
5 | 22 |
#include "tcalendardeletetest.h" |
23 |
#include "delete.h" |
|
24 |
#include "calendarheader.h" |
|
25 |
||
26 |
_LIT8(KTestInterface, "IDataSource"); |
|
27 |
_LIT8(KTestContent, "Service.Calendar"); |
|
28 |
_LIT8(KCmd, "Delete"); |
|
29 |
_LIT8(KCmdCancel, "CancelNotification"); |
|
30 |
_LIT8(KMessageId, "MessageId"); |
|
31 |
_LIT8(KMap, "NotificationType"); |
|
32 |
_LIT8(KMessageList, "MessageList" ); |
|
33 |
_LIT8(KMessage, "Message" ); |
|
34 |
_LIT8(KErrorCode,"ErrorCode"); |
|
35 |
_LIT(KMsgType,"NewMessage"); |
|
36 |
_LIT8(KContentType,"Type"); |
|
37 |
_LIT8(KFilter,"Filter"); |
|
38 |
_LIT8(KData,"Data"); |
|
39 |
_LIT8(KCalendarList, "CalendarList"); |
|
40 |
||
41 |
_LIT8(KDeleteAll,"DeleteAll"); |
|
42 |
_LIT(KCalFileName1,"C:CalendarFileA"); |
|
43 |
_LIT8(KCalendarName,"CalendarName"); |
|
44 |
||
45 |
TInt AddProvCalendar(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar); |
|
46 |
TInt RemoveProvCalendar(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar); |
|
47 |
TInt AddProvToDo(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUIDSet*& uidset); |
|
48 |
TInt AddProvDayEvent(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUIDSet*& uidset); |
|
49 |
TInt AddProvAppointmentDailyRepeat(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUIDSet*& uidset); |
|
50 |
||
51 |
||
52 |
CCalCallback* CCalCallback::NewL(CActiveSchedulerWait* aWaitSchedular, MLiwInterface* aInterface, TInt& aRes, TInt& aFlag) |
|
53 |
{ |
|
54 |
return new (ELeave) CCalCallback(aWaitSchedular, aInterface, aRes, aFlag); |
|
55 |
} |
|
56 |
||
57 |
TInt CCalCallback::HandleNotifyL(TInt aCmdId, |
|
58 |
TInt aEventId, |
|
59 |
CLiwGenericParamList& aEventParamList, |
|
60 |
const CLiwGenericParamList& aInParamList) |
|
61 |
{ |
|
45 | 62 |
TInt32 errCode = 0; |
5 | 63 |
TInt pos = 0; |
64 |
||
65 |
// Traiverse the List and Fill in the Log Files |
|
66 |
const TLiwGenericParam* p = aEventParamList.FindFirst(pos, KErrorCode); // Finding Error Code |
|
67 |
if( p ) |
|
68 |
{ |
|
69 |
errCode = p->Value().AsTInt32(); |
|
70 |
} |
|
71 |
||
72 |
if ( errCode == KErrNone ) |
|
73 |
{ |
|
74 |
||
75 |
CLiwGenericParamList* inParamList = CLiwGenericParamList::NewL(); |
|
76 |
CLiwGenericParamList* outParamList = CLiwGenericParamList::NewL(); |
|
77 |
||
78 |
TLiwVariant dsName; |
|
79 |
dsName.Set(_L("CalendarEntry")); |
|
80 |
TLiwGenericParam dsNameParam(KContentType, dsName); |
|
81 |
inParamList->AppendL(dsNameParam); |
|
82 |
dsName.Reset(); |
|
83 |
||
84 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
85 |
TLiwGenericParam filterParam(KFilter, TLiwVariant(filterMap)); |
|
86 |
inParamList->AppendL(filterParam); |
|
87 |
filterMap->DecRef(); |
|
88 |
||
89 |
TLiwVariant calname; |
|
90 |
calname.Set(KCalFileName1);; |
|
91 |
filterMap->InsertL(KCalendarName,calname); |
|
92 |
calname.Reset(); |
|
93 |
||
94 |
||
95 |
TInt err = 0; |
|
96 |
TRAP(err,iInterface->ExecuteCmdL( _L8("GetList") ,*inParamList ,*outParamList)); |
|
97 |
||
98 |
pos = 0 ; |
|
99 |
||
100 |
const TLiwGenericParam* finaloutput = outParamList->FindFirst( pos,_L8("ReturnValue")); |
|
101 |
TInt count = 0; |
|
102 |
CLiwMap* map; |
|
103 |
||
104 |
if ( finaloutput ) |
|
105 |
{ |
|
106 |
CLiwIterable* iterlist = finaloutput->Value().AsIterable(); |
|
107 |
if(iterlist) |
|
108 |
{ |
|
109 |
TLiwVariant data; |
|
110 |
while(iterlist->NextL(data) ) |
|
111 |
{ |
|
112 |
count++; |
|
113 |
} |
|
114 |
data.Reset(); |
|
115 |
} |
|
116 |
} |
|
117 |
if(iOption==1) |
|
118 |
{ |
|
119 |
if(count != 8) |
|
120 |
errCode = KErrGeneral; |
|
121 |
} |
|
122 |
else if(iOption==2) |
|
123 |
{ |
|
124 |
if(count != 5) |
|
125 |
errCode = KErrGeneral; |
|
126 |
} |
|
127 |
else if(iOption==3) |
|
128 |
{ |
|
129 |
if(count != 4) |
|
130 |
errCode = KErrGeneral; |
|
131 |
} |
|
132 |
else if(iOption==4) |
|
133 |
{ |
|
134 |
if(count != 0) |
|
135 |
errCode = KErrGeneral; |
|
136 |
} |
|
137 |
inParamList->Reset(); |
|
138 |
outParamList->Reset(); |
|
139 |
RemoveProvCalendar(inParamList, outParamList, iInterface, KCalFileName1); |
|
140 |
delete inParamList; |
|
141 |
delete outParamList; |
|
142 |
||
143 |
} |
|
144 |
if ( iWaitSchedular && iWaitSchedular->IsStarted()) |
|
145 |
{ |
|
146 |
iWaitSchedular->AsyncStop(); |
|
147 |
} |
|
148 |
iResult = errCode; |
|
149 |
return errCode; |
|
150 |
} |
|
151 |
||
152 |
||
153 |
||
154 |
CTestAsync* CTestAsync::NewL() |
|
155 |
{ |
|
156 |
CTestAsync* self = new (ELeave) CTestAsync(); |
|
157 |
self->ConstructL(); |
|
158 |
return self; |
|
159 |
} |
|
160 |
||
161 |
CTestAsync::~CTestAsync() |
|
162 |
{ |
|
163 |
Cancel(); |
|
164 |
||
165 |
if( interface ) |
|
166 |
interface->Close(); |
|
167 |
||
168 |
delete iServiceHandler; |
|
169 |
||
170 |
delete iCallback; |
|
171 |
||
172 |
if(iWaitSchedular && iWaitSchedular->IsStarted()) |
|
173 |
iWaitSchedular->AsyncStop(); |
|
174 |
||
175 |
delete iWaitSchedular; |
|
176 |
} |
|
177 |
||
178 |
||
179 |
void CTestAsync::ConstructL() |
|
180 |
{ |
|
181 |
CActiveScheduler::Add(this); |
|
182 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
183 |
} |
|
184 |
||
185 |
||
186 |
CTestAsync::CTestAsync() : |
|
187 |
CActive(EPriorityStandard) |
|
188 |
{ |
|
189 |
interface = NULL ; |
|
190 |
} |
|
191 |
||
192 |
void CTestAsync::DoCancel() |
|
193 |
{ |
|
194 |
||
195 |
} |
|
196 |
||
197 |
void CTestAsync::RunL() |
|
198 |
{ |
|
199 |
||
200 |
TestFunc(); |
|
201 |
||
202 |
} |
|
203 |
||
204 |
||
205 |
TInt CTestAsync::Start(TInt aFlag, TBool aAsync) |
|
206 |
{ |
|
207 |
iFlag = aFlag; |
|
208 |
iAsync = aAsync; |
|
209 |
if(aAsync) |
|
210 |
{ |
|
211 |
SetActive(); |
|
212 |
TRequestStatus* temp = &iStatus; |
|
213 |
User::RequestComplete(temp, KErrNone); |
|
214 |
iWaitSchedular->Start(); |
|
215 |
} |
|
216 |
else |
|
217 |
TestFunc(); |
|
218 |
||
219 |
return iResult; |
|
220 |
} |
|
221 |
||
222 |
||
223 |
int CTestAsync::TestFunc() |
|
224 |
{ |
|
225 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
226 |
||
227 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
228 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
229 |
||
230 |
||
231 |
TInt err; |
|
232 |
||
233 |
RCriteriaArray interest; |
|
234 |
CleanupClosePushL(interest); |
|
235 |
||
236 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KTestInterface,KTestContent); |
|
237 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
238 |
CleanupStack::PushL(crit); |
|
239 |
interest.AppendL(crit); |
|
240 |
iServiceHandler->AttachL(interest); |
|
241 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
242 |
||
243 |
TInt pos = 0; |
|
244 |
||
245 |
outparam->FindFirst( pos, KTestInterface ); |
|
246 |
if(pos != KErrNotFound) |
|
247 |
{ |
|
248 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
249 |
} |
|
250 |
||
251 |
CleanupStack::PopAndDestroy(crit); |
|
252 |
CleanupStack::PopAndDestroy(&interest); |
|
253 |
||
254 |
outparam->Reset(); |
|
255 |
inparam->Reset(); |
|
256 |
||
257 |
RemoveProvCalendar(inparam, outparam, interface, KCalFileName1); |
|
258 |
AddProvCalendar(inparam, outparam, interface, KCalFileName1); |
|
259 |
||
260 |
TUIDSet* uidset; |
|
261 |
//RPointerArray<TUIDSet> arruids(5); |
|
262 |
||
263 |
AddProvToDo(inparam, outparam, interface, KCalFileName1 ,uidset); |
|
264 |
delete uidset; |
|
265 |
||
266 |
AddProvDayEvent(inparam, outparam, interface, KCalFileName1 ,uidset) ; |
|
267 |
delete uidset; |
|
268 |
||
269 |
AddProvAppointmentDailyRepeat(inparam, outparam, interface, KCalFileName1 ,uidset ); |
|
270 |
delete uidset; |
|
271 |
||
272 |
TLiwVariant dsName; |
|
273 |
dsName.Set(_L("CalendarEntry")); |
|
274 |
TLiwGenericParam dsNameParam(KContentType, dsName); |
|
275 |
inparam->AppendL(dsNameParam); |
|
276 |
dsName.Reset(); |
|
277 |
||
278 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
279 |
TLiwGenericParam filterParam(KData, TLiwVariant(filterMap)); |
|
280 |
inparam->AppendL(filterParam); |
|
281 |
filterMap->DecRef(); |
|
282 |
||
283 |
filterMap->InsertL(KCalendarName,TLiwVariant(_L("C:CalendarFileA"))); |
|
284 |
if(iFlag == 1) |
|
285 |
{ |
|
286 |
filterMap->InsertL(_L8("StartRange"), TLiwVariant(TTime(TDateTime(2007,EAugust,19,0,0,0,0)))); |
|
287 |
filterMap->InsertL(_L8("EndRange"), TLiwVariant(TTime(TDateTime(2007,EOctober,24,0,0,0,0)))); |
|
288 |
} |
|
289 |
||
290 |
else if(iFlag == 2) |
|
291 |
{ |
|
292 |
filterMap->InsertL(_L8("EndRange"), TLiwVariant(TTime(TDateTime(2007,EOctober,25,11,0,0,0)))); |
|
293 |
} |
|
294 |
||
295 |
else if(iFlag == 3) |
|
296 |
{ |
|
297 |
filterMap->InsertL(_L8("StartRange"), TLiwVariant(TTime(TDateTime(2007,EOctober,25,10,0,0,0)))); |
|
298 |
} |
|
299 |
||
300 |
else if(iFlag == 4) |
|
301 |
{ |
|
302 |
filterMap->InsertL(_L8("DeleteAll"), TLiwVariant(TBool(ETrue))); |
|
303 |
} |
|
304 |
||
305 |
if(iAsync) |
|
306 |
{ |
|
307 |
iCallback = CCalCallback::NewL(iWaitSchedular, interface, iResult, iFlag); |
|
308 |
TRAPD(err1 ,interface->ExecuteCmdL(KCmd, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
309 |
inparam->Reset(); |
|
310 |
outparam->Reset(); |
|
311 |
} |
|
312 |
else |
|
313 |
{ |
|
314 |
TRAPD(err1 ,interface->ExecuteCmdL(KCmd, *inparam, *outparam)); |
|
315 |
const TLiwGenericParam* p = outparam->FindFirst(pos, KErrorCode); // Finding Error Code |
|
45 | 316 |
TInt errCode = 0; |
5 | 317 |
if( p ) |
318 |
{ |
|
319 |
errCode = p->Value().AsTInt32(); |
|
320 |
} |
|
321 |
inparam->Reset(); |
|
322 |
outparam->Reset(); |
|
323 |
||
324 |
if ( errCode == KErrNone ) |
|
325 |
{ |
|
326 |
TLiwGenericParam dsNameParam(KContentType, TLiwVariant(_L("CalendarEntry"))); |
|
327 |
inparam->AppendL(dsNameParam); |
|
328 |
||
329 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
330 |
TLiwGenericParam filterParam(KFilter, TLiwVariant(filterMap)); |
|
331 |
inparam->AppendL(filterParam); |
|
332 |
filterMap->DecRef(); |
|
333 |
||
334 |
filterMap->InsertL(KCalendarName,TLiwVariant(_L("C:CalendarFileA"))); |
|
335 |
||
336 |
||
337 |
TInt err = 0; |
|
338 |
TRAP(err,interface->ExecuteCmdL( _L8("GetList") ,*inparam ,*outparam)); |
|
339 |
||
340 |
pos = 0 ; |
|
341 |
||
342 |
const TLiwGenericParam* finaloutput = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
343 |
TInt count = 0; |
|
344 |
CLiwMap* map; |
|
345 |
||
346 |
if ( finaloutput ) |
|
347 |
{ |
|
348 |
CLiwIterable* iterlist = finaloutput->Value().AsIterable(); |
|
349 |
if(iterlist) |
|
350 |
{ |
|
351 |
TLiwVariant data; |
|
352 |
while(iterlist->NextL(data) ) |
|
353 |
{ |
|
354 |
count++; |
|
355 |
} |
|
356 |
data.Reset(); |
|
357 |
} |
|
358 |
} |
|
359 |
if(iFlag==1) |
|
360 |
{ |
|
361 |
if(count != 8) |
|
362 |
errCode = KErrGeneral; |
|
363 |
} |
|
364 |
else if(iFlag==2) |
|
365 |
{ |
|
366 |
if(count != 5) |
|
367 |
errCode = KErrGeneral; |
|
368 |
} |
|
369 |
else if(iFlag==3) |
|
370 |
{ |
|
371 |
if(count != 4) |
|
372 |
errCode = KErrGeneral; |
|
373 |
} |
|
374 |
else if(iFlag==4) |
|
375 |
{ |
|
376 |
if(count != 0) |
|
377 |
errCode = KErrGeneral; |
|
378 |
} |
|
379 |
inparam->Reset(); |
|
380 |
outparam->Reset(); |
|
381 |
RemoveProvCalendar(inparam, outparam, interface, KCalFileName1); |
|
382 |
} |
|
383 |
if ( iWaitSchedular && iWaitSchedular->IsStarted()) |
|
384 |
{ |
|
385 |
iWaitSchedular->AsyncStop(); |
|
386 |
} |
|
387 |
iResult = errCode; |
|
388 |
return errCode; |
|
389 |
} |
|
45 | 390 |
return 0; |
5 | 391 |
} |
392 |
||
393 |
||
394 |
||
395 |
int DeleteAllAsync(int flag, TBool async) |
|
396 |
{ |
|
397 |
__UHEAP_MARK; |
|
398 |
CTestAsync* test = CTestAsync::NewL(); |
|
399 |
int res = test->Start(flag, async); |
|
400 |
delete test; |
|
401 |
__UHEAP_MARKEND; |
|
402 |
return res; |
|
403 |
||
404 |
} |
|
405 |
||
406 |
||
407 |
CTestSync* CTestSync::NewL() |
|
408 |
{ |
|
409 |
CTestSync* self = new (ELeave) CTestSync(); |
|
410 |
self->ConstructL(); |
|
411 |
return self; |
|
412 |
} |
|
413 |
||
414 |
CTestSync::~CTestSync() |
|
415 |
{ |
|
416 |
if( interface ) |
|
417 |
interface->Close(); |
|
418 |
||
419 |
delete iServiceHandler; |
|
420 |
} |
|
421 |
||
422 |
||
423 |
void CTestSync::ConstructL() |
|
424 |
{ |
|
425 |
} |
|
426 |
||
427 |
||
428 |
CTestSync::CTestSync() |
|
429 |
{ |
|
430 |
interface = NULL ; |
|
431 |
} |
|
432 |
||
433 |
int CTestSync::TestFunc() |
|
434 |
{ |
|
435 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
436 |
||
437 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
438 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
439 |
||
440 |
||
441 |
TInt err; |
|
442 |
RCriteriaArray interest; |
|
443 |
CleanupClosePushL(interest); |
|
444 |
||
445 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KTestInterface,KTestContent); |
|
446 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
447 |
CleanupStack::PushL(crit); |
|
448 |
interest.AppendL(crit); |
|
449 |
||
450 |
iServiceHandler->AttachL(interest); |
|
451 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
452 |
||
453 |
TInt pos = 0; |
|
454 |
||
455 |
outparam->FindFirst( pos, KTestInterface ); |
|
456 |
if(pos != KErrNotFound) |
|
457 |
{ |
|
458 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
459 |
} |
|
460 |
CleanupStack::PopAndDestroy(crit); |
|
461 |
CleanupStack::PopAndDestroy(&interest); |
|
462 |
||
463 |
outparam->Reset(); |
|
464 |
inparam->Reset(); |
|
465 |
TLiwVariant dsName; |
|
466 |
dsName.Set(_L("CalendarEntry")); |
|
467 |
TLiwGenericParam dsNameParam(KContentType, dsName); |
|
468 |
inparam->AppendL(dsNameParam); |
|
469 |
dsName.Reset(); |
|
470 |
||
471 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
472 |
TLiwGenericParam filterParam(KData, TLiwVariant(filterMap)); |
|
473 |
inparam->AppendL(filterParam); |
|
474 |
filterMap->DecRef(); |
|
475 |
||
476 |
TLiwVariant calname; |
|
477 |
calname.Set(KCalFileName1);; |
|
478 |
filterMap->InsertL(_L8("CalendarName"),calname); |
|
479 |
calname.Reset(); |
|
480 |
||
481 |
TLiwVariant flag; |
|
482 |
flag.Set(ETrue);; |
|
483 |
filterMap->InsertL(KDeleteAll,flag); |
|
484 |
flag.Reset(); |
|
485 |
||
486 |
TRAPD(err1 ,interface->ExecuteCmdL(KCmd, *inparam, *outparam/*, KLiwOptASyncronous, iCallback*/)); |
|
487 |
inparam->Reset(); |
|
488 |
outparam->Reset(); |
|
489 |
return err1; |
|
490 |
} |
|
491 |
||
492 |
||
493 |
int DeleteAllSync() |
|
494 |
{ |
|
495 |
__UHEAP_MARK; |
|
496 |
CTestSync* test = CTestSync::NewL(); |
|
497 |
int res = test->TestFunc(); |
|
498 |
delete test; |
|
499 |
__UHEAP_MARKEND; |
|
500 |
return 0; |
|
501 |
||
502 |
} |
|
503 |
||
504 |
int DeleteDefaultSync() |
|
505 |
{ |
|
506 |
__UHEAP_MARK; |
|
507 |
CTestSync* test = CTestSync::NewL(); |
|
508 |
int res = test->DeleteDefaultCalendar(); |
|
509 |
delete test; |
|
510 |
__UHEAP_MARKEND; |
|
511 |
return res; |
|
512 |
||
513 |
} |
|
514 |
int DeleteWrongSync() |
|
515 |
{ |
|
516 |
__UHEAP_MARK; |
|
517 |
CTestSync* test = CTestSync::NewL(); |
|
518 |
int res = test->DeleteWrongCal(); |
|
519 |
delete test; |
|
520 |
__UHEAP_MARKEND; |
|
521 |
return res; |
|
522 |
||
523 |
} |
|
524 |
||
525 |
int CTestSync::DeleteDefaultCalendar() |
|
526 |
{ |
|
527 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
528 |
||
529 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
530 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
531 |
||
532 |
||
533 |
TInt err; |
|
534 |
RCriteriaArray interest; |
|
535 |
CleanupClosePushL(interest); |
|
536 |
||
537 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KTestInterface,KTestContent); |
|
538 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
539 |
CleanupStack::PushL(crit); |
|
540 |
interest.AppendL(crit); |
|
541 |
||
542 |
iServiceHandler->AttachL(interest); |
|
543 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
544 |
||
545 |
TInt pos = 0; |
|
546 |
||
547 |
outparam->FindFirst( pos, KTestInterface ); |
|
548 |
if(pos != KErrNotFound) |
|
549 |
{ |
|
550 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
551 |
} |
|
552 |
CleanupStack::PopAndDestroy(crit); |
|
553 |
CleanupStack::PopAndDestroy(&interest); |
|
554 |
||
555 |
outparam->Reset(); |
|
556 |
inparam->Reset(); |
|
557 |
TLiwVariant dsName; |
|
558 |
dsName.Set(_L("Calendar")); |
|
559 |
TLiwGenericParam dsNameParam(KContentType, dsName); |
|
560 |
inparam->AppendL(dsNameParam); |
|
561 |
dsName.Reset(); |
|
562 |
||
563 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
564 |
TLiwGenericParam filterParam(KData, TLiwVariant(filterMap)); |
|
565 |
inparam->AppendL(filterParam); |
|
566 |
filterMap->DecRef(); |
|
567 |
||
568 |
filterMap->InsertL(KCalendarName,TLiwVariant(_L("C:Calendar"))); |
|
569 |
||
570 |
TRAPD(err1 ,interface->ExecuteCmdL(KCmd, *inparam, *outparam/*, KLiwOptASyncronous, iCallback*/)); |
|
45 | 571 |
TInt errCode = 0; |
5 | 572 |
const TLiwGenericParam* p = outparam->FindFirst(pos, KErrorCode); // Finding Error Code |
573 |
if( p ) |
|
574 |
{ |
|
575 |
errCode = p->Value().AsTInt32(); |
|
576 |
} |
|
577 |
inparam->Reset(); |
|
578 |
outparam->Reset(); |
|
579 |
return errCode; |
|
580 |
} |
|
581 |
||
582 |
int CTestSync::DeleteWrongCal() |
|
583 |
{ |
|
584 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
585 |
||
586 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
587 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
588 |
||
589 |
||
590 |
TInt err; |
|
591 |
RCriteriaArray interest; |
|
592 |
CleanupClosePushL(interest); |
|
593 |
||
594 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KTestInterface,KTestContent); |
|
595 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
596 |
CleanupStack::PushL(crit); |
|
597 |
interest.AppendL(crit); |
|
598 |
||
599 |
iServiceHandler->AttachL(interest); |
|
600 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
601 |
||
602 |
TInt pos = 0; |
|
603 |
||
604 |
outparam->FindFirst( pos, KTestInterface ); |
|
605 |
if(pos != KErrNotFound) |
|
606 |
{ |
|
607 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
608 |
} |
|
609 |
CleanupStack::PopAndDestroy(crit); |
|
610 |
CleanupStack::PopAndDestroy(&interest); |
|
611 |
||
612 |
outparam->Reset(); |
|
613 |
inparam->Reset(); |
|
614 |
TLiwVariant dsName; |
|
615 |
dsName.Set(_L("Calendar")); |
|
616 |
TLiwGenericParam dsNameParam(KContentType, dsName); |
|
617 |
inparam->AppendL(dsNameParam); |
|
618 |
dsName.Reset(); |
|
619 |
||
620 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
621 |
TLiwGenericParam filterParam(KData, TLiwVariant(filterMap)); |
|
622 |
inparam->AppendL(filterParam); |
|
623 |
filterMap->DecRef(); |
|
624 |
||
625 |
filterMap->InsertL(KCalendarName,TLiwVariant(_L("C:CalendarFileZ"))); |
|
626 |
||
627 |
TRAPD(err1 ,interface->ExecuteCmdL(KCmd, *inparam, *outparam/*, KLiwOptASyncronous, iCallback*/)); |
|
45 | 628 |
TInt errCode = 0; |
5 | 629 |
const TLiwGenericParam* p = outparam->FindFirst(pos, KErrorCode); // Finding Error Code |
630 |
if( p ) |
|
631 |
{ |
|
632 |
errCode = p->Value().AsTInt32(); |
|
633 |
} |
|
634 |
inparam->Reset(); |
|
635 |
outparam->Reset(); |
|
636 |
return errCode; |
|
637 |
} |