71 // --------------------------------------------------------------------------- |
71 // --------------------------------------------------------------------------- |
72 // |
72 // |
73 void CCalendarAddEntry::AddL( TUIDSet*& aGuidAdded ) |
73 void CCalendarAddEntry::AddL( TUIDSet*& aGuidAdded ) |
74 { |
74 { |
75 if ( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::ELocalUid ) |
75 if ( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::ELocalUid ) |
76 UpdateEntryL( aGuidAdded ); |
76 UpdateEntryL( aGuidAdded ); |
|
77 else if( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EGlobalUid ) |
|
78 UpdateEntryL( aGuidAdded ); |
77 else |
79 else |
78 AddNewEntryL( aGuidAdded ); |
80 AddNewEntryL( aGuidAdded ); |
79 } |
81 } |
80 |
82 |
81 // --------------------------------------------------------------------------- |
83 // --------------------------------------------------------------------------- |
162 // |
164 // |
163 void CCalendarAddEntry::UpdateEntryL( TUIDSet*& aGuidAdded ) |
165 void CCalendarAddEntry::UpdateEntryL( TUIDSet*& aGuidAdded ) |
164 { |
166 { |
165 aGuidAdded = new(ELeave) TUIDSet; |
167 aGuidAdded = new(ELeave) TUIDSet; |
166 |
168 |
167 CleanupStack::PushL( aGuidAdded ); |
169 CleanupStack::PushL( aGuidAdded ); |
|
170 |
|
171 TPtrC8 globaluid(KNullDesC8); |
|
172 globaluid.Set( iCalendarEntry->GlobalUid()); |
168 |
173 |
169 // Instance Modification as the instance start time has been specified |
174 // Instance Modification as the instance start time has been specified |
170 if( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EInsStartTime ) |
175 if( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EInsStartTime ) |
171 { |
176 { |
172 if( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::ERepeatRule ) |
177 if( iCalendarEntry->ModifiedAttributes() & CEntryAttributes::ERepeatRule ) |
173 User::Leave( KErrArgument ); |
178 User::Leave( KErrArgument ); |
174 |
179 |
175 TCalTime instanceStTime = iCalendarEntry->InstanceStartTime(); |
180 TCalTime instanceStTime = iCalendarEntry->InstanceStartTime(); |
176 |
181 |
177 // Fetch instance having start time specified |
182 CCalInstance* instance; |
178 CCalInstance* instance = GetInstanceL( instanceStTime, iCalendarEntry->LocalUid() ); |
183 |
|
184 |
|
185 // Fetch instance having start time and LocalUid specified and GlobalUid specified |
|
186 if(iCalendarEntry->ModifiedAttributes() & CEntryAttributes::ELocalUid) |
|
187 { |
|
188 instance = GetInstanceL( instanceStTime, iCalendarEntry->LocalUid() ); |
|
189 } |
|
190 else if(iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EGlobalUid) |
|
191 { |
|
192 instance = GetGlobalInstanceL(instanceStTime, globaluid); |
|
193 } |
|
194 |
|
195 ///add code here |
179 |
196 |
180 if ( !instance ) |
197 if ( !instance ) |
181 User::Leave( KErrArgument ); |
198 User::Leave( KErrArgument ); |
182 |
199 |
183 CleanupStack::PushL( instance ); |
200 CleanupStack::PushL( instance ); |
243 } |
260 } |
244 // Entry Modification |
261 // Entry Modification |
245 else |
262 else |
246 { |
263 { |
247 // Fetch entry to be modified |
264 // Fetch entry to be modified |
248 CCalEntry* entry = iSessionInfo->EntryView()->FetchL( iCalendarEntry->LocalUid() ); |
265 CCalEntry* entry ; |
249 |
266 |
|
267 if(iCalendarEntry->ModifiedAttributes() & CEntryAttributes::ELocalUid) |
|
268 { |
|
269 entry = iSessionInfo->EntryView()->FetchL( iCalendarEntry->LocalUid() ); |
|
270 } |
|
271 else if(iCalendarEntry->ModifiedAttributes() & CEntryAttributes::EGlobalUid) |
|
272 { |
|
273 RPointerArray<CCalEntry> entryList; |
|
274 CleanupStack::PushL( TCleanupItem(CleanupCCalEntryArray, &entryList) ); |
|
275 iSessionInfo->EntryView()->FetchL( globaluid, entryList); |
|
276 entry = entryList[0]; |
|
277 entryList[0] = NULL; |
|
278 CleanupStack::PopAndDestroy( &entryList ); |
|
279 } |
|
280 |
250 //Invalid LocalUID |
281 //Invalid LocalUID |
251 if( !entry ) |
282 if( !entry ) |
252 User::Leave( KErrArgument ); |
283 User::Leave( KErrArgument ); |
253 |
284 |
254 CleanupStack::PushL( entry ); |
285 CleanupStack::PushL( entry ); |
642 } |
673 } |
643 CleanupStack::PopAndDestroy( &insArray ); |
674 CleanupStack::PopAndDestroy( &insArray ); |
644 |
675 |
645 return instance; |
676 return instance; |
646 } |
677 } |
647 |
678 // --------------------------------------------------------------------------- |
|
679 // CCalendarAddEntry::GetGlobalInstanceL |
|
680 // Retrieves the Instance for the given global Uid |
|
681 // --------------------------------------------------------------------------- |
|
682 // |
|
683 CCalInstance* CCalendarAddEntry::GetGlobalInstanceL( const TCalTime& aInsStTime, |
|
684 const TDesC8& aUid ) |
|
685 { |
|
686 CCalInstance* instance = NULL; |
|
687 |
|
688 RPointerArray<CCalInstance> insArray( KArrayGran ); |
|
689 |
|
690 CleanupStack::PushL( TCleanupItem(CleanupCCalInstanceArray, &insArray) ); |
|
691 |
|
692 // Find instance having the instance start time specified |
|
693 iSessionInfo->InstanceView()->FindInstanceL(insArray, CalCommon::EIncludeAll, |
|
694 CalCommon::TCalTimeRange(aInsStTime, aInsStTime)); |
|
695 |
|
696 TInt count = insArray.Count(); |
|
697 |
|
698 for( TInt index = 0 ; index < count; index++ ) |
|
699 { |
|
700 if ( insArray[index]->Entry().UidL() == aUid ) |
|
701 { |
|
702 instance = insArray[index]; |
|
703 insArray[index] = NULL; |
|
704 break; |
|
705 } |
|
706 } |
|
707 CleanupStack::PopAndDestroy( &insArray ); |
|
708 |
|
709 return instance; |
|
710 |
|
711 } |
648 // --------------------------------------------------------------------------- |
712 // --------------------------------------------------------------------------- |
649 // CCalendarAddEntry::SetStartEndTimeL |
713 // CCalendarAddEntry::SetStartEndTimeL |
650 // Set instance start and end time |
714 // Set instance start and end time |
651 // --------------------------------------------------------------------------- |
715 // --------------------------------------------------------------------------- |
652 // |
716 // |