|
1 /* |
|
2 * Copyright (c) 2007 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 <e32base.h> |
|
20 #include <e32def.h> |
|
21 |
|
22 |
|
23 #include "serviceerrno.h" |
|
24 #include "calendarheader.h" |
|
25 #include "entryattributes.h" |
|
26 #include "calendarservice.h" |
|
27 #include "calendarinterface.h" |
|
28 #include "calendarcallback.h" |
|
29 #include "calendariterableimpl.h" |
|
30 |
|
31 using namespace LIW; |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // Two-phased constructor. |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CCalendarInterface* CCalendarInterface::NewL() |
|
38 { |
|
39 CCalendarInterface* self = new (ELeave) CCalendarInterface(); |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop( self ); |
|
43 return self; |
|
44 } |
|
45 // --------------------------------------------------------------------------- |
|
46 // Destructor. |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CCalendarInterface::~CCalendarInterface() |
|
50 { |
|
51 TInt count = iArrayCalEntryList.Count(); |
|
52 for(TInt index = 0; index < count; index++ ) |
|
53 { |
|
54 iArrayCalEntryList[index]->SetResourceFree(); |
|
55 } |
|
56 |
|
57 iArrayCalEntryList.Reset(); |
|
58 delete iCalService; |
|
59 delete iErrorMessage; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // Constructor |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CCalendarInterface::CCalendarInterface() |
|
67 { |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // Symbian Constructor |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 void CCalendarInterface::ConstructL() |
|
75 { |
|
76 iCalService = CCalendarService::NewL(); |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // Executes the SAPI as per params |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void CCalendarInterface::ExecuteCmdL( const TDesC8& aCmdName, |
|
84 const CLiwGenericParamList& aInParamList, |
|
85 CLiwGenericParamList& aOutParamList, |
|
86 TUint aCmdOptions, |
|
87 MLiwNotifyCallback* aCallback ) |
|
88 { |
|
89 TInt errcode = KErrNotSupported; |
|
90 TInt32 transactionId = -1; |
|
91 |
|
92 aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
|
93 TLiwVariant( ErrCodeConversion( KErrNone )))); |
|
94 |
|
95 TBool posBased; |
|
96 |
|
97 TPtrC contentType = GetContentType( aInParamList, posBased ); |
|
98 |
|
99 if ( ( contentType.CompareF( KContentCalendar ) != 0 ) && |
|
100 ( contentType.CompareF( KContentCalendarEntry ) != 0 ) && |
|
101 ( aCmdName.CompareF( KCmdCancel ) != 0) ) |
|
102 { |
|
103 errcode = KErrArgument; |
|
104 AppendErrorMessageL( aCmdName, KContentType, KInvalid ); |
|
105 } |
|
106 |
|
107 else if (( aCallback && !( KLiwOptASyncronous & aCmdOptions )) || |
|
108 ( !aCallback && ( KLiwOptASyncronous & aCmdOptions )) ) |
|
109 { |
|
110 errcode = KErrArgument; |
|
111 AppendErrorMessageL(aCmdName, KNullDesC8, _L("Insufficent arguments for asynchronous request")); |
|
112 } |
|
113 |
|
114 else if ( aCmdName.CompareF( KCmdAdd ) == 0 ) |
|
115 { |
|
116 if( !aCallback ) |
|
117 { |
|
118 if ( contentType.CompareF( KContentCalendar ) == 0 ) |
|
119 { |
|
120 TRAP(errcode, AddCalendarL( aInParamList, aOutParamList, posBased )); |
|
121 } |
|
122 else if ( contentType.CompareF( KContentCalendarEntry ) == 0 ) |
|
123 { |
|
124 TRAP(errcode, AddCalendarEntryL( aInParamList, aOutParamList, posBased )); |
|
125 } |
|
126 } |
|
127 else |
|
128 { |
|
129 AppendErrorMessageL(aCmdName, KNullDesC8, KAsyncNotSupported); |
|
130 } |
|
131 } |
|
132 |
|
133 else if ( aCmdName.CompareF( KCmdDelete ) == 0 ) |
|
134 { |
|
135 if( contentType.CompareF( KContentCalendar ) == 0 ) |
|
136 { |
|
137 if ( !aCallback )//deletion of calendars only synchronous |
|
138 { |
|
139 TRAP(errcode, DeleteCalendarL( aInParamList, posBased) ); |
|
140 } |
|
141 else |
|
142 { |
|
143 AppendErrorMessageL(aCmdName, KNullDesC8, KAsyncNotSupported); |
|
144 } |
|
145 } |
|
146 else if ( contentType.CompareF( KContentCalendarEntry ) == 0) |
|
147 { |
|
148 TRAP(errcode, DeleteCalendarEntryL( aInParamList, aOutParamList, aCmdOptions, aCallback, posBased, transactionId )); |
|
149 } |
|
150 } |
|
151 |
|
152 else if ( aCmdName.CompareF( KCmdImport ) == 0 ) |
|
153 { |
|
154 if ( contentType.CompareF( KContentCalendarEntry ) == 0 ) |
|
155 { |
|
156 TRAP(errcode, ImportCalendarEntryL( aInParamList, aOutParamList, aCmdOptions, aCallback, posBased, transactionId )); |
|
157 } |
|
158 else |
|
159 { |
|
160 AppendErrorMessageL( aCmdName, KContentType, KInvalid ); |
|
161 } |
|
162 } |
|
163 |
|
164 else if ( aCmdName.CompareF( KCmdExport ) == 0 ) |
|
165 { |
|
166 if ( contentType.CompareF( KContentCalendarEntry ) == 0 ) |
|
167 { |
|
168 TRAP(errcode, ExportCalendarEntryL( aInParamList, aOutParamList, aCmdOptions, aCallback, posBased, transactionId )); |
|
169 } |
|
170 else |
|
171 { |
|
172 AppendErrorMessageL( aCmdName, KContentType, KInvalid ); |
|
173 } |
|
174 } |
|
175 |
|
176 else if ( aCmdName.CompareF( KCmdGetList ) == 0 ) |
|
177 { |
|
178 if( !aCallback ) |
|
179 { |
|
180 if ( contentType.CompareF( KContentCalendar ) == 0 ) |
|
181 { |
|
182 TRAP(errcode, GetListCalendarL( aInParamList, aOutParamList, posBased )); |
|
183 } |
|
184 else if ( contentType.CompareF( KContentCalendarEntry ) == 0 ) |
|
185 { |
|
186 TRAP(errcode, GetListCalendarEntryL( aInParamList, aOutParamList, posBased )); |
|
187 } |
|
188 } |
|
189 else |
|
190 { |
|
191 AppendErrorMessageL(aCmdName, KNullDesC8, KAsyncNotSupported); |
|
192 } |
|
193 } |
|
194 |
|
195 else if ( aCmdName.CompareF( KCmdReqNot ) == 0 ) |
|
196 { |
|
197 if (( contentType.CompareF( KContentCalendarEntry ) == 0 ) && |
|
198 aCallback && ( KLiwOptASyncronous & aCmdOptions ) ) |
|
199 { |
|
200 TRAP(errcode, RequestNotificationL(aInParamList, aCallback, posBased, transactionId )); |
|
201 } |
|
202 else if( !aCallback || !( KLiwOptASyncronous & aCmdOptions )) |
|
203 { |
|
204 AppendErrorMessageL(aCmdName, KNullDesC8, KInvalidAsyncParam); |
|
205 } |
|
206 else |
|
207 { |
|
208 AppendErrorMessageL( aCmdName, KContentType, KInvalid ); |
|
209 } |
|
210 } |
|
211 |
|
212 else if ( aCmdName.CompareF( KCmdCancel ) == 0 ) |
|
213 { |
|
214 TInt32 transactionId; |
|
215 if( (KLiwOptCancel & aCmdOptions ) && !aCallback ) |
|
216 { |
|
217 TRAP( errcode, GetTransactionIdL( aInParamList, transactionId ) ); |
|
218 if( errcode == KErrNone ) |
|
219 { |
|
220 errcode = iCalService->Cancel( transactionId ); |
|
221 if ( errcode == KErrNotFound ) |
|
222 { |
|
223 AppendErrorMessageL( aCmdName, KTransactionID, KInvalid ); |
|
224 } |
|
225 else if( errcode == KErrInUse ) |
|
226 { |
|
227 AppendErrorMessageL( aCmdName, KNullDesC8, KServiceInUse ); |
|
228 } |
|
229 } |
|
230 } |
|
231 else |
|
232 { |
|
233 AppendErrorMessageL( aCmdName, KNullDesC8, KInvalidCancelParam ); |
|
234 } |
|
235 } |
|
236 |
|
237 else |
|
238 { |
|
239 AppendErrorMessageL(aCmdName, KNullDesC8, KCmdInvalid); |
|
240 } |
|
241 |
|
242 // Append transaction id in case of asynchronous requests |
|
243 if( aCallback && ( KLiwOptASyncronous & aCmdOptions ) && |
|
244 ( errcode == KErrNone ) && ( transactionId != -1 ) ) |
|
245 { |
|
246 aOutParamList.AppendL(TLiwGenericParam( KTransactionID, |
|
247 TLiwVariant( TInt32( transactionId )))); |
|
248 } |
|
249 |
|
250 if( errcode != KErrNone ) |
|
251 { |
|
252 aOutParamList.Reset(); |
|
253 aOutParamList.AppendL(TLiwGenericParam( KErrorCode, |
|
254 TLiwVariant(ErrCodeConversion(errcode)))); |
|
255 |
|
256 if ( iErrorMessage ) |
|
257 { |
|
258 aOutParamList.AppendL(TLiwGenericParam( KErrorMessage, |
|
259 TLiwVariant(iErrorMessage->Des()))); |
|
260 delete iErrorMessage; |
|
261 iErrorMessage = NULL; |
|
262 } |
|
263 } |
|
264 } |
|
265 |
|
266 // --------------------------------------------------------------------------- |
|
267 // Closes the interface |
|
268 // --------------------------------------------------------------------------- |
|
269 // |
|
270 void CCalendarInterface::Close() |
|
271 { |
|
272 delete this; |
|
273 } |
|
274 |
|
275 // --------------------------------------------------------------------------- |
|
276 // Issues Add Calendar request to Calendar Service |
|
277 // --------------------------------------------------------------------------- |
|
278 // |
|
279 void CCalendarInterface::AddCalendarL(const CLiwGenericParamList& aInParamList, |
|
280 CLiwGenericParamList& /*aOutParamList*/, |
|
281 const TBool aPosBased ) |
|
282 { |
|
283 HBufC* calName = NULL; |
|
284 GetCalendarNameL( aInParamList, KCmdAdd, KItem, aPosBased, calName ); |
|
285 if ( calName && calName->Des().Length() ) |
|
286 { |
|
287 CleanupStack::PushL(calName); |
|
288 iCalService->AddL( calName->Des() ); |
|
289 CleanupStack::PopAndDestroy(calName); |
|
290 } |
|
291 else |
|
292 { |
|
293 AppendErrorMessageL( KCmdAdd, KCalendarName, KMissing ); |
|
294 User::Leave( KErrArgument ); |
|
295 } |
|
296 } |
|
297 |
|
298 // --------------------------------------------------------------------------- |
|
299 // Issues Add Calendar Entry request to Calendar Service |
|
300 // --------------------------------------------------------------------------- |
|
301 // |
|
302 void CCalendarInterface::AddCalendarEntryL(const CLiwGenericParamList& aInParamList, |
|
303 CLiwGenericParamList& aOutParamList, |
|
304 const TBool aPosBased ) |
|
305 { |
|
306 HBufC* calName = NULL; |
|
307 |
|
308 GetCalendarNameL( aInParamList, KCmdAdd, KItem, aPosBased, calName ); |
|
309 |
|
310 if ( calName ) |
|
311 { |
|
312 CleanupStack::PushL(calName); |
|
313 } |
|
314 |
|
315 // Get New entry attributes from input param list |
|
316 CEntryAttributes* addAttributes = GetAddParametersL( aInParamList, |
|
317 calName ? calName->Des() : TPtrC(), |
|
318 aPosBased ); |
|
319 |
|
320 CleanupStack::PushL( addAttributes ); |
|
321 |
|
322 TUIDSet* uidset = NULL; |
|
323 |
|
324 iCalService->AddL( calName ? calName->Des() : TPtrC() , addAttributes, uidset ); |
|
325 |
|
326 // Return Uid of the newly added entry |
|
327 if ( uidset ) |
|
328 { |
|
329 CleanupStack::PushL( uidset ); |
|
330 |
|
331 HBufC* globalUid = HBufC::NewL( uidset->iGlobalUID->Length() + 1 ); |
|
332 CleanupStack::PushL( globalUid ); |
|
333 globalUid->Des().Copy( uidset->iGlobalUID->Des() ); |
|
334 aOutParamList.AppendL( TLiwGenericParam( KReturnValue, TLiwVariant(*globalUid) )); |
|
335 CleanupStack::PopAndDestroy( globalUid ); |
|
336 |
|
337 CleanupStack::Pop( uidset ); |
|
338 |
|
339 delete uidset; |
|
340 |
|
341 CleanupStack::PopAndDestroy( addAttributes ); |
|
342 } |
|
343 else |
|
344 { |
|
345 AppendErrorMessageL( KCmdAdd, KNullDesC8, KCmdFailed ); |
|
346 User::Leave( KErrGeneral ); |
|
347 } |
|
348 |
|
349 if ( calName ) |
|
350 { |
|
351 CleanupStack::PopAndDestroy(calName); |
|
352 } |
|
353 } |
|
354 |
|
355 // --------------------------------------------------------------------------- |
|
356 // Issues Delete Calendar request to Calendar Service |
|
357 // --------------------------------------------------------------------------- |
|
358 // |
|
359 void CCalendarInterface::DeleteCalendarL( const CLiwGenericParamList& aInParamList, TBool aPosBased) |
|
360 { |
|
361 HBufC* calName = NULL; |
|
362 GetCalendarNameL( aInParamList, KCmdDelete, KData, aPosBased, calName ); |
|
363 if ( calName && calName->Length() ) |
|
364 { |
|
365 CleanupStack::PushL( calName ); |
|
366 if( CheckCalendarInUse( *calName ) ) |
|
367 { |
|
368 AppendErrorMessageL( KCmdDelete, KCalendarName, _L(" in use.") ); |
|
369 User::Leave( KErrInUse ); |
|
370 } |
|
371 iCalService->DeleteL( calName->Des() ); |
|
372 CleanupStack::PopAndDestroy( calName ); |
|
373 } |
|
374 else |
|
375 { |
|
376 AppendErrorMessageL( KCmdDelete, KCalendarName, KMissing ); |
|
377 User::Leave( KErrArgument ); |
|
378 } |
|
379 } |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // Issues Delete Calendar Entry request to Calendar Service |
|
383 // --------------------------------------------------------------------------- |
|
384 // |
|
385 void CCalendarInterface::DeleteCalendarEntryL( const CLiwGenericParamList& aInParamList, |
|
386 CLiwGenericParamList& /*aOutParamList*/, |
|
387 TUint aCmdOptions, |
|
388 MLiwNotifyCallback* aCallback, |
|
389 const TBool aPosBased, |
|
390 TInt32& aTransactionId ) |
|
391 { |
|
392 HBufC* calName = NULL; |
|
393 |
|
394 GetCalendarNameL( aInParamList, KCmdDelete, KData, aPosBased, calName ); |
|
395 |
|
396 if ( calName ) |
|
397 { |
|
398 CleanupStack::PushL(calName); |
|
399 } |
|
400 |
|
401 CCalendarFilter* filter = CCalendarFilter::NewL(); |
|
402 |
|
403 CleanupStack::PushL(filter); |
|
404 |
|
405 // Get filter parameters from input list |
|
406 GetDeleteEntryFilterL( aInParamList, *filter, aPosBased ); |
|
407 |
|
408 // Leave if there was no filter |
|
409 if( ! filter->Filter() ) |
|
410 { |
|
411 AppendErrorMessageL( KCmdDelete, KData, KMissing ); |
|
412 User::Leave( KErrArgument ); |
|
413 } |
|
414 |
|
415 // Issue asynchronous request if Callback present |
|
416 if ( aCallback && ( KLiwOptASyncronous & aCmdOptions )) |
|
417 { |
|
418 aTransactionId = aCallback->GetTransactionID(); |
|
419 |
|
420 CCalCallbackInt* callback = CCalCallbackInt::NewL( aCallback, aInParamList, aTransactionId ); |
|
421 |
|
422 CleanupStack::PushL( callback ); |
|
423 |
|
424 iCalService->DeleteL( calName ? calName->Des() : TPtrC() , filter, callback ); |
|
425 |
|
426 CleanupStack::Pop( callback ); |
|
427 } |
|
428 // Synchronous request |
|
429 else |
|
430 { |
|
431 iCalService->DeleteL( calName ? calName->Des() : TPtrC(), filter ); |
|
432 } |
|
433 |
|
434 CleanupStack::PopAndDestroy(filter); |
|
435 |
|
436 if ( calName ) |
|
437 { |
|
438 CleanupStack::PopAndDestroy(calName); |
|
439 } |
|
440 |
|
441 } |
|
442 |
|
443 // --------------------------------------------------------------------------- |
|
444 // Issues GetList Calendar request to Calendar Service |
|
445 // --------------------------------------------------------------------------- |
|
446 // |
|
447 void CCalendarInterface::GetListCalendarL(const CLiwGenericParamList& aInParamList, |
|
448 CLiwGenericParamList& aOutParamList, |
|
449 const TBool aPosBased ) |
|
450 { |
|
451 const TLiwGenericParam* filter = NULL; |
|
452 |
|
453 if ( aPosBased ) |
|
454 { |
|
455 if ( aInParamList.Count() > 1 ) |
|
456 filter = &aInParamList[1]; |
|
457 } |
|
458 else |
|
459 { |
|
460 TInt pos = 0 ; |
|
461 filter = aInParamList.FindFirst( pos, KFilter ); |
|
462 } |
|
463 |
|
464 TBool defaultCalendar = EFalse; |
|
465 |
|
466 // Extracting "Default" input param |
|
467 // If True, Only default calendar is returned |
|
468 if ( filter ) |
|
469 { |
|
470 const CLiwMap* inputMap = filter->Value().AsMap(); |
|
471 if ( inputMap ) |
|
472 { |
|
473 TLiwVariant defaultvalue; |
|
474 if( inputMap->FindL( KDefault, defaultvalue)) |
|
475 { |
|
476 ValidateParamTypeL( defaultvalue, LIW::EVariantTypeTBool, |
|
477 KCmdGetList, KDefault, KInvalid ); |
|
478 |
|
479 defaultCalendar = defaultvalue.AsTBool(); |
|
480 } |
|
481 defaultvalue.Reset(); |
|
482 } |
|
483 else |
|
484 { |
|
485 AppendErrorMessageL( KCmdGetList, KFilter, KInvalid ); |
|
486 User::Leave(KErrArgument); |
|
487 } |
|
488 } |
|
489 |
|
490 CDesCArray* returnList = NULL; |
|
491 |
|
492 // Issue request to Calendar Service |
|
493 iCalService->GetListL( returnList, defaultCalendar ); |
|
494 |
|
495 CleanupStack::PushL( returnList ); |
|
496 |
|
497 // Encapsulate the returned list as Iterable |
|
498 CIterableCalendarList* iterList = CIterableCalendarList::NewL( returnList ); |
|
499 |
|
500 CleanupStack::Pop( returnList ); |
|
501 |
|
502 CleanupClosePushL( *iterList ); |
|
503 |
|
504 aOutParamList.AppendL( TLiwGenericParam( KReturnValue, TLiwVariant( iterList ))); |
|
505 |
|
506 CleanupStack::PopAndDestroy( iterList ); |
|
507 |
|
508 } |
|
509 |
|
510 // --------------------------------------------------------------------------- |
|
511 // Issues GetList Calendar Entry request to Calendar Service |
|
512 // --------------------------------------------------------------------------- |
|
513 // |
|
514 void CCalendarInterface::GetListCalendarEntryL(const CLiwGenericParamList& aInParamList, |
|
515 CLiwGenericParamList& aOutParamList, |
|
516 const TBool aPosBased ) |
|
517 { |
|
518 const TLiwGenericParam* filterParam = NULL; |
|
519 |
|
520 if ( aPosBased ) |
|
521 { |
|
522 if ( aInParamList.Count() > 1 ) |
|
523 filterParam = &aInParamList[1]; |
|
524 } |
|
525 else |
|
526 { |
|
527 TInt pos = 0 ; |
|
528 filterParam = aInParamList.FindFirst( pos, KFilter ); |
|
529 } |
|
530 |
|
531 CCalendarFilter* filter = CCalendarFilter::NewL(); |
|
532 |
|
533 CleanupStack::PushL( filter ); |
|
534 |
|
535 HBufC* calName = NULL; |
|
536 |
|
537 // Extract filter information from input param list |
|
538 if ( filterParam ) |
|
539 { |
|
540 const CLiwMap* inputMap = filterParam->Value().AsMap(); |
|
541 if ( inputMap ) |
|
542 { |
|
543 TLiwVariant param; |
|
544 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , ¶m)); |
|
545 |
|
546 |
|
547 if( inputMap->FindL( KId, param )) |
|
548 { |
|
549 ValidateParamTypeL( param, LIW::EVariantTypeDesC, |
|
550 KCmdGetList, KId, KInvalid ); |
|
551 |
|
552 //filter->AddGuidL( param.AsData() ); |
|
553 HBufC8* globalUid = HBufC8::NewL(param.AsDes().Length()); |
|
554 CleanupStack::PushL( globalUid ); |
|
555 GetGlobalUid(param.AsDes(), globalUid->Des()); |
|
556 filter->AddGuidL( globalUid->Des() ); |
|
557 CleanupStack::PopAndDestroy( globalUid ); |
|
558 } |
|
559 |
|
560 if( inputMap->FindL( KLocalId, param )) |
|
561 { |
|
562 ValidateParamTypeL( param, LIW::EVariantTypeDesC, |
|
563 KCmdGetList, KLocalId, KInvalid ); |
|
564 |
|
565 //filter->AddLocalUid( param.AsTUint() ); |
|
566 TCalLocalUid localUid; |
|
567 GetLocalUid( param.AsDes(), localUid ); |
|
568 filter->AddLocalUid( localUid ); |
|
569 } |
|
570 |
|
571 if( inputMap->FindL( KStartRange, param)) |
|
572 { |
|
573 ValidateParamTypeL( param, LIW::EVariantTypeTTime, |
|
574 KCmdGetList, KStartRange, KInvalid ); |
|
575 |
|
576 filter->SetStartTimeL( param.AsTTime() ); |
|
577 } |
|
578 |
|
579 if( inputMap->FindL( KEndRange, param)) |
|
580 { |
|
581 ValidateParamTypeL( param, LIW::EVariantTypeTTime, |
|
582 KCmdGetList, KEndRange, KInvalid ); |
|
583 |
|
584 filter->SetEndTimeL( param.AsTTime() ); |
|
585 } |
|
586 |
|
587 if( inputMap->FindL( KSearchText, param)) |
|
588 { |
|
589 ValidateParamTypeL( param, LIW::EVariantTypeDesC, |
|
590 KCmdGetList, KSearchText, KInvalid ); |
|
591 |
|
592 filter->SetFilterTextL( param.AsDes() ); |
|
593 } |
|
594 |
|
595 if( inputMap->FindL( KEntryType, param)) |
|
596 { |
|
597 ValidateParamTypeL( param, LIW::EVariantTypeDesC, |
|
598 KCmdGetList, _L8("Entry Type") , KInvalid ); |
|
599 |
|
600 filter->SetFilterTypeL( param.AsDes() ); |
|
601 } |
|
602 |
|
603 if( inputMap->FindL( KCalendarName, param)) |
|
604 { |
|
605 ValidateParamTypeL( param, LIW::EVariantTypeDesC, |
|
606 KCmdGetList, KCalendarName, KInvalid ); |
|
607 |
|
608 calName = param.AsDes().AllocL(); |
|
609 } |
|
610 |
|
611 CleanupStack::Pop( ¶m); |
|
612 param.Reset(); |
|
613 } |
|
614 else |
|
615 { |
|
616 AppendErrorMessageL(KCmdGetList, KFilter, KInvalid); |
|
617 User::Leave(KErrArgument); |
|
618 } |
|
619 } |
|
620 if( calName ) |
|
621 CleanupStack::PushL(calName); |
|
622 TPtrC calendarName( calName ? calName->Des() : TPtrC() ); |
|
623 |
|
624 // Return list of CalendarEntries if any of LocalUid or GlobalUid is passed as Filter. |
|
625 if ( ( filter->Filter() & EFilterGUid ) || |
|
626 ( filter->Filter() & EFilterLUid ) ) |
|
627 { |
|
628 CIterableCalEntryList* iterEntryList = CIterableCalEntryList::NewL( *this, calendarName, ETrue ); |
|
629 CleanupStack::PushL( TCleanupItem(CleanupIterableCalEntry, iterEntryList ) ); |
|
630 |
|
631 |
|
632 if ( filter->Filter() & EFilterLUid ) |
|
633 { |
|
634 // In case of LocalUid only one entry is returned. |
|
635 iCalService->GetListL( calendarName, (filter->LocalUidList())[0], iterEntryList->EntryArray()); |
|
636 } |
|
637 else |
|
638 { |
|
639 // In case of GlobalUid there can be more than one entry(child entries) |
|
640 iCalService->GetListL( calendarName, (*filter->GuidList())[0], iterEntryList->EntryArray()); |
|
641 } |
|
642 |
|
643 aOutParamList.AppendL( TLiwGenericParam( KReturnValue, TLiwVariant( iterEntryList ))); |
|
644 iterEntryList->DecRef(); |
|
645 |
|
646 iArrayCalEntryList.Append( iterEntryList ); |
|
647 |
|
648 CleanupStack::Pop( iterEntryList ); |
|
649 } |
|
650 // Return list of Instances if none of LocalUid or GlobalUid is passed as Filter. |
|
651 else |
|
652 { |
|
653 CIterableCalEntryList* iterInstList = CIterableCalEntryList::NewL( *this, calendarName, EFalse ); |
|
654 CleanupStack::PushL( TCleanupItem(CleanupIterableCalEntry, iterInstList ) ); |
|
655 |
|
656 iCalService->GetListL( calendarName, filter, iterInstList->InstanceArray()); |
|
657 |
|
658 aOutParamList.AppendL( TLiwGenericParam( KReturnValue, TLiwVariant( iterInstList ))); |
|
659 iterInstList->DecRef(); |
|
660 |
|
661 iArrayCalEntryList.Append( iterInstList ); |
|
662 |
|
663 CleanupStack::Pop( iterInstList ); |
|
664 } |
|
665 |
|
666 if ( calName ) |
|
667 CleanupStack::PopAndDestroy(calName); |
|
668 |
|
669 CleanupStack::PopAndDestroy(filter); |
|
670 } |
|
671 |
|
672 // --------------------------------------------------------------------------- |
|
673 // Issues Import Calendar Entry request to Calendar Service |
|
674 // --------------------------------------------------------------------------- |
|
675 // |
|
676 void CCalendarInterface::ImportCalendarEntryL(const CLiwGenericParamList& aInParamList, |
|
677 CLiwGenericParamList& aOutParamList, |
|
678 TUint aCmdOptions, |
|
679 MLiwNotifyCallback* aCallback , |
|
680 const TBool aPosBased, |
|
681 TInt32& aTransactionId ) |
|
682 { |
|
683 HBufC8* inputBuffer = NULL; |
|
684 |
|
685 HBufC* calName = NULL; |
|
686 |
|
687 HBufC* importFile = NULL; |
|
688 |
|
689 HBufC8* calendarFormat = NULL; |
|
690 |
|
691 // Extract input information from input param list |
|
692 GetCalendarNameL( aInParamList, KCmdImport, KData, aPosBased, calName ); |
|
693 if ( calName ) |
|
694 { |
|
695 CleanupStack::PushL( calName ); |
|
696 } |
|
697 |
|
698 GetDesCFieldFromMapL( aInParamList, KCmdImport, KData, KImExFileName, aPosBased, importFile ); |
|
699 if ( importFile ) |
|
700 { |
|
701 CleanupStack::PushL( importFile ); |
|
702 } |
|
703 |
|
704 GetDesC8FieldFromMapL( aInParamList, KCmdImport, KData, KInputBuffer, aPosBased, inputBuffer ); |
|
705 if ( inputBuffer ) |
|
706 { |
|
707 CleanupStack::PushL( inputBuffer ); |
|
708 } |
|
709 else if ( !importFile ) |
|
710 { |
|
711 AppendErrorMessageL( KCmdImport, KImExFileName, KMissing ); |
|
712 User::Leave( KErrArgument ); |
|
713 } |
|
714 |
|
715 HBufC* tmpFormat = NULL; |
|
716 GetDesCFieldFromMapL( aInParamList, KCmdImport, KData, KCalendarFormat, aPosBased, tmpFormat ); |
|
717 if ( tmpFormat ) |
|
718 { |
|
719 CleanupStack::PushL( tmpFormat ); |
|
720 calendarFormat = HBufC8::NewL(tmpFormat->Des().Length()); |
|
721 calendarFormat->Des().Copy(tmpFormat->Des()); |
|
722 CleanupStack::PopAndDestroy( tmpFormat ); |
|
723 CleanupStack::PushL( calendarFormat ); |
|
724 } |
|
725 else |
|
726 { |
|
727 AppendErrorMessageL( KCmdImport, KCalendarFormat, KMissing ); |
|
728 User::Leave( KErrArgument ); |
|
729 } |
|
730 |
|
731 |
|
732 //asynchronous version of import is called if callback is provided |
|
733 if ( aCallback && ( KLiwOptASyncronous & aCmdOptions )) |
|
734 { |
|
735 aTransactionId = aCallback->GetTransactionID(); |
|
736 |
|
737 CCalCallbackBaseUIDSet* callback = CCalCallbackBaseUIDSet::NewL( aCallback, aInParamList, aTransactionId); |
|
738 |
|
739 CleanupStack::PushL( callback ); |
|
740 |
|
741 if ( inputBuffer ) |
|
742 { |
|
743 // Import from the input buffer |
|
744 iCalService->ImportL( calName ? calName->Des() : TPtrC(), |
|
745 *calendarFormat, *inputBuffer, callback ); |
|
746 } |
|
747 else |
|
748 { |
|
749 // Import from the given file |
|
750 iCalService->ImportL( calName ? calName->Des() : TPtrC(), |
|
751 *calendarFormat , *importFile, callback ); |
|
752 } |
|
753 |
|
754 CleanupStack::Pop( callback ); |
|
755 } |
|
756 else //synchronous version of import |
|
757 { |
|
758 RPointerArray<TUIDSet> outputUIDSet;//Push on to CalennupStack |
|
759 |
|
760 if ( inputBuffer ) |
|
761 { |
|
762 // Import from the input buffer |
|
763 iCalService->ImportL( calName ? calName->Des() : TPtrC(), |
|
764 *calendarFormat , *inputBuffer, outputUIDSet ); |
|
765 } |
|
766 else |
|
767 { |
|
768 // Import from the input file |
|
769 iCalService->ImportL( calName ? calName->Des() : TPtrC(), |
|
770 *calendarFormat , *importFile, outputUIDSet ); |
|
771 } |
|
772 |
|
773 // Set output to output param |
|
774 SetImportOutputL( outputUIDSet, aOutParamList ); |
|
775 |
|
776 outputUIDSet.ResetAndDestroy(); |
|
777 } |
|
778 |
|
779 CleanupStack::PopAndDestroy( calendarFormat ); |
|
780 |
|
781 if ( inputBuffer ) |
|
782 CleanupStack::PopAndDestroy( inputBuffer ); |
|
783 |
|
784 if ( importFile ) |
|
785 CleanupStack::PopAndDestroy( importFile ); |
|
786 |
|
787 if ( calName ) |
|
788 CleanupStack::PopAndDestroy( calName ); |
|
789 } |
|
790 |
|
791 // --------------------------------------------------------------------------- |
|
792 // Issues Export Calendar Entry request to Calendar Service |
|
793 // --------------------------------------------------------------------------- |
|
794 // |
|
795 void CCalendarInterface::ExportCalendarEntryL(const CLiwGenericParamList& aInParamList, |
|
796 CLiwGenericParamList& aOutParamList, |
|
797 TUint aCmdOptions, |
|
798 MLiwNotifyCallback* aCallback , |
|
799 const TBool aPosBased, |
|
800 TInt32& aTransactionId ) |
|
801 { |
|
802 HBufC* calendarName = NULL; |
|
803 |
|
804 HBufC8* exportFormat = NULL; |
|
805 |
|
806 CCalendarExportParams* calendarExportParams = CCalendarExportParams::NewL(); |
|
807 |
|
808 CleanupStack::PushL( calendarExportParams ); |
|
809 |
|
810 // Extract input information from input param list |
|
811 GetCalendarNameL( aInParamList, KCmdExport, KData, aPosBased, calendarName ); |
|
812 if ( calendarName ) |
|
813 { |
|
814 CleanupStack::PushL( calendarName ); |
|
815 } |
|
816 |
|
817 HBufC* tmpFormat = NULL; |
|
818 GetDesCFieldFromMapL( aInParamList, KCmdExport, KData, KCalendarFormat, aPosBased, tmpFormat ); |
|
819 if ( tmpFormat ) |
|
820 { |
|
821 CleanupStack::PushL( tmpFormat ); |
|
822 exportFormat = HBufC8::NewL(tmpFormat->Des().Length()); |
|
823 exportFormat->Des().Copy(tmpFormat->Des()); |
|
824 CleanupStack::PopAndDestroy( tmpFormat ); |
|
825 CleanupStack::PushL( exportFormat ); |
|
826 } |
|
827 else |
|
828 { |
|
829 AppendErrorMessageL( KCmdExport, KCalendarFormat, KMissing ); |
|
830 User::Leave( KErrArgument ); |
|
831 } |
|
832 |
|
833 // Extract input information from input param list |
|
834 GetExportInputL( aInParamList , aPosBased , *calendarExportParams ); |
|
835 |
|
836 //asynchronous version of Export is called if callback is provided |
|
837 if ( aCallback && ( KLiwOptASyncronous & aCmdOptions )) |
|
838 { |
|
839 aTransactionId = aCallback->GetTransactionID(); |
|
840 |
|
841 CCalCallbackBaseBuffer* callback = CCalCallbackBaseBuffer::NewL( aCallback, aInParamList, aTransactionId ); |
|
842 |
|
843 CleanupStack::PushL( callback ); |
|
844 |
|
845 iCalService->ExportL( calendarName ? calendarName->Des() : TPtrC(), |
|
846 *exportFormat, calendarExportParams , callback ); |
|
847 |
|
848 CleanupStack::Pop( callback ); |
|
849 } |
|
850 else //synchronous version of Export |
|
851 { |
|
852 HBufC8* outputBuffer = NULL; |
|
853 |
|
854 iCalService->ExportL( calendarName ? calendarName->Des() : TPtrC() , |
|
855 *exportFormat, calendarExportParams , outputBuffer ); |
|
856 |
|
857 // outputBuffer is NULL in case export is done to file |
|
858 if ( outputBuffer ) |
|
859 { |
|
860 CleanupStack::PushL( outputBuffer ); |
|
861 aOutParamList.AppendL( TLiwGenericParam( KReturnValue, TLiwVariant( *outputBuffer ) ) ); |
|
862 CleanupStack::PopAndDestroy( outputBuffer ); |
|
863 } |
|
864 } |
|
865 |
|
866 CleanupStack::PopAndDestroy( exportFormat ); |
|
867 |
|
868 if ( calendarName ) |
|
869 CleanupStack::PopAndDestroy( calendarName ); |
|
870 |
|
871 CleanupStack::PopAndDestroy( calendarExportParams ); |
|
872 } |
|
873 |
|
874 |
|
875 // --------------------------------------------------------------------------- |
|
876 // Issues Change Notification request to Calendar Service |
|
877 // --------------------------------------------------------------------------- |
|
878 // |
|
879 void CCalendarInterface::RequestNotificationL( const CLiwGenericParamList& aInParamList, |
|
880 MLiwNotifyCallback* aCallback, |
|
881 const TBool aPosBased, |
|
882 TInt32& aTransactionId ) |
|
883 { |
|
884 HBufC* calName = NULL; |
|
885 |
|
886 GetCalendarNameL( aInParamList, KCmdReqNot, KFilter, aPosBased, calName ); |
|
887 |
|
888 if ( calName ) |
|
889 { |
|
890 CleanupStack::PushL(calName); |
|
891 } |
|
892 |
|
893 CCalendarFilter* filter = CCalendarFilter::NewL(); |
|
894 |
|
895 CleanupStack::PushL(filter); |
|
896 |
|
897 // Get Notification filter |
|
898 GetNotificationFilterL( aInParamList, *filter, aPosBased ); |
|
899 |
|
900 aTransactionId = aCallback->GetTransactionID(); |
|
901 |
|
902 CCalCallbackChangeNotify* callback = CCalCallbackChangeNotify::NewL( aCallback, aInParamList, aTransactionId ); |
|
903 |
|
904 CleanupStack::PushL( callback ); |
|
905 |
|
906 // Issue request |
|
907 iCalService->StartChangeNotifyL( calName ? calName->Des() : TPtrC(), filter, callback ); |
|
908 |
|
909 CleanupStack::Pop( callback ); |
|
910 |
|
911 CleanupStack::PopAndDestroy(filter); |
|
912 |
|
913 if ( calName ) |
|
914 { |
|
915 CleanupStack::PopAndDestroy(calName); |
|
916 } |
|
917 |
|
918 } |
|
919 |
|
920 // --------------------------------------------------------------------------- |
|
921 // Get content type from input param list |
|
922 // --------------------------------------------------------------------------- |
|
923 // |
|
924 TPtrC CCalendarInterface::GetContentType(const CLiwGenericParamList& aInParamList, TBool& aPosBased ) |
|
925 { |
|
926 TInt pos = 0; |
|
927 |
|
928 const TLiwGenericParam* inContentType = aInParamList.FindFirst( pos, KContentType ); |
|
929 |
|
930 TPtrC type; |
|
931 |
|
932 if ( inContentType ) |
|
933 { |
|
934 type.Set( inContentType->Value().AsDes() ); |
|
935 aPosBased = EFalse; |
|
936 } |
|
937 else |
|
938 { |
|
939 if ( aInParamList.Count() > 0 ) |
|
940 { |
|
941 inContentType = &aInParamList[0]; |
|
942 if( inContentType->Name().Compare(KNullDesC8) == 0 ) |
|
943 { |
|
944 type.Set( aInParamList[0].Value().AsDes() ); |
|
945 aPosBased = ETrue; |
|
946 } |
|
947 } |
|
948 } |
|
949 |
|
950 return type; |
|
951 } |
|
952 |
|
953 // --------------------------------------------------------------------------- |
|
954 // Gets the Transaction id |
|
955 // --------------------------------------------------------------------------- |
|
956 // |
|
957 void CCalendarInterface::GetTransactionIdL( const CLiwGenericParamList& aInParamList, TInt32& aTransactionId ) |
|
958 { |
|
959 TInt pos = 0; |
|
960 |
|
961 const TLiwGenericParam* param = aInParamList.FindFirst( pos, |
|
962 KTransactionID, |
|
963 EVariantTypeTInt32 ); |
|
964 if(!param && aInParamList.Count() > 0) |
|
965 { |
|
966 param = &aInParamList[0]; |
|
967 if( param->Name().Compare(KNullDesC8) != 0 ) |
|
968 { |
|
969 AppendErrorMessageL( KCmdCancel, KTransactionID, KMissing ); |
|
970 User::Leave(KErrArgument); |
|
971 } |
|
972 } |
|
973 |
|
974 if ( param ) |
|
975 { |
|
976 TLiwVariant* tempparam = const_cast<TLiwVariant*>(& param->Value()); |
|
977 ValidateParamTypeL( *tempparam, LIW::EVariantTypeTInt32, |
|
978 KCmdCancel, KTransactionID, KInvalid ); |
|
979 |
|
980 aTransactionId = param->Value().AsTInt32(); |
|
981 } |
|
982 else |
|
983 { |
|
984 AppendErrorMessageL( KCmdCancel, KTransactionID, KMissing ); |
|
985 User::Leave(KErrArgument); |
|
986 } |
|
987 } |
|
988 |
|
989 // --------------------------------------------------------------------------- |
|
990 // Gets the Calendar Name from input param list |
|
991 // --------------------------------------------------------------------------- |
|
992 // |
|
993 void CCalendarInterface::GetCalendarNameL( const CLiwGenericParamList& aInParamList, |
|
994 const TDesC8& aCmdName, |
|
995 const TDesC8& aField, |
|
996 TBool aPosBased, |
|
997 HBufC*& aCalendarName ) |
|
998 { |
|
999 const TLiwGenericParam* param = NULL; |
|
1000 |
|
1001 if ( aPosBased && aInParamList.Count() > 1) |
|
1002 { |
|
1003 param = &aInParamList[1]; |
|
1004 } |
|
1005 else |
|
1006 { |
|
1007 TInt pos = 0; |
|
1008 param = aInParamList.FindFirst( pos, aField ); |
|
1009 } |
|
1010 |
|
1011 if ( param ) |
|
1012 { |
|
1013 const CLiwMap* inMap = param->Value().AsMap(); |
|
1014 |
|
1015 if(inMap) |
|
1016 { |
|
1017 TLiwVariant inParam; |
|
1018 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &inParam)); |
|
1019 if ( inMap->FindL( KCalendarName, inParam ) ) |
|
1020 { |
|
1021 ValidateParamTypeL( inParam, LIW::EVariantTypeDesC, |
|
1022 aCmdName, KCalendarName, KInvalid ); |
|
1023 |
|
1024 if ( inParam.AsDes().Length() > KMaxFileName ) |
|
1025 { |
|
1026 AppendErrorMessageL( aCmdName, KCalendarName, KInvalid ); |
|
1027 User::Leave(KErrArgument); |
|
1028 } |
|
1029 |
|
1030 if( inParam.AsDes().Length() ) |
|
1031 { |
|
1032 if ( inParam.AsDes().LocateF(':') == KErrNotFound ) |
|
1033 { |
|
1034 AppendErrorMessageL( aCmdName, KCalendarName, KInvalid ); |
|
1035 User::Leave(KErrArgument); |
|
1036 } |
|
1037 else |
|
1038 { |
|
1039 aCalendarName = inParam.AsDes().AllocL(); |
|
1040 aCalendarName->Des().Trim(); |
|
1041 } |
|
1042 } |
|
1043 } |
|
1044 CleanupStack::Pop( &inParam ); |
|
1045 inParam.Reset(); |
|
1046 } |
|
1047 else |
|
1048 { |
|
1049 AppendErrorMessageL( aCmdName, aField, KInvalid ); |
|
1050 User::Leave(KErrArgument); |
|
1051 } |
|
1052 } |
|
1053 } |
|
1054 |
|
1055 // --------------------------------------------------------------------------- |
|
1056 // Gets the Field from Map in input param list |
|
1057 // --------------------------------------------------------------------------- |
|
1058 // |
|
1059 void CCalendarInterface::GetDesCFieldFromMapL( const CLiwGenericParamList& aInParamList, |
|
1060 const TDesC8& aCmdName, |
|
1061 const TDesC8& aMapName, |
|
1062 const TDesC8& aFieldName, |
|
1063 TBool aPosBased, |
|
1064 HBufC*& aOutputField ) |
|
1065 { |
|
1066 const TLiwGenericParam* param = NULL; |
|
1067 |
|
1068 if ( aPosBased && aInParamList.Count() > 1) |
|
1069 { |
|
1070 param = &aInParamList[1]; |
|
1071 } |
|
1072 else |
|
1073 { |
|
1074 TInt pos = 0; |
|
1075 param = aInParamList.FindFirst( pos, aMapName ); |
|
1076 } |
|
1077 |
|
1078 if ( param ) |
|
1079 { |
|
1080 const CLiwMap* inMap = param->Value().AsMap(); |
|
1081 |
|
1082 if(inMap) |
|
1083 { |
|
1084 TLiwVariant inParam; |
|
1085 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &inParam)); |
|
1086 if ( inMap->FindL( aFieldName, inParam ) ) |
|
1087 { |
|
1088 ValidateParamTypeL( inParam, LIW::EVariantTypeDesC, |
|
1089 aCmdName, aFieldName, KInvalid ); |
|
1090 |
|
1091 if ( inParam.AsDes().Length() > KMaxFileNameLength ) |
|
1092 { |
|
1093 AppendErrorMessageL( aCmdName, aFieldName, KInvalid ); |
|
1094 User::Leave(KErrArgument); |
|
1095 } |
|
1096 |
|
1097 if( inParam.AsDes().Length() ) |
|
1098 { |
|
1099 aOutputField = HBufC::NewL(inParam.AsDes().Length()); |
|
1100 aOutputField->Des().Copy( inParam.AsDes() ); |
|
1101 } |
|
1102 } |
|
1103 CleanupStack::Pop( &inParam ); |
|
1104 inParam.Reset(); |
|
1105 } |
|
1106 else |
|
1107 { |
|
1108 AppendErrorMessageL( aCmdName, aMapName, KInvalid ); |
|
1109 User::Leave(KErrArgument); |
|
1110 } |
|
1111 } |
|
1112 } |
|
1113 |
|
1114 // --------------------------------------------------------------------------- |
|
1115 // Gets the Field from Map in input param list |
|
1116 // --------------------------------------------------------------------------- |
|
1117 // |
|
1118 void CCalendarInterface::GetDesC8FieldFromMapL( const CLiwGenericParamList& aInParamList, |
|
1119 const TDesC8& aCmdName, |
|
1120 const TDesC8& aMapName, |
|
1121 const TDesC8& aFieldName, |
|
1122 TBool aPosBased, |
|
1123 HBufC8*& aOutputField ) |
|
1124 { |
|
1125 const TLiwGenericParam* param = NULL; |
|
1126 |
|
1127 if ( aPosBased && aInParamList.Count() > 1) |
|
1128 { |
|
1129 param = &aInParamList[1]; |
|
1130 } |
|
1131 else |
|
1132 { |
|
1133 TInt pos = 0; |
|
1134 param = aInParamList.FindFirst( pos, aMapName ); |
|
1135 } |
|
1136 |
|
1137 if ( param ) |
|
1138 { |
|
1139 const CLiwMap* inMap = param->Value().AsMap(); |
|
1140 |
|
1141 if(inMap) |
|
1142 { |
|
1143 TLiwVariant inParam; |
|
1144 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &inParam)); |
|
1145 |
|
1146 if ( inMap->FindL( aFieldName, inParam ) ) |
|
1147 { |
|
1148 ValidateParamTypeL( inParam, LIW::EVariantTypeDesC8, |
|
1149 aCmdName, aFieldName, KInvalid ); |
|
1150 |
|
1151 if( inParam.AsData().Length() ) |
|
1152 { |
|
1153 aOutputField = inParam.AsData().AllocL(); |
|
1154 } |
|
1155 } |
|
1156 CleanupStack::Pop( &inParam ); |
|
1157 inParam.Reset(); |
|
1158 } |
|
1159 else |
|
1160 { |
|
1161 AppendErrorMessageL( aCmdName, aMapName, KInvalid ); |
|
1162 User::Leave(KErrArgument); |
|
1163 } |
|
1164 } |
|
1165 } |
|
1166 |
|
1167 // --------------------------------------------------------------------------- |
|
1168 // Extracts Entry attributes of a Calendar entry |
|
1169 // --------------------------------------------------------------------------- |
|
1170 // |
|
1171 CEntryAttributes* CCalendarInterface::GetAddParametersL( const CLiwGenericParamList& aInParamList, |
|
1172 const TDesC& aCalendarName, |
|
1173 TBool aPosBasedSearch ) |
|
1174 { |
|
1175 CEntryAttributes* entryAttributes = CEntryAttributes::NewL(); |
|
1176 |
|
1177 CleanupStack::PushL( entryAttributes ); |
|
1178 |
|
1179 const TLiwGenericParam* param = NULL; |
|
1180 |
|
1181 if ( aPosBasedSearch ) |
|
1182 { |
|
1183 if( aInParamList.Count() > 1 ) |
|
1184 param = &aInParamList[1]; |
|
1185 } |
|
1186 else |
|
1187 { |
|
1188 TInt pos = 0; |
|
1189 param = aInParamList.FindFirst( pos, KItem ); |
|
1190 } |
|
1191 |
|
1192 if ( param ) |
|
1193 { |
|
1194 const CLiwMap* inMap = param->Value().AsMap(); |
|
1195 if( inMap ) |
|
1196 { |
|
1197 TLiwVariant inParam; |
|
1198 TInt error = KErrNone; |
|
1199 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &inParam)); |
|
1200 |
|
1201 // Applicable only for Update request |
|
1202 TBool isUpdate = EFalse; |
|
1203 TInt entryType = -1; |
|
1204 if ( inMap->FindL( KLocalId, inParam ) ) |
|
1205 { |
|
1206 ValidateParamTypeL( inParam, LIW::EVariantTypeDesC, |
|
1207 KCmdAdd, KLocalId, KInvalid ); |
|
1208 |
|
1209 //entryAttributes->SetLocalUid( TCalLocalUid(inParam.AsTUint() )); |
|
1210 TCalLocalUid localUid; |
|
1211 GetLocalUid( inParam.AsDes(), localUid ); |
|
1212 entryAttributes->SetLocalUid( localUid ); |
|
1213 isUpdate = ETrue; |
|
1214 } |
|
1215 |
|
1216 if ( inMap->FindL( KType, inParam ) ) |
|
1217 { |
|
1218 ValidateParamTypeL( inParam, LIW::EVariantTypeDesC, |
|
1219 KCmdAdd, _L8("Entry Type"), KInvalid ); |
|
1220 |
|
1221 entryAttributes->SetTypeL( inParam.AsDes() ); |
|
1222 entryType = entryAttributes->EntryType(); |
|
1223 } |
|
1224 |
|
1225 //Adding New Entry |
|
1226 else if( !isUpdate ) |
|
1227 { |
|
1228 AppendErrorMessageL( KCmdAdd, KType, KMissing ); |
|
1229 User::Leave( KErrArgument ); |
|
1230 } |
|
1231 |
|
1232 //Updating Existing Entry |
|
1233 //Get the type of the original entry. User cannot change the type |
|
1234 if( isUpdate ) |
|
1235 { |
|
1236 entryType = GetEntryType( aCalendarName, entryAttributes->LocalUid() ); |
|
1237 if ( entryType == -1 ) |
|
1238 { |
|
1239 AppendErrorMessageL( KCmdAdd, KLocalId, KInvalid ); |
|
1240 User::Leave( KErrArgument ); |
|
1241 } |
|
1242 |
|
1243 // Leave if tring to set different entry type |
|
1244 if ( entryAttributes->ModifiedAttributes() & CEntryAttributes::EEntryType ) |
|
1245 { |
|
1246 TInt tmpType = entryAttributes->EntryType(); |
|
1247 if ( tmpType != entryType ) |
|
1248 { |
|
1249 AppendErrorMessageL( KCmdAdd, _L8("Entry Type "), KInvalid ); |
|
1250 User::Leave( KErrArgument ); |
|
1251 } |
|
1252 } |
|
1253 } |
|
1254 |
|
1255 //For Add |
|
1256 if ( inMap->FindL( KSummary, inParam ) ) |
|
1257 { |
|
1258 ValidateParamTypeL( inParam, LIW::EVariantTypeDesC, |
|
1259 KCmdAdd, KSummary, KInvalid ); |
|
1260 |
|
1261 entryAttributes->SetSummaryL( inParam.AsDes() ); |
|
1262 } |
|
1263 |
|
1264 if ( inMap->FindL( KDescription, inParam ) ) |
|
1265 { |
|
1266 ValidateParamTypeL( inParam, LIW::EVariantTypeDesC, |
|
1267 KCmdAdd, KDescription, KInvalid ); |
|
1268 |
|
1269 entryAttributes->SetDescriptionL( inParam.AsDes() ); |
|
1270 } |
|
1271 |
|
1272 if ( inMap->FindL( KReplication, inParam ) ) |
|
1273 { |
|
1274 ValidateParamTypeL( inParam, LIW::EVariantTypeDesC, |
|
1275 KCmdAdd, KReplication, KInvalid ); |
|
1276 |
|
1277 entryAttributes->SetReplicationL( inParam.AsDes() ); |
|
1278 } |
|
1279 |
|
1280 if ( inMap->FindL( KPriority, inParam ) ) |
|
1281 { |
|
1282 ValidateParamTypeL( inParam, LIW::EVariantTypeTInt32, |
|
1283 KCmdAdd, KPriority, KInvalid ); |
|
1284 |
|
1285 error = entryAttributes->SetPriority( inParam.AsTInt32() ); |
|
1286 User::LeaveIfError( error ); |
|
1287 } |
|
1288 |
|
1289 if ( ( entryType != CCalEntry::ETodo ) && |
|
1290 inMap->FindL( KStartTime, inParam ) ) |
|
1291 { |
|
1292 ValidateParamTypeL( inParam, LIW::EVariantTypeTTime, |
|
1293 KCmdAdd, KStartTime, KInvalid ); |
|
1294 |
|
1295 entryAttributes->SetStartTimeL( inParam.AsTTime() ); |
|
1296 } |
|
1297 |
|
1298 if ( ( ( entryType == CCalEntry::EAppt ) || |
|
1299 ( entryType == CCalEntry::ETodo ) || |
|
1300 ( entryType == CCalEntry::EEvent ) ) && |
|
1301 inMap->FindL( KEndTime, inParam ) ) |
|
1302 { |
|
1303 ValidateParamTypeL( inParam, LIW::EVariantTypeTTime, |
|
1304 KCmdAdd, KEndTime, KInvalid ); |
|
1305 |
|
1306 entryAttributes->SetEndTimeL( inParam.AsTTime() ); |
|
1307 } |
|
1308 |
|
1309 if ( inMap->FindL( KAlarmTime, inParam ) ) |
|
1310 { |
|
1311 ValidateParamTypeL( inParam, LIW::EVariantTypeTTime, |
|
1312 KCmdAdd, KAlarmTime, KInvalid ); |
|
1313 |
|
1314 entryAttributes->SetAlarm( inParam.AsTTime() ); |
|
1315 } |
|
1316 |
|
1317 if( ( entryType == CCalEntry::EAppt ) || |
|
1318 ( entryType == CCalEntry::ETodo ) ) |
|
1319 { |
|
1320 if ( inMap->FindL( KStatus, inParam ) ) |
|
1321 { |
|
1322 ValidateParamTypeL( inParam, LIW::EVariantTypeDesC, |
|
1323 KCmdAdd, KStatus, KInvalid ); |
|
1324 |
|
1325 entryAttributes->SetEntryStatusL( inParam.AsDes() ); |
|
1326 } |
|
1327 } |
|
1328 |
|
1329 if( entryType == CCalEntry::EAppt ) |
|
1330 { |
|
1331 // Applicable only for Update request |
|
1332 if ( isUpdate && inMap->FindL( KInstStartTime, inParam ) ) |
|
1333 { |
|
1334 ValidateParamTypeL( inParam, LIW::EVariantTypeTTime, |
|
1335 KCmdAdd, KInstStartTime, KInvalid ); |
|
1336 |
|
1337 entryAttributes->SetInstanceStartTimeL( inParam.AsTTime() ); |
|
1338 } |
|
1339 |
|
1340 if ( inMap->FindL( KLocation, inParam ) ) |
|
1341 { |
|
1342 ValidateParamTypeL( inParam, LIW::EVariantTypeDesC, |
|
1343 KCmdAdd, KLocation, KInvalid ); |
|
1344 |
|
1345 entryAttributes->SetLocationL( inParam.AsDes() ); |
|
1346 } |
|
1347 |
|
1348 if ( inMap->FindL( KMethod, inParam ) ) |
|
1349 { |
|
1350 ValidateParamTypeL( inParam, LIW::EVariantTypeDesC, |
|
1351 KCmdAdd, KMethod, KInvalid ); |
|
1352 |
|
1353 entryAttributes->SetMethodL( inParam.AsDes() ); |
|
1354 } |
|
1355 |
|
1356 if ( inMap->FindL( KSeqNum, inParam ) ) |
|
1357 { |
|
1358 ValidateParamTypeL( inParam, LIW::EVariantTypeTInt32, |
|
1359 KCmdAdd, KSeqNum, KInvalid ); |
|
1360 |
|
1361 entryAttributes->SetSequenceNumber( inParam.AsTInt32() ); |
|
1362 } |
|
1363 |
|
1364 if ( inMap->FindL( KPhoneOwner, inParam ) ) |
|
1365 { |
|
1366 ValidateParamTypeL( inParam, LIW::EVariantTypeDesC, |
|
1367 KCmdAdd, KPhoneOwner, KInvalid ); |
|
1368 |
|
1369 entryAttributes->SetPhoneOwnerDataL( inParam.AsDes() ); |
|
1370 } |
|
1371 |
|
1372 if ( inMap->FindL( KOrganizer, inParam ) ) |
|
1373 { |
|
1374 const CLiwMap* map = inParam.AsMap(); |
|
1375 if ( map ) |
|
1376 { |
|
1377 TLiwVariant orgParam; |
|
1378 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &orgParam)); |
|
1379 if ( map->FindL( KAddress, orgParam ) ) |
|
1380 { |
|
1381 CAttendeeInfo* organizer = CAttendeeInfo::NewL( orgParam.AsDes() ); |
|
1382 CleanupStack::PushL( organizer ); |
|
1383 if ( map->FindL( KCommonName, orgParam ) ) |
|
1384 { |
|
1385 ValidateParamTypeL( orgParam, LIW::EVariantTypeDesC, |
|
1386 KCmdAdd, KCommonName, KInvalid ); |
|
1387 |
|
1388 organizer->SetCommonNameL( orgParam.AsDes() ); |
|
1389 } |
|
1390 entryAttributes->SetOrganizerDataL( organizer ); |
|
1391 CleanupStack::PopAndDestroy( organizer ); |
|
1392 } |
|
1393 else |
|
1394 { |
|
1395 AppendErrorMessageL(KCmdAdd, KOrganizer, KInvalid ); |
|
1396 User::Leave( KErrArgument ); |
|
1397 } |
|
1398 CleanupStack::Pop( &orgParam ); |
|
1399 orgParam.Reset(); |
|
1400 } |
|
1401 else |
|
1402 { |
|
1403 AppendErrorMessageL(KCmdAdd, KOrganizer, KInvalid ); |
|
1404 User::Leave( KErrArgument ); |
|
1405 } |
|
1406 } |
|
1407 |
|
1408 if ( inMap->FindL( KAttendeeList, inParam ) ) |
|
1409 { |
|
1410 const CLiwList* obj = inParam.AsList(); |
|
1411 if ( obj ) |
|
1412 { |
|
1413 TInt count = obj->Count(); |
|
1414 for ( int index = 0; index < count; index++ ) |
|
1415 { |
|
1416 TLiwVariant element; |
|
1417 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &element)); |
|
1418 obj->AtL(index, element); |
|
1419 const CLiwMap* map = element.AsMap(); |
|
1420 TLiwVariant attParam; |
|
1421 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &attParam)); |
|
1422 if ( map && map->FindL(KAddress, attParam) ) |
|
1423 { |
|
1424 ValidateParamTypeL( attParam, LIW::EVariantTypeDesC, |
|
1425 KCmdAdd, KAddress, KInvalid ); |
|
1426 |
|
1427 CAttendeeInfo* attendee = CAttendeeInfo::NewL( attParam.AsDes() ); |
|
1428 CleanupStack::PushL( attendee ); |
|
1429 if ( map->FindL( KCommonName, attParam ) ) |
|
1430 { |
|
1431 ValidateParamTypeL( attParam, LIW::EVariantTypeDesC, |
|
1432 KCmdAdd, KCommonName, KInvalid ); |
|
1433 |
|
1434 attendee->SetCommonNameL( attParam.AsDes() ); |
|
1435 } |
|
1436 if ( map->FindL( KRole, attParam ) ) |
|
1437 { |
|
1438 ValidateParamTypeL( attParam, LIW::EVariantTypeDesC, |
|
1439 KCmdAdd, KRole, KInvalid ); |
|
1440 |
|
1441 attendee->SetRoleL( attParam.AsDes() ); |
|
1442 } |
|
1443 |
|
1444 if ( map->FindL( KStatus, attParam ) ) |
|
1445 { |
|
1446 ValidateParamTypeL( attParam, LIW::EVariantTypeDesC, |
|
1447 KCmdAdd, KStatus, KInvalid ); |
|
1448 |
|
1449 attendee->SetStatusL( attParam.AsDes() ); |
|
1450 } |
|
1451 |
|
1452 if ( map->FindL( KRsvp, attParam ) ) |
|
1453 { |
|
1454 ValidateParamTypeL( attParam, LIW::EVariantTypeTBool, |
|
1455 KCmdAdd, KRsvp, KInvalid ); |
|
1456 |
|
1457 attendee->SetRsvp( attParam.AsTBool() ); |
|
1458 } |
|
1459 entryAttributes->AddAttendeeL( attendee ); |
|
1460 CleanupStack::PopAndDestroy( attendee ); |
|
1461 } |
|
1462 else |
|
1463 { |
|
1464 AppendErrorMessageL(KCmdAdd, KAttendeeList, KInvalid); |
|
1465 User::Leave( KErrArgument ); |
|
1466 } |
|
1467 CleanupStack::Pop( &attParam ); |
|
1468 attParam.Reset(); |
|
1469 CleanupStack::Pop( &element ); |
|
1470 element.Reset(); |
|
1471 } |
|
1472 } |
|
1473 else |
|
1474 { |
|
1475 AppendErrorMessageL(KCmdAdd, KAttendeeList, KInvalid); |
|
1476 User::Leave( KErrArgument ); |
|
1477 } |
|
1478 } |
|
1479 |
|
1480 if( inMap->FindL( KRepeatDates, inParam ) ) |
|
1481 { |
|
1482 const CLiwList* obj = inParam.AsList(); |
|
1483 if ( obj ) |
|
1484 { |
|
1485 for ( int index = 0; index < obj->Count(); index++ ) |
|
1486 { |
|
1487 TLiwVariant element; |
|
1488 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &element)); |
|
1489 obj->AtL(index, element); |
|
1490 |
|
1491 ValidateParamTypeL( element, LIW::EVariantTypeTTime, |
|
1492 KCmdAdd, KRepeatDates, KInvalid); |
|
1493 |
|
1494 TTime reptDate = element.AsTTime(); |
|
1495 entryAttributes->AddRepeatDateL( reptDate ); |
|
1496 CleanupStack::Pop( &element ); |
|
1497 element.Reset(); |
|
1498 } |
|
1499 } |
|
1500 else |
|
1501 { |
|
1502 AppendErrorMessageL(KCmdAdd, KRepeatDates, KInvalid); |
|
1503 User::Leave( KErrArgument ); |
|
1504 } |
|
1505 } |
|
1506 |
|
1507 if( inMap->FindL( KExceptionDates, inParam ) ) |
|
1508 { |
|
1509 const CLiwList* obj = inParam.AsList(); |
|
1510 if ( obj ) |
|
1511 { |
|
1512 for ( int index = 0; index < obj->Count(); index++ ) |
|
1513 { |
|
1514 TLiwVariant element; |
|
1515 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &element)); |
|
1516 obj->AtL(index, element); |
|
1517 |
|
1518 ValidateParamTypeL( element, LIW::EVariantTypeTTime, |
|
1519 KCmdAdd, KExceptionDates, KInvalid ); |
|
1520 |
|
1521 TTime exDate = element.AsTTime(); |
|
1522 entryAttributes->AddExceptionDateL( exDate ); |
|
1523 CleanupStack::Pop( &element ); |
|
1524 element.Reset(); |
|
1525 } |
|
1526 } |
|
1527 else |
|
1528 { |
|
1529 inParam.Reset(); |
|
1530 AppendErrorMessageL( KCmdAdd, KExceptionDates, KInvalid ); |
|
1531 User::Leave( KErrArgument ); |
|
1532 } |
|
1533 } |
|
1534 |
|
1535 if ( inMap->FindL( KRepeatRule, inParam ) ) |
|
1536 { |
|
1537 const CLiwMap* map = inParam.AsMap(); |
|
1538 if ( map ) |
|
1539 { |
|
1540 CRepeatInfo* rrule = NULL; |
|
1541 TLiwVariant rptParam; |
|
1542 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &rptParam)); |
|
1543 if ( map->FindL( KRepeatType, rptParam ) ) |
|
1544 { |
|
1545 ValidateParamTypeL( rptParam, LIW::EVariantTypeTInt32, |
|
1546 KCmdAdd, KRepeatType, KInvalid ); |
|
1547 |
|
1548 rrule = CRepeatInfo::NewL( rptParam.AsTInt32() ); |
|
1549 CleanupStack::PushL( rrule ); |
|
1550 } |
|
1551 else |
|
1552 { |
|
1553 AppendErrorMessageL( KCmdAdd, KRepeatType, KMissing ); |
|
1554 User::Leave( KErrArgument ); |
|
1555 } |
|
1556 |
|
1557 if ( map->FindL( KDaysInWeek, rptParam ) ) |
|
1558 { |
|
1559 const CLiwList* obj = rptParam.AsList(); |
|
1560 if ( obj ) |
|
1561 { |
|
1562 RArray < TDay > days; |
|
1563 for ( int index = 0; index < obj->Count(); index++ ) |
|
1564 { |
|
1565 TLiwVariant element; |
|
1566 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &element)); |
|
1567 obj->AtL(index, element); |
|
1568 |
|
1569 ValidateParamTypeL( element, LIW::EVariantTypeTInt32, |
|
1570 KCmdAdd, KDaysInWeek, KInvalid ); |
|
1571 |
|
1572 days.Append( TDay( element.AsTInt32() ) ); |
|
1573 if( element.AsTInt32() < 0 || element.AsTInt32() > 6 ) |
|
1574 { |
|
1575 days.Close(); |
|
1576 AppendErrorMessageL( KCmdAdd, KDaysInWeek, KInvalid ); |
|
1577 User::Leave( KErrArgument ); |
|
1578 } |
|
1579 CleanupStack::Pop( &element ); |
|
1580 element.Reset(); |
|
1581 } |
|
1582 rrule->SetDaysInWeek(days); |
|
1583 days.Close(); |
|
1584 } |
|
1585 else |
|
1586 { |
|
1587 AppendErrorMessageL( KCmdAdd, KDaysInWeek, KInvalid ); |
|
1588 User::Leave( KErrArgument ); |
|
1589 } |
|
1590 } |
|
1591 |
|
1592 if ( map->FindL( KUntilDate, rptParam ) ) |
|
1593 { |
|
1594 ValidateParamTypeL( rptParam, LIW::EVariantTypeTTime, |
|
1595 KCmdAdd, KUntilDate, KInvalid ); |
|
1596 |
|
1597 rrule->SetUntilTimeL( rptParam.AsTTime() ); |
|
1598 } |
|
1599 |
|
1600 if ( map->FindL( KRStartDate, rptParam ) ) |
|
1601 { |
|
1602 ValidateParamTypeL( rptParam, LIW::EVariantTypeTTime, |
|
1603 KCmdAdd, _L8("RepeatRule:StartDate"), KInvalid ); |
|
1604 |
|
1605 rrule->SetStartTimeL( rptParam.AsTTime() ); |
|
1606 } |
|
1607 if ( map->FindL( KInterval, rptParam ) ) |
|
1608 { |
|
1609 ValidateParamTypeL( rptParam, LIW::EVariantTypeTInt32, |
|
1610 KCmdAdd, KInterval, KInvalid ); |
|
1611 |
|
1612 rrule->SetInterval( rptParam.AsTInt32() ); |
|
1613 } |
|
1614 |
|
1615 if ( map->FindL( KMonthDays, rptParam ) ) |
|
1616 { |
|
1617 const CLiwList* obj = rptParam.AsList(); |
|
1618 if ( obj ) |
|
1619 { |
|
1620 RArray < TInt > days; |
|
1621 for ( int index = 0; index < obj->Count(); index++ ) |
|
1622 { |
|
1623 TLiwVariant element; |
|
1624 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &element)); |
|
1625 |
|
1626 obj->AtL(index, element); |
|
1627 |
|
1628 ValidateParamTypeL( element, LIW::EVariantTypeTInt32, |
|
1629 KCmdAdd, KMonthDays, KInvalid ); |
|
1630 |
|
1631 TInt mthdays = element.AsTInt32(); |
|
1632 if( mthdays < 0 || mthdays > 30 ) |
|
1633 { |
|
1634 days.Close(); |
|
1635 AppendErrorMessageL( KCmdAdd, KMonthDays, KInvalid ); |
|
1636 User::Leave( KErrArgument ); |
|
1637 } |
|
1638 days.Append( TDay( mthdays ) ); |
|
1639 CleanupStack::Pop( &element ); |
|
1640 element.Reset(); |
|
1641 } |
|
1642 rrule->SetMonthDates(days); |
|
1643 days.Close(); |
|
1644 } |
|
1645 else |
|
1646 { |
|
1647 AppendErrorMessageL( KCmdAdd, KMonthDays, KInvalid ); |
|
1648 User::Leave( KErrArgument ); |
|
1649 } |
|
1650 } |
|
1651 |
|
1652 if ( map->FindL( KDaysOfMonth, rptParam ) ) |
|
1653 { |
|
1654 const CLiwList* obj = rptParam.AsList(); |
|
1655 if ( obj ) |
|
1656 { |
|
1657 RArray <TCalRRule::TDayOfMonth> monthdays; |
|
1658 TInt count = obj->Count(); |
|
1659 for ( int index = 0; index < count ; index++ ) |
|
1660 { |
|
1661 TLiwVariant element; |
|
1662 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &element)); |
|
1663 obj->AtL(index, element); |
|
1664 const CLiwMap* map = element.AsMap(); |
|
1665 if( map ) |
|
1666 { |
|
1667 TLiwVariant dayno; |
|
1668 TLiwVariant week; |
|
1669 |
|
1670 if ( map->FindL( KDay, dayno ) && map->FindL( KWeekNum, week ) ) |
|
1671 { |
|
1672 ValidateParamTypeL( dayno, LIW::EVariantTypeTInt32, |
|
1673 KCmdAdd, _L8("RepeatRule:DaysOfMonth:Day"), KInvalid ); |
|
1674 |
|
1675 ValidateParamTypeL( week, LIW::EVariantTypeTInt32, |
|
1676 KCmdAdd, KRepeatWeekNum, KInvalid ); |
|
1677 |
|
1678 TInt weekno = week.AsTInt32(); |
|
1679 TInt daynum = dayno.AsTInt32(); |
|
1680 |
|
1681 if ( ( ( weekno == -1 ) || ( weekno >=1 && weekno <=4 ) ) && |
|
1682 ( daynum >=0 && daynum <=6 )) |
|
1683 { |
|
1684 monthdays.Append(TCalRRule::TDayOfMonth( TDay( daynum ), weekno ) ); |
|
1685 } |
|
1686 else |
|
1687 { |
|
1688 AppendErrorMessageL(KCmdAdd, KRepeatWeekNum, KInvalid); |
|
1689 User::Leave( KErrArgument ); |
|
1690 } |
|
1691 } |
|
1692 dayno.Reset(); |
|
1693 week.Reset(); |
|
1694 CleanupStack::Pop( &element ); |
|
1695 element.Reset(); |
|
1696 } |
|
1697 else |
|
1698 { |
|
1699 AppendErrorMessageL(KCmdAdd, KDaysOfMonth, KInvalid); |
|
1700 User::Leave( KErrArgument ); |
|
1701 } |
|
1702 } |
|
1703 rrule->SetMonthDays( monthdays ); |
|
1704 monthdays.Close(); |
|
1705 } |
|
1706 else |
|
1707 { |
|
1708 AppendErrorMessageL(KCmdAdd, KDaysOfMonth, KInvalid); |
|
1709 User::Leave( KErrArgument ); |
|
1710 } |
|
1711 } |
|
1712 |
|
1713 if ( map->FindL( KMonth, rptParam ) ) |
|
1714 { |
|
1715 ValidateParamTypeL( rptParam, LIW::EVariantTypeTInt32, |
|
1716 KCmdAdd, KMonth, KInvalid ); |
|
1717 |
|
1718 TInt rptmonth = rptParam.AsTInt32(); |
|
1719 if( rptmonth <0 || rptmonth > 11 ) |
|
1720 { |
|
1721 AppendErrorMessageL( KCmdAdd, KMonth, KInvalid ); |
|
1722 User::Leave( KErrArgument ); |
|
1723 } |
|
1724 rrule->SetMonth( rptmonth ); |
|
1725 } |
|
1726 entryAttributes->SetRepeatRule( rrule ); |
|
1727 CleanupStack::PopAndDestroy( rrule ); |
|
1728 CleanupStack::Pop( &rptParam ); |
|
1729 rptParam.Reset(); |
|
1730 } |
|
1731 else |
|
1732 { |
|
1733 AppendErrorMessageL( KCmdAdd, KRepeatRule, KInvalid ); |
|
1734 User::Leave( KErrArgument ); |
|
1735 } |
|
1736 |
|
1737 } |
|
1738 } |
|
1739 |
|
1740 |
|
1741 CleanupStack::Pop( &inParam ); |
|
1742 inParam.Reset(); |
|
1743 } |
|
1744 else |
|
1745 { |
|
1746 AppendErrorMessageL( KCmdAdd, KItem, KInvalid ); |
|
1747 User::Leave( KErrArgument ); |
|
1748 } |
|
1749 |
|
1750 } |
|
1751 else |
|
1752 { |
|
1753 AppendErrorMessageL( KCmdAdd, KItem, KMissing ); |
|
1754 User::Leave( KErrArgument ); |
|
1755 } |
|
1756 CleanupStack::Pop( entryAttributes ); |
|
1757 return entryAttributes; |
|
1758 } |
|
1759 |
|
1760 // --------------------------------------------------------------------------- |
|
1761 // Extracts Delete Filter from input param list |
|
1762 // --------------------------------------------------------------------------- |
|
1763 // |
|
1764 void CCalendarInterface::GetDeleteEntryFilterL(const CLiwGenericParamList& aInParamList, |
|
1765 CCalendarFilter& aFilter, |
|
1766 const TBool aPosBased ) |
|
1767 { |
|
1768 const TLiwGenericParam* filter = NULL; |
|
1769 |
|
1770 if ( aPosBased ) |
|
1771 { |
|
1772 if ( aInParamList.Count() > 1 ) |
|
1773 filter = &aInParamList[1]; |
|
1774 } |
|
1775 else |
|
1776 { |
|
1777 TInt pos = 0 ; |
|
1778 filter = aInParamList.FindFirst( pos, KData ); |
|
1779 } |
|
1780 |
|
1781 if ( filter ) |
|
1782 { |
|
1783 const CLiwMap* filterMap = filter->Value().AsMap(); |
|
1784 if ( filterMap ) |
|
1785 { |
|
1786 TLiwVariant param; |
|
1787 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , ¶m)); |
|
1788 if( filterMap->FindL( KStartRange, param )) |
|
1789 { |
|
1790 ValidateParamTypeL( param, LIW::EVariantTypeTTime, |
|
1791 KCmdDelete, KStartRange, KInvalid ); |
|
1792 |
|
1793 aFilter.SetStartTimeL(param.AsTTime()); |
|
1794 } |
|
1795 |
|
1796 if( filterMap->FindL( KEndRange, param )) |
|
1797 { |
|
1798 ValidateParamTypeL( param, LIW::EVariantTypeTTime, |
|
1799 KCmdDelete, KEndRange, KInvalid ); |
|
1800 |
|
1801 aFilter.SetEndTimeL(param.AsTTime()); |
|
1802 } |
|
1803 |
|
1804 if( filterMap->FindL( KDeleteAll, param )) |
|
1805 { |
|
1806 ValidateParamTypeL( param, LIW::EVariantTypeTBool, |
|
1807 KCmdDelete, KDeleteAll, KInvalid ); |
|
1808 |
|
1809 aFilter.SetDeleteAll( param.AsTBool() ); |
|
1810 } |
|
1811 |
|
1812 if( filterMap->FindL( KIdList, param )) |
|
1813 { |
|
1814 const CLiwList* guidList = param.AsList(); |
|
1815 if ( guidList ) |
|
1816 { |
|
1817 TLiwVariant listElement; |
|
1818 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &listElement)); |
|
1819 TInt count = guidList->Count(); |
|
1820 for(TInt index = 0; index < count; index++) |
|
1821 { |
|
1822 if ( guidList->AtL(index, listElement) ) |
|
1823 { |
|
1824 //aFilter.AddGuidL( listElement.AsData() ); |
|
1825 ValidateParamTypeL( listElement, LIW::EVariantTypeDesC, |
|
1826 KCmdDelete, KIdList, KInvalid ); |
|
1827 |
|
1828 HBufC8* globalUid = HBufC8::NewL(listElement.AsDes().Length()); |
|
1829 CleanupStack::PushL( globalUid ); |
|
1830 GetGlobalUid(listElement.AsDes(), globalUid->Des()); |
|
1831 aFilter.AddGuidL( globalUid->Des() ); |
|
1832 CleanupStack::PopAndDestroy( globalUid ); |
|
1833 } |
|
1834 } |
|
1835 CleanupStack::Pop( &listElement ); |
|
1836 listElement.Reset(); |
|
1837 } |
|
1838 else |
|
1839 { |
|
1840 AppendErrorMessageL( KCmdDelete, KIdList, KInvalid ); |
|
1841 User::Leave(KErrArgument); |
|
1842 } |
|
1843 } |
|
1844 |
|
1845 if( filterMap->FindL( KLocalIdList, param )) |
|
1846 { |
|
1847 const CLiwList* luidList = param.AsList(); |
|
1848 if ( luidList ) |
|
1849 { |
|
1850 TLiwVariant listElement; |
|
1851 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &listElement)); |
|
1852 TInt count = luidList->Count(); |
|
1853 for(TInt index = 0; index < count; index++) |
|
1854 { |
|
1855 if ( luidList->AtL(index, listElement) ) |
|
1856 { |
|
1857 //aFilter.AddLocalUid( TCalLocalUid( listElement.AsTUint() )); |
|
1858 ValidateParamTypeL( listElement, LIW::EVariantTypeDesC, |
|
1859 KCmdDelete, KLocalIdList, KInvalid ); |
|
1860 |
|
1861 |
|
1862 TCalLocalUid localUid; |
|
1863 GetLocalUid( listElement.AsDes(), localUid ); |
|
1864 aFilter.AddLocalUid( localUid ); |
|
1865 } |
|
1866 } |
|
1867 CleanupStack::Pop( &listElement ); |
|
1868 listElement.Reset(); |
|
1869 } |
|
1870 else |
|
1871 { |
|
1872 AppendErrorMessageL( KCmdDelete, KLocalIdList, KInvalid ); |
|
1873 User::Leave(KErrArgument); |
|
1874 } |
|
1875 } |
|
1876 CleanupStack::Pop( ¶m ); |
|
1877 param.Reset(); |
|
1878 } |
|
1879 else |
|
1880 { |
|
1881 AppendErrorMessageL( KCmdDelete, KData, KInvalid ); |
|
1882 User::Leave(KErrArgument); |
|
1883 } |
|
1884 } |
|
1885 else |
|
1886 { |
|
1887 AppendErrorMessageL( KCmdDelete, KData, KMissing ); |
|
1888 User::Leave(KErrArgument); |
|
1889 } |
|
1890 } |
|
1891 |
|
1892 // --------------------------------------------------------------------------- |
|
1893 // Extracts Import input from input param list |
|
1894 // --------------------------------------------------------------------------- |
|
1895 // |
|
1896 void CCalendarInterface::GetImportInputL( const CLiwGenericParamList& aInParamList, |
|
1897 TBool aPosBased, |
|
1898 HBufC8*& aInputBuffer, |
|
1899 TDes& importFile, |
|
1900 TDes8& aCalendarFormat, |
|
1901 TDes& aCalendarName ) |
|
1902 { |
|
1903 |
|
1904 //get the Input Filter Map |
|
1905 const TLiwGenericParam* inMap = NULL; |
|
1906 |
|
1907 if( aPosBased ) |
|
1908 { |
|
1909 if( aInParamList.Count() > 1 ) |
|
1910 inMap = &(aInParamList[1]);//start searching from pos and reset the pos to found at index |
|
1911 } |
|
1912 else |
|
1913 { |
|
1914 TInt pos = 0; |
|
1915 inMap = aInParamList.FindFirst( pos, KData ); |
|
1916 } |
|
1917 |
|
1918 if ( inMap ) |
|
1919 { |
|
1920 const CLiwMap * filterMap = inMap->Value().AsMap(); |
|
1921 |
|
1922 if ( filterMap ) |
|
1923 { |
|
1924 TLiwVariant value; |
|
1925 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &value)); |
|
1926 |
|
1927 if ( filterMap->FindL( KCalendarName, value )) |
|
1928 { |
|
1929 ValidateParamTypeL( value, LIW::EVariantTypeDesC, |
|
1930 KCmdImport, KCalendarName, KInvalid ); |
|
1931 |
|
1932 aCalendarName.Copy( value.AsDes() ); |
|
1933 } |
|
1934 |
|
1935 if ( filterMap->FindL( KCalendarFormat, value )) |
|
1936 { |
|
1937 ValidateParamTypeL( value, LIW::EVariantTypeDesC, |
|
1938 KCmdImport, KCalendarFormat, KInvalid ); |
|
1939 |
|
1940 aCalendarFormat.Copy( value.AsDes() ); |
|
1941 } |
|
1942 else |
|
1943 { |
|
1944 AppendErrorMessageL( KCmdImport, KCalendarFormat, KMissing ); |
|
1945 User::Leave( KErrArgument ); |
|
1946 } |
|
1947 |
|
1948 if ( filterMap->FindL( KInputBuffer, value )) |
|
1949 { |
|
1950 ValidateParamTypeL( value, LIW::EVariantTypeDesC8, |
|
1951 KCmdImport, KInputBuffer, KInvalid ); |
|
1952 |
|
1953 aInputBuffer = value.AsData().AllocL(); |
|
1954 } |
|
1955 else if ( filterMap->FindL( KImExFileName, value )) |
|
1956 { |
|
1957 ValidateParamTypeL( value, LIW::EVariantTypeDesC, |
|
1958 KCmdImport, KImExFileName, KInvalid ); |
|
1959 |
|
1960 importFile.Copy( value.AsDes() ); |
|
1961 } |
|
1962 else |
|
1963 { |
|
1964 AppendErrorMessageL( KCmdImport, KImExFileName, KMissing ); |
|
1965 User::Leave( KErrArgument ); |
|
1966 } |
|
1967 CleanupStack::Pop( &value ); |
|
1968 value.Reset(); |
|
1969 |
|
1970 } |
|
1971 else |
|
1972 { |
|
1973 AppendErrorMessageL( KCmdImport, KData, KInvalid ); |
|
1974 User::Leave( KErrArgument ); |
|
1975 } |
|
1976 } |
|
1977 else |
|
1978 { |
|
1979 AppendErrorMessageL( KCmdImport, KData, KMissing ); |
|
1980 User::Leave( KErrArgument ); |
|
1981 } |
|
1982 } |
|
1983 |
|
1984 // --------------------------------------------------------------------------- |
|
1985 // Extracts Export input from input param list |
|
1986 // --------------------------------------------------------------------------- |
|
1987 // |
|
1988 void CCalendarInterface::GetExportInputL( const CLiwGenericParamList& aInParamList, |
|
1989 TBool aPosBased, |
|
1990 CCalendarExportParams& aCalExportParams ) |
|
1991 { |
|
1992 const TLiwGenericParam* inMap = NULL; //get the Input Filter Map |
|
1993 |
|
1994 TInt pos = 0; |
|
1995 |
|
1996 if( aPosBased ) |
|
1997 { |
|
1998 if( aInParamList.Count() > 1 ) |
|
1999 inMap = &(aInParamList[1]); |
|
2000 } |
|
2001 else |
|
2002 inMap = aInParamList.FindFirst( pos, KData ); |
|
2003 |
|
2004 if( inMap ) |
|
2005 { |
|
2006 const CLiwMap *filterMap = inMap->Value().AsMap(); |
|
2007 |
|
2008 if( filterMap ) |
|
2009 { |
|
2010 TLiwVariant tLiwVariantValue; |
|
2011 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &tLiwVariantValue)); |
|
2012 |
|
2013 if ( filterMap->FindL( KImExFileName, tLiwVariantValue )) |
|
2014 { |
|
2015 ValidateParamTypeL( tLiwVariantValue, LIW::EVariantTypeDesC, |
|
2016 KCmdExport, KImExFileName, KInvalid ); |
|
2017 |
|
2018 aCalExportParams.SetExportFileNameL( tLiwVariantValue.AsDes() ); |
|
2019 } |
|
2020 |
|
2021 |
|
2022 TLiwVariant tLiwVariantValueTemp; |
|
2023 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &tLiwVariantValueTemp)); |
|
2024 if( filterMap->FindL( KCalendarGuidList, tLiwVariantValue ) ) |
|
2025 { |
|
2026 const CLiwList *cLiwList = tLiwVariantValue.AsList(); |
|
2027 |
|
2028 if ( cLiwList ) |
|
2029 { |
|
2030 for( TInt x = 0; x < cLiwList->Count(); ++x ) |
|
2031 { |
|
2032 cLiwList->AtL( x , tLiwVariantValueTemp ); |
|
2033 |
|
2034 ValidateParamTypeL( tLiwVariantValueTemp, LIW::EVariantTypeDesC, |
|
2035 KCmdExport, KCalendarGuidList, KInvalid ); |
|
2036 |
|
2037 HBufC8* globalUid = HBufC8::NewL(tLiwVariantValueTemp.AsDes().Length()); |
|
2038 CleanupStack::PushL( globalUid ); |
|
2039 GetGlobalUid(tLiwVariantValueTemp.AsDes(), globalUid->Des()); |
|
2040 aCalExportParams.AddGuidL( globalUid->Des() ); |
|
2041 CleanupStack::PopAndDestroy( globalUid ); |
|
2042 } |
|
2043 } |
|
2044 else |
|
2045 { |
|
2046 AppendErrorMessageL( KCmdExport, KCalendarGuidList, KInvalid ); |
|
2047 User::Leave( KErrArgument ); |
|
2048 } |
|
2049 |
|
2050 } |
|
2051 |
|
2052 if( filterMap->FindL( KCalendarLuidList, tLiwVariantValue ) ) |
|
2053 { |
|
2054 const CLiwList *cLiwListTemp = tLiwVariantValue.AsList(); |
|
2055 |
|
2056 if ( cLiwListTemp ) |
|
2057 { |
|
2058 if( cLiwListTemp->Count() && ( aCalExportParams.Params() & CCalendarExportParams::EParamsGUid ) ) |
|
2059 {//means the GUIDS are set so break, as both GUIDS and LUids cant be set |
|
2060 AppendErrorMessageL(KCmdExport, KNullDesC8,_L("Only one of IdList and LocalIdList can be given")); |
|
2061 User::Leave( KErrArgument ); |
|
2062 } |
|
2063 |
|
2064 for( TInt x = 0; x < cLiwListTemp->Count(); ++x ) |
|
2065 { |
|
2066 cLiwListTemp->AtL( x , tLiwVariantValueTemp ); |
|
2067 |
|
2068 ValidateParamTypeL( tLiwVariantValueTemp, LIW::EVariantTypeDesC, |
|
2069 KCmdExport, KCalendarLuidList, KInvalid ); |
|
2070 |
|
2071 TCalLocalUid localUid; |
|
2072 GetLocalUid( tLiwVariantValueTemp.AsDes(), localUid ); |
|
2073 aCalExportParams.AddLocalUid( localUid ); |
|
2074 } |
|
2075 } |
|
2076 else |
|
2077 { |
|
2078 AppendErrorMessageL( KCmdExport, KCalendarLuidList, KInvalid ); |
|
2079 User::Leave( KErrArgument ); |
|
2080 } |
|
2081 } |
|
2082 |
|
2083 CleanupStack::Pop( &tLiwVariantValueTemp ); |
|
2084 tLiwVariantValueTemp.Reset(); |
|
2085 CleanupStack::Pop( &tLiwVariantValue ); |
|
2086 tLiwVariantValue.Reset(); |
|
2087 } |
|
2088 else |
|
2089 { |
|
2090 AppendErrorMessageL( KCmdExport, KData, KInvalid ); |
|
2091 User::Leave( KErrArgument ); |
|
2092 } |
|
2093 } |
|
2094 else |
|
2095 { |
|
2096 AppendErrorMessageL( KCmdExport, KData, KMissing ); |
|
2097 User::Leave( KErrArgument ); |
|
2098 } |
|
2099 } |
|
2100 |
|
2101 // --------------------------------------------------------------------------- |
|
2102 // Extracts Change Notification filter from input param list |
|
2103 // --------------------------------------------------------------------------- |
|
2104 // |
|
2105 void CCalendarInterface::GetNotificationFilterL(const CLiwGenericParamList& aInParamList, |
|
2106 CCalendarFilter& aFilter, |
|
2107 const TBool aPosBased ) |
|
2108 { |
|
2109 const TLiwGenericParam* filter = NULL; |
|
2110 |
|
2111 if ( aPosBased ) |
|
2112 { |
|
2113 if ( aInParamList.Count() > 1 ) |
|
2114 filter = &aInParamList[1]; |
|
2115 } |
|
2116 else |
|
2117 { |
|
2118 TInt pos = 0 ; |
|
2119 filter = aInParamList.FindFirst( pos, KFilter ); |
|
2120 } |
|
2121 |
|
2122 if ( filter ) |
|
2123 { |
|
2124 const CLiwMap* filterMap = filter->Value().AsMap(); |
|
2125 if ( filterMap ) |
|
2126 { |
|
2127 TLiwVariant param; |
|
2128 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , ¶m)); |
|
2129 if( filterMap->FindL( KStartRange, param )) |
|
2130 { |
|
2131 ValidateParamTypeL( param, LIW::EVariantTypeTTime, |
|
2132 KCmdReqNot, KStartRange, KInvalid ); |
|
2133 |
|
2134 aFilter.SetStartTimeL(param.AsTTime()); |
|
2135 } |
|
2136 |
|
2137 if( filterMap->FindL( KEndRange, param )) |
|
2138 { |
|
2139 ValidateParamTypeL( param, LIW::EVariantTypeTTime, |
|
2140 KCmdReqNot, KEndRange, KInvalid ); |
|
2141 |
|
2142 aFilter.SetEndTimeL(param.AsTTime()); |
|
2143 } |
|
2144 |
|
2145 if( filterMap->FindL( KIncludeUndatedTodos, param )) |
|
2146 { |
|
2147 ValidateParamTypeL( param, LIW::EVariantTypeTBool, |
|
2148 KCmdReqNot, KIncludeUndatedTodos, KInvalid ); |
|
2149 |
|
2150 aFilter.SetIncludeUnDateToDo( param.AsTBool() ); |
|
2151 } |
|
2152 |
|
2153 if( filterMap->FindL( KLocalIdList, param )) |
|
2154 { |
|
2155 const CLiwList* luidList = param.AsList(); |
|
2156 if ( luidList ) |
|
2157 { |
|
2158 TLiwVariant listElement; |
|
2159 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &listElement)); |
|
2160 TInt count = luidList->Count(); |
|
2161 for(TInt index = 0; index < count; index++) |
|
2162 { |
|
2163 if ( luidList->AtL(index, listElement) ) |
|
2164 { |
|
2165 TCalLocalUid localUid; |
|
2166 |
|
2167 ValidateParamTypeL( listElement, LIW::EVariantTypeDesC, |
|
2168 KCmdReqNot, KLocalIdList, KInvalid ); |
|
2169 |
|
2170 GetLocalUid( listElement.AsDes(), localUid ); |
|
2171 aFilter.AddLocalUid( localUid ); |
|
2172 } |
|
2173 } |
|
2174 CleanupStack::Pop( &listElement ); |
|
2175 listElement.Reset(); |
|
2176 } |
|
2177 else |
|
2178 { |
|
2179 AppendErrorMessageL( KCmdReqNot, KLocalIdList, KInvalid ); |
|
2180 User::Leave(KErrArgument); |
|
2181 } |
|
2182 } |
|
2183 CleanupStack::Pop( ¶m ); |
|
2184 param.Reset(); |
|
2185 } |
|
2186 else |
|
2187 { |
|
2188 AppendErrorMessageL( KCmdReqNot, KFilter, KInvalid ); |
|
2189 User::Leave(KErrArgument); |
|
2190 } |
|
2191 } |
|
2192 } |
|
2193 |
|
2194 |
|
2195 // --------------------------------------------------------------------------- |
|
2196 // Extracts LocalUid as TCalLocalUid from input Uid String |
|
2197 // --------------------------------------------------------------------------- |
|
2198 // |
|
2199 void CCalendarInterface::GetLocalUid( const TDesC& aLocalUid, TCalLocalUid& aOutLocalUid ) |
|
2200 { |
|
2201 aOutLocalUid = 0; |
|
2202 /*if( aLocalUid.Length() ) |
|
2203 { |
|
2204 TInt sepPos = aLocalUid.Locate( KUidSeparator ); |
|
2205 TPtrC temp; |
|
2206 if( sepPos == KErrNotFound ) |
|
2207 { |
|
2208 temp.Set(aLocalUid.Mid(0)); |
|
2209 } |
|
2210 else |
|
2211 { |
|
2212 temp.Set(aLocalUid.Mid(0, sepPos)); |
|
2213 } |
|
2214 }*/ |
|
2215 TLex lex(aLocalUid); |
|
2216 TInt32 num; |
|
2217 |
|
2218 if(lex.Val(num) == KErrNone) |
|
2219 aOutLocalUid = TCalLocalUid(num); |
|
2220 |
|
2221 } |
|
2222 |
|
2223 // --------------------------------------------------------------------------- |
|
2224 // Extracts GlobalUid as 8-bit string from input Uid String |
|
2225 // --------------------------------------------------------------------------- |
|
2226 // |
|
2227 void CCalendarInterface::GetGlobalUid( const TDesC& aGlobalUid, TPtr8 aOutGlobalUid ) |
|
2228 { |
|
2229 if( aGlobalUid.Length() ) |
|
2230 { |
|
2231 /*TInt sepPos = aGlobalUid.Locate( KUidSeparator ); |
|
2232 |
|
2233 if( sepPos == KErrNotFound ) |
|
2234 { |
|
2235 aOutGlobalUid.Copy( aGlobalUid.Mid(0) ); |
|
2236 } |
|
2237 else |
|
2238 { |
|
2239 aOutGlobalUid.Copy( aGlobalUid.Mid( sepPos + 1 ) ); |
|
2240 }*/ |
|
2241 aOutGlobalUid.Copy( aGlobalUid ); |
|
2242 } |
|
2243 |
|
2244 } |
|
2245 |
|
2246 // --------------------------------------------------------------------------- |
|
2247 // ErrCode Conversion |
|
2248 // --------------------------------------------------------------------------- |
|
2249 // |
|
2250 TInt32 CCalendarInterface::ErrCodeConversion(TInt code) |
|
2251 { |
|
2252 TInt32 err; |
|
2253 switch (code) |
|
2254 { |
|
2255 case KErrCancel: |
|
2256 // Returning KErrNone incase of KErrCancel |
|
2257 case KErrNone: |
|
2258 err= SErrNone; |
|
2259 break; |
|
2260 |
|
2261 case KErrNotFound: |
|
2262 err= SErrNotFound; |
|
2263 break; |
|
2264 |
|
2265 case KErrNoMemory: |
|
2266 err = SErrNoMemory; |
|
2267 break; |
|
2268 |
|
2269 case KErrInUse: |
|
2270 err = SErrServiceInUse; |
|
2271 break; |
|
2272 |
|
2273 case KErrNotSupported: |
|
2274 err = SErrServiceNotSupported; |
|
2275 break; |
|
2276 |
|
2277 case KErrBadName: |
|
2278 err = SErrBadArgumentType; |
|
2279 break; |
|
2280 |
|
2281 case KErrArgument: |
|
2282 err = SErrInvalidServiceArgument; |
|
2283 break; |
|
2284 |
|
2285 case KErrAccessDenied: |
|
2286 err = SErrAccessDenied; |
|
2287 break; |
|
2288 |
|
2289 case KErrPathNotFound: |
|
2290 err = SErrPathNotFound; |
|
2291 break; |
|
2292 |
|
2293 case KErrAlreadyExists: |
|
2294 err = SErrEntryExists; |
|
2295 break; |
|
2296 |
|
2297 default : |
|
2298 err = SErrGeneralError; |
|
2299 break; |
|
2300 } |
|
2301 |
|
2302 return err; |
|
2303 |
|
2304 } |
|
2305 |
|
2306 // --------------------------------------------------------------------------- |
|
2307 // Validate the type of the input param with the expected type |
|
2308 // --------------------------------------------------------------------------- |
|
2309 // |
|
2310 void CCalendarInterface::ValidateParamTypeL( TLiwVariant& aParam, |
|
2311 LIW::TVariantTypeId aExpectedtype, |
|
2312 const TDesC8& aCmdName, |
|
2313 const TDesC8& aParameter, |
|
2314 const TDesC& aMessage ) |
|
2315 { |
|
2316 if( aParam.TypeId() != aExpectedtype ) |
|
2317 { |
|
2318 AppendErrorMessageL(aCmdName, aParameter, aMessage); |
|
2319 aParam.Reset(); |
|
2320 User::Leave(KErrArgument); |
|
2321 } |
|
2322 } |
|
2323 |
|
2324 // --------------------------------------------------------------------------- |
|
2325 // Append Error Message |
|
2326 // --------------------------------------------------------------------------- |
|
2327 // |
|
2328 void CCalendarInterface::AppendErrorMessageL( const TDesC8& aCmdName, const TDesC8& aParameter, const TDesC& aMessage ) |
|
2329 { |
|
2330 iErrorMessage = HBufC::NewL( KMaxErrorMessageLength ); |
|
2331 TPtr tmpMsgPtr = iErrorMessage->Des(); |
|
2332 tmpMsgPtr.Copy(KDomainName); |
|
2333 |
|
2334 HBufC* temp = HBufC::NewL( KMaxErrorMessageLength ); |
|
2335 |
|
2336 if ( aCmdName.Length() ) |
|
2337 { |
|
2338 tmpMsgPtr.Append( KErrorMsgSeparator ); |
|
2339 temp->Des().Copy( aCmdName ); |
|
2340 tmpMsgPtr.Append( temp->Des() ); |
|
2341 } |
|
2342 |
|
2343 tmpMsgPtr.Append(KErrorMsgSeparator); |
|
2344 |
|
2345 if ( aParameter.Length() ) |
|
2346 { |
|
2347 temp->Des().Copy(aParameter); |
|
2348 tmpMsgPtr.Append(temp->Des()); |
|
2349 } |
|
2350 |
|
2351 if ( aMessage.Length() ) |
|
2352 { |
|
2353 tmpMsgPtr.Append( aMessage ); |
|
2354 } |
|
2355 |
|
2356 delete temp; |
|
2357 } |
|
2358 |
|
2359 // --------------------------------------------------------------------------- |
|
2360 // Set Import output to output parameter |
|
2361 // --------------------------------------------------------------------------- |
|
2362 // |
|
2363 void CCalendarInterface::SetImportOutputL( RPointerArray<TUIDSet>& aOutputUIDSet, CLiwGenericParamList& aOutParamList ) |
|
2364 { |
|
2365 TInt arrCount = aOutputUIDSet.Count(); |
|
2366 |
|
2367 //List of Maps |
|
2368 CLiwDefaultList *uIDList = CLiwDefaultList::NewL(); |
|
2369 |
|
2370 CleanupClosePushL( *uIDList ); |
|
2371 |
|
2372 for( TInt index = 0; index < arrCount; ++index ) |
|
2373 { |
|
2374 TLiwVariant liwVariant; |
|
2375 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &liwVariant)); |
|
2376 |
|
2377 GetTLiwVariantForUIDSetL( liwVariant, aOutputUIDSet[ index ] ); |
|
2378 |
|
2379 uIDList->AppendL( liwVariant ); |
|
2380 |
|
2381 CleanupStack::Pop( &liwVariant ); |
|
2382 liwVariant.Reset(); |
|
2383 } |
|
2384 |
|
2385 //Iterator over List of Maps |
|
2386 CIterableUIDMapList *outputIterableList = CIterableUIDMapList::NewL( uIDList ); |
|
2387 |
|
2388 CleanupClosePushL( *outputIterableList ); |
|
2389 // Appending the Iteratot over List of Maps to the outParamList CLiwGenericParamList |
|
2390 aOutParamList.AppendL( TLiwGenericParam( KReturnValue, TLiwVariant( outputIterableList ) ) ); |
|
2391 |
|
2392 CleanupStack::PopAndDestroy( outputIterableList );//doubt check at debugging |
|
2393 |
|
2394 CleanupStack::Pop( uIDList ); |
|
2395 } |
|
2396 |
|
2397 // --------------------------------------------------------------------------- |
|
2398 // Set Change Notification output to output parameter |
|
2399 // --------------------------------------------------------------------------- |
|
2400 // |
|
2401 void CCalendarInterface::SetNotifyOutputL( RArray<TCalChangeEntry>& aOutputChangeSet, CLiwGenericParamList& aOutParamList ) |
|
2402 { |
|
2403 TInt arrCount = aOutputChangeSet.Count(); |
|
2404 |
|
2405 //List of Maps |
|
2406 CLiwDefaultList *changeList = CLiwDefaultList::NewL(); |
|
2407 |
|
2408 CleanupClosePushL( *changeList ); |
|
2409 |
|
2410 for( TInt index = 0; index < arrCount; ++index ) |
|
2411 { |
|
2412 TLiwVariant liwVariant; |
|
2413 CleanupStack::PushL( TCleanupItem(TLiwVariant::VariantCleanup , &liwVariant)); |
|
2414 |
|
2415 GetTLiwVariantForCalChangeEntryL( liwVariant, aOutputChangeSet[index] ); |
|
2416 |
|
2417 changeList->AppendL( liwVariant ); |
|
2418 |
|
2419 CleanupStack::Pop( &liwVariant ); |
|
2420 liwVariant.Reset(); |
|
2421 } |
|
2422 |
|
2423 //Iterator over List of Maps |
|
2424 CIterableUIDMapList *outputIterableList = CIterableUIDMapList::NewL( changeList ); |
|
2425 CleanupStack::Pop( changeList ); |
|
2426 CleanupClosePushL( *outputIterableList ); |
|
2427 |
|
2428 // Appending the Iteratot over List of Maps to the outParamList CLiwGenericParamList |
|
2429 aOutParamList.AppendL( TLiwGenericParam( KReturnValue, TLiwVariant( outputIterableList ) ) ); |
|
2430 |
|
2431 CleanupStack::PopAndDestroy( outputIterableList ); |
|
2432 |
|
2433 } |
|
2434 |
|
2435 // --------------------------------------------------------------------------- |
|
2436 // Set GlobalUid/LocalUid to the LiwVariant |
|
2437 // --------------------------------------------------------------------------- |
|
2438 // |
|
2439 void CCalendarInterface::GetTLiwVariantForUIDSetL( TLiwVariant& aValue, TUIDSet* aUIDSet ) |
|
2440 { |
|
2441 HBufC* globalUid = HBufC::NewL( aUIDSet->iGlobalUID->Length() + 1 ); |
|
2442 CleanupStack::PushL( globalUid ); |
|
2443 globalUid->Des().Copy( aUIDSet->iGlobalUID->Des() ); |
|
2444 aValue.SetL( TLiwVariant(*globalUid)); |
|
2445 CleanupStack::PopAndDestroy( globalUid ); |
|
2446 } |
|
2447 |
|
2448 // --------------------------------------------------------------------------- |
|
2449 // Set Change type to the LiwVariant |
|
2450 // --------------------------------------------------------------------------- |
|
2451 // |
|
2452 void CCalendarInterface::GetTLiwVariantForCalChangeEntryL( TLiwVariant& aValue, TCalChangeEntry& aChangeEntry ) |
|
2453 { |
|
2454 CLiwDefaultMap* uIDMap = CLiwDefaultMap::NewL(); |
|
2455 |
|
2456 CleanupClosePushL( *uIDMap ); |
|
2457 |
|
2458 TBuf<20> localUid; |
|
2459 |
|
2460 localUid.Num( TInt64(aChangeEntry.iEntryId )); |
|
2461 |
|
2462 uIDMap->InsertL( KLocalId, TLiwVariant( localUid ) ); |
|
2463 |
|
2464 uIDMap->InsertL( KChangeType, TLiwVariant( CCalendarInterface::GetChangeType( aChangeEntry.iChangeType ) ) ); |
|
2465 |
|
2466 aValue.SetL( uIDMap ); |
|
2467 |
|
2468 CleanupStack::PopAndDestroy( uIDMap ); |
|
2469 |
|
2470 } |
|
2471 |
|
2472 // --------------------------------------------------------------------------- |
|
2473 // Cleanup function for an CIterableCalEntryList |
|
2474 // --------------------------------------------------------------------------- |
|
2475 // |
|
2476 void CCalendarInterface::CleanupIterableCalEntry(void* aIterEntryList) |
|
2477 { |
|
2478 CIterableCalEntryList* iterEntryList = static_cast<CIterableCalEntryList*>(aIterEntryList); |
|
2479 if ( iterEntryList ) |
|
2480 { |
|
2481 iterEntryList->DecRef(); |
|
2482 } |
|
2483 } |
|
2484 |
|
2485 // --------------------------------------------------------------------------- |
|
2486 // Returns Day of Month of repeat rule as LiwVariant Map. Caller takes the ownership of map |
|
2487 // --------------------------------------------------------------------------- |
|
2488 // |
|
2489 CLiwDefaultMap* CCalendarInterface::GetDayOfMonthL( const TCalRRule::TDayOfMonth& aDayOfMonth ) |
|
2490 { |
|
2491 CLiwDefaultMap* dayMap = CLiwDefaultMap::NewL(); |
|
2492 CleanupClosePushL( *dayMap ); |
|
2493 |
|
2494 dayMap->InsertL( KDay, TLiwVariant( TInt32( aDayOfMonth.Day() ) )); |
|
2495 dayMap->InsertL( KWeekNum, TLiwVariant( TInt32( aDayOfMonth.WeekInMonth() ) )); |
|
2496 |
|
2497 CleanupStack::Pop( dayMap ); |
|
2498 return dayMap; |
|
2499 } |
|
2500 |
|
2501 // --------------------------------------------------------------------------- |
|
2502 // Returns CalUser as LiwVariant Map. Caller takes the ownership of map |
|
2503 // --------------------------------------------------------------------------- |
|
2504 // |
|
2505 CLiwDefaultMap* CCalendarInterface::GetCalUserL( CCalUser* aCalUser, TBool aAttendee ) |
|
2506 { |
|
2507 CLiwDefaultMap* userMap = CLiwDefaultMap::NewL(); |
|
2508 CleanupClosePushL( *userMap ); |
|
2509 |
|
2510 userMap->InsertL( KCommonName, TLiwVariant( aCalUser->CommonName() ) ); |
|
2511 userMap->InsertL( KAddress, TLiwVariant( aCalUser->Address() ) ); |
|
2512 |
|
2513 if ( aAttendee ) |
|
2514 { |
|
2515 userMap->InsertL( KRole, TLiwVariant( CCalendarInterface::GetAttendeeRoleL(((CCalAttendee*)aCalUser)->RoleL() ) )); |
|
2516 userMap->InsertL( KStatus, TLiwVariant( CCalendarInterface::GetAttendeeStatusL(((CCalAttendee*)aCalUser)->StatusL() ) )); |
|
2517 userMap->InsertL( KRsvp, TLiwVariant( ((CCalAttendee*)aCalUser)->ResponseRequested() ) ); |
|
2518 } |
|
2519 |
|
2520 CleanupStack::Pop( userMap ); |
|
2521 return userMap; |
|
2522 } |
|
2523 |
|
2524 // --------------------------------------------------------------------------- |
|
2525 // Returns array of CalTime as LiwVariant List. Caller takes the ownership of list |
|
2526 // --------------------------------------------------------------------------- |
|
2527 // |
|
2528 CLiwDefaultList* CCalendarInterface::GetDatesListL( RArray<TCalTime>& aDates ) |
|
2529 { |
|
2530 TInt count = aDates.Count(); |
|
2531 |
|
2532 CLiwDefaultList* dateList = CLiwDefaultList::NewL(); |
|
2533 CleanupClosePushL( *dateList ); |
|
2534 |
|
2535 for ( TInt index = 0 ; index < count; index++ ) |
|
2536 { |
|
2537 dateList->AppendL( aDates[index].TimeUtcL() ); |
|
2538 } |
|
2539 |
|
2540 CleanupStack::Pop( dateList ); |
|
2541 return dateList; |
|
2542 } |
|
2543 |
|
2544 // --------------------------------------------------------------------------- |
|
2545 // Returns RepeatRule as LiwVariant Map. Caller takes the ownership of map |
|
2546 // --------------------------------------------------------------------------- |
|
2547 // |
|
2548 CLiwDefaultMap* CCalendarInterface::GetRRMapL( const TCalRRule& repeatRule ) |
|
2549 { |
|
2550 TCalRRule::TType rrType = repeatRule.Type(); |
|
2551 |
|
2552 if ( rrType == TCalRRule::EInvalid ) |
|
2553 return NULL; |
|
2554 |
|
2555 CLiwDefaultMap* rrMap = CLiwDefaultMap::NewL(); |
|
2556 |
|
2557 CleanupClosePushL( *rrMap ); |
|
2558 |
|
2559 rrMap->InsertL( KRepeatType, TLiwVariant( TInt32( rrType ) )); |
|
2560 |
|
2561 rrMap->InsertL( KUntilDate, TLiwVariant( repeatRule.Until().TimeUtcL() )); |
|
2562 |
|
2563 rrMap->InsertL( KInterval, TLiwVariant( TInt32( repeatRule.Interval() ))); |
|
2564 |
|
2565 rrMap->InsertL( KRStartDate, TLiwVariant( repeatRule.DtStart().TimeUtcL() )); |
|
2566 |
|
2567 if ( rrType == TCalRRule::EWeekly ) |
|
2568 { |
|
2569 RArray<TDay> dayArray; |
|
2570 repeatRule.GetByDayL( dayArray ); |
|
2571 |
|
2572 CLiwDefaultList* dayList = CLiwDefaultList::NewL(); |
|
2573 CleanupClosePushL( *dayList ); |
|
2574 |
|
2575 TInt count = dayArray.Count(); |
|
2576 for ( TInt index = 0 ; index < count; index++ ) |
|
2577 { |
|
2578 dayList->AppendL( TInt32( dayArray[index] )); |
|
2579 } |
|
2580 |
|
2581 rrMap->InsertL( KDaysInWeek, TLiwVariant( dayList )); |
|
2582 |
|
2583 CleanupStack::PopAndDestroy( dayList ); |
|
2584 |
|
2585 dayArray.Reset(); |
|
2586 } |
|
2587 else if ( rrType == TCalRRule::EMonthly ) |
|
2588 { |
|
2589 RArray<TInt> monthDays; |
|
2590 repeatRule.GetByMonthDayL( monthDays ); |
|
2591 TInt count = monthDays.Count(); |
|
2592 if ( count > 0 ) |
|
2593 { |
|
2594 // |
|
2595 CLiwDefaultList* dayList = CLiwDefaultList::NewL(); |
|
2596 CleanupClosePushL( *dayList ); |
|
2597 |
|
2598 for ( TInt index = 0 ; index < count; index++ ) |
|
2599 { |
|
2600 dayList->AppendL( TInt32(monthDays[index] )); |
|
2601 } |
|
2602 |
|
2603 rrMap->InsertL( KMonthDays, TLiwVariant( dayList )); |
|
2604 |
|
2605 CleanupStack::PopAndDestroy( dayList ); |
|
2606 |
|
2607 |
|
2608 } |
|
2609 else |
|
2610 { |
|
2611 RArray< TCalRRule::TDayOfMonth > daysOfMonth; |
|
2612 repeatRule.GetByDayL( daysOfMonth ); |
|
2613 count = daysOfMonth.Count(); |
|
2614 if ( count > 0 ) |
|
2615 { |
|
2616 CLiwDefaultList* dayList = CLiwDefaultList::NewL(); |
|
2617 CleanupClosePushL( *dayList ); |
|
2618 |
|
2619 for ( TInt index = 0; index < count; index++ ) |
|
2620 { |
|
2621 CLiwDefaultMap* dayOfMonthMap = CCalendarInterface::GetDayOfMonthL( daysOfMonth[index] ); |
|
2622 dayList->AppendL( TLiwVariant ( dayOfMonthMap ) ); |
|
2623 dayOfMonthMap->DecRef(); |
|
2624 } |
|
2625 |
|
2626 rrMap->InsertL( KDaysOfMonth, TLiwVariant( dayList )); |
|
2627 |
|
2628 CleanupStack::PopAndDestroy( dayList ); |
|
2629 |
|
2630 } |
|
2631 daysOfMonth.Reset(); |
|
2632 } |
|
2633 monthDays.Reset(); |
|
2634 } |
|
2635 else if ( rrType == TCalRRule::EYearly ) |
|
2636 { |
|
2637 RArray<TMonth> monthArray; |
|
2638 repeatRule.GetByMonthL( monthArray ); |
|
2639 |
|
2640 if ( monthArray.Count() > 0 ) |
|
2641 { |
|
2642 rrMap->InsertL( KMonth, TLiwVariant( TInt32( monthArray[0] ) )); |
|
2643 } |
|
2644 monthArray.Reset(); |
|
2645 |
|
2646 |
|
2647 RArray< TCalRRule::TDayOfMonth > daysOfMonth; |
|
2648 repeatRule.GetByDayL( daysOfMonth ); |
|
2649 TInt count = daysOfMonth.Count(); |
|
2650 if ( count > 0 ) |
|
2651 { |
|
2652 CLiwDefaultList* dayList = CLiwDefaultList::NewL(); |
|
2653 CleanupClosePushL( *dayList ); |
|
2654 |
|
2655 for ( TInt index = 0; index < count; index++ ) |
|
2656 { |
|
2657 CLiwDefaultMap* dayOfMonthMap = CCalendarInterface::GetDayOfMonthL( daysOfMonth[index] ); |
|
2658 dayList->AppendL( TLiwVariant ( dayOfMonthMap ) ); |
|
2659 dayOfMonthMap->DecRef(); |
|
2660 } |
|
2661 |
|
2662 rrMap->InsertL( KDaysOfMonth, TLiwVariant( dayList )); |
|
2663 |
|
2664 CleanupStack::PopAndDestroy( dayList ); |
|
2665 |
|
2666 } |
|
2667 daysOfMonth.Reset(); |
|
2668 |
|
2669 } |
|
2670 |
|
2671 CleanupStack::Pop( rrMap ); |
|
2672 |
|
2673 return rrMap; |
|
2674 } |
|
2675 |
|
2676 |
|
2677 // --------------------------------------------------------------------------- |
|
2678 // Returns string literal for the given Entry Type |
|
2679 // --------------------------------------------------------------------------- |
|
2680 // |
|
2681 TPtrC CCalendarInterface::GetEntryTypeL( const CCalEntry::TType aType ) |
|
2682 { |
|
2683 TPtrC retValue; |
|
2684 |
|
2685 if ( aType == CCalEntry::EAppt ) |
|
2686 retValue.Set( KEntryAppt ); |
|
2687 |
|
2688 else if ( aType == CCalEntry::ETodo ) |
|
2689 retValue.Set( KEntryTodo ); |
|
2690 |
|
2691 else if ( aType == CCalEntry::EEvent ) |
|
2692 retValue.Set( KEntryEvent ); |
|
2693 |
|
2694 else if ( aType == CCalEntry::EReminder ) |
|
2695 retValue.Set( KEntryReminder ); |
|
2696 |
|
2697 else if ( aType == CCalEntry::EAnniv ) |
|
2698 retValue.Set( KEntryAnniv ); |
|
2699 |
|
2700 else |
|
2701 User::Leave(KErrArgument); |
|
2702 |
|
2703 return retValue; |
|
2704 |
|
2705 } |
|
2706 |
|
2707 // --------------------------------------------------------------------------- |
|
2708 // Returns string literal for the given Entry Replication status |
|
2709 // --------------------------------------------------------------------------- |
|
2710 // |
|
2711 TPtrC CCalendarInterface::GetReplicationL( const CCalEntry::TReplicationStatus aType ) |
|
2712 { |
|
2713 TPtrC retValue; |
|
2714 |
|
2715 if ( aType == CCalEntry::EPrivate ) |
|
2716 retValue.Set( KReplPrivate ); |
|
2717 |
|
2718 else if ( aType == CCalEntry::ERestricted ) |
|
2719 retValue.Set( KReplRest ); |
|
2720 |
|
2721 else |
|
2722 retValue.Set( KReplOpen ); |
|
2723 |
|
2724 return retValue; |
|
2725 |
|
2726 } |
|
2727 |
|
2728 // --------------------------------------------------------------------------- |
|
2729 // Returns string literal for Change Types |
|
2730 // --------------------------------------------------------------------------- |
|
2731 // |
|
2732 TPtrC CCalendarInterface::GetChangeType( const MCalChangeCallBack2::TChangeType aType ) |
|
2733 { |
|
2734 TPtrC retValue; |
|
2735 |
|
2736 if ( aType == MCalChangeCallBack2::EChangeAdd ) |
|
2737 retValue.Set( KChangeAdd ); |
|
2738 |
|
2739 else if ( aType == MCalChangeCallBack2::EChangeDelete ) |
|
2740 retValue.Set( KChangeDelete ); |
|
2741 |
|
2742 else if ( aType == MCalChangeCallBack2::EChangeModify ) |
|
2743 retValue.Set( KChangeModify ); |
|
2744 |
|
2745 else |
|
2746 retValue.Set( KChangeUndefined ); |
|
2747 |
|
2748 return retValue; |
|
2749 |
|
2750 } |
|
2751 |
|
2752 // --------------------------------------------------------------------------- |
|
2753 // Returns string literal for Entry Status |
|
2754 // --------------------------------------------------------------------------- |
|
2755 // |
|
2756 TPtrC CCalendarInterface::GetStatusL( const CCalEntry::TStatus aStatus ) |
|
2757 { |
|
2758 TPtrC retValue; |
|
2759 |
|
2760 if ( aStatus == CCalEntry::ETentative ) |
|
2761 retValue.Set( KStatusTentative ); |
|
2762 |
|
2763 else if ( aStatus == CCalEntry::EConfirmed ) |
|
2764 retValue.Set( KStatusConfirmed ); |
|
2765 |
|
2766 else if ( aStatus == CCalEntry::ECancelled ) |
|
2767 retValue.Set( KStatusCancelled ); |
|
2768 |
|
2769 else if ( aStatus == CCalEntry::ETodoNeedsAction ) |
|
2770 retValue.Set( KStatusTodoNeedsAction ); |
|
2771 |
|
2772 else if ( aStatus == CCalEntry::ETodoCompleted ) |
|
2773 retValue.Set( KStatusTodoCompleted ); |
|
2774 |
|
2775 else if ( aStatus == CCalEntry::ETodoInProcess ) |
|
2776 retValue.Set( KStatusTodoInProcess ); |
|
2777 |
|
2778 else |
|
2779 retValue.Set( KNullStatus ); |
|
2780 |
|
2781 return retValue; |
|
2782 } |
|
2783 |
|
2784 // --------------------------------------------------------------------------- |
|
2785 // Returns string literal for Attendee Status |
|
2786 // --------------------------------------------------------------------------- |
|
2787 // |
|
2788 TPtrC CCalendarInterface::GetAttendeeStatusL( const CCalAttendee::TCalStatus aStatus ) |
|
2789 { |
|
2790 TPtrC retValue; |
|
2791 |
|
2792 if ( aStatus == CCalAttendee::EAccepted ) |
|
2793 retValue.Set( KAttStatusAccepted ); |
|
2794 |
|
2795 else if ( aStatus == CCalAttendee::ETentative ) |
|
2796 retValue.Set( KAttStatusTentative ); |
|
2797 |
|
2798 else if ( aStatus == CCalAttendee::EConfirmed ) |
|
2799 retValue.Set( KAttStatusConfirmed ); |
|
2800 |
|
2801 else if ( aStatus == CCalAttendee::EDeclined ) |
|
2802 retValue.Set( KAttStatusDeclined ); |
|
2803 |
|
2804 else if ( aStatus == CCalAttendee::ECompleted ) |
|
2805 retValue.Set( KAttStatusCompleted ); |
|
2806 |
|
2807 else if ( aStatus == CCalAttendee::EDelegated ) |
|
2808 retValue.Set( KAttStatusDelegated ); |
|
2809 |
|
2810 else if ( aStatus == CCalAttendee::EInProcess ) |
|
2811 retValue.Set( KAttStatusInProcess ); |
|
2812 |
|
2813 else |
|
2814 retValue.Set( KAttStatusNeedsAction ); |
|
2815 |
|
2816 return retValue; |
|
2817 } |
|
2818 |
|
2819 // --------------------------------------------------------------------------- |
|
2820 // Get string literal for Attendee Role |
|
2821 // --------------------------------------------------------------------------- |
|
2822 // |
|
2823 TPtrC CCalendarInterface::GetAttendeeRoleL( const CCalAttendee::TCalRole aRole ) |
|
2824 { |
|
2825 TPtrC retValue; |
|
2826 |
|
2827 if ( aRole == CCalAttendee::EOptParticipant ) |
|
2828 retValue.Set( KAttRoleOptParticipant ); |
|
2829 |
|
2830 else if ( aRole == CCalAttendee::ENonParticipant ) |
|
2831 retValue.Set( KAttRoleNonParticipant ); |
|
2832 |
|
2833 else if ( aRole == CCalAttendee::EChair ) |
|
2834 retValue.Set( KAttRoleChair ); |
|
2835 |
|
2836 else |
|
2837 retValue.Set( KAttRoleReqParticipant ); |
|
2838 |
|
2839 return retValue; |
|
2840 } |
|
2841 |
|
2842 // --------------------------------------------------------------------------- |
|
2843 // Return string literal for Entry Method |
|
2844 // --------------------------------------------------------------------------- |
|
2845 // |
|
2846 TPtrC CCalendarInterface::GetMethodL( const CCalEntry::TMethod aMethod ) |
|
2847 { |
|
2848 TPtrC retValue; |
|
2849 |
|
2850 if ( aMethod == CCalEntry::EMethodPublish ) |
|
2851 retValue.Set( KMethodPublish ); |
|
2852 |
|
2853 else if ( aMethod == CCalEntry::EMethodRequest) |
|
2854 retValue.Set( KMethodRequest ); |
|
2855 |
|
2856 else if ( aMethod == CCalEntry::EMethodReply) |
|
2857 retValue.Set( KMethodReply ); |
|
2858 |
|
2859 else if ( aMethod == CCalEntry::EMethodAdd ) |
|
2860 retValue.Set( KMethodAdd ); |
|
2861 |
|
2862 else if ( aMethod == CCalEntry::EMethodCancel ) |
|
2863 retValue.Set( KMethodCancel ); |
|
2864 |
|
2865 else if ( aMethod == CCalEntry::EMethodRefresh ) |
|
2866 retValue.Set( KMethodRefresh ); |
|
2867 |
|
2868 else if ( aMethod == CCalEntry::EMethodCounter ) |
|
2869 retValue.Set( KMethodCounter ); |
|
2870 |
|
2871 else if ( aMethod == CCalEntry::EMethodDeclineCounter ) |
|
2872 retValue.Set( KMethodDecCounter ); |
|
2873 |
|
2874 else |
|
2875 retValue.Set( KMethodNone ); |
|
2876 |
|
2877 return retValue; |
|
2878 } |
|
2879 |
|
2880 // --------------------------------------------------------------------------- |
|
2881 // Return string literal for Entry Method |
|
2882 // --------------------------------------------------------------------------- |
|
2883 // |
|
2884 void CCalendarInterface::RemoveCalEntryListFromArray( CIterableCalEntryList* aCalEntryList ) |
|
2885 { |
|
2886 TInt count = iArrayCalEntryList.Count(); |
|
2887 for(TInt index = 0; index < count; index++ ) |
|
2888 { |
|
2889 if ( iArrayCalEntryList[index] == aCalEntryList ) |
|
2890 { |
|
2891 iArrayCalEntryList.Remove( index ); |
|
2892 break; |
|
2893 } |
|
2894 } |
|
2895 |
|
2896 iArrayCalEntryList.Compress(); |
|
2897 } |
|
2898 |
|
2899 // --------------------------------------------------------------------------- |
|
2900 // Return Entry Type for given LocalUid |
|
2901 // --------------------------------------------------------------------------- |
|
2902 // |
|
2903 TInt CCalendarInterface::GetEntryType( const TDesC& aCalendarName, TCalLocalUid aLocalUid ) |
|
2904 { |
|
2905 TInt entryType = -1; |
|
2906 RPointerArray<CCalEntry> entryArray; |
|
2907 iCalService->GetListL( aCalendarName, aLocalUid, entryArray); |
|
2908 if( entryArray.Count() ) |
|
2909 { |
|
2910 entryType = entryArray[0]->EntryTypeL(); |
|
2911 } |
|
2912 entryArray.ResetAndDestroy(); |
|
2913 return entryType; |
|
2914 } |
|
2915 |
|
2916 // --------------------------------------------------------------------------- |
|
2917 // Check if given calendar is in use by other resources |
|
2918 // --------------------------------------------------------------------------- |
|
2919 // |
|
2920 TBool CCalendarInterface::CheckCalendarInUse( const TDesC& aCalendarName ) |
|
2921 { |
|
2922 TBool retValue = EFalse; |
|
2923 TInt count = iArrayCalEntryList.Count(); |
|
2924 for(TInt index = 0; index < count; index++ ) |
|
2925 { |
|
2926 if ( aCalendarName.CompareF( iArrayCalEntryList[index]->CalendarName() ) == 0 ) |
|
2927 { |
|
2928 retValue = ETrue; |
|
2929 break; |
|
2930 } |
|
2931 } |
|
2932 return retValue; |
|
2933 } |