|
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: Interface to Calender service |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <calsession.h> |
|
21 #include <calinstance.h> |
|
22 #include <calentryview.h> |
|
23 #include <calinstanceview.h> |
|
24 #include <calrrule.h> |
|
25 #include <badesca.h> |
|
26 |
|
27 #include "calendarheader.h" |
|
28 #include "calendarconstants.h" |
|
29 #include "entryattributes.h" |
|
30 #include "calendarservice.h" |
|
31 #include "Calendarnotify.h" |
|
32 #include "calendardeleteentry.h" |
|
33 #include "calendarimport.h" |
|
34 #include "calendarexport.h" |
|
35 #include "addentry.h" |
|
36 #include "asyncreqobserver.h" |
|
37 |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // Two-phased constructor. |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CAsyncRequestObserver* CAsyncRequestObserver::NewL() |
|
44 { |
|
45 return new(ELeave) CAsyncRequestObserver; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // Destructor. |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CAsyncRequestObserver::~CAsyncRequestObserver() |
|
53 { |
|
54 DeleteAsyncObjects();//deletes all Asychronous objects |
|
55 iAsyncObjArray.Reset(); |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // Notifies about the completeion of an async request. |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 void CAsyncRequestObserver::RequestComplete( const TInt32 aTransactionId ) |
|
63 { |
|
64 TInt pos = iAsyncObjArray.Count() - 1; |
|
65 TAsyncRequestInfo obj; |
|
66 for ( ; pos >= 0; pos-- ) |
|
67 { |
|
68 obj = iAsyncObjArray[pos]; |
|
69 // Remove object with transaction id aTransactionId from async object array |
|
70 if( obj.iTransactionId == aTransactionId ) |
|
71 { |
|
72 iAsyncObjArray.Remove(pos); |
|
73 iAsyncObjArray.Compress(); |
|
74 return; |
|
75 } |
|
76 } |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // Deletes all the asynchronous request objects |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void CAsyncRequestObserver::DeleteAsyncObjects() |
|
84 { |
|
85 TInt pos = iAsyncObjArray.Count() - 1; |
|
86 TAsyncRequestInfo obj; |
|
87 for ( ; pos >= 0; pos-- ) |
|
88 { |
|
89 obj = iAsyncObjArray[pos]; |
|
90 obj.iAsyncObj->Cancel(); |
|
91 delete obj.iAsyncObj; |
|
92 } |
|
93 } |
|
94 |
|
95 |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // Cancels asynchronous request |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 EXPORT_C TInt CAsyncRequestObserver::Cancel( const TInt32 aTransactionId ) |
|
102 { |
|
103 TInt pos = iAsyncObjArray.Count() - 1; |
|
104 TAsyncRequestInfo obj; |
|
105 for ( ; pos >= 0; pos-- ) |
|
106 { |
|
107 obj = iAsyncObjArray[pos]; |
|
108 // Cancel and remove object with transaction id aTransactionId from async object array |
|
109 if( obj.iTransactionId == aTransactionId ) |
|
110 { |
|
111 if(obj.iAsyncObj->IsInProgress()) |
|
112 return KErrInUse; |
|
113 |
|
114 obj.iAsyncObj->Cancel(); |
|
115 delete obj.iAsyncObj; |
|
116 return KErrNone; |
|
117 } |
|
118 } |
|
119 |
|
120 return KErrNotFound; |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // Adds asynchronous request object |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 void CAsyncRequestObserver::AddAsyncObjL( const TInt32 aTransactionId, CCalendarASyncRequest* aAsyncObj ) |
|
128 { |
|
129 // Add async object to array to keep track of async requests |
|
130 TAsyncRequestInfo asyncRequestInfo; |
|
131 asyncRequestInfo.iTransactionId = aTransactionId; |
|
132 asyncRequestInfo.iAsyncObj = aAsyncObj; |
|
133 User::LeaveIfError( iAsyncObjArray.Append( asyncRequestInfo ) ); |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // Two-phased constructor. |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 EXPORT_C CCalendarService* CCalendarService::NewL() |
|
141 { |
|
142 CCalendarService* self = new (ELeave) CCalendarService; |
|
143 CleanupStack::PushL( self ); |
|
144 self->ConstructL(); |
|
145 CleanupStack::Pop( self ); |
|
146 return self; |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // Destructor. |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 CCalendarService::~CCalendarService() |
|
154 { |
|
155 delete iAsyncReqObserver; |
|
156 iArraySessionInfo.ResetAndDestroy(); |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // Constructor. |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 CCalendarService::CCalendarService() |
|
164 { |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // Two-phased constructor. |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 void CCalendarService::ConstructL() |
|
172 { |
|
173 //Create default calendar session |
|
174 CalendarSessionInfoL( KNullDesC ); |
|
175 iAsyncReqObserver = CAsyncRequestObserver::NewL(); |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // Returns list of available calendars in device. |
|
180 // Default calendar will be returned in case aDefault is true. |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 EXPORT_C void CCalendarService::GetListL( CDesCArray*& aCalendarList, const TBool aDefault ) |
|
184 { |
|
185 if ( aDefault ) |
|
186 { |
|
187 aCalendarList = new(ELeave) CDesCArraySeg( KArrayGran ); |
|
188 // Append default calendar to calendar list if aDefault == ETrue |
|
189 CleanupStack::PushL( aCalendarList ); |
|
190 aCalendarList->AppendL( iArraySessionInfo[KArrayZeroIndex]->Calendar() ); |
|
191 CleanupStack::Pop( aCalendarList ); |
|
192 } |
|
193 else |
|
194 { |
|
195 // Append all available to calendar list |
|
196 aCalendarList = iArraySessionInfo[KArrayZeroIndex]->Session()->ListCalFilesL(); |
|
197 } |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // Returns list of calendar entries from given calendar with the given Global UID. |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 EXPORT_C void CCalendarService::GetListL( const TDesC& aCalendarName, const TDesC8& aGuid, RPointerArray<CCalEntry>& aEntryList) |
|
205 { |
|
206 CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
207 |
|
208 // Get list of calendar entries using CCalEntryView |
|
209 sessionInfo->EntryView()->FetchL( aGuid, aEntryList ); |
|
210 } |
|
211 |
|
212 // --------------------------------------------------------------------------- |
|
213 // Returns list of calendar entries from given calendar with the given Local UID. |
|
214 // --------------------------------------------------------------------------- |
|
215 // |
|
216 EXPORT_C void CCalendarService::GetListL( const TDesC& aCalendarName, const TCalLocalUid aLocalUid, RPointerArray<CCalEntry>& aEntryList) |
|
217 { |
|
218 CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
219 |
|
220 // Fetch only that entry having local uid aLocalUid |
|
221 CCalEntry* entry = sessionInfo->EntryView()->FetchL( aLocalUid ); |
|
222 if( entry ) |
|
223 { |
|
224 aEntryList.Append( entry ); |
|
225 } |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // Returns list of calendar instances from given calendar based on input filter. |
|
230 // --------------------------------------------------------------------------- |
|
231 // |
|
232 EXPORT_C void CCalendarService::GetListL( const TDesC& aCalendarName, CCalendarFilter* aFilter, |
|
233 RPointerArray<CCalInstance>& aInstanceList ) |
|
234 { |
|
235 if ( !aFilter ) |
|
236 User::Leave( KErrArgument ); |
|
237 |
|
238 CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
239 CalCommon::TCalTimeRange range = aFilter->TimeRange(); |
|
240 if( (range.EndTime().TimeLocalL()) < (range.StartTime().TimeLocalL()) ) |
|
241 User::Leave( KErrArgument ); |
|
242 if ( aFilter->FilterText().Length() ) |
|
243 { |
|
244 // Search and return all instances which match filter text and time range |
|
245 CCalInstanceView::TCalSearchParams searchParam( aFilter->FilterText(), CalCommon::EFoldedTextSearch ); |
|
246 sessionInfo->InstanceView()->FindInstanceL( aInstanceList, |
|
247 aFilter->FilterType(), |
|
248 aFilter->TimeRange(), searchParam ) ; |
|
249 } |
|
250 else |
|
251 { |
|
252 // Search and return all instances which match filter type and time range |
|
253 sessionInfo->InstanceView()->FindInstanceL( aInstanceList, |
|
254 aFilter->FilterType(), |
|
255 aFilter->TimeRange() ) ; |
|
256 } |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // Adds new calendar |
|
261 // --------------------------------------------------------------------------- |
|
262 // |
|
263 EXPORT_C void CCalendarService::AddL( const TDesC& aCalendarName ) |
|
264 { |
|
265 //Create a new calendar file using the existing session object |
|
266 iArraySessionInfo[KArrayZeroIndex]->Session()->CreateCalFileL( aCalendarName ); |
|
267 } |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // Add |
|
271 // --------------------------------------------------------------------------- |
|
272 // |
|
273 EXPORT_C void CCalendarService::AddL( const TDesC& aCalendarName, |
|
274 CEntryAttributes* aCalendarData, TUIDSet*& aUidAdded ) |
|
275 { |
|
276 if ( !aCalendarData ) |
|
277 User::Leave( KErrArgument ); |
|
278 |
|
279 CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
280 CCalendarAddEntry* obj = CCalendarAddEntry::NewL( sessionInfo, aCalendarData ); |
|
281 CleanupStack::PushL( obj ); |
|
282 obj->AddL( aUidAdded ); |
|
283 CleanupStack::PopAndDestroy( obj ); |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // Remove calendar from the device. Deletion of defaut calendar is not supported |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 EXPORT_C void CCalendarService::DeleteL( const TDesC& aCalendarName ) |
|
291 { |
|
292 if ( aCalendarName.CompareF(iArraySessionInfo[KArrayZeroIndex]->Calendar()) != 0 ) |
|
293 { |
|
294 RemoveSessionInfo( aCalendarName ); |
|
295 iArraySessionInfo[KArrayZeroIndex]->Session()->DeleteCalFileL( aCalendarName ); |
|
296 } |
|
297 else |
|
298 { |
|
299 User::Leave( KErrNotSupported ); |
|
300 } |
|
301 } |
|
302 |
|
303 // --------------------------------------------------------------------------- |
|
304 // Remove entries from the given calendar based on input filter |
|
305 // --------------------------------------------------------------------------- |
|
306 // |
|
307 EXPORT_C void CCalendarService::DeleteL( const TDesC& aCalendarName, CCalendarFilter* aFilter, MCalCallbackBase* aCallBack ) |
|
308 { |
|
309 if ( !aFilter ) |
|
310 User::Leave( KErrArgument ); |
|
311 |
|
312 CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
313 |
|
314 //Instantiate the Delete Class Object |
|
315 CCalendarDeleteEntry* obj = CCalendarDeleteEntry::NewL( sessionInfo, aFilter, iAsyncReqObserver, aCallBack); |
|
316 |
|
317 CleanupStack::PushL( obj ); |
|
318 |
|
319 // Call the appropriate version of delete depending on input |
|
320 obj->DeleteL(); |
|
321 |
|
322 if ( aCallBack ) |
|
323 { |
|
324 AddAsyncObjL(aCallBack->iTransactionId, obj ); |
|
325 CleanupStack::Pop( obj ); |
|
326 } |
|
327 else |
|
328 CleanupStack::PopAndDestroy( obj ); |
|
329 } |
|
330 |
|
331 // --------------------------------------------------------------------------- |
|
332 // ImportL: This is the Synchronous version of Import which imports all the |
|
333 // entries in the format specified from the Calendar |
|
334 // --------------------------------------------------------------------------- |
|
335 // |
|
336 EXPORT_C void CCalendarService::ImportL( const TDesC& aCalendarName, |
|
337 const TDesC8& aFormat, |
|
338 const TDesC8& aInputBuffer, |
|
339 RPointerArray<TUIDSet>& aUIDSet ) |
|
340 { |
|
341 //Step 1: get the session |
|
342 CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
343 |
|
344 //Step 2: Instantiate the Import CoreClass Object |
|
345 CCalendarImport* importObj = CCalendarImport::NewL( sessionInfo, aFormat, aInputBuffer ); |
|
346 |
|
347 //Step 3: Push the ImportObject onto the cleanup stack as the Import function can Leave |
|
348 CleanupStack::PushL( importObj ); |
|
349 |
|
350 //Step 4: Call the Import along side the handle to the Output i.e.., aUIDSet |
|
351 importObj->ImportL( aUIDSet ); |
|
352 |
|
353 //Step 5: Destroy the Object as the processing is done |
|
354 CleanupStack::PopAndDestroy( importObj ); |
|
355 } |
|
356 |
|
357 // --------------------------------------------------------------------------- |
|
358 // ImportL: This is the Synchronous version of Import which imports all the |
|
359 // entries in the format specified from the Calendar |
|
360 // --------------------------------------------------------------------------- |
|
361 // |
|
362 EXPORT_C void CCalendarService::ImportL( const TDesC& aCalendarName, |
|
363 const TDesC8& aFormat, |
|
364 const TDesC& aImportFile, |
|
365 RPointerArray<TUIDSet>& aUIDSet ) |
|
366 { |
|
367 //Step 1: get the session |
|
368 CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
369 |
|
370 //Step 2: Instantiate the Import CoreClass Object |
|
371 CCalendarImport* importObj = CCalendarImport::NewL( sessionInfo, aFormat, aImportFile ); |
|
372 |
|
373 //Step 3: Push the ImportObject onto the cleanup stack as the Import function can Leave |
|
374 CleanupStack::PushL( importObj ); |
|
375 |
|
376 //Step 4: Call the Import along side the handle to the Output i.e.., aUIDSet |
|
377 importObj->ImportL( aUIDSet ); |
|
378 |
|
379 //Step 5: Destroy the Object as the processing is done |
|
380 CleanupStack::PopAndDestroy( importObj ); |
|
381 } |
|
382 |
|
383 // ----------------------------------------------------------------------------- |
|
384 // ImportAsyncL: This is the Asynchronous version of Import which imports all the |
|
385 // entries in the format specified to the Calendar |
|
386 // ------------------------------------------------------------------------------ |
|
387 // |
|
388 EXPORT_C void CCalendarService::ImportL( const TDesC& aCalendarName, |
|
389 const TDesC8& aFormat, |
|
390 const TDesC8& aInputBuffer, |
|
391 MCalCallbackBase* aCallBack ) |
|
392 { |
|
393 //get the session |
|
394 CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
395 |
|
396 //Instantiate the Import CoreClass Object |
|
397 CCalendarImport* importObj = CCalendarImport::NewL( sessionInfo, aFormat, aInputBuffer, iAsyncReqObserver, aCallBack ); |
|
398 |
|
399 //Push the ImportObject onto the cleanup stack as the Import function can Leave |
|
400 CleanupStack::PushL( importObj ); |
|
401 |
|
402 importObj->ImportL(); |
|
403 |
|
404 AddAsyncObjL( aCallBack->iTransactionId, importObj ); |
|
405 |
|
406 CleanupStack::Pop( importObj ); |
|
407 } |
|
408 |
|
409 // ----------------------------------------------------------------------------- |
|
410 // ImportAsyncL: This is the Asynchronous version of Import which imports all the |
|
411 // entries in the format specified to the Calendar |
|
412 // ------------------------------------------------------------------------------ |
|
413 // |
|
414 EXPORT_C void CCalendarService::ImportL( const TDesC& aCalendarName, |
|
415 const TDesC8& aFormat, |
|
416 const TDesC& aImportFile, |
|
417 MCalCallbackBase* aCallBack ) |
|
418 { |
|
419 //get the session |
|
420 CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
421 |
|
422 //Instantiate the Import CoreClass Object |
|
423 CCalendarImport* importObj = CCalendarImport::NewL( sessionInfo, aFormat, aImportFile, iAsyncReqObserver, aCallBack ); |
|
424 |
|
425 //Push the ImportObject onto the cleanup stack as the Import function can Leave |
|
426 CleanupStack::PushL( importObj ); |
|
427 |
|
428 importObj->ImportL(); |
|
429 |
|
430 AddAsyncObjL( aCallBack->iTransactionId, importObj ); |
|
431 |
|
432 CleanupStack::Pop( importObj ); |
|
433 } |
|
434 |
|
435 |
|
436 |
|
437 // --------------------------------------------------------------------------- |
|
438 // ExportL: This is the Synchronous Version which exports all the entries of |
|
439 // Calendar in the Specified format |
|
440 // --------------------------------------------------------------------------- |
|
441 // |
|
442 EXPORT_C void CCalendarService::ExportL( const TDesC& aCalendarName, |
|
443 const TDesC8& aFormat, |
|
444 CCalendarExportParams* aParams, |
|
445 HBufC8*& aOutputBuffer ) |
|
446 { |
|
447 if( !aParams ) |
|
448 User::Leave( KErrArgument ); |
|
449 |
|
450 CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
451 |
|
452 CCalendarExport* exportObj = CCalendarExport::NewL( sessionInfo, aFormat, aParams ); |
|
453 |
|
454 CleanupStack::PushL( exportObj ); |
|
455 |
|
456 exportObj->ExportL( aOutputBuffer ); |
|
457 |
|
458 CleanupStack::PopAndDestroy( exportObj ); |
|
459 } |
|
460 |
|
461 |
|
462 // --------------------------------------------------------------------------- |
|
463 // ExportAsyncL: This is the Asynchronous Version which exports all the entries of |
|
464 // Calendar in the Specified format |
|
465 // --------------------------------------------------------------------------- |
|
466 // |
|
467 EXPORT_C void CCalendarService::ExportL( const TDesC& aCalendarName, |
|
468 const TDesC8& aFormat, |
|
469 CCalendarExportParams* aParams, |
|
470 MCalCallbackBase* aCallBack ) |
|
471 { |
|
472 if( !aParams ) |
|
473 User::Leave( KErrArgument ); |
|
474 |
|
475 CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
476 |
|
477 CCalendarExport* exportObj = CCalendarExport::NewL( sessionInfo, aFormat, aParams, iAsyncReqObserver, aCallBack ); |
|
478 |
|
479 CleanupStack::PushL( exportObj ); |
|
480 |
|
481 exportObj->ExportL(); |
|
482 |
|
483 AddAsyncObjL(aCallBack->iTransactionId, exportObj ); |
|
484 |
|
485 CleanupStack::Pop( exportObj ); |
|
486 } |
|
487 |
|
488 // --------------------------------------------------------------------------- |
|
489 // Start Notification for changes in given calendar |
|
490 // --------------------------------------------------------------------------- |
|
491 // |
|
492 EXPORT_C void CCalendarService::StartChangeNotifyL( const TDesC& aCalendarName, CCalendarFilter* aFilter, MCalCallbackBase* aCallBack ) |
|
493 { |
|
494 if( !aCallBack || !aFilter ) |
|
495 User::Leave( KErrArgument ); |
|
496 |
|
497 CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
498 |
|
499 CCalendarObserver* obj = CCalendarObserver::NewL( sessionInfo, aFilter, iAsyncReqObserver, aCallBack ); |
|
500 |
|
501 CleanupStack::PushL( obj ); |
|
502 |
|
503 // notify in case of add/delete/update operation performed on calendar entries |
|
504 obj->StartChangeNotificationL(); |
|
505 |
|
506 AddAsyncObjL(aCallBack->iTransactionId, obj ); |
|
507 |
|
508 CleanupStack::Pop( obj ); |
|
509 |
|
510 } |
|
511 |
|
512 // --------------------------------------------------------------------------- |
|
513 // Adds asynchronous request object |
|
514 // --------------------------------------------------------------------------- |
|
515 // |
|
516 void CCalendarService::AddAsyncObjL( const TInt32 aTransactionId, CCalendarASyncRequest* aAsyncObj ) |
|
517 { |
|
518 iAsyncReqObserver->AddAsyncObjL( aTransactionId, aAsyncObj ); |
|
519 } |
|
520 |
|
521 // --------------------------------------------------------------------------- |
|
522 // Cancels asynchronous request |
|
523 // --------------------------------------------------------------------------- |
|
524 // |
|
525 EXPORT_C TInt CCalendarService::Cancel( const TInt32 aTransactionId ) |
|
526 { |
|
527 return iAsyncReqObserver->Cancel( aTransactionId ); |
|
528 } |
|
529 |
|
530 // --------------------------------------------------------------------------- |
|
531 // Returns Calendar session information for given calendar |
|
532 // --------------------------------------------------------------------------- |
|
533 // |
|
534 CCalendarSessionInfo* CCalendarService::CalendarSessionInfoL( const TDesC& aCalendar ) |
|
535 { |
|
536 // Return default session object if aCalendar is KNullDesC |
|
537 if ( ( iArraySessionInfo.Count() > 0 ) && ( aCalendar.Length() == 0 ) ) |
|
538 return iArraySessionInfo[KArrayZeroIndex]; |
|
539 |
|
540 TInt count = iArraySessionInfo.Count(); |
|
541 for( TInt index = 0; index < count; index++ ) |
|
542 { |
|
543 // Return session information of object corresponding to aCalendar |
|
544 if ( aCalendar.CompareF(iArraySessionInfo[index]->Calendar() ) == 0 ) |
|
545 return iArraySessionInfo[index]; |
|
546 } |
|
547 // If session object is not found, create new session object |
|
548 // and append to session info array |
|
549 CCalendarSessionInfo* sessionInfo = CCalendarSessionInfo::NewL( aCalendar ); |
|
550 CleanupStack::PushL( sessionInfo ); |
|
551 iArraySessionInfo.AppendL( sessionInfo ); |
|
552 CleanupStack::Pop( sessionInfo ); |
|
553 return sessionInfo; |
|
554 } |
|
555 |
|
556 // --------------------------------------------------------------------------- |
|
557 // Closes Calendar session for given calendar |
|
558 // --------------------------------------------------------------------------- |
|
559 // |
|
560 void CCalendarService::RemoveSessionInfo( const TDesC& aCalendar ) |
|
561 { |
|
562 TInt count = iArraySessionInfo.Count(); |
|
563 for( TInt index = 1; index < count; index++ ) |
|
564 { |
|
565 if( aCalendar.CompareF(iArraySessionInfo[index]->Calendar()) == 0 ) |
|
566 { |
|
567 // Remove session information for aCalendar and close session |
|
568 CCalendarSessionInfo* sessionInfo = iArraySessionInfo[index]; |
|
569 iArraySessionInfo.Remove( index ); |
|
570 iArraySessionInfo.Compress(); |
|
571 delete sessionInfo; |
|
572 break; |
|
573 } |
|
574 } |
|
575 } |