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 |
child 58 | ea43c23d28d2 |
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 |
||
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
19 |
#include<liwcommon.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
20 |
#include<liwvariant.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
21 |
#include<liwservicehandler.h> |
19 | 22 |
#include "tcalendaraddtest.h" |
23 |
#include "calendarheader.h" |
|
24 |
#include "calendarconstants.h" |
|
25 |
||
26 |
_LIT8(KTestInterface, "IDataSource"); |
|
27 |
_LIT8(KTestContent, "Service.Calendar"); |
|
28 |
_LIT8(KCmd, "Delete"); |
|
29 |
_LIT8(KMessageId, "MessageId"); |
|
30 |
_LIT8(KMap, "NotificationType"); |
|
31 |
_LIT8(KMessageList, "MessageList" ); |
|
32 |
_LIT8(KMessage, "Message" ); |
|
33 |
_LIT(KMsgType,"NewMessage"); |
|
34 |
//_LIT8(KContentType, "Type"); |
|
35 |
//_LIT8(KCalendarName, "CalendarName"); |
|
36 |
//_LIT8(KFilter, "Filter"); |
|
37 |
||
38 |
_LIT(KCalFileName1,"C:Calendar"); |
|
39 |
||
40 |
TInt AddProvAppointmentDailyRepeatAndAttendees(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUIDSet*& uidset); |
|
41 |
TInt AddProvAppointmentWeeklyRepeat(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUIDSet*& uidset); |
|
42 |
void GetLocalUid( const TDesC& aLocalUid, TCalLocalUid& aOutLocalUid ); |
|
43 |
void GetGlobalUid( const TDesC& aGlobalUid, TDes8& aOutGlobalUid ); |
|
44 |
TInt AddProvAppointmentMonthlyRepeat(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUIDSet*& uidset); |
|
45 |
TInt AddProvAppointmentDailyRepeat(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar, TUIDSet*& uidset); |
|
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 AddProvCalendar(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, MLiwInterface* interface, const TDesC& aCalendar); |
|
49 |
enum TFormat |
|
50 |
{ |
|
51 |
ETestUnicode = 0x01, |
|
52 |
ETestAscii = 0x02, |
|
53 |
}; |
|
54 |
||
55 |
HBufC* FillBuffer(int size, TFormat encoding) |
|
56 |
{ |
|
57 |
HBufC* buffer = NULL; |
|
58 |
if( encoding == ETestUnicode) |
|
59 |
{ |
|
60 |
buffer = HBufC::NewL(size); |
|
61 |
for(int i=0;i<size;i++) |
|
62 |
buffer->Des().Append(0xE0FF); //append some unicode character |
|
63 |
} |
|
64 |
else if(encoding == ETestAscii) |
|
65 |
{ |
|
66 |
buffer = HBufC::NewL(size); |
|
67 |
for(int i=0;i<size;i++) |
|
68 |
buffer->Des().Append(0xFF); //append some ascii character |
|
69 |
} |
|
70 |
return buffer; |
|
71 |
} |
|
72 |
||
73 |
class CTestSync : public CBase |
|
74 |
{ |
|
75 |
public: |
|
76 |
static CTestSync* NewL(); |
|
77 |
int TestFunc(); |
|
78 |
int TestFuncMonthly(); |
|
79 |
void GetInterfaceHandle(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam); |
|
80 |
int UpdateRepeatRule(); |
|
81 |
int UpdateInstanceWithRepeat(); |
|
82 |
int UpdateEntryWithRepeatAndExceptionDates(); |
|
83 |
int AddEntryWithVeryLongDescription(); |
|
84 |
TDesC& GetEntry(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, TPtrC localuid, const TDesC& calname ); |
|
85 |
CTestSync(); |
|
86 |
~CTestSync(); |
|
87 |
||
88 |
private: |
|
89 |
void ConstructL(); |
|
90 |
||
91 |
||
92 |
||
93 |
private: |
|
94 |
CLiwServiceHandler* iServiceHandler; |
|
95 |
TInt iResult; |
|
96 |
MLiwInterface* interface ; |
|
97 |
}; |
|
98 |
||
99 |
||
100 |
CTestSync* CTestSync::NewL() |
|
101 |
{ |
|
102 |
CTestSync* self = new (ELeave) CTestSync(); |
|
103 |
self->ConstructL(); |
|
104 |
return self; |
|
105 |
} |
|
106 |
||
107 |
CTestSync::~CTestSync() |
|
108 |
{ |
|
109 |
if( interface ) |
|
110 |
interface->Close(); |
|
111 |
||
112 |
delete iServiceHandler; |
|
113 |
} |
|
114 |
||
115 |
||
116 |
void CTestSync::ConstructL() |
|
117 |
{ |
|
118 |
} |
|
119 |
||
120 |
||
121 |
CTestSync::CTestSync() |
|
122 |
{ |
|
123 |
interface = NULL ; |
|
124 |
} |
|
125 |
||
126 |
int CTestSync::TestFunc() |
|
127 |
{ |
|
128 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
129 |
||
130 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
131 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
132 |
||
133 |
||
134 |
TInt err; |
|
135 |
RCriteriaArray interest; |
|
136 |
CleanupClosePushL(interest); |
|
137 |
||
138 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KTestInterface,KTestContent); |
|
139 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
140 |
CleanupStack::PushL(crit); |
|
141 |
interest.AppendL(crit); |
|
142 |
||
143 |
iServiceHandler->AttachL(interest); |
|
144 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
145 |
||
146 |
TInt pos = 0; |
|
147 |
||
148 |
outparam->FindFirst( pos, KTestInterface ); |
|
149 |
if(pos != KErrNotFound) |
|
150 |
{ |
|
151 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
152 |
} |
|
153 |
CleanupStack::PopAndDestroy(crit); |
|
154 |
CleanupStack::PopAndDestroy(&interest); |
|
155 |
||
156 |
outparam->Reset(); |
|
157 |
inparam->Reset(); |
|
158 |
||
159 |
AddProvCalendar(inparam, outparam, interface, KCalFileName1); |
|
160 |
TUIDSet* uidset1; |
|
161 |
TBuf<50> globaluid; |
|
162 |
//AddProvAppointmentDailyRepeatAndAttendees(inparam, outparam, interface, KCalFileName1 ,uidset1 ); |
|
163 |
AddProvAppointmentWeeklyRepeat(inparam, outparam, interface, KCalFileName1 ,uidset1); |
|
164 |
//localuid.Num(TInt64(uidset1->iLocalUID)); |
|
165 |
globaluid.Copy(uidset1->iGlobalUID->Des()); |
|
166 |
||
167 |
TLiwGenericParam dsNameParam(KContentType, TLiwVariant(_L("CalendarEntry"))); |
|
168 |
inparam->AppendL(dsNameParam); |
|
169 |
||
170 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
171 |
TLiwGenericParam filterParam(KFilter, TLiwVariant(filterMap)); |
|
172 |
inparam->AppendL(filterParam); |
|
173 |
filterMap->DecRef(); |
|
174 |
||
175 |
filterMap->InsertL(KCalendarName,TLiwVariant(_L("C:CalendarFileA"))); |
|
176 |
filterMap->InsertL(_L8("id"),TLiwVariant(globaluid)); |
|
177 |
||
178 |
TRAP(err,interface->ExecuteCmdL( _L8("GetList") ,*inparam ,*outparam)); |
|
179 |
||
180 |
pos = 0 ; |
|
181 |
||
182 |
const TLiwGenericParam* finaloutput = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
183 |
TInt count = 0; |
|
184 |
CLiwMap* map; |
|
185 |
TInt retvalue = KErrNone; |
|
186 |
if ( finaloutput ) |
|
187 |
{ |
|
188 |
CLiwIterable* iterlist = finaloutput->Value().AsIterable(); |
|
189 |
if(iterlist) |
|
190 |
{ |
|
191 |
TLiwVariant data1; |
|
192 |
while(iterlist->NextL(data1) ) |
|
193 |
{ |
|
194 |
const CLiwMap* res = data1.AsMap(); |
|
195 |
if ( res ) |
|
196 |
{ |
|
197 |
TLiwVariant data; |
|
198 |
if(res->FindL(_L8("Type"), data)) |
|
199 |
{ |
|
200 |
TPtrC type = data.AsDes(); |
|
201 |
if(type.CompareF(_L("Meeting")) != 0 ) |
|
202 |
{ |
|
203 |
retvalue = KErrGeneral; |
|
204 |
break; |
|
205 |
} |
|
206 |
} |
|
207 |
if(res->FindL(_L8("StartTime"), data)) |
|
208 |
{ |
|
209 |
TTime ostime(TDateTime(2007,EOctober,23,10,0,0,0)); |
|
210 |
TTime stime = data.AsTTime(); |
|
211 |
if( ostime != stime) |
|
212 |
{ |
|
213 |
retvalue = KErrGeneral; |
|
214 |
break; |
|
215 |
} |
|
216 |
} |
|
217 |
if(res->FindL(_L8("EndTime"), data)) |
|
218 |
{ |
|
219 |
TTime oetime(TDateTime(2007,EOctober,23,10,30,0,0)); |
|
220 |
TTime etime = data.AsTTime(); |
|
221 |
if( oetime != etime) |
|
222 |
{ |
|
223 |
retvalue = KErrGeneral; |
|
224 |
break; |
|
225 |
} |
|
226 |
} |
|
227 |
if(res->FindL(_L8("Replication"), data)) |
|
228 |
{ |
|
229 |
TPtrC rep = data.AsDes(); |
|
230 |
if(rep.CompareF(_L("Open")) != 0 ) |
|
231 |
{ |
|
232 |
retvalue = KErrGeneral; |
|
233 |
break; |
|
234 |
} |
|
235 |
} |
|
236 |
if(res->FindL(_L8("Description"), data)) |
|
237 |
{ |
|
238 |
TPtrC rep = data.AsDes(); |
|
239 |
if(rep.CompareF(_L("Meeting")) != 0 ) |
|
240 |
{ |
|
241 |
retvalue = KErrGeneral; |
|
242 |
break; |
|
243 |
} |
|
244 |
} |
|
245 |
if(res->FindL(_L8("Status"), data)) |
|
246 |
{ |
|
247 |
TPtrC rep = data.AsDes(); |
|
248 |
if(rep.CompareF(_L("Confirmed")) != 0 ) |
|
249 |
{ |
|
250 |
retvalue = KErrGeneral; |
|
251 |
break; |
|
252 |
} |
|
253 |
} |
|
254 |
if(res->FindL(_L8("Method"), data)) |
|
255 |
{ |
|
256 |
TPtrC rep = data.AsDes(); |
|
257 |
if(rep.CompareF(_L("None")) != 0 ) |
|
258 |
{ |
|
259 |
retvalue = KErrGeneral; |
|
260 |
break; |
|
261 |
} |
|
262 |
} |
|
263 |
||
264 |
if(res->FindL(_L8("Organizer"), data)) |
|
265 |
{ |
|
266 |
const CLiwMap* map = data.AsMap(); |
|
267 |
TLiwVariant rdata; |
|
268 |
if(map->FindL(_L8("CommonName"), rdata)) |
|
269 |
{ |
|
270 |
TPtrC cn = rdata.AsDes(); |
|
271 |
if( cn.CompareF(_L("sapi")) != 0 ) |
|
272 |
{ |
|
273 |
retvalue = KErrGeneral; |
|
274 |
rdata.Reset(); |
|
275 |
break; |
|
276 |
} |
|
277 |
} |
|
278 |
if(map->FindL(_L8("Address"), rdata)) |
|
279 |
{ |
|
280 |
TPtrC add = rdata.AsDes(); |
|
281 |
if( add.CompareF(_L("mdc@nokia.com")) != 0 ) |
|
282 |
{ |
|
283 |
retvalue = KErrGeneral; |
|
284 |
rdata.Reset(); |
|
285 |
break; |
|
286 |
} |
|
287 |
} |
|
288 |
rdata.Reset(); |
|
289 |
} |
|
290 |
||
291 |
if(res->FindL(_L8("PhoneOwner"), data)) |
|
292 |
{ |
|
293 |
TPtrC rep = data.AsDes(); |
|
294 |
if(rep.CompareF(_L("h2s@nokia.com")) != 0 ) |
|
295 |
{ |
|
296 |
retvalue = KErrGeneral; |
|
297 |
break; |
|
298 |
} |
|
299 |
} |
|
300 |
||
301 |
if(res->FindL(_L8("Attendees"), data)) |
|
302 |
{ |
|
303 |
const CLiwList* list = data.AsList(); |
|
304 |
if ( list ) |
|
305 |
{ |
|
306 |
TInt count = list->Count(); |
|
307 |
for ( int index = 0; index < count; index++ ) |
|
308 |
{ |
|
309 |
TLiwVariant element; |
|
310 |
list->AtL(index, element); |
|
311 |
const CLiwMap* map = element.AsMap(); |
|
312 |
TLiwVariant attParam; |
|
313 |
if ( map && map->FindL(_L8("Address"), attParam) ) |
|
314 |
{ |
|
315 |
TPtrC address = attParam.AsDes(); |
|
316 |
if( address.CompareF(_L("h2s@nokia.com")) != 0 ) |
|
317 |
{ |
|
318 |
retvalue = KErrGeneral; |
|
319 |
attParam.Reset(); |
|
320 |
element.Reset(); |
|
321 |
break; |
|
322 |
} |
|
323 |
} |
|
324 |
if ( map->FindL( _L8("CommonName"), attParam ) ) |
|
325 |
{ |
|
326 |
TPtrC cn = attParam.AsDes(); |
|
327 |
if( cn.CompareF(_L("sapi")) != 0 ) |
|
328 |
{ |
|
329 |
retvalue = KErrGeneral; |
|
330 |
attParam.Reset(); |
|
331 |
element.Reset(); |
|
332 |
break; |
|
333 |
} |
|
334 |
} |
|
335 |
attParam.Reset(); |
|
336 |
element.Reset(); |
|
337 |
} |
|
338 |
} |
|
339 |
} |
|
340 |
||
341 |
if(res->FindL(_L8("RepeatRule"), data)) |
|
342 |
{ |
|
343 |
const CLiwMap* map = data.AsMap(); |
|
344 |
TLiwVariant rdata; |
|
345 |
if(map->FindL(_L8("Type"), rdata)) |
|
346 |
{ |
|
347 |
TInt type = rdata.AsTInt32(); |
|
348 |
if( type != 2 ) |
|
349 |
{ |
|
350 |
retvalue = KErrGeneral; |
|
351 |
rdata.Reset(); |
|
352 |
break; |
|
353 |
} |
|
354 |
} |
|
355 |
if(map->FindL(_L8("StartDate"), rdata)) |
|
356 |
{ |
|
357 |
TTime sdate = rdata.AsTTime(); |
|
358 |
TTime ostime(TDateTime(2007,EOctober,23,10,0,0,0)); |
|
359 |
if( sdate != ostime) |
|
360 |
{ |
|
361 |
retvalue = KErrGeneral; |
|
362 |
rdata.Reset(); |
|
363 |
break; |
|
364 |
} |
|
365 |
} |
|
366 |
if(map->FindL(_L8("UntilDate"), rdata)) |
|
367 |
{ |
|
368 |
TTime udate = rdata.AsTTime(); |
|
369 |
//TTime outime(TDateTime(2007,EOctober,30,10,0,0,0)); |
|
370 |
TTime outime(TDateTime(2007,ENovember,27,10,0,0,0)); |
|
371 |
if( udate != outime ) |
|
372 |
{ |
|
373 |
retvalue = KErrGeneral; |
|
374 |
rdata.Reset(); |
|
375 |
break; |
|
376 |
} |
|
377 |
} |
|
378 |
rdata.Reset(); |
|
379 |
} |
|
380 |
||
381 |
data.Reset(); |
|
382 |
} |
|
383 |
} |
|
384 |
data1.Reset(); |
|
385 |
} |
|
386 |
} |
|
387 |
||
388 |
inparam->Reset(); |
|
389 |
outparam->Reset(); |
|
390 |
delete uidset1; |
|
391 |
RemoveProvCalendar(inparam, outparam, interface, KCalFileName1); |
|
392 |
return retvalue; |
|
393 |
} |
|
394 |
||
395 |
int CTestSync::TestFuncMonthly() |
|
396 |
{ |
|
397 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
398 |
||
399 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
400 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
401 |
||
402 |
||
403 |
TInt err; |
|
404 |
RCriteriaArray interest; |
|
405 |
CleanupClosePushL(interest); |
|
406 |
||
407 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KTestInterface,KTestContent); |
|
408 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
409 |
CleanupStack::PushL(crit); |
|
410 |
interest.AppendL(crit); |
|
411 |
||
412 |
iServiceHandler->AttachL(interest); |
|
413 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
414 |
||
415 |
TInt pos = 0; |
|
416 |
||
417 |
outparam->FindFirst( pos, KTestInterface ); |
|
418 |
if(pos != KErrNotFound) |
|
419 |
{ |
|
420 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
421 |
} |
|
422 |
CleanupStack::PopAndDestroy(crit); |
|
423 |
CleanupStack::PopAndDestroy(&interest); |
|
424 |
||
425 |
outparam->Reset(); |
|
426 |
inparam->Reset(); |
|
427 |
||
428 |
AddProvCalendar(inparam, outparam, interface, KCalFileName1); |
|
429 |
TUIDSet* uidset1; |
|
430 |
TBuf<50> globaluid; |
|
431 |
//AddProvAppointmentDailyRepeatAndAttendees(inparam, outparam, interface, KCalFileName1 ,uidset1 ); |
|
432 |
AddProvAppointmentMonthlyRepeat(inparam, outparam, interface, KCalFileName1 ,uidset1); |
|
433 |
//localuid.Num(TInt64(uidset1->iLocalUID)); |
|
434 |
||
435 |
globaluid.Copy(uidset1->iGlobalUID->Des()); |
|
436 |
TLiwGenericParam dsNameParam(KContentType, TLiwVariant(_L("CalendarEntry"))); |
|
437 |
inparam->AppendL(dsNameParam); |
|
438 |
||
439 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
440 |
TLiwGenericParam filterParam(KFilter, TLiwVariant(filterMap)); |
|
441 |
inparam->AppendL(filterParam); |
|
442 |
filterMap->DecRef(); |
|
443 |
||
444 |
filterMap->InsertL(KCalendarName,TLiwVariant(_L("C:CalendarFileA"))); |
|
445 |
filterMap->InsertL(_L8("id"),TLiwVariant(globaluid)); |
|
446 |
||
447 |
TRAP(err,interface->ExecuteCmdL( _L8("GetList") ,*inparam ,*outparam)); |
|
448 |
||
449 |
pos = 0 ; |
|
450 |
||
451 |
const TLiwGenericParam* finaloutput = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
452 |
TInt count = 0; |
|
453 |
CLiwMap* map; |
|
454 |
TInt retvalue = KErrNone; |
|
455 |
if ( finaloutput ) |
|
456 |
{ |
|
457 |
CLiwIterable* iterlist = finaloutput->Value().AsIterable(); |
|
458 |
if(iterlist) |
|
459 |
{ |
|
460 |
TLiwVariant data1; |
|
461 |
while(iterlist->NextL(data1) ) |
|
462 |
{ |
|
463 |
const CLiwMap* res = data1.AsMap(); |
|
464 |
if ( res ) |
|
465 |
{ |
|
466 |
TLiwVariant data; |
|
467 |
if(res->FindL(_L8("StartTime"), data)) |
|
468 |
{ |
|
469 |
TTime ostime(TDateTime(2007,EOctober,23,10,0,0,0)); |
|
470 |
TTime stime = data.AsTTime(); |
|
471 |
if( ostime != stime) |
|
472 |
{ |
|
473 |
retvalue = KErrGeneral; |
|
474 |
break; |
|
475 |
} |
|
476 |
} |
|
477 |
||
478 |
if(res->FindL(_L8("RepeatRule"), data)) |
|
479 |
{ |
|
480 |
const CLiwMap* map = data.AsMap(); |
|
481 |
TLiwVariant rdata; |
|
482 |
if(map->FindL(_L8("Type"), rdata)) |
|
483 |
{ |
|
484 |
TInt type = rdata.AsTInt32(); |
|
485 |
if( type != 2 ) |
|
486 |
{ |
|
487 |
retvalue = KErrGeneral; |
|
488 |
rdata.Reset(); |
|
489 |
break; |
|
490 |
} |
|
491 |
} |
|
492 |
if(map->FindL(_L8("StartDate"), rdata)) |
|
493 |
{ |
|
494 |
TTime sdate = rdata.AsTTime(); |
|
495 |
TTime ostime(TDateTime(2007,EOctober,23,10,0,0,0)); |
|
496 |
if( sdate != ostime) |
|
497 |
{ |
|
498 |
retvalue = KErrGeneral; |
|
499 |
rdata.Reset(); |
|
500 |
break; |
|
501 |
} |
|
502 |
} |
|
503 |
if(map->FindL(_L8("UntilDate"), rdata)) |
|
504 |
{ |
|
505 |
TTime udate = rdata.AsTTime(); |
|
506 |
//TTime outime(TDateTime(2007,EOctober,30,10,0,0,0)); |
|
507 |
TTime outime(TDateTime(2007,EDecember,23,10,0,0,0)); |
|
508 |
if( udate != outime ) |
|
509 |
{ |
|
510 |
retvalue = KErrGeneral; |
|
511 |
rdata.Reset(); |
|
512 |
break; |
|
513 |
} |
|
514 |
} |
|
515 |
rdata.Reset(); |
|
516 |
} |
|
517 |
||
518 |
data.Reset(); |
|
519 |
} |
|
520 |
} |
|
521 |
data1.Reset(); |
|
522 |
} |
|
523 |
} |
|
524 |
||
525 |
inparam->Reset(); |
|
526 |
outparam->Reset(); |
|
527 |
delete uidset1; |
|
528 |
RemoveProvCalendar(inparam, outparam, interface, KCalFileName1); |
|
529 |
return retvalue; |
|
530 |
} |
|
531 |
||
532 |
int AddEntryWithAllAttributes() |
|
533 |
{ |
|
534 |
__UHEAP_MARK; |
|
535 |
CTestSync* test = CTestSync::NewL(); |
|
536 |
int res = test->TestFunc(); |
|
537 |
delete test; |
|
538 |
__UHEAP_MARKEND; |
|
539 |
return res; |
|
540 |
||
541 |
} |
|
542 |
||
543 |
int UpdateEntryWithRDates() |
|
544 |
{ |
|
545 |
__UHEAP_MARK; |
|
546 |
CTestSync* test = CTestSync::NewL(); |
|
547 |
int res = test->UpdateEntryWithRepeatAndExceptionDates(); |
|
548 |
delete test; |
|
549 |
__UHEAP_MARKEND; |
|
550 |
return res; |
|
551 |
||
552 |
} |
|
553 |
||
554 |
int AddMonthlyRepeatingEntry() |
|
555 |
{ |
|
556 |
__UHEAP_MARK; |
|
557 |
CTestSync* test = CTestSync::NewL(); |
|
558 |
int res = test->TestFuncMonthly(); |
|
559 |
delete test; |
|
560 |
__UHEAP_MARKEND; |
|
561 |
return res; |
|
562 |
||
563 |
} |
|
564 |
||
565 |
int ModifyRepeatRule() |
|
566 |
{ |
|
567 |
__UHEAP_MARK; |
|
568 |
CTestSync* test = CTestSync::NewL(); |
|
569 |
int res = test->UpdateRepeatRule(); |
|
570 |
delete test; |
|
571 |
__UHEAP_MARKEND; |
|
572 |
return res; |
|
573 |
||
574 |
} |
|
575 |
int UpdateApptInstanceWithRepeat() |
|
576 |
{ |
|
577 |
__UHEAP_MARK; |
|
578 |
CTestSync* test = CTestSync::NewL(); |
|
579 |
int res = test->UpdateInstanceWithRepeat(); |
|
580 |
delete test; |
|
581 |
__UHEAP_MARKEND; |
|
582 |
return res; |
|
583 |
||
584 |
} |
|
585 |
int TestForLongStrings() |
|
586 |
{ |
|
587 |
__UHEAP_MARK; |
|
588 |
CTestSync* test = CTestSync::NewL(); |
|
589 |
int res = test->AddEntryWithVeryLongDescription(); |
|
590 |
delete test; |
|
591 |
__UHEAP_MARKEND; |
|
592 |
return res; |
|
593 |
||
594 |
} |
|
595 |
||
596 |
/*int CTestSync::TestFunc() |
|
597 |
{ |
|
598 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
599 |
||
600 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
601 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
602 |
||
603 |
||
604 |
TInt err; |
|
605 |
RCriteriaArray interest; |
|
606 |
CleanupClosePushL(interest); |
|
607 |
||
608 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KTestInterface,KTestContent); |
|
609 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
610 |
CleanupStack::PushL(crit); |
|
611 |
interest.AppendL(crit); |
|
612 |
||
613 |
iServiceHandler->AttachL(interest); |
|
614 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
615 |
||
616 |
TInt pos = 0; |
|
617 |
||
618 |
outparam->FindFirst( pos, KTestInterface ); |
|
619 |
if(pos != KErrNotFound) |
|
620 |
{ |
|
621 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
622 |
} |
|
623 |
CleanupStack::PopAndDestroy(crit); |
|
624 |
CleanupStack::PopAndDestroy(&interest); |
|
625 |
||
626 |
outparam->Reset(); |
|
627 |
inparam->Reset(); |
|
628 |
||
629 |
AddProvCalendar(inparam, outparam, interface, KCalFileName1); |
|
630 |
TUIDSet* uidset1; |
|
631 |
TBuf<10> localuid; |
|
632 |
//AddProvAppointmentDailyRepeatAndAttendees(inparam, outparam, interface, KCalFileName1 ,uidset1 ); |
|
633 |
AddProvAppointmentWeeklyRepeat(inparam, outparam, interface, KCalFileName1 ,uidset1); |
|
634 |
localuid.Num(TInt64(uidset1->iLocalUID)); |
|
635 |
||
636 |
TLiwGenericParam dsNameParam(KContentType, TLiwVariant(_L("CalendarEntry"))); |
|
637 |
inparam->AppendL(dsNameParam); |
|
638 |
||
639 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
640 |
TLiwGenericParam filterParam(KFilter, TLiwVariant(filterMap)); |
|
641 |
inparam->AppendL(filterParam); |
|
642 |
filterMap->DecRef(); |
|
643 |
||
644 |
filterMap->InsertL(KCalendarName,TLiwVariant(_L("C:CalendarFileA"))); |
|
645 |
filterMap->InsertL(_L8("LocalUid"),TLiwVariant(localuid)); |
|
646 |
||
647 |
TRAP(err,interface->ExecuteCmdL( _L8("GetList") ,*inparam ,*outparam)); |
|
648 |
||
649 |
pos = 0 ; |
|
650 |
||
651 |
const TLiwGenericParam* finaloutput = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
652 |
TInt count = 0; |
|
653 |
CLiwMap* map; |
|
654 |
TInt retvalue = KErrNone; |
|
655 |
if ( finaloutput ) |
|
656 |
{ |
|
657 |
CLiwIterable* iterlist = finaloutput->Value().AsIterable(); |
|
658 |
if(iterlist) |
|
659 |
{ |
|
660 |
TLiwVariant data1; |
|
661 |
while(iterlist->NextL(data1) ) |
|
662 |
{ |
|
663 |
const CLiwMap* res = data1.AsMap(); |
|
664 |
if ( res ) |
|
665 |
{ |
|
666 |
TLiwVariant data; |
|
667 |
if(res->FindL(_L8("Type"), data)) |
|
668 |
{ |
|
669 |
TPtrC type = data.AsDes(); |
|
670 |
if(type.CompareF(_L("Meeting")) != 0 ) |
|
671 |
{ |
|
672 |
retvalue = KErrGeneral; |
|
673 |
break; |
|
674 |
} |
|
675 |
} |
|
676 |
if(res->FindL(_L8("StartTime"), data)) |
|
677 |
{ |
|
678 |
TTime ostime(TDateTime(2007,EOctober,23,10,0,0,0)); |
|
679 |
TTime stime = data.AsTTime(); |
|
680 |
if( ostime != stime) |
|
681 |
{ |
|
682 |
retvalue = KErrGeneral; |
|
683 |
break; |
|
684 |
} |
|
685 |
} |
|
686 |
if(res->FindL(_L8("EndTime"), data)) |
|
687 |
{ |
|
688 |
TTime oetime(TDateTime(2007,EOctober,23,10,30,0,0)); |
|
689 |
TTime etime = data.AsTTime(); |
|
690 |
if( oetime != etime) |
|
691 |
{ |
|
692 |
retvalue = KErrGeneral; |
|
693 |
break; |
|
694 |
} |
|
695 |
} |
|
696 |
if(res->FindL(_L8("Replication"), data)) |
|
697 |
{ |
|
698 |
TPtrC rep = data.AsDes(); |
|
699 |
if(rep.CompareF(_L("Open")) != 0 ) |
|
700 |
{ |
|
701 |
retvalue = KErrGeneral; |
|
702 |
break; |
|
703 |
} |
|
704 |
} |
|
705 |
if(res->FindL(_L8("Description"), data)) |
|
706 |
{ |
|
707 |
TPtrC rep = data.AsDes(); |
|
708 |
if(rep.CompareF(_L("Meeting")) != 0 ) |
|
709 |
{ |
|
710 |
retvalue = KErrGeneral; |
|
711 |
break; |
|
712 |
} |
|
713 |
} |
|
714 |
if(res->FindL(_L8("Status"), data)) |
|
715 |
{ |
|
716 |
TPtrC rep = data.AsDes(); |
|
717 |
if(rep.CompareF(_L("Confirmed")) != 0 ) |
|
718 |
{ |
|
719 |
retvalue = KErrGeneral; |
|
720 |
break; |
|
721 |
} |
|
722 |
} |
|
723 |
if(res->FindL(_L8("Method"), data)) |
|
724 |
{ |
|
725 |
TPtrC rep = data.AsDes(); |
|
726 |
if(rep.CompareF(_L("None")) != 0 ) |
|
727 |
{ |
|
728 |
retvalue = KErrGeneral; |
|
729 |
break; |
|
730 |
} |
|
731 |
} |
|
732 |
||
733 |
if(res->FindL(_L8("Organizer"), data)) |
|
734 |
{ |
|
735 |
const CLiwMap* map = data.AsMap(); |
|
736 |
TLiwVariant rdata; |
|
737 |
if(map->FindL(_L8("CommonName"), rdata)) |
|
738 |
{ |
|
739 |
TPtrC cn = rdata.AsDes(); |
|
740 |
if( cn.CompareF(_L("sapi")) != 0 ) |
|
741 |
{ |
|
742 |
retvalue = KErrGeneral; |
|
743 |
rdata.Reset(); |
|
744 |
break; |
|
745 |
} |
|
746 |
} |
|
747 |
if(map->FindL(_L8("Address"), rdata)) |
|
748 |
{ |
|
749 |
TPtrC add = rdata.AsDes(); |
|
750 |
if( add.CompareF(_L("")) != 0 ) |
|
751 |
{ |
|
752 |
retvalue = KErrGeneral; |
|
753 |
rdata.Reset(); |
|
754 |
break; |
|
755 |
} |
|
756 |
} |
|
757 |
rdata.Reset(); |
|
758 |
} |
|
759 |
||
760 |
if(res->FindL(_L8("PhoneOwner"), data)) |
|
761 |
{ |
|
762 |
TPtrC rep = data.AsDes(); |
|
763 |
if(rep.CompareF(_L("")) != 0 ) |
|
764 |
{ |
|
765 |
retvalue = KErrGeneral; |
|
766 |
break; |
|
767 |
} |
|
768 |
} |
|
769 |
||
770 |
if(res->FindL(_L8("Attendees"), data)) |
|
771 |
{ |
|
772 |
const CLiwList* list = data.AsList(); |
|
773 |
if ( list ) |
|
774 |
{ |
|
775 |
TInt count = list->Count(); |
|
776 |
for ( int index = 0; index < count; index++ ) |
|
777 |
{ |
|
778 |
TLiwVariant element; |
|
779 |
list->AtL(index, element); |
|
780 |
const CLiwMap* map = element.AsMap(); |
|
781 |
TLiwVariant attParam; |
|
782 |
if ( map && map->FindL(_L8("Address"), attParam) ) |
|
783 |
{ |
|
784 |
TPtrC address = attParam.AsDes(); |
|
785 |
if( address.CompareF(_L("")) != 0 ) |
|
786 |
{ |
|
787 |
retvalue = KErrGeneral; |
|
788 |
attParam.Reset(); |
|
789 |
element.Reset(); |
|
790 |
break; |
|
791 |
} |
|
792 |
} |
|
793 |
if ( map->FindL( _L8("CommonName"), attParam ) ) |
|
794 |
{ |
|
795 |
TPtrC cn = attParam.AsDes(); |
|
796 |
if( cn.CompareF(_L("sapi")) != 0 ) |
|
797 |
{ |
|
798 |
retvalue = KErrGeneral; |
|
799 |
attParam.Reset(); |
|
800 |
element.Reset(); |
|
801 |
break; |
|
802 |
} |
|
803 |
} |
|
804 |
attParam.Reset(); |
|
805 |
element.Reset(); |
|
806 |
} |
|
807 |
} |
|
808 |
} |
|
809 |
||
810 |
if(res->FindL(_L8("RepeatRule"), data)) |
|
811 |
{ |
|
812 |
const CLiwMap* map = data.AsMap(); |
|
813 |
TLiwVariant rdata; |
|
814 |
if(map->FindL(_L8("Type"), rdata)) |
|
815 |
{ |
|
816 |
TInt type = rdata.AsTInt32(); |
|
817 |
if( type != 2 ) |
|
818 |
{ |
|
819 |
retvalue = KErrGeneral; |
|
820 |
rdata.Reset(); |
|
821 |
break; |
|
822 |
} |
|
823 |
} |
|
824 |
if(map->FindL(_L8("StartDate"), rdata)) |
|
825 |
{ |
|
826 |
TTime sdate = rdata.AsTTime(); |
|
827 |
TTime ostime(TDateTime(2007,EOctober,23,10,0,0,0)); |
|
828 |
if( sdate != ostime) |
|
829 |
{ |
|
830 |
retvalue = KErrGeneral; |
|
831 |
rdata.Reset(); |
|
832 |
break; |
|
833 |
} |
|
834 |
} |
|
835 |
if(map->FindL(_L8("UntilDate"), rdata)) |
|
836 |
{ |
|
837 |
TTime udate = rdata.AsTTime(); |
|
838 |
//TTime outime(TDateTime(2007,EOctober,30,10,0,0,0)); |
|
839 |
TTime outime(TDateTime(2007,ENovember,27,10,0,0,0)); |
|
840 |
if( udate != outime ) |
|
841 |
{ |
|
842 |
retvalue = KErrGeneral; |
|
843 |
rdata.Reset(); |
|
844 |
break; |
|
845 |
} |
|
846 |
} |
|
847 |
rdata.Reset(); |
|
848 |
} |
|
849 |
||
850 |
data.Reset(); |
|
851 |
} |
|
852 |
} |
|
853 |
data1.Reset(); |
|
854 |
} |
|
855 |
} |
|
856 |
||
857 |
inparam->Reset(); |
|
858 |
outparam->Reset(); |
|
859 |
delete uidset1; |
|
860 |
RemoveProvCalendar(inparam, outparam, interface, KCalFileName1); |
|
861 |
return retvalue; |
|
862 |
}*/ |
|
863 |
||
864 |
void CTestSync::GetInterfaceHandle(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam) |
|
865 |
{ |
|
866 |
||
867 |
||
868 |
TInt err; |
|
869 |
RCriteriaArray interest; |
|
870 |
CleanupClosePushL(interest); |
|
871 |
||
872 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1, KTestInterface,KTestContent); |
|
873 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
874 |
CleanupStack::PushL(crit); |
|
875 |
interest.AppendL(crit); |
|
876 |
||
877 |
iServiceHandler->AttachL(interest); |
|
878 |
iServiceHandler->ExecuteServiceCmdL(*crit, *inparam, *outparam); |
|
879 |
||
880 |
TInt pos = 0; |
|
881 |
||
882 |
outparam->FindFirst( pos, KTestInterface ); |
|
883 |
if(pos != KErrNotFound) |
|
884 |
{ |
|
885 |
interface = (*outparam)[pos].Value().AsInterface(); |
|
886 |
} |
|
887 |
CleanupStack::PopAndDestroy(crit); |
|
888 |
CleanupStack::PopAndDestroy(&interest); |
|
889 |
||
890 |
outparam->Reset(); |
|
891 |
inparam->Reset(); |
|
892 |
||
893 |
} |
|
894 |
||
895 |
int CTestSync::UpdateRepeatRule() |
|
896 |
{ |
|
897 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
898 |
||
899 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
900 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
901 |
||
902 |
GetInterfaceHandle(inparam, outparam); |
|
903 |
TUIDSet* uidset1; |
|
904 |
TBuf<50> globaluid; |
|
905 |
TBuf<10> localuid; |
|
906 |
AddProvAppointmentDailyRepeat(inparam, outparam, interface, KCalFileName1 ,uidset1); |
|
907 |
//localuid.Num(TInt64(uidset1->iLocalUID)); |
|
908 |
globaluid.Copy(uidset1->iGlobalUID->Des()); |
|
909 |
||
910 |
delete uidset1; |
|
911 |
//update repeat from daily to weekly |
|
912 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
913 |
CleanupStack::PushL(map); |
|
914 |
localuid = GetEntry(inparam, outparam, globaluid, KCalFileName1); |
|
915 |
TLiwVariant content(_L("CalendarEntry")); |
|
916 |
TLiwGenericParam element1; |
|
917 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
918 |
inparam->AppendL(element1); |
|
919 |
content.Reset(); |
|
920 |
element1.Reset(); |
|
921 |
||
922 |
CLiwDefaultMap* repeatmap = CLiwDefaultMap::NewL(); |
|
923 |
CleanupStack::PushL(repeatmap); |
|
924 |
repeatmap->InsertL(_L8("Type"), TLiwVariant(TInt32(2))); |
|
925 |
repeatmap->InsertL(_L8("UntilDate"), TLiwVariant(TTime(TDateTime(2007,EDecember,30,10,0,0,0)))); |
|
926 |
map->InsertL(_L8("RepeatRule"), TLiwVariant(repeatmap)); |
|
927 |
CleanupStack::Pop(repeatmap); |
|
928 |
repeatmap->DecRef(); |
|
929 |
||
930 |
map->InsertL(_L8("LocalId"), TLiwVariant(localuid)); |
|
931 |
||
932 |
TLiwGenericParam element; |
|
933 |
element.SetNameAndValueL(_L8("Item"),TLiwVariant(map)); |
|
934 |
||
935 |
inparam->AppendL(element); |
|
936 |
element.Reset(); |
|
937 |
map->DecRef(); |
|
938 |
CleanupStack::Pop(map); |
|
939 |
||
940 |
TRAPD(err, interface->ExecuteCmdL( KCmdAdd, *inparam,*outparam )); |
|
941 |
TInt pos = 0 ; |
|
942 |
||
943 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
944 |
if(output) |
|
945 |
err = output->Value().AsTInt32(); |
|
946 |
||
947 |
//update from weekly to monthly |
|
948 |
if( err == KErrNone ) |
|
949 |
{ |
|
950 |
inparam->Reset(); |
|
951 |
outparam->Reset(); |
|
952 |
||
953 |
CLiwDefaultMap* map1 = CLiwDefaultMap::NewL(); |
|
954 |
CleanupStack::PushL(map1); |
|
955 |
||
956 |
TLiwVariant content(_L("CalendarEntry")); |
|
957 |
TLiwGenericParam element1; |
|
958 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
959 |
inparam->AppendL(element1); |
|
960 |
content.Reset(); |
|
961 |
element1.Reset(); |
|
962 |
||
963 |
map1->InsertL(_L8("LocalId"),TLiwVariant(localuid)); |
|
964 |
||
965 |
CLiwDefaultMap* repeatmap = CLiwDefaultMap::NewL(); |
|
966 |
CleanupStack::PushL(repeatmap); |
|
967 |
repeatmap->InsertL(_L8("Type"), TLiwVariant(TInt32(3))); |
|
968 |
repeatmap->InsertL(_L8("StartDate"), TLiwVariant(TTime(TDateTime(2007,EJanuary,30,10,0,0,0)))); |
|
969 |
repeatmap->InsertL(_L8("UntilDate"), TLiwVariant(TTime(TDateTime(2009,EJanuary,30,10,0,0,0)))); |
|
970 |
||
971 |
CLiwDefaultList* daysofmonthlist = CLiwDefaultList::NewL(); |
|
972 |
CLiwDefaultMap* map3 = CLiwDefaultMap::NewL(); |
|
973 |
map3->InsertL(_L8("Day"), TLiwVariant(TInt32(0)) ); |
|
974 |
map3->InsertL(_L8("WeekNum"), TLiwVariant( TInt32(1))); |
|
975 |
daysofmonthlist->AppendL(TLiwVariant(map3)); |
|
976 |
map3->DecRef(); |
|
977 |
||
978 |
CLiwDefaultMap* map2 = CLiwDefaultMap::NewL(); |
|
979 |
map2->InsertL(_L8("Day"), TLiwVariant(TInt32(2)) ); |
|
980 |
map2->InsertL(_L8("WeekNum"), TLiwVariant( TInt32(3))); |
|
981 |
daysofmonthlist->AppendL(TLiwVariant(map2)); |
|
982 |
map2->DecRef(); |
|
983 |
||
984 |
repeatmap->InsertL(_L8("DaysOfMonth"),TLiwVariant(daysofmonthlist)); |
|
985 |
daysofmonthlist->DecRef(); |
|
986 |
||
987 |
map1->InsertL(_L8("RepeatRule"), TLiwVariant(repeatmap)); |
|
988 |
CleanupStack::Pop(repeatmap); |
|
989 |
repeatmap->DecRef(); |
|
990 |
||
991 |
TLiwGenericParam element; |
|
992 |
element.SetNameAndValueL(_L8("Item"),TLiwVariant(map1)); |
|
993 |
||
994 |
inparam->AppendL(element); |
|
995 |
element.Reset(); |
|
996 |
CleanupStack::Pop(map1); |
|
997 |
map1->DecRef(); |
|
998 |
TRAP(err, interface->ExecuteCmdL( KCmdAdd, *inparam,*outparam )); |
|
999 |
TInt pos1 = 0 ; |
|
1000 |
const TLiwGenericParam* output = outparam->FindFirst( pos1,_L8("ErrorCode")); |
|
1001 |
if(output) |
|
1002 |
err = output->Value().AsTInt32(); |
|
1003 |
inparam->Reset(); |
|
1004 |
outparam->Reset(); |
|
1005 |
||
1006 |
} |
|
1007 |
return err; |
|
1008 |
} |
|
1009 |
||
1010 |
int CTestSync::UpdateInstanceWithRepeat() |
|
1011 |
{ |
|
1012 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
1013 |
||
1014 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
1015 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
1016 |
||
1017 |
GetInterfaceHandle(inparam, outparam); |
|
1018 |
TUIDSet* uidset1; |
|
1019 |
TBuf<10> localuid; |
|
1020 |
TBuf<50> globaluid; |
|
1021 |
AddProvAppointmentDailyRepeat(inparam, outparam, interface, KCalFileName1 ,uidset1); |
|
1022 |
//localuid.Num(TInt64(uidset1->iLocalUID)); |
|
1023 |
globaluid.Copy(uidset1->iGlobalUID->Des()); |
|
1024 |
localuid = GetEntry( inparam, outparam, globaluid, KCalFileName1); |
|
1025 |
delete uidset1; |
|
1026 |
//update repeat from daily to weekly |
|
1027 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
1028 |
CleanupStack::PushL(map); |
|
1029 |
||
1030 |
TLiwVariant content(_L("CalendarEntry")); |
|
1031 |
TLiwGenericParam element1; |
|
1032 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
1033 |
inparam->AppendL(element1); |
|
1034 |
content.Reset(); |
|
1035 |
element1.Reset(); |
|
1036 |
||
1037 |
CLiwDefaultMap* repeatmap = CLiwDefaultMap::NewL(); |
|
1038 |
CleanupStack::PushL(repeatmap); |
|
1039 |
repeatmap->InsertL(_L8("Type"), TLiwVariant(TInt32(2))); |
|
1040 |
repeatmap->InsertL(_L8("UntilDate"), TLiwVariant(TTime(TDateTime(2007,EDecember,30,10,0,0,0)))); |
|
1041 |
map->InsertL(_L8("RepeatRule"), TLiwVariant(repeatmap)); |
|
1042 |
CleanupStack::Pop(repeatmap); |
|
1043 |
repeatmap->DecRef(); |
|
1044 |
||
1045 |
map->InsertL(_L8("LocalUid"), TLiwVariant(localuid)); |
|
1046 |
map->InsertL(_L8("InstanceStartTime"), TLiwVariant(TTime(TDateTime(2007,EDecember,30,10,0,0,0)))); |
|
1047 |
map->InsertL(_L8("CalendarName"), TLiwVariant(_L("C:Calendar"))); |
|
1048 |
||
1049 |
||
1050 |
TLiwGenericParam element; |
|
1051 |
element.SetNameAndValueL(_L8("Item"),TLiwVariant(map)); |
|
1052 |
||
1053 |
inparam->AppendL(element); |
|
1054 |
element.Reset(); |
|
1055 |
map->DecRef(); |
|
1056 |
CleanupStack::Pop(map); |
|
1057 |
||
1058 |
TRAPD(err, interface->ExecuteCmdL( KCmdAdd, *inparam,*outparam )); |
|
1059 |
TInt pos = 0 ; |
|
1060 |
||
1061 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
1062 |
if(output) |
|
1063 |
err = output->Value().AsTInt32(); |
|
1064 |
||
1065 |
//update from weekly to monthly |
|
1066 |
if( err == KErrNone ) |
|
1067 |
{ |
|
1068 |
inparam->Reset(); |
|
1069 |
outparam->Reset(); |
|
1070 |
||
1071 |
CLiwDefaultMap* map1 = CLiwDefaultMap::NewL(); |
|
1072 |
CleanupStack::PushL(map1); |
|
1073 |
||
1074 |
TLiwVariant content(_L("CalendarEntry")); |
|
1075 |
TLiwGenericParam element1; |
|
1076 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
1077 |
inparam->AppendL(element1); |
|
1078 |
content.Reset(); |
|
1079 |
element1.Reset(); |
|
1080 |
||
1081 |
map1->InsertL(_L8("LocalId"),TLiwVariant(localuid)); |
|
1082 |
||
1083 |
CLiwDefaultMap* repeatmap = CLiwDefaultMap::NewL(); |
|
1084 |
CleanupStack::PushL(repeatmap); |
|
1085 |
repeatmap->InsertL(_L8("Type"), TLiwVariant(TInt32(3))); |
|
1086 |
repeatmap->InsertL(_L8("StartDate"), TLiwVariant(TTime(TDateTime(2007,EJanuary,30,10,0,0,0)))); |
|
1087 |
repeatmap->InsertL(_L8("UntilDate"), TLiwVariant(TTime(TDateTime(2009,EJanuary,30,10,0,0,0)))); |
|
1088 |
||
1089 |
CLiwDefaultList* daysofmonthlist = CLiwDefaultList::NewL(); |
|
1090 |
CLiwDefaultMap* map3 = CLiwDefaultMap::NewL(); |
|
1091 |
map3->InsertL(_L8("Day"), TLiwVariant(TInt32(0)) ); |
|
1092 |
map3->InsertL(_L8("WeekNum"), TLiwVariant( TInt32(1))); |
|
1093 |
daysofmonthlist->AppendL(TLiwVariant(map3)); |
|
1094 |
map3->DecRef(); |
|
1095 |
||
1096 |
CLiwDefaultMap* map2 = CLiwDefaultMap::NewL(); |
|
1097 |
map2->InsertL(_L8("Day"), TLiwVariant(TInt32(2)) ); |
|
1098 |
map2->InsertL(_L8("WeekNum"), TLiwVariant( TInt32(3))); |
|
1099 |
daysofmonthlist->AppendL(TLiwVariant(map2)); |
|
1100 |
map2->DecRef(); |
|
1101 |
||
1102 |
repeatmap->InsertL(_L8("DaysOfMonth"),TLiwVariant(daysofmonthlist)); |
|
1103 |
daysofmonthlist->DecRef(); |
|
1104 |
||
1105 |
map1->InsertL(_L8("RepeatRule"), TLiwVariant(repeatmap)); |
|
1106 |
CleanupStack::Pop(repeatmap); |
|
1107 |
repeatmap->DecRef(); |
|
1108 |
||
1109 |
TLiwGenericParam element; |
|
1110 |
element.SetNameAndValueL(_L8("Item"),TLiwVariant(map1)); |
|
1111 |
||
1112 |
inparam->AppendL(element); |
|
1113 |
element.Reset(); |
|
1114 |
CleanupStack::Pop(map1); |
|
1115 |
map1->DecRef(); |
|
1116 |
TRAPD(err1, interface->ExecuteCmdL( KCmdAdd, *inparam,*outparam )); |
|
1117 |
TInt pos1 = 0 ; |
|
1118 |
const TLiwGenericParam* output = outparam->FindFirst( pos1,_L8("ErrorCode")); |
|
1119 |
if(output) |
|
1120 |
err = output->Value().AsTInt32(); |
|
1121 |
inparam->Reset(); |
|
1122 |
outparam->Reset(); |
|
1123 |
||
1124 |
} |
|
1125 |
return err; |
|
1126 |
} |
|
1127 |
||
1128 |
int CTestSync::UpdateEntryWithRepeatAndExceptionDates() |
|
1129 |
{ |
|
1130 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
1131 |
||
1132 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
1133 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
1134 |
||
1135 |
GetInterfaceHandle(inparam, outparam); |
|
1136 |
TUIDSet* uidset1; |
|
1137 |
TBuf<10> localuid; |
|
1138 |
TBuf<50> globaluid; |
|
1139 |
AddProvToDo(inparam, outparam, interface, KCalFileName1 ,uidset1); |
|
1140 |
//localuid.Num(TInt64(uidset1->iLocalUID)); |
|
1141 |
globaluid.Copy(uidset1->iGlobalUID->Des()); |
|
1142 |
localuid = GetEntry( inparam, outparam, globaluid, KCalFileName1); |
|
1143 |
delete uidset1; |
|
1144 |
//update repeat from daily to weekly |
|
1145 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
1146 |
CleanupStack::PushL(map); |
|
1147 |
||
1148 |
TLiwVariant content(_L("CalendarEntry")); |
|
1149 |
TLiwGenericParam element1; |
|
1150 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
1151 |
inparam->AppendL(element1); |
|
1152 |
content.Reset(); |
|
1153 |
element1.Reset(); |
|
1154 |
||
1155 |
CLiwDefaultList* repeatdts = CLiwDefaultList::NewL(); |
|
1156 |
CleanupStack::PushL(repeatdts); |
|
1157 |
repeatdts->AppendL(TLiwVariant(TTime(TDateTime(2007,EDecember,30,10,0,0,0)))); |
|
1158 |
repeatdts->AppendL(TLiwVariant(TTime(TDateTime(2007,EDecember,30,10,0,0,0)))); |
|
1159 |
repeatdts->AppendL(TLiwVariant(TTime(TDateTime(2007,EDecember,30,10,0,0,0)))); |
|
1160 |
repeatdts->AppendL(TLiwVariant(TTime(TDateTime(2007,EDecember,30,10,0,0,0)))); |
|
1161 |
map->InsertL(_L8("RepeatDates"), TLiwVariant(repeatdts)); |
|
1162 |
CleanupStack::Pop(repeatdts); |
|
1163 |
repeatdts->DecRef(); |
|
1164 |
||
1165 |
||
1166 |
CLiwDefaultMap* repeatmap = CLiwDefaultMap::NewL(); |
|
1167 |
CleanupStack::PushL(repeatmap); |
|
1168 |
repeatmap->InsertL(_L8("Type"), TLiwVariant(TInt32(2))); |
|
1169 |
repeatmap->InsertL(_L8("UntilDate"), TLiwVariant(TTime(TDateTime(2007,EDecember,30,10,0,0,0)))); |
|
1170 |
map->InsertL(_L8("RepeatRule"), TLiwVariant(repeatmap)); |
|
1171 |
CleanupStack::Pop(repeatmap); |
|
1172 |
repeatmap->DecRef(); |
|
1173 |
||
1174 |
map->InsertL(_L8("LocalId"), TLiwVariant(localuid)); |
|
1175 |
||
1176 |
TLiwGenericParam element; |
|
1177 |
element.SetNameAndValueL(_L8("Item"),TLiwVariant(map)); |
|
1178 |
||
1179 |
inparam->AppendL(element); |
|
1180 |
element.Reset(); |
|
1181 |
map->DecRef(); |
|
1182 |
CleanupStack::Pop(map); |
|
1183 |
||
1184 |
TRAPD(err, interface->ExecuteCmdL( KCmdAdd, *inparam,*outparam )); |
|
1185 |
TInt pos = 0 ; |
|
1186 |
||
1187 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
1188 |
if(output) |
|
1189 |
err = output->Value().AsTInt32(); |
|
1190 |
||
1191 |
//update from weekly to monthly |
|
1192 |
if( err == KErrNone ) |
|
1193 |
{ |
|
1194 |
inparam->Reset(); |
|
1195 |
outparam->Reset(); |
|
1196 |
||
1197 |
CLiwDefaultMap* map1 = CLiwDefaultMap::NewL(); |
|
1198 |
CleanupStack::PushL(map1); |
|
1199 |
||
1200 |
TLiwVariant content(_L("CalendarEntry")); |
|
1201 |
TLiwGenericParam element1; |
|
1202 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
1203 |
inparam->AppendL(element1); |
|
1204 |
content.Reset(); |
|
1205 |
element1.Reset(); |
|
1206 |
||
1207 |
map1->InsertL(_L8("LocalUid"),TLiwVariant(localuid)); |
|
1208 |
||
1209 |
CLiwDefaultMap* repeatmap = CLiwDefaultMap::NewL(); |
|
1210 |
CleanupStack::PushL(repeatmap); |
|
1211 |
repeatmap->InsertL(_L8("Type"), TLiwVariant(TInt32(3))); |
|
1212 |
repeatmap->InsertL(_L8("StartDate"), TLiwVariant(TTime(TDateTime(2007,EJanuary,30,10,0,0,0)))); |
|
1213 |
repeatmap->InsertL(_L8("UntilDate"), TLiwVariant(TTime(TDateTime(2009,EJanuary,30,10,0,0,0)))); |
|
1214 |
||
1215 |
CLiwDefaultList* daysofmonthlist = CLiwDefaultList::NewL(); |
|
1216 |
CLiwDefaultMap* map3 = CLiwDefaultMap::NewL(); |
|
1217 |
map3->InsertL(_L8("Day"), TLiwVariant(TInt32(0)) ); |
|
1218 |
map3->InsertL(_L8("WeekNum"), TLiwVariant( TInt32(1))); |
|
1219 |
daysofmonthlist->AppendL(TLiwVariant(map3)); |
|
1220 |
map3->DecRef(); |
|
1221 |
||
1222 |
CLiwDefaultMap* map2 = CLiwDefaultMap::NewL(); |
|
1223 |
map2->InsertL(_L8("Day"), TLiwVariant(TInt32(2)) ); |
|
1224 |
map2->InsertL(_L8("WeekNum"), TLiwVariant( TInt32(3))); |
|
1225 |
daysofmonthlist->AppendL(TLiwVariant(map2)); |
|
1226 |
map2->DecRef(); |
|
1227 |
||
1228 |
repeatmap->InsertL(_L8("DaysOfMonth"),TLiwVariant(daysofmonthlist)); |
|
1229 |
daysofmonthlist->DecRef(); |
|
1230 |
||
1231 |
map1->InsertL(_L8("RepeatRule"), TLiwVariant(repeatmap)); |
|
1232 |
CleanupStack::Pop(repeatmap); |
|
1233 |
repeatmap->DecRef(); |
|
1234 |
||
1235 |
TLiwGenericParam element; |
|
1236 |
element.SetNameAndValueL(_L8("Item"),TLiwVariant(map1)); |
|
1237 |
||
1238 |
inparam->AppendL(element); |
|
1239 |
element.Reset(); |
|
1240 |
CleanupStack::Pop(map1); |
|
1241 |
map1->DecRef(); |
|
1242 |
TRAPD(err1, interface->ExecuteCmdL( KCmdAdd, *inparam,*outparam )); |
|
1243 |
TInt pos1 = 0 ; |
|
1244 |
const TLiwGenericParam* output = outparam->FindFirst( pos1,_L8("ErrorCode")); |
|
1245 |
if(output) |
|
1246 |
err = output->Value().AsTInt32(); |
|
1247 |
inparam->Reset(); |
|
1248 |
outparam->Reset(); |
|
1249 |
||
1250 |
} |
|
1251 |
return err; |
|
1252 |
} |
|
1253 |
||
1254 |
int CTestSync::AddEntryWithVeryLongDescription() |
|
1255 |
{ |
|
1256 |
iServiceHandler = CLiwServiceHandler::NewL(); |
|
1257 |
||
1258 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
1259 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
1260 |
||
1261 |
GetInterfaceHandle(inparam, outparam); |
|
1262 |
||
1263 |
CLiwDefaultMap* map = CLiwDefaultMap::NewL(); |
|
1264 |
CleanupStack::PushL(map); |
|
1265 |
||
1266 |
TLiwVariant content(_L("CalendarEntry")); |
|
1267 |
TLiwGenericParam element1; |
|
1268 |
element1.SetNameAndValueL(_L8("Type"),content); |
|
1269 |
inparam->AppendL(element1); |
|
1270 |
content.Reset(); |
|
1271 |
element1.Reset(); |
|
1272 |
||
1273 |
||
1274 |
map->InsertL(_L8("Type"), TLiwVariant( KEntryTodo )); |
|
1275 |
map->InsertL(_L8("EndTime"), TLiwVariant(TTime(TDateTime(2007,EAugust,20,0,0,0,0)))); |
|
1276 |
map->InsertL(_L8("Replication"), TLiwVariant(_L("Open"))); |
|
1277 |
HBufC* description = FillBuffer(1000, ETestUnicode); |
|
1278 |
map->InsertL(_L8("Description"), TLiwVariant(description->Des())); |
|
1279 |
delete description; |
|
1280 |
description = NULL; |
|
1281 |
//map->InsertL(_L8("Method"), TLiwVariant(_L("None"))); |
|
1282 |
||
1283 |
TLiwGenericParam element; |
|
1284 |
element.SetNameAndValueL(_L8("Item"),TLiwVariant(map)); |
|
1285 |
||
1286 |
inparam->AppendL(element); |
|
1287 |
element.Reset(); |
|
1288 |
map->DecRef(); |
|
1289 |
CleanupStack::Pop(map); |
|
1290 |
||
1291 |
TRAPD(err, interface->ExecuteCmdL( KCmdAdd, *inparam,*outparam )); |
|
1292 |
TInt pos = 0 ; |
|
1293 |
||
1294 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
1295 |
||
1296 |
if(output) |
|
1297 |
{ |
|
1298 |
err = output->Value().AsTInt32(); |
|
1299 |
} |
|
1300 |
inparam->Reset(); |
|
1301 |
outparam->Reset(); |
|
1302 |
||
1303 |
return err; |
|
1304 |
||
1305 |
} |
|
1306 |
||
1307 |
TDesC& CTestSync::GetEntry(CLiwGenericParamList* inparam, CLiwGenericParamList* outparam, TPtrC globaluid, const TDesC& calname) |
|
1308 |
{ |
|
1309 |
inparam->Reset(); |
|
1310 |
outparam->Reset(); |
|
1311 |
||
1312 |
TLiwGenericParam dsNameParam(KContentType, TLiwVariant(_L("CalendarEntry"))); |
|
1313 |
inparam->AppendL(dsNameParam); |
|
1314 |
||
1315 |
CLiwDefaultMap *filterMap = CLiwDefaultMap::NewL(); |
|
1316 |
TLiwGenericParam filterParam(KFilter, TLiwVariant(filterMap)); |
|
1317 |
inparam->AppendL(filterParam); |
|
1318 |
filterMap->DecRef(); |
|
1319 |
||
1320 |
if(calname.Length()) |
|
1321 |
filterMap->InsertL(KCalendarName,TLiwVariant(calname)); |
|
1322 |
filterMap->InsertL(_L8("id"),TLiwVariant(globaluid)); |
|
1323 |
||
1324 |
TRAPD(err,interface->ExecuteCmdL( _L8("GetList") ,*inparam ,*outparam)); |
|
1325 |
TInt pos = 0 ; |
|
1326 |
TBuf<10> result; |
|
1327 |
const TLiwGenericParam* output = outparam->FindFirst( pos,_L8("ErrorCode")); |
|
1328 |
||
1329 |
if(output) |
|
1330 |
{ |
|
1331 |
err = output->Value().AsTInt32(); |
|
1332 |
if( err == KErrNone ) |
|
1333 |
{ |
|
1334 |
pos = 0; |
|
1335 |
output = outparam->FindFirst( pos,_L8("ReturnValue")); |
|
1336 |
CLiwMap* map; |
|
1337 |
TInt retvalue = KErrNone; |
|
1338 |
||
1339 |
if ( output ) |
|
1340 |
{ |
|
1341 |
CLiwIterable* iterlist = output->Value().AsIterable(); |
|
1342 |
if(iterlist) |
|
1343 |
{ |
|
1344 |
TLiwVariant data1; |
|
1345 |
while(iterlist->NextL(data1) ) |
|
1346 |
{ |
|
1347 |
const CLiwMap* res = data1.AsMap(); |
|
1348 |
if ( res ) |
|
1349 |
{ |
|
1350 |
TLiwVariant data; |
|
1351 |
if(res->FindL(_L8("LocalId"), data)) |
|
1352 |
result = data.AsDes(); |
|
1353 |
data.Reset(); |
|
1354 |
} |
|
1355 |
} |
|
1356 |
data1.Reset(); |
|
1357 |
} |
|
1358 |
} |
|
1359 |
} |
|
1360 |
} |
|
1361 |
||
1362 |
inparam->Reset(); |
|
1363 |
outparam->Reset(); |
|
1364 |
||
1365 |
return result; |
|
1366 |
} |