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