author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 22 | fc9cf246af83 |
permissions | -rw-r--r-- |
19 | 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" |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
31 |
#include "calendarnotify.h" |
19 | 32 |
#include "calendardeleteentry.h" |
33 |
#include "calendarimport.h" |
|
34 |
#include "calendarexport.h" |
|
35 |
#include "addentry.h" |
|
36 |
#include "asyncreqobserver.h" |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
37 |
#include "calendargetlist.h" |
19 | 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 |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
209 |
CCalendarGetList* getlistObj = CCalendarGetList::NewL( sessionInfo, aGuid ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
210 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
211 |
CleanupStack::PushL( getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
212 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
213 |
getlistObj->GetListL( aGuid, aEntryList ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
214 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
215 |
CleanupStack::PopAndDestroy( getlistObj ); |
19 | 216 |
} |
217 |
||
218 |
// --------------------------------------------------------------------------- |
|
219 |
// Returns list of calendar entries from given calendar with the given Local UID. |
|
220 |
// --------------------------------------------------------------------------- |
|
221 |
// |
|
222 |
EXPORT_C void CCalendarService::GetListL( const TDesC& aCalendarName, const TCalLocalUid aLocalUid, RPointerArray<CCalEntry>& aEntryList) |
|
223 |
{ |
|
224 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
225 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
226 |
CCalendarGetList* getlistObj = CCalendarGetList::NewL( sessionInfo, aLocalUid ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
227 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
228 |
CleanupStack::PushL( getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
229 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
230 |
getlistObj->GetListL( aLocalUid, aEntryList ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
231 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
232 |
CleanupStack::PopAndDestroy( getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
233 |
|
19 | 234 |
} |
235 |
||
236 |
// --------------------------------------------------------------------------- |
|
237 |
// Returns list of calendar instances from given calendar based on input filter. |
|
238 |
// --------------------------------------------------------------------------- |
|
239 |
// |
|
240 |
EXPORT_C void CCalendarService::GetListL( const TDesC& aCalendarName, CCalendarFilter* aFilter, |
|
241 |
RPointerArray<CCalInstance>& aInstanceList ) |
|
242 |
{ |
|
243 |
if ( !aFilter ) |
|
244 |
User::Leave( KErrArgument ); |
|
245 |
||
246 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
247 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
248 |
CCalendarGetList* getlistObj = CCalendarGetList::NewL( sessionInfo, aFilter ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
249 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
250 |
CleanupStack::PushL( getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
251 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
252 |
getlistObj->GetListL( aInstanceList ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
253 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
254 |
CleanupStack::PopAndDestroy( getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
255 |
|
19 | 256 |
} |
257 |
||
258 |
// --------------------------------------------------------------------------- |
|
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
259 |
// Returns list of calendar instances from given calendar based on input filter and callback. |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
260 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
261 |
// |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
262 |
EXPORT_C void CCalendarService::GetListL( const TDesC& aCalendarName, CCalendarFilter* aFilter, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
263 |
MCalCallbackBase* aCallBack ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
264 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
265 |
if ( !aFilter ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
266 |
User::Leave( KErrArgument ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
267 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
268 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
269 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
270 |
//Instantiate the getlist CoreClass Object |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
271 |
CCalendarGetList* getlistObj = CCalendarGetList::NewL( sessionInfo, aFilter, iAsyncReqObserver, aCallBack ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
272 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
273 |
//Push the GetlistObject onto the cleanup stack as the getlist function can Leave |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
274 |
CleanupStack::PushL( getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
275 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
276 |
getlistObj->GetListL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
277 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
278 |
AddAsyncObjL( aCallBack->iTransactionId, getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
279 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
280 |
CleanupStack::Pop( getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
281 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
282 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
283 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
284 |
// Returns list of calendar entries from given calendar with the given Global UID. |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
285 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
286 |
// |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
287 |
EXPORT_C void CCalendarService::GetListL( const TDesC& aCalendarName, const TDesC8& aGuid, MCalCallbackBase* aCallBack) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
288 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
289 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
290 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
291 |
CCalendarGetList* getlistObj = CCalendarGetList::NewL( sessionInfo, aGuid, iAsyncReqObserver, aCallBack ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
292 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
293 |
CleanupStack::PushL( getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
294 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
295 |
getlistObj->GetListL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
296 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
297 |
AddAsyncObjL( aCallBack->iTransactionId, getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
298 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
299 |
CleanupStack::Pop( getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
300 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
301 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
302 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
303 |
// Returns list of calendar entries from given calendar with the given Local UID. |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
304 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
305 |
// |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
306 |
EXPORT_C void CCalendarService::GetListL( const TDesC& aCalendarName, const TCalLocalUid aLocalUid, MCalCallbackBase* aCallBack) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
307 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
308 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
309 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
310 |
CCalendarGetList* getlistObj = CCalendarGetList::NewL( sessionInfo, aLocalUid, iAsyncReqObserver, aCallBack ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
311 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
312 |
CleanupStack::PushL( getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
313 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
314 |
getlistObj->GetListL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
315 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
316 |
AddAsyncObjL( aCallBack->iTransactionId, getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
317 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
318 |
CleanupStack::Pop( getlistObj ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
319 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
320 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
321 |
// --------------------------------------------------------------------------- |
19 | 322 |
// Adds new calendar |
323 |
// --------------------------------------------------------------------------- |
|
324 |
// |
|
325 |
EXPORT_C void CCalendarService::AddL( const TDesC& aCalendarName ) |
|
326 |
{ |
|
327 |
//Create a new calendar file using the existing session object |
|
328 |
iArraySessionInfo[KArrayZeroIndex]->Session()->CreateCalFileL( aCalendarName ); |
|
329 |
} |
|
330 |
||
331 |
// --------------------------------------------------------------------------- |
|
332 |
// Add |
|
333 |
// --------------------------------------------------------------------------- |
|
334 |
// |
|
335 |
EXPORT_C void CCalendarService::AddL( const TDesC& aCalendarName, |
|
336 |
CEntryAttributes* aCalendarData, TUIDSet*& aUidAdded ) |
|
337 |
{ |
|
338 |
if ( !aCalendarData ) |
|
339 |
User::Leave( KErrArgument ); |
|
340 |
||
341 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
342 |
CCalendarAddEntry* obj = CCalendarAddEntry::NewL( sessionInfo, aCalendarData ); |
|
343 |
CleanupStack::PushL( obj ); |
|
344 |
obj->AddL( aUidAdded ); |
|
345 |
CleanupStack::PopAndDestroy( obj ); |
|
346 |
} |
|
347 |
||
348 |
// --------------------------------------------------------------------------- |
|
349 |
// Remove calendar from the device. Deletion of defaut calendar is not supported |
|
350 |
// --------------------------------------------------------------------------- |
|
351 |
// |
|
352 |
EXPORT_C void CCalendarService::DeleteL( const TDesC& aCalendarName ) |
|
353 |
{ |
|
354 |
if ( aCalendarName.CompareF(iArraySessionInfo[KArrayZeroIndex]->Calendar()) != 0 ) |
|
355 |
{ |
|
356 |
RemoveSessionInfo( aCalendarName ); |
|
357 |
iArraySessionInfo[KArrayZeroIndex]->Session()->DeleteCalFileL( aCalendarName ); |
|
358 |
} |
|
359 |
else |
|
360 |
{ |
|
361 |
User::Leave( KErrNotSupported ); |
|
362 |
} |
|
363 |
} |
|
364 |
||
365 |
// --------------------------------------------------------------------------- |
|
366 |
// Remove entries from the given calendar based on input filter |
|
367 |
// --------------------------------------------------------------------------- |
|
368 |
// |
|
369 |
EXPORT_C void CCalendarService::DeleteL( const TDesC& aCalendarName, CCalendarFilter* aFilter, MCalCallbackBase* aCallBack ) |
|
370 |
{ |
|
371 |
if ( !aFilter ) |
|
372 |
User::Leave( KErrArgument ); |
|
373 |
||
374 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
375 |
||
376 |
//Instantiate the Delete Class Object |
|
377 |
CCalendarDeleteEntry* obj = CCalendarDeleteEntry::NewL( sessionInfo, aFilter, iAsyncReqObserver, aCallBack); |
|
378 |
||
379 |
CleanupStack::PushL( obj ); |
|
380 |
||
381 |
// Call the appropriate version of delete depending on input |
|
382 |
obj->DeleteL(); |
|
383 |
||
384 |
if ( aCallBack ) |
|
385 |
{ |
|
386 |
AddAsyncObjL(aCallBack->iTransactionId, obj ); |
|
387 |
CleanupStack::Pop( obj ); |
|
388 |
} |
|
389 |
else |
|
390 |
CleanupStack::PopAndDestroy( obj ); |
|
391 |
} |
|
392 |
||
393 |
// --------------------------------------------------------------------------- |
|
394 |
// ImportL: This is the Synchronous version of Import which imports all the |
|
395 |
// entries in the format specified from the Calendar |
|
396 |
// --------------------------------------------------------------------------- |
|
397 |
// |
|
398 |
EXPORT_C void CCalendarService::ImportL( const TDesC& aCalendarName, |
|
399 |
const TDesC8& aFormat, |
|
400 |
const TDesC8& aInputBuffer, |
|
401 |
RPointerArray<TUIDSet>& aUIDSet ) |
|
402 |
{ |
|
403 |
//Step 1: get the session |
|
404 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
405 |
||
406 |
//Step 2: Instantiate the Import CoreClass Object |
|
407 |
CCalendarImport* importObj = CCalendarImport::NewL( sessionInfo, aFormat, aInputBuffer ); |
|
408 |
||
409 |
//Step 3: Push the ImportObject onto the cleanup stack as the Import function can Leave |
|
410 |
CleanupStack::PushL( importObj ); |
|
411 |
||
412 |
//Step 4: Call the Import along side the handle to the Output i.e.., aUIDSet |
|
413 |
importObj->ImportL( aUIDSet ); |
|
414 |
||
415 |
//Step 5: Destroy the Object as the processing is done |
|
416 |
CleanupStack::PopAndDestroy( importObj ); |
|
417 |
} |
|
418 |
||
419 |
// --------------------------------------------------------------------------- |
|
420 |
// ImportL: This is the Synchronous version of Import which imports all the |
|
421 |
// entries in the format specified from the Calendar |
|
422 |
// --------------------------------------------------------------------------- |
|
423 |
// |
|
424 |
EXPORT_C void CCalendarService::ImportL( const TDesC& aCalendarName, |
|
425 |
const TDesC8& aFormat, |
|
426 |
const TDesC& aImportFile, |
|
427 |
RPointerArray<TUIDSet>& aUIDSet ) |
|
428 |
{ |
|
429 |
//Step 1: get the session |
|
430 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
431 |
||
432 |
//Step 2: Instantiate the Import CoreClass Object |
|
433 |
CCalendarImport* importObj = CCalendarImport::NewL( sessionInfo, aFormat, aImportFile ); |
|
434 |
||
435 |
//Step 3: Push the ImportObject onto the cleanup stack as the Import function can Leave |
|
436 |
CleanupStack::PushL( importObj ); |
|
437 |
||
438 |
//Step 4: Call the Import along side the handle to the Output i.e.., aUIDSet |
|
439 |
importObj->ImportL( aUIDSet ); |
|
440 |
||
441 |
//Step 5: Destroy the Object as the processing is done |
|
442 |
CleanupStack::PopAndDestroy( importObj ); |
|
443 |
} |
|
444 |
||
445 |
// ----------------------------------------------------------------------------- |
|
446 |
// ImportAsyncL: This is the Asynchronous version of Import which imports all the |
|
447 |
// entries in the format specified to the Calendar |
|
448 |
// ------------------------------------------------------------------------------ |
|
449 |
// |
|
450 |
EXPORT_C void CCalendarService::ImportL( const TDesC& aCalendarName, |
|
451 |
const TDesC8& aFormat, |
|
452 |
const TDesC8& aInputBuffer, |
|
453 |
MCalCallbackBase* aCallBack ) |
|
454 |
{ |
|
455 |
//get the session |
|
456 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
457 |
||
458 |
//Instantiate the Import CoreClass Object |
|
459 |
CCalendarImport* importObj = CCalendarImport::NewL( sessionInfo, aFormat, aInputBuffer, iAsyncReqObserver, aCallBack ); |
|
460 |
||
461 |
//Push the ImportObject onto the cleanup stack as the Import function can Leave |
|
462 |
CleanupStack::PushL( importObj ); |
|
463 |
||
464 |
importObj->ImportL(); |
|
465 |
||
466 |
AddAsyncObjL( aCallBack->iTransactionId, importObj ); |
|
467 |
||
468 |
CleanupStack::Pop( importObj ); |
|
469 |
} |
|
470 |
||
471 |
// ----------------------------------------------------------------------------- |
|
472 |
// ImportAsyncL: This is the Asynchronous version of Import which imports all the |
|
473 |
// entries in the format specified to the Calendar |
|
474 |
// ------------------------------------------------------------------------------ |
|
475 |
// |
|
476 |
EXPORT_C void CCalendarService::ImportL( const TDesC& aCalendarName, |
|
477 |
const TDesC8& aFormat, |
|
478 |
const TDesC& aImportFile, |
|
479 |
MCalCallbackBase* aCallBack ) |
|
480 |
{ |
|
481 |
//get the session |
|
482 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
483 |
||
484 |
//Instantiate the Import CoreClass Object |
|
485 |
CCalendarImport* importObj = CCalendarImport::NewL( sessionInfo, aFormat, aImportFile, iAsyncReqObserver, aCallBack ); |
|
486 |
||
487 |
//Push the ImportObject onto the cleanup stack as the Import function can Leave |
|
488 |
CleanupStack::PushL( importObj ); |
|
489 |
||
490 |
importObj->ImportL(); |
|
491 |
||
492 |
AddAsyncObjL( aCallBack->iTransactionId, importObj ); |
|
493 |
||
494 |
CleanupStack::Pop( importObj ); |
|
495 |
} |
|
496 |
||
497 |
||
498 |
||
499 |
// --------------------------------------------------------------------------- |
|
500 |
// ExportL: This is the Synchronous Version which exports all the entries of |
|
501 |
// Calendar in the Specified format |
|
502 |
// --------------------------------------------------------------------------- |
|
503 |
// |
|
504 |
EXPORT_C void CCalendarService::ExportL( const TDesC& aCalendarName, |
|
505 |
const TDesC8& aFormat, |
|
506 |
CCalendarExportParams* aParams, |
|
507 |
HBufC8*& aOutputBuffer ) |
|
508 |
{ |
|
509 |
if( !aParams ) |
|
510 |
User::Leave( KErrArgument ); |
|
511 |
||
512 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
513 |
||
514 |
CCalendarExport* exportObj = CCalendarExport::NewL( sessionInfo, aFormat, aParams ); |
|
515 |
||
516 |
CleanupStack::PushL( exportObj ); |
|
517 |
||
518 |
exportObj->ExportL( aOutputBuffer ); |
|
519 |
||
520 |
CleanupStack::PopAndDestroy( exportObj ); |
|
521 |
} |
|
522 |
||
523 |
||
524 |
// --------------------------------------------------------------------------- |
|
525 |
// ExportAsyncL: This is the Asynchronous Version which exports all the entries of |
|
526 |
// Calendar in the Specified format |
|
527 |
// --------------------------------------------------------------------------- |
|
528 |
// |
|
529 |
EXPORT_C void CCalendarService::ExportL( const TDesC& aCalendarName, |
|
530 |
const TDesC8& aFormat, |
|
531 |
CCalendarExportParams* aParams, |
|
532 |
MCalCallbackBase* aCallBack ) |
|
533 |
{ |
|
534 |
if( !aParams ) |
|
535 |
User::Leave( KErrArgument ); |
|
536 |
||
537 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
538 |
||
539 |
CCalendarExport* exportObj = CCalendarExport::NewL( sessionInfo, aFormat, aParams, iAsyncReqObserver, aCallBack ); |
|
540 |
||
541 |
CleanupStack::PushL( exportObj ); |
|
542 |
||
543 |
exportObj->ExportL(); |
|
544 |
||
545 |
AddAsyncObjL(aCallBack->iTransactionId, exportObj ); |
|
546 |
||
547 |
CleanupStack::Pop( exportObj ); |
|
548 |
} |
|
549 |
||
550 |
// --------------------------------------------------------------------------- |
|
551 |
// Start Notification for changes in given calendar |
|
552 |
// --------------------------------------------------------------------------- |
|
553 |
// |
|
554 |
EXPORT_C void CCalendarService::StartChangeNotifyL( const TDesC& aCalendarName, CCalendarFilter* aFilter, MCalCallbackBase* aCallBack ) |
|
555 |
{ |
|
556 |
if( !aCallBack || !aFilter ) |
|
557 |
User::Leave( KErrArgument ); |
|
558 |
||
559 |
CCalendarSessionInfo* sessionInfo = CalendarSessionInfoL( aCalendarName ); |
|
560 |
||
561 |
CCalendarObserver* obj = CCalendarObserver::NewL( sessionInfo, aFilter, iAsyncReqObserver, aCallBack ); |
|
562 |
||
563 |
CleanupStack::PushL( obj ); |
|
564 |
||
565 |
// notify in case of add/delete/update operation performed on calendar entries |
|
566 |
obj->StartChangeNotificationL(); |
|
567 |
||
568 |
AddAsyncObjL(aCallBack->iTransactionId, obj ); |
|
569 |
||
570 |
CleanupStack::Pop( obj ); |
|
571 |
||
572 |
} |
|
573 |
||
574 |
// --------------------------------------------------------------------------- |
|
575 |
// Adds asynchronous request object |
|
576 |
// --------------------------------------------------------------------------- |
|
577 |
// |
|
578 |
void CCalendarService::AddAsyncObjL( const TInt32 aTransactionId, CCalendarASyncRequest* aAsyncObj ) |
|
579 |
{ |
|
580 |
iAsyncReqObserver->AddAsyncObjL( aTransactionId, aAsyncObj ); |
|
581 |
} |
|
582 |
||
583 |
// --------------------------------------------------------------------------- |
|
584 |
// Cancels asynchronous request |
|
585 |
// --------------------------------------------------------------------------- |
|
586 |
// |
|
587 |
EXPORT_C TInt CCalendarService::Cancel( const TInt32 aTransactionId ) |
|
588 |
{ |
|
589 |
return iAsyncReqObserver->Cancel( aTransactionId ); |
|
590 |
} |
|
591 |
||
592 |
// --------------------------------------------------------------------------- |
|
593 |
// Returns Calendar session information for given calendar |
|
594 |
// --------------------------------------------------------------------------- |
|
595 |
// |
|
596 |
CCalendarSessionInfo* CCalendarService::CalendarSessionInfoL( const TDesC& aCalendar ) |
|
597 |
{ |
|
598 |
// Return default session object if aCalendar is KNullDesC |
|
599 |
if ( ( iArraySessionInfo.Count() > 0 ) && ( aCalendar.Length() == 0 ) ) |
|
600 |
return iArraySessionInfo[KArrayZeroIndex]; |
|
601 |
||
602 |
TInt count = iArraySessionInfo.Count(); |
|
603 |
for( TInt index = 0; index < count; index++ ) |
|
604 |
{ |
|
605 |
// Return session information of object corresponding to aCalendar |
|
606 |
if ( aCalendar.CompareF(iArraySessionInfo[index]->Calendar() ) == 0 ) |
|
607 |
return iArraySessionInfo[index]; |
|
608 |
} |
|
609 |
// If session object is not found, create new session object |
|
610 |
// and append to session info array |
|
611 |
CCalendarSessionInfo* sessionInfo = CCalendarSessionInfo::NewL( aCalendar ); |
|
612 |
CleanupStack::PushL( sessionInfo ); |
|
613 |
iArraySessionInfo.AppendL( sessionInfo ); |
|
614 |
CleanupStack::Pop( sessionInfo ); |
|
615 |
return sessionInfo; |
|
616 |
} |
|
617 |
||
618 |
// --------------------------------------------------------------------------- |
|
619 |
// Closes Calendar session for given calendar |
|
620 |
// --------------------------------------------------------------------------- |
|
621 |
// |
|
622 |
void CCalendarService::RemoveSessionInfo( const TDesC& aCalendar ) |
|
623 |
{ |
|
624 |
TInt count = iArraySessionInfo.Count(); |
|
625 |
for( TInt index = 1; index < count; index++ ) |
|
626 |
{ |
|
627 |
if( aCalendar.CompareF(iArraySessionInfo[index]->Calendar()) == 0 ) |
|
628 |
{ |
|
629 |
// Remove session information for aCalendar and close session |
|
630 |
CCalendarSessionInfo* sessionInfo = iArraySessionInfo[index]; |
|
631 |
iArraySessionInfo.Remove( index ); |
|
632 |
iArraySessionInfo.Compress(); |
|
633 |
delete sessionInfo; |
|
634 |
break; |
|
635 |
} |
|
636 |
} |
|
637 |
} |