author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 17 Dec 2009 09:09:50 +0200 | |
changeset 26 | 5d0ec8b709be |
parent 23 | 50974a8b132e |
child 34 | 5dae2c62e9b6 |
permissions | -rw-r--r-- |
5 | 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 <calsession.h> |
|
21 |
#include <calinstance.h> |
|
22 |
#include <calentryview.h> |
|
23 |
#include <calinstanceview.h> |
|
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
24 |
#include <CalenInterimUtils2.h> |
5 | 25 |
#include <calrrule.h> |
26 |
#include <calalarm.h> |
|
27 |
#include <caluser.h> |
|
28 |
||
29 |
#include "calendarheader.h" |
|
30 |
#include "calendarconstants.h" |
|
31 |
#include "asyncreqobserver.h" |
|
32 |
#include "entryattributes.h" |
|
33 |
#include "addentry.h" |
|
34 |
||
35 |
||
36 |
void CleanupCCalEntryArray(TAny* aPointer); |
|
37 |
void CleanupCCalInstanceArray(TAny* aPointer); |
|
38 |
||
39 |
||
40 |
// --------------------------------------------------------------------------- |
|
41 |
// Two-phased constructor. |
|
42 |
// --------------------------------------------------------------------------- |
|
43 |
// |
|
44 |
CCalendarAddEntry* CCalendarAddEntry::NewL( CCalendarSessionInfo* aSessionInfo, |
|
45 |
CEntryAttributes* aCalendarData ) |
|
46 |
{ |
|
47 |
return new (ELeave) CCalendarAddEntry( aSessionInfo, aCalendarData ); |
|
48 |
} |
|
49 |
||
50 |
// --------------------------------------------------------------------------- |
|
51 |
// Destructor. |
|
52 |
// --------------------------------------------------------------------------- |
|
53 |
// |
|
54 |
CCalendarAddEntry::~CCalendarAddEntry() |
|
55 |
{ |
|
56 |
} |
|
57 |
||
58 |
// --------------------------------------------------------------------------- |
|
59 |
// Constructor |
|
60 |
// --------------------------------------------------------------------------- |
|
61 |
// |
|
62 |
CCalendarAddEntry::CCalendarAddEntry( CCalendarSessionInfo* aSessionInfo, |
|
63 |
CEntryAttributes* aCalendarData ): |
|
64 |
iSessionInfo( aSessionInfo ), |
|
65 |
iCalendarEntry( aCalendarData ) |
|
66 |
{ |
|
67 |
} |
|
68 |
||
69 |
// --------------------------------------------------------------------------- |
|
70 |
// CAddEntry::AddL |
|
71 |
// --------------------------------------------------------------------------- |
|
72 |
// |
|
73 |
void CCalendarAddEntry::AddL( TUIDSet*& aGuidAdded ) |
|
74 |
{ |
|
75 |
if ( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::ELocalUid ) |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
76 |
UpdateEntryL( aGuidAdded ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
77 |
else if( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EGlobalUid ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
78 |
UpdateEntryL( aGuidAdded ); |
5 | 79 |
else |
80 |
AddNewEntryL( aGuidAdded ); |
|
81 |
} |
|
82 |
||
83 |
// --------------------------------------------------------------------------- |
|
84 |
// CAddEntry::AddNewEntryL |
|
85 |
// --------------------------------------------------------------------------- |
|
86 |
// |
|
87 |
void CCalendarAddEntry::AddNewEntryL( TUIDSet*& aGuidAdded ) |
|
88 |
{ |
|
89 |
if ( !( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EEntryType )) |
|
90 |
User::Leave( KErrArgument ); |
|
91 |
||
92 |
CCalenInterimUtils2* interimUtils2 = CCalenInterimUtils2::NewL(); |
|
93 |
||
94 |
CleanupStack::PushL( interimUtils2 ); |
|
95 |
||
96 |
// Obtain a new global uid which is an ASCII string |
|
97 |
HBufC8* guid = interimUtils2->GlobalUidL(); |
|
98 |
||
99 |
CleanupStack::PopAndDestroy( interimUtils2 ); |
|
100 |
||
101 |
CCalEntry* newEntry = CCalEntry::NewL( iCalendarEntry->EntryType(), |
|
102 |
guid, iCalendarEntry->Method(), iCalendarEntry->SequenceNumber()); |
|
103 |
||
104 |
CleanupStack::PushL( newEntry ); |
|
105 |
||
106 |
if( !( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EStartTime && |
|
107 |
iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EEndTime ) && |
|
108 |
iCalendarEntry->EntryType() == CCalEntry::EAppt ) |
|
109 |
{ |
|
110 |
// For Appointment need to have both start and end time |
|
111 |
User::Leave( KErrArgument ); |
|
112 |
} |
|
113 |
||
114 |
else if ( ( iCalendarEntry->EntryType() == CCalEntry::EAnniv || |
|
115 |
iCalendarEntry->EntryType() == CCalEntry::EReminder ) ) |
|
116 |
{ |
|
117 |
// For Reminder and Anniversary need to have start time |
|
118 |
// End time can be set to same as start time |
|
119 |
if ( !(iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EStartTime) ) |
|
120 |
{ |
|
121 |
User::Leave( KErrArgument ); |
|
122 |
} |
|
123 |
else |
|
124 |
{ |
|
125 |
iCalendarEntry->SetEndTimeL(iCalendarEntry->StartTime().TimeUtcL()); |
|
126 |
} |
|
127 |
} |
|
128 |
||
129 |
else if ( iCalendarEntry->EntryType() == CCalEntry::EEvent ) |
|
130 |
{ |
|
131 |
// For Event need to have start time |
|
132 |
if ( !(iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EStartTime) ) |
|
133 |
{ |
|
134 |
User::Leave( KErrArgument ); |
|
135 |
} |
|
136 |
else if( !(iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EEndTime) ) |
|
137 |
{ |
|
138 |
iCalendarEntry->SetEndTimeL(iCalendarEntry->StartTime().TimeUtcL()); |
|
139 |
} |
|
140 |
} |
|
141 |
||
142 |
// For Todo both endtime and starttime are optional |
|
143 |
||
144 |
UpdateEntryAttributesL( newEntry ); |
|
145 |
||
146 |
//store the entry in the calendar file |
|
147 |
CCalenInterimUtils2::StoreL(*(iSessionInfo->EntryView()), *newEntry); |
|
148 |
||
149 |
aGuidAdded = new(ELeave) TUIDSet; |
|
150 |
CleanupStack::PushL( aGuidAdded ); |
|
151 |
aGuidAdded->iLocalUID = newEntry->LocalUidL();//local uid of the entry |
|
152 |
aGuidAdded->iGlobalUID = newEntry->UidL().AllocL();//global uid of the entry |
|
153 |
CleanupStack::Pop( aGuidAdded ); |
|
154 |
||
155 |
CleanupStack::PopAndDestroy( newEntry ); |
|
156 |
} |
|
157 |
||
158 |
||
159 |
||
160 |
||
161 |
// --------------------------------------------------------------------------- |
|
162 |
// CAddEntry::UpdateEntryL |
|
163 |
// --------------------------------------------------------------------------- |
|
164 |
// |
|
165 |
void CCalendarAddEntry::UpdateEntryL( TUIDSet*& aGuidAdded ) |
|
166 |
{ |
|
167 |
aGuidAdded = new(ELeave) TUIDSet; |
|
168 |
||
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
169 |
CleanupStack::PushL( aGuidAdded ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
170 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
171 |
TPtrC8 globaluid(KNullDesC8); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
172 |
globaluid.Set( iCalendarEntry->GlobalUid()); |
5 | 173 |
|
174 |
// Instance Modification as the instance start time has been specified |
|
175 |
if( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EInsStartTime ) |
|
176 |
{ |
|
177 |
if( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::ERepeatRule ) |
|
178 |
User::Leave( KErrArgument ); |
|
179 |
||
180 |
TCalTime instanceStTime = iCalendarEntry->InstanceStartTime(); |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
181 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
182 |
CCalInstance* instance; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
183 |
|
5 | 184 |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
185 |
// Fetch instance having start time and LocalUid specified and GlobalUid specified |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
186 |
if(iCalendarEntry->ModifiedAttributes() & CEntryAttributes::ELocalUid) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
187 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
188 |
instance = GetInstanceL( instanceStTime, iCalendarEntry->LocalUid() ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
189 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
190 |
else if(iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EGlobalUid) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
191 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
192 |
instance = GetGlobalInstanceL(instanceStTime, globaluid); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
193 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
194 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
195 |
///add code here |
5 | 196 |
|
197 |
if ( !instance ) |
|
198 |
User::Leave( KErrArgument ); |
|
199 |
||
200 |
CleanupStack::PushL( instance ); |
|
201 |
||
202 |
TTime inStTime = instanceStTime.TimeLocalL(); |
|
203 |
||
204 |
TCalTime instStTime; |
|
205 |
||
206 |
// if entry is of type appointment set instance start time tom fixed |
|
207 |
if( ( &instance->Entry() )->EntryTypeL() == CCalEntry::EAppt ) |
|
208 |
instStTime.SetTimeLocalL( inStTime ); |
|
209 |
// for other entry types set time mode to floating |
|
210 |
else |
|
211 |
instStTime.SetTimeLocalFloatingL( inStTime ); |
|
212 |
||
213 |
CCalEntry* parent = &instance->Entry(); |
|
214 |
||
215 |
TCalTime recId = parent->RecurrenceIdL(); |
|
216 |
||
217 |
TBool newModEntry = ( recId.TimeLocalL() == Time::NullTTime() ); |
|
218 |
||
219 |
CCalEntry* modifyingEntry = NULL; |
|
220 |
||
221 |
// If entry does not have a recurrence id, then it is the parent entry |
|
222 |
if ( newModEntry ) |
|
223 |
{ |
|
224 |
HBufC8* guid = parent->UidL().AllocL(); |
|
225 |
||
226 |
//Create a modifying entry |
|
227 |
modifyingEntry = CCalEntry::NewL( parent->EntryTypeL(), guid, |
|
228 |
iCalendarEntry->Method(), |
|
229 |
iCalendarEntry->SequenceNumber(), |
|
230 |
instStTime, |
|
231 |
CalCommon::EThisOnly); |
|
232 |
CleanupStack::PushL( modifyingEntry ); |
|
233 |
} |
|
234 |
else |
|
235 |
{ |
|
236 |
modifyingEntry = parent; |
|
237 |
} |
|
238 |
||
239 |
// Sets instance start and end time |
|
240 |
SetStartEndTimeL(modifyingEntry, instance->StartTimeL(), instance->EndTimeL() ); |
|
241 |
||
242 |
// Add new entry or update existing entry |
|
243 |
UpdateEntryAttributesL( modifyingEntry ); |
|
244 |
||
245 |
// If new modifying is created then update blank fields from parent entry |
|
246 |
if ( newModEntry ) |
|
247 |
CCalenInterimUtils2::PopulateChildFromParentL( *modifyingEntry, *parent ); |
|
248 |
||
249 |
// Store entry in calendar file |
|
250 |
CCalenInterimUtils2::StoreL( *iSessionInfo->EntryView(), *modifyingEntry, ETrue ); |
|
251 |
||
252 |
// Populate local and global uid fields |
|
253 |
aGuidAdded->iLocalUID = modifyingEntry->LocalUidL(); |
|
254 |
aGuidAdded->iGlobalUID = modifyingEntry->UidL().AllocL(); |
|
255 |
||
256 |
if ( newModEntry ) |
|
257 |
CleanupStack::PopAndDestroy( modifyingEntry ); |
|
258 |
||
259 |
CleanupStack::PopAndDestroy( instance ); |
|
260 |
} |
|
261 |
// Entry Modification |
|
262 |
else |
|
263 |
{ |
|
264 |
// Fetch entry to be modified |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
265 |
CCalEntry* entry ; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
266 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
267 |
if(iCalendarEntry->ModifiedAttributes() & CEntryAttributes::ELocalUid) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
268 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
269 |
entry = iSessionInfo->EntryView()->FetchL( iCalendarEntry->LocalUid() ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
270 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
271 |
else if(iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EGlobalUid) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
272 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
273 |
RPointerArray<CCalEntry> entryList; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
274 |
CleanupStack::PushL( TCleanupItem(CleanupCCalEntryArray, &entryList) ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
275 |
iSessionInfo->EntryView()->FetchL( globaluid, entryList); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
276 |
entry = entryList[0]; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
277 |
entryList[0] = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
278 |
CleanupStack::PopAndDestroy( &entryList ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
279 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
280 |
|
5 | 281 |
//Invalid LocalUID |
282 |
if( !entry ) |
|
283 |
User::Leave( KErrArgument ); |
|
284 |
||
285 |
CleanupStack::PushL( entry ); |
|
286 |
||
287 |
// Set entry's start and end time |
|
288 |
SetStartEndTimeL( entry, entry->StartTimeL(), entry->EndTimeL() ); |
|
289 |
||
290 |
// Update only those attributes which have new values |
|
291 |
UpdateEntryAttributesL( entry ); |
|
292 |
||
293 |
// Store the updated entry in calendar file |
|
294 |
CCalenInterimUtils2::StoreL( *iSessionInfo->EntryView(), *entry, ETrue ); |
|
295 |
||
296 |
// Populate and return global and local uids |
|
297 |
aGuidAdded->iLocalUID = entry->LocalUidL(); |
|
298 |
aGuidAdded->iGlobalUID = entry->UidL().AllocL(); |
|
299 |
||
300 |
CleanupStack::PopAndDestroy( entry ); |
|
301 |
} |
|
302 |
||
303 |
CleanupStack::Pop( aGuidAdded ); |
|
304 |
} |
|
305 |
||
306 |
// --------------------------------------------------------------------------- |
|
307 |
// CAddEntry::UpdateEntryAttributesL |
|
308 |
// Updates those attributes which have been set |
|
309 |
// --------------------------------------------------------------------------- |
|
310 |
// |
|
311 |
void CCalendarAddEntry::UpdateEntryAttributesL( CCalEntry* aEntry ) |
|
312 |
{ |
|
313 |
// Get the attributes which have been set by user |
|
314 |
TInt32 modifiedAttr = iCalendarEntry->ModifiedAttributes(); |
|
315 |
||
316 |
if( modifiedAttr & CEntryAttributes::ESummary ) |
|
317 |
{ |
|
318 |
aEntry->SetSummaryL( iCalendarEntry->Summary() );//set entry summary field |
|
319 |
} |
|
320 |
||
321 |
if( modifiedAttr & CEntryAttributes::EDescription ) |
|
322 |
{ |
|
323 |
aEntry->SetDescriptionL( iCalendarEntry->Description() );//set entry description field |
|
324 |
} |
|
325 |
||
326 |
if( modifiedAttr & CEntryAttributes::ELocation ) |
|
327 |
{ |
|
328 |
if ( aEntry->EntryTypeL() == CCalEntry::EAppt ) |
|
329 |
{ |
|
330 |
aEntry->SetLocationL( iCalendarEntry->Location() ); //set entry location field |
|
331 |
} |
|
332 |
else |
|
333 |
{ |
|
334 |
User::Leave( KErrArgument ); |
|
335 |
} |
|
336 |
} |
|
337 |
||
338 |
if( modifiedAttr & CEntryAttributes::EReplication ) |
|
339 |
{ |
|
340 |
aEntry->SetReplicationStatusL( iCalendarEntry->ReplicationStatus() ); //set entry replication status |
|
341 |
} |
|
342 |
||
343 |
if( modifiedAttr & CEntryAttributes::EPriority ) |
|
344 |
{ |
|
345 |
aEntry->SetPriorityL( iCalendarEntry->Priority() ); //set entry priority field |
|
346 |
} |
|
347 |
||
348 |
if( modifiedAttr & CEntryAttributes::EStatus ) |
|
349 |
{ |
|
350 |
if ( aEntry->EntryTypeL() == CCalEntry::EAppt || |
|
351 |
aEntry->EntryTypeL() == CCalEntry::ETodo ) |
|
352 |
{ |
|
353 |
aEntry->SetStatusL( iCalendarEntry->EntryStatus() );// set entry status field |
|
354 |
} |
|
355 |
else |
|
356 |
{ |
|
357 |
User::Leave( KErrArgument ); |
|
358 |
} |
|
359 |
} |
|
360 |
||
361 |
if( modifiedAttr & CEntryAttributes::EOrganizer ) |
|
362 |
{ |
|
363 |
if ( aEntry->EntryTypeL() == CCalEntry::EAppt ) |
|
364 |
{ |
|
365 |
CCalUser* caluser = CCalUser::NewL( iCalendarEntry->Organizer()->Address() ); |
|
366 |
CleanupStack::PushL( caluser ); |
|
367 |
caluser->SetCommonNameL( iCalendarEntry->Organizer()->CommonName() ); |
|
368 |
CleanupStack::Pop( caluser ); |
|
369 |
aEntry->SetOrganizerL( caluser ); // set organizer for appointment entry, entry takes ownership |
|
370 |
} |
|
371 |
else |
|
372 |
{ |
|
373 |
User::Leave( KErrArgument ); |
|
374 |
} |
|
375 |
} |
|
376 |
||
377 |
if( modifiedAttr & CEntryAttributes::EAttendees ) |
|
378 |
{ |
|
379 |
if ( aEntry->EntryTypeL() == CCalEntry::EAppt ) |
|
380 |
{ |
|
381 |
RPointerArray<CCalAttendee>& attendeeList = iCalendarEntry->AttendeeList(); |
|
382 |
||
383 |
for ( int i=0; i<attendeeList.Count(); i++ ) |
|
384 |
{ |
|
385 |
CCalAttendee* caluser = CCalAttendee::NewL( attendeeList[i]->Address() ); |
|
386 |
CleanupStack::PushL( caluser ); |
|
387 |
||
388 |
caluser->SetCommonNameL( attendeeList[i]->CommonName() ); |
|
389 |
caluser->SetRoleL( attendeeList[i]->RoleL() ); |
|
390 |
caluser->SetStatusL( attendeeList[i]->StatusL() ); |
|
391 |
caluser->SetResponseRequested( attendeeList[i]->ResponseRequested() ); |
|
392 |
||
393 |
CleanupStack::Pop( caluser ); |
|
394 |
aEntry->AddAttendeeL(caluser);// add attendee to appointment entry, entry takes ownership |
|
395 |
} |
|
396 |
} |
|
397 |
else |
|
398 |
{ |
|
399 |
User::Leave( KErrArgument ); |
|
400 |
} |
|
401 |
||
402 |
||
403 |
} |
|
404 |
||
405 |
if( modifiedAttr & CEntryAttributes::EPhoneOwner ) |
|
406 |
{ |
|
407 |
if ( aEntry->EntryTypeL() == CCalEntry::EAppt ) |
|
408 |
{ |
|
409 |
TBool ownerSet = EFalse; |
|
410 |
||
411 |
RPointerArray<CCalAttendee>& attendeeList = aEntry->AttendeesL(); |
|
412 |
||
413 |
for ( int i=0;i<attendeeList.Count();i++ ) |
|
414 |
{ |
|
415 |
// phone owner must match one of the attendees |
|
416 |
if( iCalendarEntry->PhoneOwner().CompareF( attendeeList[i]->Address() ) == 0 ) |
|
417 |
{ |
|
418 |
aEntry->SetPhoneOwnerL( attendeeList[i] ); //add phone owner to appointment entry |
|
419 |
ownerSet = ETrue; // entry takes ownership |
|
420 |
break; |
|
421 |
} |
|
422 |
} |
|
423 |
||
424 |
if( !ownerSet) |
|
425 |
{ |
|
426 |
User::Leave( KErrArgument ); |
|
427 |
} |
|
428 |
} |
|
429 |
else |
|
430 |
{ |
|
431 |
User::Leave( KErrArgument ); |
|
432 |
} |
|
433 |
} |
|
434 |
||
435 |
if( modifiedAttr & CEntryAttributes::ESeqNum ) |
|
436 |
{ |
|
437 |
if ( aEntry->EntryTypeL() == CCalEntry::EAppt ) |
|
438 |
{ |
|
439 |
aEntry->SetSequenceNumberL( iCalendarEntry->SequenceNumber() ); // set entry sequence number field |
|
440 |
} |
|
441 |
else |
|
442 |
{ |
|
443 |
User::Leave( KErrArgument ); |
|
444 |
} |
|
445 |
} |
|
446 |
||
447 |
if( modifiedAttr & CEntryAttributes::EMethod ) |
|
448 |
{ |
|
449 |
if ( aEntry->EntryTypeL() == CCalEntry::EAppt ) |
|
450 |
{ |
|
451 |
aEntry->SetMethodL( iCalendarEntry->Method() ); |
|
452 |
} |
|
453 |
else |
|
454 |
{ |
|
455 |
User::Leave( KErrArgument ); |
|
456 |
} |
|
457 |
} |
|
458 |
||
459 |
||
460 |
if( modifiedAttr & CEntryAttributes::EStartTime || modifiedAttr & CEntryAttributes::EEndTime ) |
|
461 |
{ |
|
462 |
if( aEntry->EntryTypeL() == CCalEntry::EAppt || |
|
463 |
aEntry->EntryTypeL() == CCalEntry::EEvent ) |
|
464 |
{ |
|
465 |
// Meeting needs to be Fixed time |
|
466 |
if( iCalendarEntry->StartTime().TimeLocalL() <= iCalendarEntry->EndTime().TimeLocalL() ) |
|
467 |
{ |
|
468 |
aEntry->SetStartAndEndTimeL( iCalendarEntry->StartTime(), iCalendarEntry->EndTime() ); |
|
469 |
} |
|
470 |
else |
|
471 |
{ |
|
472 |
User::Leave( KErrArgument ); |
|
473 |
} |
|
474 |
} |
|
475 |
||
476 |
else |
|
477 |
{ |
|
478 |
// Except Meeting all need to be floating time |
|
479 |
TCalTime startTime = iCalendarEntry->StartTime(); |
|
480 |
TCalTime endTime = iCalendarEntry->EndTime(); |
|
481 |
||
482 |
if( startTime.TimeLocalL() != Time::NullTTime() && endTime.TimeLocalL() != Time::NullTTime() ) |
|
483 |
{ |
|
484 |
if ( startTime.TimeLocalL() > endTime.TimeLocalL() ) |
|
485 |
{ |
|
486 |
User::Leave( KErrArgument ); |
|
487 |
} |
|
488 |
} |
|
489 |
||
490 |
startTime.SetTimeLocalFloatingL( startTime.TimeLocalL() ); |
|
491 |
endTime.SetTimeLocalFloatingL( endTime.TimeLocalL() ); |
|
492 |
||
493 |
aEntry->SetStartAndEndTimeL( startTime, endTime ); |
|
494 |
} |
|
495 |
} |
|
496 |
||
497 |
if( modifiedAttr & CEntryAttributes::EAlarmTime ) |
|
498 |
{ |
|
499 |
TTime alarmTime = iCalendarEntry->AlarmTime(); |
|
500 |
TTimeIntervalMinutes minutes; |
|
501 |
if ( alarmTime != Time::NullTTime() ) |
|
502 |
{ |
|
503 |
TDateTime alDtTime = alarmTime.DateTime(); |
|
504 |
alDtTime.SetSecond(0); |
|
505 |
alDtTime.SetMicroSecond(0); |
|
506 |
TTime alTime( alDtTime ); |
|
507 |
||
508 |
if ( aEntry->EntryTypeL() == CCalEntry::EAppt || aEntry->EntryTypeL() == CCalEntry::EReminder ) |
|
509 |
{ |
|
510 |
if( alarmTime > iCalendarEntry->StartTime().TimeUtcL() ) |
|
511 |
User::Leave( KErrNotSupported ); |
|
512 |
} |
|
513 |
||
514 |
else if( aEntry->EntryTypeL() == CCalEntry::EAnniv || aEntry->EntryTypeL() == CCalEntry::EEvent) |
|
515 |
{ |
|
516 |
TTime starttime = iCalendarEntry->StartTime().TimeUtcL(); |
|
517 |
TDateTime startdttime = starttime.DateTime(); |
|
518 |
startdttime.SetHour(0); |
|
519 |
startdttime.SetMinute(0); |
|
520 |
startdttime.SetSecond(0); |
|
521 |
startdttime.SetMicroSecond(0); |
|
522 |
TTime temp( startdttime ); |
|
523 |
temp = temp + TTimeIntervalDays(1); |
|
524 |
if( alarmTime >= temp ) |
|
525 |
User::Leave( KErrNotSupported ); |
|
526 |
} |
|
527 |
||
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
528 |
if( aEntry->EntryTypeL() != CCalEntry::ETodo ) |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
529 |
{ |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
530 |
TDateTime stTime; |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
531 |
stTime = aEntry->StartTimeL().TimeUtcL().DateTime(); |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
532 |
alTime.MinutesFrom( stTime, minutes );// calculate the offset between alarm time and start time |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
533 |
CCalAlarm* alarm = CCalAlarm::NewL(); |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
534 |
CleanupStack::PushL( alarm ); |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
535 |
alarm->SetTimeOffset(-minutes.Int()); |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
536 |
aEntry->SetAlarmL(alarm); // set the alarm for the entry |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
537 |
CleanupStack::PopAndDestroy( alarm ); |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
538 |
} |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
539 |
else |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
540 |
{ |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
541 |
TTime endTime; |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
542 |
endTime = aEntry->EndTimeL().TimeUtcL(); |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
543 |
if ( endTime != Time::NullTTime() ) |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
544 |
{ |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
545 |
alTime.MinutesFrom( endTime, minutes );// calculate the offset between alarm time and start time |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
546 |
if(minutes.Int() < 0 ) |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
547 |
{ |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
548 |
CCalAlarm* alarm = CCalAlarm::NewL(); |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
549 |
CleanupStack::PushL( alarm ); |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
550 |
alarm->SetTimeOffset(-minutes.Int()); |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
551 |
aEntry->SetAlarmL(alarm); // set the alarm for the entry |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
552 |
CleanupStack::PopAndDestroy( alarm ); |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
553 |
} |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
554 |
else |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
555 |
{ |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
556 |
User::Leave( KErrNotSupported ); |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
557 |
} |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
558 |
} |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
559 |
} |
5 | 560 |
} |
561 |
} |
|
562 |
||
563 |
TBool parentEntry = EFalse; |
|
564 |
||
565 |
if ( aEntry->RecurrenceIdL().TimeLocalL() == Time::NullTTime()) |
|
566 |
{ |
|
567 |
parentEntry = ETrue; |
|
568 |
} |
|
569 |
||
570 |
if( parentEntry ) |
|
571 |
{ |
|
572 |
if ( iCalendarEntry->RepeatRuleL().Type() != TCalRRule::EInvalid )// if repeat rule is valid |
|
573 |
{ |
|
574 |
if ( aEntry->EntryTypeL() == CCalEntry::EAppt || aEntry->EntryTypeL() == CCalEntry::EAnniv)// set rp rule st time to entry st time and calc st day for weekly repeat from entry's st time |
|
575 |
{ |
|
576 |
TCalTime sttime; |
|
577 |
if ( modifiedAttr & CEntryAttributes::ELocalUid ) |
|
578 |
{ |
|
579 |
CCalEntry* entry = iSessionInfo->EntryView()->FetchL( iCalendarEntry->LocalUid() ); |
|
580 |
if ( entry ) |
|
581 |
{ |
|
582 |
CleanupStack::PushL( entry ); |
|
583 |
sttime = entry->StartTimeL(); |
|
584 |
CleanupStack::PopAndDestroy( entry ); |
|
585 |
} |
|
586 |
else |
|
587 |
{ |
|
588 |
User::Leave( KErrArgument ); |
|
589 |
} |
|
590 |
} |
|
591 |
else |
|
592 |
{ |
|
593 |
sttime = iCalendarEntry->StartTime(); |
|
594 |
} |
|
595 |
if ( iCalendarEntry->RepeatRuleL().DtStart().TimeLocalL() == Time::NullTTime() ) |
|
596 |
{ |
|
597 |
iCalendarEntry->RepeatRuleL().SetDtStart( sttime ); |
|
598 |
} |
|
599 |
if ( iCalendarEntry->RepeatRuleL().Type() == TCalRRule::EWeekly ) |
|
600 |
{ |
|
601 |
RArray<TDay> weekDays; |
|
602 |
iCalendarEntry->RepeatRuleL().GetByDayL( weekDays ); |
|
603 |
if( weekDays.Count() == 0 ) |
|
604 |
{ |
|
605 |
weekDays.Reset(); |
|
606 |
weekDays.Append( TDay( sttime.TimeLocalL().DayNoInWeek() ) ); |
|
607 |
iCalendarEntry->RepeatRuleL().SetByDay( weekDays ); |
|
608 |
} |
|
609 |
weekDays.Close(); |
|
610 |
} |
|
611 |
||
612 |
else if ( iCalendarEntry->RepeatRuleL().Type() == TCalRRule::EMonthly ) |
|
613 |
{ |
|
614 |
RArray<TInt> monthDates; |
|
615 |
iCalendarEntry->RepeatRuleL().GetByMonthDayL( monthDates ); |
|
616 |
RArray<TCalRRule::TDayOfMonth> monthDays; |
|
617 |
iCalendarEntry->RepeatRuleL().GetByDayL( monthDays ); |
|
618 |
||
619 |
if( monthDates.Count() > 0 && monthDays.Count() > 0 ) |
|
620 |
{ |
|
621 |
User::Leave( KErrArgument ); |
|
622 |
} |
|
623 |
if( monthDates.Count() == 0 && monthDays.Count() == 0 ) |
|
624 |
{ |
|
625 |
monthDates.Reset(); |
|
626 |
monthDates.Append( sttime.TimeLocalL().DayNoInMonth() ); |
|
627 |
iCalendarEntry->RepeatRuleL().SetByMonthDay( monthDates ); |
|
628 |
} |
|
629 |
monthDays.Close(); |
|
630 |
monthDates.Close(); |
|
631 |
} |
|
632 |
||
633 |
aEntry->SetRRuleL(iCalendarEntry->RepeatRuleL()); |
|
634 |
} |
|
635 |
else |
|
636 |
{ |
|
637 |
User::Leave( KErrArgument ); |
|
638 |
} |
|
639 |
} |
|
640 |
} |
|
641 |
||
642 |
if( ( modifiedAttr & CEntryAttributes::ERepeatDates ) && parentEntry ) // only parent entry can have repeat dates |
|
643 |
{ |
|
644 |
if ( aEntry->EntryTypeL() == CCalEntry::EAppt ) |
|
645 |
{ |
|
646 |
aEntry->SetRDatesL( iCalendarEntry->RepeatDates() ); |
|
647 |
} |
|
648 |
else |
|
649 |
{ |
|
650 |
User::Leave( KErrArgument ); |
|
651 |
} |
|
652 |
} |
|
653 |
||
654 |
||
655 |
||
656 |
if( ( modifiedAttr & CEntryAttributes::EExDates ) && parentEntry )// only parent entry can have exception dates |
|
657 |
{ |
|
658 |
if ( aEntry->EntryTypeL() == CCalEntry::EAppt ) |
|
659 |
{ |
|
660 |
aEntry->SetExceptionDatesL( iCalendarEntry->ExceptionDates() ); |
|
661 |
} |
|
662 |
else |
|
663 |
{ |
|
664 |
User::Leave( KErrArgument ); |
|
665 |
} |
|
666 |
} |
|
667 |
} |
|
668 |
||
669 |
// --------------------------------------------------------------------------- |
|
670 |
// CCalendarAddEntry::GetInstanceL |
|
671 |
// Retrieves the Instance for the given local Uid |
|
672 |
// --------------------------------------------------------------------------- |
|
673 |
// |
|
674 |
CCalInstance* CCalendarAddEntry::GetInstanceL( const TCalTime& aInsStTime, |
|
675 |
TCalLocalUid aLUid ) |
|
676 |
{ |
|
677 |
CCalInstance* instance = NULL; |
|
678 |
||
679 |
RPointerArray<CCalInstance> insArray( KArrayGran ); |
|
680 |
||
681 |
CleanupStack::PushL( TCleanupItem(CleanupCCalInstanceArray, &insArray) ); |
|
682 |
||
683 |
// Find instance having the instance start time specified |
|
684 |
iSessionInfo->InstanceView()->FindInstanceL(insArray, CalCommon::EIncludeAll, |
|
685 |
CalCommon::TCalTimeRange(aInsStTime, aInsStTime)); |
|
686 |
||
687 |
TInt count = insArray.Count(); |
|
688 |
||
689 |
for( TInt index = 0 ; index < count; index++ ) |
|
690 |
{ |
|
691 |
if ( insArray[index]->Entry().LocalUidL() == aLUid ) |
|
692 |
{ |
|
693 |
instance = insArray[index]; |
|
694 |
insArray[index] = NULL; |
|
695 |
break; |
|
696 |
} |
|
697 |
} |
|
698 |
CleanupStack::PopAndDestroy( &insArray ); |
|
699 |
||
700 |
return instance; |
|
701 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
702 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
703 |
// CCalendarAddEntry::GetGlobalInstanceL |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
704 |
// Retrieves the Instance for the given global Uid |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
705 |
// --------------------------------------------------------------------------- |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
706 |
// |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
707 |
CCalInstance* CCalendarAddEntry::GetGlobalInstanceL( const TCalTime& aInsStTime, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
708 |
const TDesC8& aUid ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
709 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
710 |
CCalInstance* instance = NULL; |
5 | 711 |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
712 |
RPointerArray<CCalInstance> insArray( KArrayGran ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
713 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
714 |
CleanupStack::PushL( TCleanupItem(CleanupCCalInstanceArray, &insArray) ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
715 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
716 |
// Find instance having the instance start time specified |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
717 |
iSessionInfo->InstanceView()->FindInstanceL(insArray, CalCommon::EIncludeAll, |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
718 |
CalCommon::TCalTimeRange(aInsStTime, aInsStTime)); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
719 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
720 |
TInt count = insArray.Count(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
721 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
722 |
for( TInt index = 0 ; index < count; index++ ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
723 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
724 |
if ( insArray[index]->Entry().UidL() == aUid ) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
725 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
726 |
instance = insArray[index]; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
727 |
insArray[index] = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
728 |
break; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
729 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
730 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
731 |
CleanupStack::PopAndDestroy( &insArray ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
732 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
733 |
return instance; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
734 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
735 |
} |
5 | 736 |
// --------------------------------------------------------------------------- |
737 |
// CCalendarAddEntry::SetStartEndTimeL |
|
738 |
// Set instance start and end time |
|
739 |
// --------------------------------------------------------------------------- |
|
740 |
// |
|
741 |
void CCalendarAddEntry::SetStartEndTimeL( CCalEntry* aEntry, const TCalTime& aStTime, const TCalTime& aEndTime ) |
|
742 |
{ |
|
743 |
if( aEntry->EntryTypeL() == CCalEntry::EEvent || aEntry->EntryTypeL() == CCalEntry::EReminder || |
|
744 |
aEntry->EntryTypeL() == CCalEntry::EAnniv ) |
|
745 |
{ |
|
746 |
//if start time is not specified for instance, it is taken from parent |
|
747 |
if ( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EStartTime ) |
|
748 |
{ |
|
749 |
iCalendarEntry->SetEndTimeL( iCalendarEntry->StartTime().TimeUtcL() ); |
|
750 |
} |
|
751 |
else |
|
752 |
{ |
|
753 |
iCalendarEntry->SetStartTimeL( aStTime.TimeUtcL() ); |
|
754 |
iCalendarEntry->SetEndTimeL( aStTime.TimeUtcL() ); |
|
755 |
} |
|
756 |
} |
|
757 |
||
758 |
||
759 |
//if end time is not specified for instance, it is taken from parent |
|
760 |
else if ( aEntry->EntryTypeL() == CCalEntry::ETodo ) |
|
761 |
{ |
|
762 |
if ( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EEndTime ) |
|
763 |
{ |
|
764 |
iCalendarEntry->SetStartTimeL( iCalendarEntry->EndTime().TimeUtcL() ); |
|
765 |
} |
|
766 |
else |
|
767 |
{ |
|
768 |
iCalendarEntry->SetStartTimeL( aEndTime.TimeUtcL() ); |
|
769 |
iCalendarEntry->SetEndTimeL( aEndTime.TimeUtcL() ); |
|
770 |
} |
|
771 |
} |
|
772 |
||
773 |
// both start and end time need to be specified for instance whose entry type is an appointment, else they are taken from parent |
|
774 |
else if ( aEntry->EntryTypeL() == CCalEntry::EAppt ) |
|
775 |
{ |
|
776 |
if ( !( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EStartTime || |
|
777 |
iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EEndTime ) ) |
|
778 |
{ |
|
779 |
// No time set |
|
780 |
iCalendarEntry->SetStartTimeL( aStTime.TimeUtcL() ); |
|
781 |
iCalendarEntry->SetEndTimeL( aEndTime.TimeUtcL() ); |
|
782 |
} |
|
783 |
else if(!( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EStartTime )) |
|
784 |
{ |
|
785 |
// Set End time |
|
786 |
iCalendarEntry->SetStartTimeL( aStTime.TimeUtcL() ); |
|
787 |
} |
|
788 |
else if(!( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EEndTime )) |
|
789 |
{ |
|
790 |
// Set Start time |
|
791 |
iCalendarEntry->SetEndTimeL( aEndTime.TimeUtcL() ); |
|
792 |
} |
|
793 |
} |
|
794 |
} |