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) 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 |
||
19 |
#include "calendarinterface.h" |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
20 |
#include<liwcommon.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
21 |
#include<liwvariant.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
22 |
#include<liwservicehandler.h> |
19 | 23 |
|
24 |
#include"notify.h" |
|
25 |
||
26 |
_LIT8(KTestInterface, "IDataSource"); |
|
27 |
_LIT8(KTestContent, "Service.Calendar"); |
|
28 |
_LIT8(KCmd, "RequestNotification"); |
|
29 |
//_LIT8(KCmdAdd, "Add"); |
|
30 |
//_LIT8(KCmdDelete, "Delete"); |
|
31 |
//_LIT8(KCmdCancel, "Cancel"); |
|
32 |
||
33 |
//_LIT8(KFilter, "Filter"); |
|
34 |
//_LIT8(KItem, "Item"); |
|
35 |
//_LIT8(KCalendarName, "CalendarName"); |
|
36 |
||
37 |
_LIT(KEntryTypeMeeting, "Meeting"); |
|
38 |
_LIT(KEntryTypeTodo, "ToDo"); |
|
39 |
||
40 |
//const TChar KUidSeparator = ':'; |
|
41 |
||
42 |
||
43 |
_LIT(KTestCalendar, "c:CalChangeNotify"); |
|
44 |
||
45 |
TInt RemoveProvCalendar(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar); |
|
46 |
TInt AddProvCalendar(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar); |
|
47 |
TInt AddProvAppointmentDailyRepeat(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUint& localuid); |
|
48 |
TInt AddProvTodo(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUint& localuid); |
|
49 |
||
50 |
CCalCallback* CCalCallback::NewL(CActiveSchedulerWait* aWaitSchedular, TInt& aResult) |
|
51 |
{ |
|
52 |
return new (ELeave) CCalCallback(aWaitSchedular, aResult); |
|
53 |
} |
|
54 |
||
55 |
TInt CCalCallback::HandleNotifyL(TInt aCmdId, |
|
56 |
TInt aEventId, |
|
57 |
CLiwGenericParamList& aEventParamList, |
|
58 |
const CLiwGenericParamList& aInParamList) |
|
59 |
{ |
|
60 |
TInt pos = 0; |
|
61 |
TInt result = KErrNone; |
|
62 |
const TLiwGenericParam* output = aEventParamList.FindFirst( pos,_L8("ReturnValue")); |
|
63 |
||
64 |
if(output) |
|
65 |
{ |
|
66 |
CLiwIterable* iterlist = output->Value().AsIterable(); |
|
67 |
||
68 |
TLiwVariant data; |
|
69 |
||
70 |
while( iterlist->NextL(data)) |
|
71 |
{ |
|
72 |
const CLiwMap* Map = data.AsMap(); |
|
73 |
||
74 |
TLiwVariant varluid; |
|
75 |
TUint luid = 0; |
|
76 |
TInt changetype = -1; |
|
77 |
||
78 |
if( Map->FindL(_L8("LocalId"),varluid)) |
|
79 |
{ |
|
80 |
TLex lex(varluid.AsDes()); |
|
81 |
TInt32 num; |
|
82 |
lex.Val(num); |
|
83 |
||
84 |
luid = TUint(num); |
|
85 |
} |
|
86 |
||
87 |
if( Map->FindL(_L8("ChangeType"),varluid)) |
|
88 |
{ |
|
89 |
TPtrC tmp = varluid.AsDes(); |
|
90 |
if(tmp.CompareF(_L("Add")) == 0) |
|
91 |
changetype = 1; |
|
92 |
else if(tmp.CompareF(_L("Delete")) == 0) |
|
93 |
changetype = 2; |
|
94 |
else if(tmp.CompareF(_L("Modify")) == 0) |
|
95 |
changetype = 3; |
|
96 |
} |
|
97 |
varluid.Reset(); |
|
98 |
||
99 |
if( ((luid == iLocalUid) || !iCheckLocalUid ) && (iChangeType == changetype)) |
|
100 |
{ |
|
101 |
iResult = KErrNone; |
|
102 |
break; |
|
103 |
} |
|
104 |
||
105 |
} |
|
106 |
data.Reset(); |
|
107 |
} |
|
108 |
||
109 |
if ( iWaitSchedular && iWaitSchedular->IsStarted()) |
|
110 |
{ |
|
111 |
iWaitSchedular->AsyncStop(); |
|
112 |
} |
|
113 |
return 0; |
|
114 |
} |
|
115 |
||
116 |
CTestAsync* CTestAsync::NewL() |
|
117 |
{ |
|
118 |
CTestAsync* self = new (ELeave) CTestAsync(); |
|
119 |
self->ConstructL(); |
|
120 |
return self; |
|
121 |
} |
|
122 |
||
123 |
CTestAsync::~CTestAsync() |
|
124 |
{ |
|
125 |
Cancel(); |
|
126 |
||
127 |
interface->Close(); |
|
128 |
||
129 |
delete iServiceHandler; |
|
130 |
||
131 |
delete iCallback; |
|
132 |
||
133 |
if(iWaitSchedular->IsStarted()) |
|
134 |
iWaitSchedular->AsyncStop(); |
|
135 |
||
136 |
delete iWaitSchedular; |
|
137 |
} |
|
138 |
||
139 |
||
140 |
void CTestAsync::ConstructL() |
|
141 |
{ |
|
142 |
CActiveScheduler::Add(this); |
|
143 |
iWaitSchedular = new(ELeave) CActiveSchedulerWait(); |
|
144 |
} |
|
145 |
||
146 |
||
147 |
CTestAsync::CTestAsync() : |
|
148 |
CActive(EPriorityStandard) |
|
149 |
{ |
|
150 |
interface = NULL ; |
|
151 |
iTestState = ETestIssueRequest; |
|
152 |
iResult = KErrGeneral; |
|
153 |
} |
|
154 |
||
155 |
void CTestAsync::DoCancel() |
|
156 |
{ |
|
157 |
||
158 |
} |
|
159 |
||
160 |
void CTestAsync::RunL() |
|
161 |
{ |
|
162 |
if(iTestState == ETestIssueRequest) |
|
163 |
{ |
|
164 |
TestFunc(); |
|
165 |
iTestState = ETestProcessRequest; |
|
166 |
||
167 |
iStatus = KRequestPending; |
|
168 |
SetActive(); |
|
169 |
TRequestStatus* temp = &iStatus; |
|
170 |
User::RequestComplete(temp, KErrNone); |
|
171 |
if(iStopWaitSch && iWaitSchedular->IsStarted()) |
|
172 |
iWaitSchedular->AsyncStop(); |
|
173 |
} |
|
174 |
else if(iTestState == ETestProcessRequest) |
|
175 |
{ |
|
176 |
if ( iChangeType == 1 ) |
|
177 |
DoAddChange(); |
|
178 |
else if ( iChangeType == 2 ) |
|
179 |
DoDeleteChange(); |
|
180 |
if ( iChangeType == 3 ) |
|
181 |
DoUpdateChange(); |
|
182 |
} |
|
183 |
} |
|
184 |
||
185 |
void CTestAsync::DoAddChange() |
|
186 |
{ |
|
187 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
188 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
189 |
TUint localUid; |
|
190 |
AddProvAppointmentDailyRepeat(inparam, outparam, interface, KTestCalendar, localUid ); |
|
191 |
iCallback->iLocalUid = localUid; |
|
192 |
} |
|
193 |
||
194 |
void CTestAsync::DoDeleteChange() |
|
195 |
{ |
|
196 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
197 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
198 |
||
199 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
200 |
CleanupStack::PushL(map); |
|
201 |
||
202 |
TLiwGenericParam element1; |
|
203 |
element1.SetNameAndValueL(_L8("Type"),TLiwVariant(_L("CalendarEntry"))); |
|
204 |
inparam->AppendL(element1); |
|
205 |
element1.Reset(); |
|
206 |
||
207 |
map->InsertL(_L8("CalendarName"), TLiwVariant(KTestCalendar) ); |
|
208 |
||
209 |
CLiwDefaultList* uidlist = CLiwDefaultList::NewL(); |
|
210 |
||
211 |
TBuf<10> luid; |
|
212 |
luid.Num(TInt64(iLocalUid)); |
|
213 |
uidlist->AppendL(TLiwVariant(luid)); |
|
214 |
map->InsertL(_L8("LocalIdList"), TLiwVariant(uidlist)); |
|
215 |
||
216 |
uidlist->DecRef(); |
|
217 |
||
218 |
TLiwVariant filterparam(map); |
|
219 |
TLiwGenericParam element ; |
|
220 |
element.SetNameAndValueL(_L8("Data"),filterparam); |
|
221 |
filterparam.Reset(); |
|
222 |
||
223 |
inparam->AppendL(element); |
|
224 |
element.Reset(); |
|
225 |
map->DecRef(); |
|
226 |
CleanupStack::Pop(map); |
|
227 |
||
228 |
TRAPD(err1, interface->ExecuteCmdL(KCmdDelete, *inparam, *outparam )); |
|
229 |
inparam->Reset(); |
|
230 |
outparam->Reset(); |
|
231 |
} |
|
232 |
||
233 |
void CTestAsync::DoUpdateChange() |
|
234 |
{ |
|
235 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
236 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
237 |
||
238 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
239 |
CleanupStack::PushL(map); |
|
240 |
||
241 |
TLiwGenericParam element1; |
|
242 |
element1.SetNameAndValueL(_L8("Type"),TLiwVariant(_L("CalendarEntry"))); |
|
243 |
inparam->AppendL(element1); |
|
244 |
element1.Reset(); |
|
245 |
||
246 |
map->InsertL(_L8("CalendarName"), TLiwVariant(KTestCalendar) ); |
|
247 |
//map->InsertL(_L8("LocalUid"), TLiwVariant(iLocalUid) ); |
|
248 |
TBuf<10> luid; |
|
249 |
luid.Num(TInt64(iLocalUid)); |
|
250 |
map->InsertL(_L8("LocalId"), TLiwVariant(luid)); |
|
251 |
map->InsertL(_L8("Description"), TLiwVariant(_L("New Description") )); |
|
252 |
||
253 |
||
254 |
TLiwVariant filterparam(map); |
|
255 |
TLiwGenericParam element ; |
|
256 |
element.SetNameAndValueL(_L8("Item"),filterparam); |
|
257 |
filterparam.Reset(); |
|
258 |
||
259 |
inparam->AppendL(element); |
|
260 |
element.Reset(); |
|
261 |
map->DecRef(); |
|
262 |
CleanupStack::Pop(map); |
|
263 |
||
264 |
TRAPD(err1, interface->ExecuteCmdL(KCmdAdd, *inparam, *outparam )); |
|
265 |
inparam->Reset(); |
|
266 |
outparam->Reset(); |
|
267 |
} |
|
268 |
||
269 |
TInt CTestAsync::Result() |
|
270 |
{ |
|
271 |
return iResult; |
|
272 |
} |
|
273 |
||
274 |
void CTestAsync::Start( TInt aChangeType, TBool aLocalUid, TBool aPosBased, TBool aStopWaitSch ) |
|
275 |
{ |
|
276 |
iCheckLocalUid = aLocalUid; |
|
277 |
iChangeType = aChangeType; |
|
278 |
iPosBased = aPosBased; |
|
279 |
iStopWaitSch = aStopWaitSch; |
|
280 |
SetActive(); |
|
281 |
TRequestStatus* temp = &iStatus; |
|
282 |
User::RequestComplete(temp, KErrNone); |
|
283 |
iWaitSchedular->Start(); |
|
284 |
} |
|
285 |
||
286 |
void CTestAsync::CancelNotification(TBool aResetOutput) |
|
287 |
{ |
|
288 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
289 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
290 |
||
291 |
TLiwGenericParam element1; |
|
292 |
||
293 |
if(iPosBased) |
|
294 |
element1.SetNameAndValueL(KNullDesC8,TLiwVariant(_L("CalendarEntry"))); |
|
295 |
else |
|
296 |
element1.SetNameAndValueL(_L8("Type"),TLiwVariant(_L("CalendarEntry"))); |
|
297 |
||
298 |
//inparam->AppendL(element1); |
|
299 |
element1.Reset(); |
|
300 |
||
301 |
TLiwGenericParam element2; |
|
302 |
||
303 |
if(iPosBased) |
|
304 |
element2.SetNameAndValueL(KNullDesC8,TLiwVariant(iTransactionId)); |
|
305 |
else |
|
306 |
element2.SetNameAndValueL(_L8("TransactionID"), TLiwVariant(iTransactionId)); |
|
307 |
inparam->AppendL(element2); |
|
308 |
element2.Reset(); |
|
309 |
||
310 |
TRAPD(err1, interface->ExecuteCmdL(KCmdCancel, *inparam, *outparam, KLiwOptCancel )); |
|
311 |
||
312 |
TInt pos = 0 ; |
|
313 |
||
314 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
315 |
||
316 |
if ( aResetOutput && ( (err1 == KErrNone) && output )) |
|
317 |
{ |
|
318 |
iResult = output->Value().AsTInt32(); |
|
319 |
} |
|
320 |
||
321 |
inparam->Reset(); |
|
322 |
outparam->Reset(); |
|
323 |
} |
|
324 |
||
325 |
void CTestAsync::TestFunc() |
|
326 |
{ |
|
327 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
328 |
||
329 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
330 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
331 |
||
332 |
||
333 |
TInt err; |
|
334 |
||
335 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KTestInterface,KTestContent); |
|
336 |
||
337 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
338 |
||
339 |
RCriteriaArray a; |
|
340 |
a.AppendL(crit); |
|
341 |
||
342 |
iServiceHandler->AttachL(a); |
|
343 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
344 |
||
345 |
a.Reset(); |
|
346 |
delete crit; |
|
347 |
||
348 |
TInt pos = 0; |
|
349 |
||
350 |
outparam->FindFirst( pos, KTestInterface ); |
|
351 |
if(pos != KErrNotFound) |
|
352 |
{ |
|
353 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
354 |
} |
|
355 |
||
356 |
outparam->Reset(); |
|
357 |
inparam->Reset(); |
|
358 |
||
359 |
||
360 |
// Add one entry and get the LocalUid |
|
361 |
RemoveProvCalendar(inparam, outparam, interface, KTestCalendar); |
|
362 |
||
363 |
if( AddProvCalendar(inparam, outparam, interface, KTestCalendar) != KErrNone) |
|
364 |
{ |
|
365 |
if(iWaitSchedular->IsStarted()) |
|
366 |
iWaitSchedular->AsyncStop(); |
|
367 |
inparam->Reset(); |
|
368 |
outparam->Reset(); |
|
369 |
return; |
|
370 |
}; |
|
371 |
||
372 |
||
373 |
TUint localUid; |
|
374 |
if( AddProvAppointmentDailyRepeat(inparam, outparam, interface, KTestCalendar, localUid ) != KErrNone ) |
|
375 |
{ |
|
376 |
if(iWaitSchedular->IsStarted()) |
|
377 |
iWaitSchedular->AsyncStop(); |
|
378 |
inparam->Reset(); |
|
379 |
outparam->Reset(); |
|
380 |
return; |
|
381 |
}; |
|
382 |
||
383 |
inparam->Reset(); |
|
384 |
outparam->Reset(); |
|
385 |
||
386 |
if( AddProvAppointmentDailyRepeat(inparam, outparam, interface, KTestCalendar, localUid ) != KErrNone ) |
|
387 |
{ |
|
388 |
if(iWaitSchedular->IsStarted()) |
|
389 |
iWaitSchedular->AsyncStop(); |
|
390 |
inparam->Reset(); |
|
391 |
outparam->Reset(); |
|
392 |
return; |
|
393 |
}; |
|
394 |
||
395 |
inparam->Reset(); |
|
396 |
outparam->Reset(); |
|
397 |
||
398 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
399 |
CleanupStack::PushL(map); |
|
400 |
||
401 |
TLiwGenericParam element1; |
|
402 |
||
403 |
if( iPosBased ) |
|
404 |
element1.SetNameAndValueL(KNullDesC8,TLiwVariant(_L("CalendarEntry"))); |
|
405 |
else |
|
406 |
element1.SetNameAndValueL(_L8("Type"),TLiwVariant(_L("CalendarEntry"))); |
|
407 |
||
408 |
inparam->AppendL(element1); |
|
409 |
element1.Reset(); |
|
410 |
||
411 |
map->InsertL(_L8("CalendarName"), TLiwVariant(KTestCalendar) ); |
|
412 |
||
413 |
CLiwDefaultList* uidlist = CLiwDefaultList::NewL(); |
|
414 |
TBuf<10> luid; |
|
415 |
luid.Num(TInt64(localUid)); |
|
416 |
//map->InsertL(_L8("LocalUid"), TLiwVariant(luid)); |
|
417 |
uidlist->AppendL(TLiwVariant(luid)); |
|
418 |
||
419 |
if ( iChangeType != 1 ) |
|
420 |
map->InsertL(_L8("LocalIdList"), TLiwVariant(uidlist)); |
|
421 |
||
422 |
uidlist->DecRef(); |
|
423 |
||
424 |
TLiwVariant filterparam(map); |
|
425 |
TLiwGenericParam element ; |
|
426 |
||
427 |
if( iPosBased ) |
|
428 |
element.SetNameAndValueL(KNullDesC8,filterparam); |
|
429 |
else |
|
430 |
element.SetNameAndValueL(_L8("Filter"),filterparam); |
|
431 |
||
432 |
filterparam.Reset(); |
|
433 |
||
434 |
inparam->AppendL(element); |
|
435 |
element.Reset(); |
|
436 |
map->DecRef(); |
|
437 |
CleanupStack::Pop(map); |
|
438 |
||
439 |
||
440 |
iCallback = CCalCallback::NewL(iWaitSchedular, iResult); |
|
441 |
||
442 |
iCallback->iChangeType = iChangeType; |
|
443 |
iCallback->iLocalUid = localUid; |
|
444 |
iCallback->iCheckLocalUid = iCheckLocalUid; |
|
445 |
iLocalUid = localUid; |
|
446 |
||
447 |
TRAPD(err1, interface->ExecuteCmdL(KCmd, *inparam, *outparam, KLiwOptASyncronous, iCallback)); |
|
448 |
||
449 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("TransactionID")); |
|
450 |
||
451 |
if(output) |
|
452 |
{ |
|
453 |
iTransactionId = output->Value().AsTInt32(); |
|
454 |
} |
|
455 |
else |
|
456 |
{ |
|
457 |
if(iWaitSchedular->IsStarted()) |
|
458 |
iWaitSchedular->AsyncStop(); |
|
459 |
} |
|
460 |
||
461 |
||
462 |
inparam->Reset(); |
|
463 |
outparam->Reset(); |
|
464 |
} |
|
465 |
||
466 |
||
467 |
TInt ReqNotification( TInt aChangeType, TBool aLocalUid, TBool aPosBased ) |
|
468 |
{ |
|
469 |
TInt result; |
|
470 |
||
471 |
__UHEAP_MARK; |
|
472 |
TInt cells = User::CountAllocCells(); |
|
473 |
CTestAsync* test = CTestAsync::NewL(); |
|
474 |
test->Start( aChangeType, aLocalUid, aPosBased ); |
|
475 |
result = test->Result(); |
|
476 |
test->CancelNotification(); |
|
477 |
delete test; |
|
478 |
cells = User::CountAllocCells(); |
|
479 |
__UHEAP_MARKEND; |
|
480 |
||
481 |
return result; |
|
482 |
} |
|
483 |
||
484 |
TInt ReqNotificationCancel( TInt aChangeType, TBool aLocalUid, TBool aPosBased, TBool aInvalidId, TBool aMultiCancel ) |
|
485 |
{ |
|
486 |
TInt result; |
|
487 |
||
488 |
__UHEAP_MARK; |
|
489 |
TInt cells = User::CountAllocCells(); |
|
490 |
CTestAsync* test = CTestAsync::NewL(); |
|
491 |
test->Start( aChangeType, aLocalUid, aPosBased ); |
|
492 |
result = test->Result(); |
|
493 |
test->CancelNotification(); |
|
494 |
||
495 |
if( aInvalidId ) |
|
496 |
{ |
|
497 |
test->CancelNotification(ETrue); |
|
498 |
result = test->Result(); |
|
499 |
if(result == 1012) |
|
500 |
result = KErrNone; |
|
501 |
} |
|
502 |
||
503 |
if( aMultiCancel ) |
|
504 |
{ |
|
505 |
for(TInt i = 0; i < 100; i++) |
|
506 |
test->CancelNotification(ETrue); |
|
507 |
||
508 |
result = test->Result(); |
|
509 |
if(result == 1012) |
|
510 |
result = KErrNone; |
|
511 |
} |
|
512 |
||
513 |
delete test; |
|
514 |
cells = User::CountAllocCells(); |
|
515 |
__UHEAP_MARKEND; |
|
516 |
||
517 |
return result; |
|
518 |
} |
|
519 |
||
520 |
TInt ReqNotificationWithoutWaitSch( TInt aChangeType, TBool aLocalUid, TBool aPosBased ) |
|
521 |
{ |
|
522 |
__UHEAP_MARK; |
|
523 |
TInt cells = User::CountAllocCells(); |
|
524 |
CTestAsync* test = CTestAsync::NewL(); |
|
525 |
test->Start( aChangeType, aLocalUid, aPosBased, ETrue ); |
|
526 |
//test->CancelNotification(); |
|
527 |
delete test; |
|
528 |
cells = User::CountAllocCells(); |
|
529 |
__UHEAP_MARKEND; |
|
530 |
||
531 |
return KErrNone; |
|
532 |
} |
|
533 |
||
534 |
TInt RemoveProvCalendar(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar) |
|
535 |
{ |
|
536 |
inparam->Reset(); |
|
537 |
outparam->Reset(); |
|
538 |
||
539 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
540 |
CleanupStack::PushL(map); |
|
541 |
||
542 |
TLiwVariant content(_L("Calendar")); |
|
543 |
TLiwGenericParam element1; |
|
544 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
545 |
inparam->AppendL(element1); |
|
546 |
content.Reset(); |
|
547 |
element1.Reset(); |
|
548 |
||
549 |
map->InsertL(_L8("CalendarName"), TLiwVariant(aCalendar)); |
|
550 |
||
551 |
TLiwVariant filterparam(map); |
|
552 |
TLiwGenericParam element ; |
|
553 |
element.SetNameAndValueL(_L8("Data"),filterparam); |
|
554 |
filterparam.Reset(); |
|
555 |
||
556 |
inparam->AppendL(element); |
|
557 |
element.Reset(); |
|
558 |
map->DecRef(); |
|
559 |
CleanupStack::Pop(map); |
|
560 |
||
561 |
TRAPD(err, interface->ExecuteCmdL( KCmdDelete ,*inparam,*outparam )); |
|
562 |
TInt pos = 0 ; |
|
563 |
||
564 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
565 |
||
566 |
if(output) |
|
567 |
{ |
|
568 |
err = output->Value().AsTInt32(); |
|
569 |
} |
|
570 |
||
571 |
inparam->Reset(); |
|
572 |
outparam->Reset(); |
|
573 |
||
574 |
return err; |
|
575 |
} |
|
576 |
||
577 |
TInt AddProvCalendar(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar) |
|
578 |
{ |
|
579 |
inparam->Reset(); |
|
580 |
outparam->Reset(); |
|
581 |
||
582 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
583 |
CleanupStack::PushL(map); |
|
584 |
||
585 |
TLiwVariant content(_L("Calendar")); |
|
586 |
TLiwGenericParam element1; |
|
587 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
588 |
inparam->AppendL(element1); |
|
589 |
content.Reset(); |
|
590 |
element1.Reset(); |
|
591 |
||
592 |
||
593 |
map->InsertL(_L8("CalendarName"), TLiwVariant(aCalendar) ); |
|
594 |
||
595 |
TLiwGenericParam element; |
|
596 |
element.SetNameAndValueL(_L8("Item"),TLiwVariant(map)); |
|
597 |
||
598 |
inparam->AppendL(element); |
|
599 |
element.Reset(); |
|
600 |
map->DecRef(); |
|
601 |
CleanupStack::Pop(map); |
|
602 |
||
603 |
TRAPD(err, interface->ExecuteCmdL( KCmdAdd, *inparam,*outparam )); |
|
604 |
TInt pos = 0 ; |
|
605 |
||
606 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
607 |
||
608 |
if(output) |
|
609 |
{ |
|
610 |
err = output->Value().AsTInt32(); |
|
611 |
} |
|
612 |
||
613 |
inparam->Reset(); |
|
614 |
outparam->Reset(); |
|
615 |
||
616 |
return err; |
|
617 |
}; |
|
618 |
||
619 |
void GetLocalId( CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aGlobalUid, const TDesC& calname, TUint& localuid ) |
|
620 |
{ |
|
621 |
/*aOutLocalUid = 0; |
|
622 |
if( aLocalUid.Length() ) |
|
623 |
{ |
|
624 |
TInt sepPos = aLocalUid.Locate( KUidSeparator ); |
|
625 |
TPtrC temp; |
|
626 |
if( sepPos == KErrNotFound ) |
|
627 |
{ |
|
628 |
temp.Set(aLocalUid.Mid(0)); |
|
629 |
} |
|
630 |
else |
|
631 |
{ |
|
632 |
temp.Set(aLocalUid.Mid(0, sepPos)); |
|
633 |
} |
|
634 |
||
635 |
TLex lex(temp); |
|
636 |
TInt32 num; |
|
637 |
||
638 |
if(lex.Val(num) == KErrNone) |
|
639 |
aOutLocalUid = TCalLocalUid(num); |
|
640 |
}*/ |
|
641 |
TBuf<10> local; |
|
642 |
||
643 |
inparam->Reset(); |
|
644 |
outparam->Reset(); |
|
645 |
||
646 |
TLiwGenericParam dsNameParam(KContentType, TLiwVariant(_L("CalendarEntry"))); |
|
647 |
inparam->AppendL(dsNameParam); |
|
648 |
||
649 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
650 |
TLiwGenericParam filterParam(KFilter, TLiwVariant(filterMap)); |
|
651 |
inparam->AppendL(filterParam); |
|
652 |
filterMap->DecRef(); |
|
653 |
||
654 |
if(calname.Length()) |
|
655 |
filterMap->InsertL(KCalendarName,TLiwVariant(calname)); |
|
656 |
filterMap->InsertL(_L8("id"),TLiwVariant(aGlobalUid)); |
|
657 |
||
658 |
TRAPD(err,interface->ExecuteCmdL( _L8("GetList") ,*inparam ,*outparam)); |
|
659 |
TInt pos = 0 ; |
|
660 |
TBuf<10> result; |
|
661 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
662 |
||
663 |
if(output) |
|
664 |
{ |
|
665 |
err = output->Value().AsTInt32(); |
|
666 |
if( err == KErrNone ) |
|
667 |
{ |
|
668 |
pos = 0; |
|
669 |
output = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
670 |
CLiwMap* map; |
|
671 |
TInt retvalue = KErrNone; |
|
672 |
||
673 |
if ( output ) |
|
674 |
{ |
|
675 |
CLiwIterable* iterlist = output->Value().AsIterable(); |
|
676 |
if(iterlist) |
|
677 |
{ |
|
678 |
TLiwVariant data1; |
|
679 |
while(iterlist->NextL(data1) ) |
|
680 |
{ |
|
681 |
const CLiwMap* res = data1.AsMap(); |
|
682 |
if ( res ) |
|
683 |
{ |
|
684 |
TLiwVariant data; |
|
685 |
if(res->FindL(_L8("LocalId"), data)) |
|
686 |
local.Copy( data.AsDes() ) ; |
|
687 |
TLex lex(local); |
|
688 |
TInt32 num; |
|
689 |
||
690 |
if(lex.Val(num) == KErrNone) |
|
691 |
localuid = TCalLocalUid(num); |
|
692 |
||
693 |
data.Reset(); |
|
694 |
} |
|
695 |
} |
|
696 |
data1.Reset(); |
|
697 |
} |
|
698 |
} |
|
699 |
} |
|
700 |
} |
|
701 |
||
702 |
inparam->Reset(); |
|
703 |
outparam->Reset(); |
|
704 |
} |
|
705 |
||
706 |
TInt AddProvAppointmentDailyRepeat(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUint& localuid) |
|
707 |
{ |
|
708 |
inparam->Reset(); |
|
709 |
outparam->Reset(); |
|
710 |
TBuf<10> luid; |
|
711 |
luid.Zero(); |
|
712 |
TBuf<50> uidval; |
|
713 |
TInt cells = User::CountAllocCells(); |
|
714 |
// __UHEAP_MARK; |
|
715 |
||
716 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
717 |
CleanupStack::PushL(map); |
|
718 |
||
719 |
TLiwVariant content(_L("CalendarEntry")); |
|
720 |
TLiwGenericParam element1; |
|
721 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
722 |
inparam->AppendL(element1); |
|
723 |
content.Reset(); |
|
724 |
element1.Reset(); |
|
725 |
||
726 |
||
727 |
map->InsertL(_L8("CalendarName"), TLiwVariant(aCalendar) ); |
|
728 |
map->InsertL(_L8("Type"), TLiwVariant( KEntryTypeMeeting )); |
|
729 |
map->InsertL(_L8("StartTime"), TLiwVariant(TTime(TDateTime(2007,EOctober,23,10,0,0,0)))); |
|
730 |
map->InsertL(_L8("EndTime"), TLiwVariant(TTime(TDateTime(2007,EOctober,23,10,30,0,0)))); |
|
731 |
map->InsertL(_L8("Replication"), TLiwVariant(_L("Open"))); |
|
732 |
map->InsertL(_L8("Description"), TLiwVariant(_L("Meeting"))); |
|
733 |
map->InsertL(_L8("Status"), TLiwVariant(_L("Confirmed"))); |
|
734 |
map->InsertL(_L8("Method"), TLiwVariant(_L("None"))); |
|
735 |
||
736 |
CLiwDefaultMap* repeatmap = CLiwDefaultMap::NewL(); |
|
737 |
CleanupStack::PushL(repeatmap); |
|
738 |
repeatmap->InsertL(_L8("Type"), TLiwVariant(TInt32(1))); |
|
739 |
repeatmap->InsertL(_L8("StartDate"), TLiwVariant(TTime(TDateTime(2007,EOctober,23,10,0,0,0)))); |
|
740 |
repeatmap->InsertL(_L8("UntilDate"), TLiwVariant(TTime(TDateTime(2007,EOctober,30,10,0,0,0)))); |
|
741 |
map->InsertL(_L8("RepeatRule"), TLiwVariant(repeatmap)); |
|
742 |
CleanupStack::Pop(repeatmap); |
|
743 |
repeatmap->DecRef(); |
|
744 |
||
745 |
||
746 |
TLiwGenericParam element; |
|
747 |
element.SetNameAndValueL(_L8("Item"),TLiwVariant(map)); |
|
748 |
||
749 |
inparam->AppendL(element); |
|
750 |
element.Reset(); |
|
751 |
map->DecRef(); |
|
752 |
CleanupStack::Pop(map); |
|
753 |
||
754 |
cells = User::CountAllocCells(); |
|
755 |
||
756 |
//TInt err; |
|
757 |
TRAPD(err, interface->ExecuteCmdL( KCmdAdd, *inparam,*outparam )); |
|
758 |
TInt pos = 0 ; |
|
759 |
||
760 |
cells = User::CountAllocCells(); |
|
761 |
||
762 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
763 |
||
764 |
cells = User::CountAllocCells(); |
|
765 |
||
766 |
if(output) |
|
767 |
{ |
|
768 |
err = output->Value().AsTInt32(); |
|
769 |
if ( err == KErrNone ) |
|
770 |
{ |
|
771 |
output = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
772 |
if(output) |
|
773 |
{ |
|
774 |
uidval.Copy((TPtrC)(output->Value().AsDes())) ; |
|
775 |
TPtrC globaluid(uidval); |
|
776 |
GetLocalId( inparam, outparam, interface, globaluid, aCalendar, localuid ); |
|
777 |
/*const CLiwMap* res = output->Value().AsMap(); |
|
778 |
if ( res ) |
|
779 |
{ |
|
780 |
TLiwVariant luid; |
|
781 |
if(res->FindL(_L8("LocalUid"), luid)) |
|
782 |
{ |
|
783 |
TLex lex(luid.AsDes()); |
|
784 |
TInt32 num; |
|
785 |
lex.Val(num); |
|
786 |
||
787 |
TUint localuid = 0; |
|
788 |
localuid = TUint(num); |
|
789 |
} |
|
790 |
else |
|
791 |
err = -1; |
|
792 |
luid.Reset(); |
|
793 |
} |
|
794 |
else |
|
795 |
err = -1;*/ |
|
796 |
} |
|
797 |
else |
|
798 |
err = -1; |
|
799 |
} |
|
800 |
} |
|
801 |
cells = User::CountAllocCells(); |
|
802 |
inparam->Reset(); |
|
803 |
outparam->Reset(); |
|
804 |
cells = User::CountAllocCells(); |
|
805 |
// __UHEAP_MARKEND; |
|
806 |
||
807 |
return err; |
|
808 |
}; |
|
809 |
||
810 |
TInt AddProvTodo(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUint& localuid) |
|
811 |
{ |
|
812 |
inparam->Reset(); |
|
813 |
outparam->Reset(); |
|
814 |
TBuf<10> luid; |
|
815 |
luid.Zero(); |
|
816 |
TBuf<50> uidval; |
|
817 |
TInt cells = User::CountAllocCells(); |
|
818 |
// __UHEAP_MARK; |
|
819 |
||
820 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
821 |
CleanupStack::PushL(map); |
|
822 |
||
823 |
TLiwVariant content(_L("CalendarEntry")); |
|
824 |
TLiwGenericParam element1; |
|
825 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
826 |
inparam->AppendL(element1); |
|
827 |
content.Reset(); |
|
828 |
element1.Reset(); |
|
829 |
||
830 |
||
831 |
map->InsertL(_L8("CalendarName"), TLiwVariant(aCalendar) ); |
|
832 |
map->InsertL(_L8("Type"), TLiwVariant( KEntryTypeTodo )); |
|
833 |
map->InsertL(_L8("EndTime"), TLiwVariant(TTime(TDateTime(2007,EOctober,25,10,0,0,0)))); |
|
834 |
map->InsertL(_L8("Replication"), TLiwVariant(_L("Open"))); |
|
835 |
map->InsertL(_L8("Description"), TLiwVariant(_L("Todo entry"))); |
|
836 |
||
837 |
TLiwGenericParam element; |
|
838 |
element.SetNameAndValueL(_L8("Item"),TLiwVariant(map)); |
|
839 |
||
840 |
inparam->AppendL(element); |
|
841 |
element.Reset(); |
|
842 |
map->DecRef(); |
|
843 |
CleanupStack::Pop(map); |
|
844 |
||
845 |
cells = User::CountAllocCells(); |
|
846 |
||
847 |
//TInt err; |
|
848 |
TRAPD(err, interface->ExecuteCmdL( KCmdAdd, *inparam,*outparam )); |
|
849 |
TInt pos = 0 ; |
|
850 |
||
851 |
cells = User::CountAllocCells(); |
|
852 |
||
853 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
854 |
||
855 |
cells = User::CountAllocCells(); |
|
856 |
||
857 |
if(output) |
|
858 |
{ |
|
859 |
err = output->Value().AsTInt32(); |
|
860 |
if ( err == KErrNone ) |
|
861 |
{ |
|
862 |
output = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
863 |
if(output) |
|
864 |
{ |
|
865 |
uidval.Copy((TPtrC)(output->Value().AsDes())) ; |
|
866 |
TPtrC globaluid(uidval); |
|
867 |
GetLocalId( inparam, outparam, interface, globaluid, aCalendar, localuid ); |
|
868 |
/*const CLiwMap* res = output->Value().AsMap(); |
|
869 |
if ( res ) |
|
870 |
{ |
|
871 |
TLiwVariant luid; |
|
872 |
if(res->FindL(_L8("LocalUid"), luid)) |
|
873 |
{ |
|
874 |
TLex lex(luid.AsDes()); |
|
875 |
TInt32 num; |
|
876 |
lex.Val(num); |
|
877 |
||
878 |
TUint localuid = 0; |
|
879 |
localuid = TUint(num); |
|
880 |
} |
|
881 |
else |
|
882 |
err = -1; |
|
883 |
luid.Reset(); |
|
884 |
} |
|
885 |
else |
|
886 |
err = -1;*/ |
|
887 |
} |
|
888 |
else |
|
889 |
err = -1; |
|
890 |
} |
|
891 |
} |
|
892 |
cells = User::CountAllocCells(); |
|
893 |
inparam->Reset(); |
|
894 |
outparam->Reset(); |
|
895 |
cells = User::CountAllocCells(); |
|
896 |
// __UHEAP_MARKEND; |
|
897 |
||
898 |
return err; |
|
899 |
}; |