104 // ---------------------------------------------------------------------------- |
73 // ---------------------------------------------------------------------------- |
105 // |
74 // |
106 CCalenEditUi::CCalenEditUi( CCalenController& aController ) |
75 CCalenEditUi::CCalenEditUi( CCalenController& aController ) |
107 : iController( aController ) |
76 : iController( aController ) |
108 { |
77 { |
109 TRACE_ENTRY_POINT; |
78 OstTraceFunctionEntry0( DUP1_CCALENEDITUI_CCALENEDITUI_ENTRY ); |
110 TRACE_EXIT_POINT; |
79 |
|
80 OstTraceFunctionExit0( DUP1_CCALENEDITUI_CCALENEDITUI_EXIT ); |
111 } |
81 } |
112 |
82 |
113 // ---------------------------------------------------------------------------- |
83 // ---------------------------------------------------------------------------- |
114 // CCalenEditUi::ConstructL |
84 // CCalenEditUi::ConstructL |
115 // Second stage construction |
85 // Second stage construction |
116 // (other items were commented in a header). |
86 // (other items were commented in a header). |
117 // ---------------------------------------------------------------------------- |
87 // ---------------------------------------------------------------------------- |
118 // |
88 // |
119 void CCalenEditUi::ConstructL() |
89 void CCalenEditUi::ConstructL() |
120 { |
90 { |
121 TRACE_ENTRY_POINT; |
91 OstTraceFunctionEntry0( CCALENEDITUI_CONSTRUCTL_ENTRY ); |
122 |
92 |
123 iGlobalData = CCalenGlobalData::InstanceL(); |
93 iController.RegisterForNotificationsL( this, ECalenNotifyDialogClosed ); |
124 iEntriesToComplete = 1; |
94 |
125 iMoreEntriesToComplete = EFalse; |
95 OstTraceFunctionExit0( CCALENEDITUI_CONSTRUCTL_EXIT ); |
126 isEditorActive = EFalse; |
|
127 |
|
128 iController.RegisterForNotificationsL( this, ECalenNotifyCancelStatusUpdation ); |
|
129 |
|
130 TRACE_EXIT_POINT; |
|
131 } |
96 } |
132 |
97 |
133 // ---------------------------------------------------------------------------- |
98 // ---------------------------------------------------------------------------- |
134 // CCalenEditUi::HandleActionUiCommandL |
99 // CCalenEditUi::HandleActionUiCommandL |
135 // Handles action ui commands |
100 // Handles action ui commands |
136 // (other items were commented in a header). |
101 // (other items were commented in a header). |
137 // ---------------------------------------------------------------------------- |
102 // ---------------------------------------------------------------------------- |
138 // |
103 // |
139 TBool CCalenEditUi::HandleCommandL( const TCalenCommand& aCommand ) |
104 TBool CCalenEditUi::HandleCommandL( const TCalenCommand& aCommand ) |
140 { |
105 { |
141 TRACE_ENTRY_POINT; |
106 OstTraceFunctionEntry0( CCALENEDITUI_HANDLECOMMANDL_ENTRY ); |
142 |
107 |
143 TBool continueCommand(EFalse); |
108 TBool continueCommand(EFalse); |
144 TInt command = aCommand.Command(); |
109 TInt command = aCommand.Command(); |
145 |
110 MCalenContext& context = iController.Services().Context(); |
146 switch(command) |
111 AgendaEntry editedEntry; |
|
112 QDateTime newEntryDateTime = iController.context().focusDateAndTime(); |
|
113 |
|
114 // Check if it is not on same day and set the default time and date accordingly. |
|
115 bool isSameDay = CalenDateUtils::isOnToday(newEntryDateTime); |
|
116 if (!isSameDay) { |
|
117 newEntryDateTime = CalenDateUtils::defaultTime(newEntryDateTime); |
|
118 } |
|
119 switch ( command ) |
147 { |
120 { |
148 case ECalenNewMeeting: |
121 case ECalenNewMeeting: |
149 case ECalenNewDayNote: |
122 iEditor= new CalenEditor(iController.Services().agendaInterface()); |
150 |
123 iEditor->create(newEntryDateTime, false, CalenEditor::TypeAppointment ); |
151 { |
124 connect(iEditor, SIGNAL(entrySaved()), this, SLOT(handleEntrySaved())); |
152 TUid currentView = iController.ViewManager().CurrentView(); |
125 connect(iEditor, SIGNAL(dialogClosed()), this, SLOT(handleDialogClosed())); |
153 if( KUidCalenTodoView == currentView ) |
|
154 { |
|
155 // Open NewEntry as "To-Do", if editor is launched from To-Do view. |
|
156 MCalenContext& context = iController.Services().Context(); |
|
157 // Set the date on the context to today. |
|
158 TTime homeTime; |
|
159 homeTime.HomeTime(); |
|
160 TCalTime today; |
|
161 today.SetTimeLocalL( homeTime ); |
|
162 context.SetFocusDateL( today, TVwsViewId( KUidCalendar, KUidCalenTodoView ) ); |
|
163 EditNewEntryL( CCalEntry::ETodo ); |
|
164 } |
|
165 else |
|
166 { |
|
167 EditNewEntryL(); |
|
168 } |
|
169 } |
|
170 break; |
126 break; |
171 case ECalenNewTodo: |
127 case ECalenEditCurrentEntry: |
172 EditNewEntryL( CCalEntry::ETodo ); |
128 editedEntry = iController.Services().agendaInterface()->fetchById( |
173 break; |
129 context.instanceId().mEntryLocalUid ); |
174 case ECalenNewAnniv: |
130 // For repeating entry, we need to update proper start time here |
175 EditNewEntryL( CCalEntry::EAnniv ); |
131 // from the context |
176 break; |
132 if(!editedEntry.isNull()) { |
177 case ECalenNewMeetingRequest: |
133 if (editedEntry.isRepeating()) { |
178 { |
134 // Get the instancde time frm the context |
179 EditNewMeetingRequestL(); |
135 QDateTime instanceTime = context.focusDateAndTime(); |
180 } |
136 editedEntry.setStartAndEndTime(instanceTime, editedEntry.endTime()); |
181 break; |
137 } |
182 case ECalenEditCurrentEntry: |
138 iEditor= new CalenEditor(iController.Services().agendaInterface()); |
183 case ECalenEditSeries: |
139 iEditor->edit(editedEntry, false); |
184 case ECalenEditOccurrence: |
140 connect(iEditor, SIGNAL(entrySaved()), this, SLOT(handleEntrySaved())); |
185 case ECalenCompleteTodo: |
141 connect(iEditor, SIGNAL(dialogClosed()), this, SLOT(handleDialogClosed())); |
186 case ECalenRestoreTodo: |
|
187 case ECalenMarkEntryAsDone: |
|
188 case ECalenMarkEntryAsUnDone: |
|
189 { |
|
190 // These commands need the entry view |
|
191 // to be constructed before being called |
|
192 CCalEntryView* entryView = iGlobalData->EntryViewL(); |
|
193 if( !entryView ) |
|
194 { |
|
195 // Store the command and wait for notification |
|
196 WaitForEntryViewNotificationL( aCommand ); |
|
197 } |
|
198 else |
|
199 { |
|
200 switch ( command ) |
|
201 { |
|
202 case ECalenEditCurrentEntry: |
|
203 { |
|
204 MCalenContext& context = iGlobalData->Context(); |
|
205 entryView = iGlobalData->EntryViewL(context.InstanceId().iColId); |
|
206 CCalEntry* entry = entryView->FetchL( |
|
207 context.InstanceId().iEntryLocalUid ); |
|
208 CleanupStack::PushL( entry ); |
|
209 User::LeaveIfNull( entry ); |
|
210 EditEntryL( entry, |
|
211 context.InstanceId().iInstanceTime, |
|
212 MAgnEntryUi::EEditExistingEntry ); |
|
213 |
|
214 CleanupStack::PopAndDestroy( entry ); |
|
215 |
|
216 break; |
|
217 } |
|
218 case ECalenCompleteTodo: |
|
219 SetTodoCompleteL( ETrue ); |
|
220 break; |
|
221 case ECalenRestoreTodo: |
|
222 SetTodoCompleteL( EFalse ); |
|
223 break; |
|
224 case ECalenMarkEntryAsDone: |
|
225 continueCommand = SetMultipleTodoCompleteL(ETrue ); |
|
226 break; |
|
227 case ECalenMarkEntryAsUnDone: |
|
228 continueCommand = SetMultipleTodoCompleteL(EFalse ); |
|
229 break; |
|
230 default: |
|
231 { |
|
232 // Should never reach this point. |
|
233 ASSERT( EFalse ); |
|
234 } |
|
235 } |
|
236 } |
|
237 } |
|
238 break; |
|
239 case ECalenSend: |
|
240 { |
|
241 iGlobalData->CalenSendL().DisplaySendCascadeMenuL(); |
|
242 |
|
243 if( iGlobalData->CalenSendL().CanSendL( ECalenSend ) ) |
|
244 { |
|
245 SendEntryL(); |
|
246 iController.BroadcastNotification( ECalenNotifyEntrySent ); |
|
247 } |
|
248 // ECalenNotifyDialogClosed issued when Messaging Query is cancelled |
|
249 // by the user. |
|
250 else |
|
251 { |
|
252 iController.BroadcastNotification( ECalenNotifyEntrySendCancel ); |
|
253 } |
|
254 |
|
255 } |
142 } |
256 break; |
143 break; |
257 default: |
144 default: |
258 // Controller decided this class was the place to handle this |
145 // Controller decided this class was the place to handle this |
259 // command |
146 // command |
260 break; |
147 break; |
261 } |
148 } |
262 |
149 |
263 TRACE_EXIT_POINT; |
150 OstTraceFunctionExit0( CCALENEDITUI_HANDLECOMMANDL_EXIT ); |
264 return continueCommand; |
151 return continueCommand; |
265 } |
152 } |
266 |
153 |
267 // ---------------------------------------------------------------------------- |
154 // ---------------------------------------------------------------------------- |
268 // CCalenEditUi::CalenCommandHandlerExtensionL |
155 // CCalenEditUi::handleEntrySaved |
269 // Dummy implementation. |
156 // Issues the entry saved notification after receiving signal from editor. |
270 // (other items were commented in a header). |
157 // ---------------------------------------------------------------------------- |
271 // ---------------------------------------------------------------------------- |
158 // |
272 // |
159 void CCalenEditUi::handleEntrySaved() |
273 TAny* CCalenEditUi::CalenCommandHandlerExtensionL( TUid /*aExtensionUid*/ ) |
160 { |
274 { |
161 OstTraceFunctionEntry0( CCALENEDITUI_HANDLEENTRYSAVED_ENTRY ); |
275 TRACE_ENTRY_POINT; |
162 |
276 TRACE_EXIT_POINT; |
163 iController.Services().IssueNotificationL(ECalenNotifyEntrySaved); |
277 return NULL; |
|
278 } |
|
279 |
|
280 // ---------------------------------------------------------------------------- |
|
281 // CCalenEditUi::SetTodoCompleteL |
|
282 // Completes or restores a todo. |
|
283 // (other items were commented in a header). |
|
284 // ---------------------------------------------------------------------------- |
|
285 // |
|
286 void CCalenEditUi::SetTodoCompleteL( TBool aComplete ) |
|
287 { |
|
288 TRACE_ENTRY_POINT; |
|
289 |
|
290 MCalenContext& context = iGlobalData->Context(); |
|
291 ASSERT( !( context.InstanceId() == ( TCalenInstanceId::NullInstanceId() ) ) ); |
|
292 |
|
293 // HandleActionUiCommandL creates the entry view if it has |
|
294 // not already been created before SetTodoCompleteL is called. |
|
295 CCalEntryView* entryView = iGlobalData->EntryViewL(context.InstanceId().iColId); |
|
296 ASSERT( entryView ); |
|
297 |
|
298 CCalEntry* entry = entryView->FetchL( context.InstanceId().iEntryLocalUid ); |
|
299 |
|
300 CleanupStack::PushL( entry ); |
|
301 |
|
302 if( entry ) |
|
303 { |
|
304 CalenActionUiUtils::SetToDoCompleteStatusL( *entryView, entry, aComplete ); |
|
305 //iContainer->NotifyEntryChangeL( *entry, entry->StartTimeL() ); |
|
306 iController.BroadcastNotification( ECalenNotifyEntrySaved ); |
|
307 } |
|
308 |
|
309 CleanupStack::PopAndDestroy( entry ); |
|
310 |
|
311 TRACE_EXIT_POINT; |
|
312 } |
|
313 |
|
314 // ---------------------------------------------------------------------------- |
|
315 // CCalenEditUi::SetTodoEntryCompleteL |
|
316 // Completes or restores a todo. |
|
317 // (other items were commented in a header). |
|
318 // ---------------------------------------------------------------------------- |
|
319 // |
|
320 void CCalenEditUi::SetTodoEntryCompleteL(TBool aComplete,TCalLocalUid aEntryUid,TCalCollectionId colId) |
|
321 { |
|
322 TRACE_ENTRY_POINT; |
|
323 |
|
324 // HandleActionUiCommandL creates the entry view if it has |
|
325 // not already been created before SetTodoCompleteL is called. |
|
326 CCalEntryView* entryView = iGlobalData->EntryViewL(colId); |
|
327 ASSERT( entryView ); |
|
328 |
|
329 CCalEntry* entry = entryView->FetchL( aEntryUid ); |
|
330 CleanupStack::PushL( entry ); |
|
331 |
|
332 if( entry ) |
|
333 { |
|
334 CalenActionUiUtils::SetToDoCompleteStatusL( *entryView, entry, aComplete ); |
|
335 } |
|
336 |
|
337 CleanupStack::PopAndDestroy( entry ); |
|
338 TRACE_EXIT_POINT; |
|
339 } |
|
340 |
|
341 // ---------------------------------------------------------------------------- |
|
342 // CCalenEditUi::EditNewEntryL |
|
343 // Creates a new entry and opens it for editing |
|
344 // (other items were commented in a header). |
|
345 // ---------------------------------------------------------------------------- |
|
346 // |
|
347 void CCalenEditUi::EditNewEntryL( CCalEntry::TType aEntryType) |
|
348 { |
|
349 TRACE_ENTRY_POINT; |
|
350 |
|
351 // Create unique ID. |
|
352 HBufC8* guid = iGlobalData->InterimUtilsL().GlobalUidL(); |
|
353 CleanupStack::PushL( guid ); |
|
354 CCalEntry* entry = CCalEntry::NewL( aEntryType, guid, CCalEntry::EMethodNone, 0 ); |
|
355 CleanupStack::Pop( guid ); |
|
356 |
|
357 CleanupStack::PushL( entry ); |
|
358 |
|
359 // Set initial start and end times from Calendar context |
|
360 TTime focusedTime = CalculateActiveTimeFromContextL(); |
|
361 TCalTime initialCalTime; |
|
362 |
|
363 initialCalTime.SetTimeLocalL( focusedTime ); |
|
364 |
|
365 entry->SetStartAndEndTimeL( initialCalTime, initialCalTime ); |
|
366 |
|
367 if( entry->EntryTypeL()==CCalEntry::EAnniv ) |
|
368 { |
|
369 TCalRRule rrule( TCalRRule::EYearly ); |
|
370 TCalTime startDate; |
|
371 rrule.SetDtStart( initialCalTime ); |
|
372 rrule.SetInterval( 1 ); // once a year |
|
373 entry->SetRRuleL( rrule ); |
|
374 } |
|
375 |
|
376 MCalenContext& context = iGlobalData->Context(); |
|
377 TCalCollectionId colId = context.InstanceId().iColId; |
|
378 TCalenInstanceId id = TCalenInstanceId::CreateL( *entry, initialCalTime ); |
|
379 id.iColId = colId; |
|
380 |
|
381 context.SetInstanceIdL( id, context.ViewId() ); |
|
382 |
|
383 TTime instanceTime = entry->StartTimeL().TimeLocalL(); |
|
384 EditEntryL( entry, instanceTime, MAgnEntryUi::ECreateNewEntry ); |
|
385 CleanupStack::PopAndDestroy( entry ); |
|
386 |
|
387 TRACE_EXIT_POINT; |
|
388 } |
|
389 |
|
390 // ---------------------------------------------------------------------------- |
|
391 // CCalenEditUi::EditNewMeetingRequestL |
|
392 // Creates a new meeting request and opens it for editing |
|
393 // (other items were commented in a header). |
|
394 // ---------------------------------------------------------------------------- |
|
395 // |
|
396 void CCalenEditUi::EditNewMeetingRequestL() |
|
397 { |
|
398 TRACE_ENTRY_POINT; |
|
399 |
|
400 CMRMailboxUtils::TMailboxInfo defaultMailBox; |
|
401 |
|
402 if( !iGlobalData->AttemptToRetrieveDefaultMailboxL( defaultMailBox ) ) |
|
403 { |
|
404 // User either doesn't have any mailboxes or didn't select a default mailbox. |
|
405 // Don't create the meeting request. |
|
406 TRACE_EXIT_POINT; |
|
407 return; |
|
408 } |
|
409 |
|
410 // If we got this far, defaultMailBox should be initialised. |
|
411 HBufC8* guid = iGlobalData->InterimUtilsL().GlobalUidL(); |
|
412 |
|
413 CleanupStack::PushL( guid ); |
|
414 CCalEntry* entry = CCalEntry::NewL( CCalEntry::EAppt, |
|
415 guid, |
|
416 CCalEntry::EMethodRequest, |
|
417 0 ); |
|
418 CleanupStack::Pop( guid ); |
|
419 CleanupStack::PushL( entry ); |
|
420 |
|
421 // Set initial start and end times from Active Calendar Context |
|
422 TTime focusedTime = iGlobalData->Context().FocusDateAndTimeL().TimeLocalL(); |
|
423 TCalTime initialCalTime; |
|
424 // No need to handle floating time check here, as meetings are |
|
425 // always fixed. |
|
426 initialCalTime.SetTimeLocalL( focusedTime ); |
|
427 |
|
428 entry->SetStartAndEndTimeL( initialCalTime, initialCalTime ); |
|
429 |
|
430 //Set the organizer from the selected mailbox |
|
431 CCalUser* organizer = CCalUser::NewL( defaultMailBox.iEmailAddress ); |
|
432 entry->SetOrganizerL( organizer ); |
|
433 |
|
434 TTime instanceTime = entry->StartTimeL().TimeLocalL(); |
|
435 EditEntryL( entry, instanceTime, MAgnEntryUi::ECreateNewEntry ); |
|
436 CleanupStack::PopAndDestroy( entry ); |
|
437 |
|
438 TRACE_EXIT_POINT; |
|
439 } |
|
440 |
|
441 // ---------------------------------------------------------------------------- |
|
442 // CCalenEditUi::EditEntryL |
|
443 // Opens the entry aEntry for editing |
|
444 // (other items were commented in a header). |
|
445 // ---------------------------------------------------------------------------- |
|
446 // |
|
447 void CCalenEditUi::EditEntryL( CCalEntry* aEntry, |
|
448 const TTime& aInstanceDate, |
|
449 MAgnEntryUi::TAgnEntryUiEditorMode aEditorMode ) |
|
450 { |
|
451 TRACE_ENTRY_POINT; |
|
452 |
|
453 // Set the flag |
|
454 isEditorActive = ETrue; |
|
455 |
|
456 if( !iEditorsPlugin ) |
|
457 { |
|
458 //Only created on first use |
|
459 LoadEditorsPluginL(); |
|
460 if( !iEditorsPlugin ) |
|
461 { |
|
462 // User was prompted to set a default mailbox and hit cancel |
|
463 // Entry will not be opened |
|
464 TRACE_EXIT_POINT; |
|
465 return; |
|
466 } |
|
467 } |
|
468 |
|
469 MAgnEntryUi::TAgnEntryUiInParams inParams( KUidCalendar, |
|
470 iGlobalData->CalSessionL(), |
|
471 aEditorMode ); |
|
472 |
|
473 // Use floating time for non-timed entries |
|
474 if( !CalenAgendaUtils::IsTimedEntryL(aEntry->EntryTypeL()) ) |
|
475 { |
|
476 inParams.iInstanceDate.SetTimeLocalFloatingL( aInstanceDate ); |
|
477 } |
|
478 else |
|
479 { |
|
480 inParams.iInstanceDate.SetTimeLocalL( aInstanceDate ); |
|
481 } |
|
482 |
|
483 inParams.iMsgSession = NULL; |
|
484 |
|
485 MAgnEntryUi::TAgnEntryUiOutParams outParams; |
|
486 |
|
487 // Launch Entry UI |
|
488 RPointerArray<CCalEntry> entries; |
|
489 CleanupClosePushL( entries ); |
|
490 entries.AppendL( aEntry ); // aEntry already in cleanup stack -> safe |
|
491 |
|
492 // Editors need a services implementation. |
|
493 MCalenServices* svc = CCalenServicesImpl::NewL(); |
|
494 CleanupReleasePushL( *svc ); |
|
495 inParams.iSpare = ( TInt )svc; |
|
496 |
164 |
|
165 OstTraceFunctionExit0( CCALENEDITUI_HANDLEENTRYSAVED_EXIT ); |
|
166 } |
|
167 |
|
168 // ---------------------------------------------------------------------------- |
|
169 // CCalenEditUi::handleEntrySaved |
|
170 // Issues the dialog closed notification after receiving signal from editor. |
|
171 // ---------------------------------------------------------------------------- |
|
172 // |
|
173 void CCalenEditUi::handleDialogClosed() |
|
174 { |
|
175 OstTraceFunctionEntry0( CCALENEDITUI_HANDLEDIALOGCLOSED_ENTRY ); |
|
176 |
|
177 iController.Services().IssueNotificationL(ECalenNotifyDialogClosed); |
497 |
178 |
498 // Stop the population of the current view |
179 OstTraceFunctionExit0( CCALENEDITUI_HANDLEDIALOGCLOSED_EXIT ); |
499 iController.ViewManager().InterruptPopulationL(); |
180 } |
500 |
181 |
501 // hide the toolbar |
|
502 MCalenToolbar* toolbar = iController.Services().ToolbarOrNull(); |
|
503 if(toolbar) |
|
504 { |
|
505 toolbar->SetToolbarVisibilityL(EFalse); |
|
506 } |
|
507 |
|
508 |
|
509 // If a menubar is active,stop displaying it before launching editor |
|
510 TUid viewUid = iController.ViewManager().CurrentView(); |
|
511 CEikMenuBar* menuBar = iController.AppUi().View(viewUid)->MenuBar(); |
|
512 if(menuBar) |
|
513 { |
|
514 menuBar->StopDisplayingMenuBar(); |
|
515 } |
|
516 |
|
517 // Launch the viewer / editor plugin |
|
518 iEditorsPlugin->ExecuteViewL( entries, inParams, outParams, *this ); |
|
519 |
|
520 // Reset the flag |
|
521 isEditorActive = EFalse; |
|
522 |
|
523 // Unhide the toolbar when settings is closed |
|
524 TUid activeViewUid = iController.ViewManager().CurrentView(); |
|
525 if(toolbar && (activeViewUid != KUidCalenMissedAlarmsView ) &&(activeViewUid != KUidCalenMissedEventView ) ) |
|
526 { |
|
527 toolbar->SetToolbarVisibilityL(ETrue); |
|
528 } |
|
529 |
|
530 CleanupStack::PopAndDestroy( svc ); |
|
531 |
|
532 // Close the entries array |
|
533 CleanupStack::PopAndDestroy( &entries ); |
|
534 |
|
535 switch( outParams.iAction ) |
|
536 { |
|
537 case MAgnEntryUi::EMeetingSaved: |
|
538 case MAgnEntryUi::EInstanceRescheduled: |
|
539 { |
|
540 // Update context and issue notification before confirmation dialog |
|
541 // to avoid delay of updating title pane |
|
542 MCalenContext& context = iGlobalData->Context(); |
|
543 TCalCollectionId colId = context.InstanceId().iColId; |
|
544 TCalenInstanceId id = TCalenInstanceId::CreateL( TCalLocalUid( |
|
545 outParams.iSpare), |
|
546 outParams.iNewInstanceDate.TimeLocalL(), EFalse ); |
|
547 id.iColId = colId; |
|
548 id.iType = context.InstanceId().iType; |
|
549 if( aEditorMode != MAgnEntryUi::ECreateNewEntry ) |
|
550 { |
|
551 id.iInstanceTime = context.InstanceId().iInstanceTime; |
|
552 } |
|
553 context.SetInstanceIdL( id, context.ViewId() ); |
|
554 iController.BroadcastNotification( ECalenNotifyEntrySaved ); |
|
555 |
|
556 if( aEditorMode == MAgnEntryUi::ECreateNewEntry ) |
|
557 { |
|
558 // Show saved note for new entries |
|
559 TInt res; |
|
560 if( context.InstanceId().iType == CCalEntry::ETodo ) |
|
561 { |
|
562 res = R_QTN_CALE_NOTE_TODO_SAVED; |
|
563 } |
|
564 else |
|
565 { |
|
566 res = R_TEXT_CALENDAR_NOTE_SAVED; |
|
567 } |
|
568 |
|
569 HBufC* prompt = StringLoader::LoadLC( res, CEikonEnv::Static() ); |
|
570 CAknConfirmationNote* dialog = new( ELeave )CAknConfirmationNote(); |
|
571 dialog->ExecuteLD( *prompt ); |
|
572 CleanupStack::PopAndDestroy( prompt ); |
|
573 } |
|
574 } |
|
575 break; |
|
576 |
|
577 case MAgnEntryUi::EMeetingDeleted: |
|
578 iController.BroadcastNotification( ECalenNotifyEntryDeleted ); |
|
579 break; |
|
580 |
|
581 case MAgnEntryUi::EInstanceDeleted: |
|
582 iController.BroadcastNotification( ECalenNotifyInstanceDeleted ); |
|
583 break; |
|
584 |
|
585 case MAgnEntryUi::ENoAction: |
|
586 default: |
|
587 iController.BroadcastNotification( ECalenNotifyEntrySaved ); |
|
588 break; |
|
589 } |
|
590 |
|
591 |
|
592 TRACE_EXIT_POINT; |
|
593 } |
|
594 |
|
595 // ---------------------------------------------------------------------------- |
|
596 // CCalenEditUi::LoadEditorsPluginL |
|
597 // Attempts to load the editors plugin into iEditorsPlugin. If failure occurs |
|
598 // (for example, if the user is prompted to select a default mailbox and hits |
|
599 // cancel), iEditorsPlugin is set to NULL. |
|
600 // (other items were commented in a header). |
|
601 // ---------------------------------------------------------------------------- |
|
602 // |
|
603 void CCalenEditUi::LoadEditorsPluginL() |
|
604 { |
|
605 TRACE_ENTRY_POINT; |
|
606 |
|
607 delete iEditorsPlugin; |
|
608 iEditorsPlugin = NULL; |
|
609 |
|
610 if( iGlobalData->InterimUtilsL().MRViewersEnabledL() ) |
|
611 { |
|
612 //Get the currently selected mailbox |
|
613 CMRMailboxUtils::TMailboxInfo defaultMailBox; |
|
614 |
|
615 if( iGlobalData->AttemptToRetrieveDefaultMailboxL( defaultMailBox ) ) |
|
616 { |
|
617 //CAgnEntryUi resolves Meeting request viewer based on mtm uid |
|
618 TBuf8<KMaxUidName> mrMtm; |
|
619 CnvUtfConverter::ConvertFromUnicodeToUtf8( mrMtm, |
|
620 defaultMailBox.iMtmUid.Name() ); |
|
621 iEditorsPlugin = CAgnEntryUi::NewL( mrMtm ); |
|
622 } |
|
623 } |
|
624 else |
|
625 { |
|
626 iEditorsPlugin = CCalenEditorsPlugin::NewL(); |
|
627 } |
|
628 |
|
629 TRACE_EXIT_POINT; |
|
630 } |
|
631 |
|
632 |
|
633 // ---------------------------------------------------------------------------- |
|
634 // CCalenEditUi::SendEntryL |
|
635 // Sends the current entry. |
|
636 // (other items were commented in a header). |
|
637 // ---------------------------------------------------------------------------- |
|
638 // |
|
639 void CCalenEditUi::SendEntryL() |
|
640 { |
|
641 TRACE_ENTRY_POINT; |
|
642 |
|
643 MCalenContext& context = iGlobalData->Context(); |
|
644 ASSERT( !( context.InstanceId() == TCalenInstanceId::NullInstanceId() ) ); |
|
645 |
|
646 //If todo, use the LUid. |
|
647 //Todos returns the current time if start or end time has not been saved. |
|
648 if( CCalEntry::ETodo == context.InstanceId().iType ) |
|
649 { |
|
650 CCalEntry* entry = iGlobalData->EntryViewL(context.InstanceId().iColId)->FetchL( |
|
651 context.InstanceId().iEntryLocalUid ); |
|
652 if( entry ) |
|
653 { |
|
654 CleanupStack::PushL( entry ); |
|
655 iGlobalData->CalenSendL().SendAsVCalendarL( ECalenSend, *entry ); |
|
656 CleanupStack::PopAndDestroy( entry ); |
|
657 } |
|
658 } |
|
659 else // Not todo |
|
660 { |
|
661 RArray<TInt> colIdArray; |
|
662 CleanupClosePushL(colIdArray); |
|
663 iController.GetActiveCollectionidsL(colIdArray); |
|
664 |
|
665 CCalInstance* instance = CalenActionUiUtils::FindPossibleInstanceL( |
|
666 context.InstanceId(), |
|
667 *iGlobalData->InstanceViewL(colIdArray) ); |
|
668 CleanupStack::PushL( instance ); |
|
669 |
|
670 if( instance ) |
|
671 { |
|
672 CCalEntry& entry = instance->Entry(); |
|
673 iGlobalData->CalenSendL().SendAsVCalendarL( ECalenSend, entry ); |
|
674 } |
|
675 |
|
676 CleanupStack::PopAndDestroy( instance ); |
|
677 CleanupStack::PopAndDestroy(&colIdArray); |
|
678 } |
|
679 |
|
680 TRACE_EXIT_POINT; |
|
681 } |
|
682 |
|
683 // ---------------------------------------------------------------------------- |
|
684 // CCalenEditUi::ProcessCommandWithResultL |
|
685 // This is pure virtual from MAgnEntryUiCallback. We don't use it. |
|
686 // (other items were commented in a header). |
|
687 // ---------------------------------------------------------------------------- |
|
688 // |
|
689 TInt CCalenEditUi::ProcessCommandWithResultL( TInt /*aCommandId*/ ) |
|
690 { |
|
691 TRACE_ENTRY_POINT; |
|
692 TRACE_EXIT_POINT; |
|
693 return KErrNone; |
|
694 } |
|
695 |
|
696 // ---------------------------------------------------------------------------- |
|
697 // CCalenEditUi::ProcessCommandL |
|
698 // This is pure virtual from MAgnEntryUiCallback. We don't use it. |
|
699 // (other items were commented in a header). |
|
700 // ---------------------------------------------------------------------------- |
|
701 // |
|
702 void CCalenEditUi::ProcessCommandL( TInt /*aCommandId*/ ) |
|
703 { |
|
704 TRACE_ENTRY_POINT; |
|
705 TRACE_EXIT_POINT; |
|
706 } |
|
707 |
|
708 // ---------------------------------------------------------------------------- |
|
709 // CCalenEditUi::WaitForEntryViewNotificationL |
|
710 // Register for view created notification |
|
711 // (other items were commented in a header). |
|
712 // ---------------------------------------------------------------------------- |
|
713 // |
|
714 void CCalenEditUi::WaitForEntryViewNotificationL( const TCalenCommand& aCommand ) |
|
715 { |
|
716 TRACE_ENTRY_POINT; |
|
717 |
|
718 iStoredCommand = aCommand; |
|
719 |
|
720 // Only wait for an entry view if it doesn't already exist |
|
721 ASSERT( !( iGlobalData->EntryViewL() ) ); |
|
722 |
|
723 // Register for notifications |
|
724 iController.RegisterForNotificationsL( this, ECalenNotifyEntryInstanceViewCreated ); |
|
725 |
|
726 TRACE_EXIT_POINT; |
|
727 } |
|
728 |
|
729 // ---------------------------------------------------------------------------- |
|
730 // CCalenEditUi::HandleECalenNotifyViewCreatedL |
|
731 // Handle ECalenNotifyViewCreated |
|
732 // (other items were commented in a header). |
|
733 // ---------------------------------------------------------------------------- |
|
734 // |
|
735 void CCalenEditUi::HandleECalenNotifyViewCreatedL() |
|
736 { |
|
737 TRACE_ENTRY_POINT; |
|
738 |
|
739 if( iGlobalData->EntryViewL() ) |
|
740 { |
|
741 // Handle the outstanding command |
|
742 HandleCommandL( iStoredCommand ); |
|
743 |
|
744 // Cancel the notify as the entry view is now |
|
745 // constructed. |
|
746 iController.CancelNotifications( this ); |
|
747 } |
|
748 |
|
749 TRACE_EXIT_POINT; |
|
750 } |
|
751 // ---------------------------------------------------------------------------- |
182 // ---------------------------------------------------------------------------- |
752 // CCalenEditUi::HandleNotification |
183 // CCalenEditUi::HandleNotification |
753 // Handle notifications |
184 // Handle notifications |
754 // (other items were commented in a header). |
185 // (other items were commented in a header). |
755 // ---------------------------------------------------------------------------- |
186 // ---------------------------------------------------------------------------- |
756 // |
187 // |
757 void CCalenEditUi::HandleNotification(const TCalenNotification aNotification ) |
188 void CCalenEditUi::HandleNotification(const TCalenNotification aNotification ) |
758 { |
189 { |
759 TRACE_ENTRY_POINT; |
190 OstTraceFunctionEntry0( CCALENEDITUI_HANDLENOTIFICATION_ENTRY ); |
760 |
191 |
761 if ( aNotification == ECalenNotifyEntryInstanceViewCreated ) |
192 if( aNotification == ECalenNotifyDialogClosed ) |
762 { |
193 { |
763 PIM_TRAPD_HANDLE( HandleECalenNotifyViewCreatedL() ); |
194 iEditor->deleteLater(); |
764 } |
195 } |
765 if( aNotification == ECalenNotifyCancelStatusUpdation) |
196 |
766 { |
197 OstTraceFunctionExit0( CCALENEDITUI_HANDLENOTIFICATION_EXIT ); |
767 if(iMutlipleContextIdsCount) |
198 } |
768 { |
199 // ---------------------------------------------------------------------------- |
769 // get the context |
200 // CCalenEditUi::saveEntry |
770 MCalenContext& context = iGlobalData->Context(); |
201 // save the entry from editor |
771 // reset the multiple contexts |
202 // ---------------------------------------------------------------------------- |
772 context.ResetMultipleContextIds(); |
203 // |
773 |
204 void CCalenEditUi::saveAndCloseEditor() |
774 // dismiss the waitdialog |
205 { |
775 if(iWaitDialog) |
206 iEditor->saveAndCloseEditor(); |
776 { |
|
777 TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); |
|
778 } |
|
779 } |
|
780 } |
|
781 TRACE_EXIT_POINT; |
|
782 } |
|
783 |
|
784 TBool CCalenEditUi::SetMultipleTodoCompleteL(TBool aComplete ) |
|
785 { |
|
786 TRACE_ENTRY_POINT; |
|
787 TBool continueCommand(EFalse); |
|
788 |
|
789 // get the context |
|
790 MCalenContext& context = iGlobalData->Context(); |
|
791 |
|
792 // get the multliple context ids count |
|
793 iMutlipleContextIdsCount = context.MutlipleContextIdsCount(); |
|
794 |
|
795 ASSERT( iMutlipleContextIdsCount ); |
|
796 |
|
797 if(!iMoreEntriesToComplete) |
|
798 { |
|
799 DisplayWaitDialogL(); |
|
800 } |
|
801 // get the multiple context instance ids |
|
802 RArray<TCalenInstanceId>& multipleContextIds = context.GetMutlipleContextIds(); |
|
803 |
|
804 if(iMutlipleContextIdsCount <= iEntriesToComplete ) |
|
805 { |
|
806 iMoreEntriesToComplete = EFalse; |
|
807 iEntriesToComplete = iMutlipleContextIdsCount; |
|
808 } |
|
809 else |
|
810 { |
|
811 iMoreEntriesToComplete = ETrue; |
|
812 // set the continue command flag if more entries are there to delete |
|
813 continueCommand = ETrue; |
|
814 } |
|
815 |
|
816 TInt index(0); |
|
817 while(index<iEntriesToComplete) |
|
818 { |
|
819 // get the local uid of the entry through multiple context list |
|
820 TCalLocalUid entryLocalUid = multipleContextIds[0].iEntryLocalUid; |
|
821 TCalCollectionId colId = multipleContextIds[0].iColId; |
|
822 if(entryLocalUid) |
|
823 { |
|
824 SetTodoEntryCompleteL(aComplete, entryLocalUid,colId); |
|
825 } |
|
826 // remove mutliple context based on the instanceid |
|
827 context.RemoveMultipleContextId(multipleContextIds[0]); |
|
828 index++; |
|
829 } |
|
830 |
|
831 if(!iMoreEntriesToComplete) |
|
832 { |
|
833 MarkedEntriesCompletedL(); |
|
834 } |
|
835 |
|
836 |
|
837 |
|
838 TRACE_EXIT_POINT; |
|
839 return continueCommand; |
|
840 } |
|
841 // ----------------------------------------------------------------------------- |
|
842 // CCalenEditUi::DisplayWaitDialogL |
|
843 // Display wait dialog |
|
844 // ----------------------------------------------------------------------------- |
|
845 // |
|
846 void CCalenEditUi::DisplayWaitDialogL() |
|
847 { |
|
848 TRACE_ENTRY_POINT; |
|
849 |
|
850 delete iWaitDialog; |
|
851 iWaitDialog = NULL; |
|
852 iWaitDialog = new( ELeave )CAknWaitDialog( REINTERPRET_CAST( CEikDialog**, &iWaitDialog ), ETrue ); |
|
853 iWaitDialog->ExecuteLD( R_TODO_UPDATING_STATUS_NOTE ); |
|
854 iWaitDialog->SetCallback(this); |
|
855 |
|
856 TRACE_EXIT_POINT; |
|
857 } |
|
858 |
|
859 // ----------------------------------------------------------------------------- |
|
860 // CCalenEditUi::MarkedEntriesDeletedL |
|
861 // Dismiss wait dialog and show information note |
|
862 // ----------------------------------------------------------------------------- |
|
863 // |
|
864 void CCalenEditUi::MarkedEntriesCompletedL() |
|
865 { |
|
866 TRACE_ENTRY_POINT; |
|
867 |
|
868 // dismiss the waitdialog |
|
869 if(iWaitDialog) |
|
870 { |
|
871 iWaitDialog->ProcessFinishedL(); |
|
872 } |
|
873 |
|
874 if(iMutlipleContextIdsCount) |
|
875 { |
|
876 // get the context |
|
877 MCalenContext& context = iGlobalData->Context(); |
|
878 // reset the multiple contexts |
|
879 context.ResetMultipleContextIds(); |
|
880 } |
|
881 // notify marked entries deleted |
|
882 iController.BroadcastNotification( ECalenNotifyMarkedEntryCompleted ); |
|
883 |
|
884 TRACE_EXIT_POINT; |
|
885 } |
|
886 |
|
887 void CCalenEditUi::DialogDismissedL( const TInt /*aButtonId*/ ) |
|
888 { |
|
889 TRACE_ENTRY_POINT; |
|
890 |
|
891 // no more entries to delete |
|
892 iMoreEntriesToComplete = EFalse; |
|
893 |
|
894 // issue notification cancel delete |
|
895 // iController.BroadcastNotification(ECalenNotifyCancelStatusUpdation); |
|
896 |
|
897 TRACE_EXIT_POINT; |
|
898 } |
|
899 |
|
900 // ----------------------------------------------------------------------------- |
|
901 // CCalenEditUi::CalculateActiveTimeFromContextL |
|
902 // CCalculate active time from context |
|
903 // ----------------------------------------------------------------------------- |
|
904 // |
|
905 TTime CCalenEditUi::CalculateActiveTimeFromContextL() |
|
906 { |
|
907 TRACE_ENTRY_POINT; |
|
908 // The active time is calculated based on the following table |
|
909 // Current View |
|
910 // Month Day Week ToDo |
|
911 |
|
912 // Meeting* CFD (@8am) CFD (@8am) CFD @ FCT Today (@8am) |
|
913 // Day Note CFD CFD CFD Today |
|
914 // Anniv* CFD CFD CFD Today |
|
915 // ToDo* CFD CFD CFD Today |
|
916 |
|
917 // CFD = Currently Focused Date, the one shown in Navigator toolbar |
|
918 // FCT = Focused Cell's Time, applicable only to Week View |
|
919 // (*) Alarm Default times are also set using the values |
|
920 |
|
921 TTime activeTime(Time::NullTTime()); // initialize with NULL time |
|
922 MCalenContext &context = iGlobalData->Context(); |
|
923 /*TTime& activeTimeRef = activeTime; |
|
924 TUid currentView = iController.ViewManager().CurrentView(); |
|
925 if(currentView == KUidCalenWeekView) |
|
926 { |
|
927 // use CFD |
|
928 activeTime = CalenDateUtils::BeginningOfDay( |
|
929 context.FocusDateAndTimeL().TimeLocalL()); // CFD |
|
930 |
|
931 // CFD @ FCT |
|
932 // focus on empty nontimed cell |
|
933 if( context.FocusDateAndTimeL().TimeUtcL() == Time::NullTTime() ) |
|
934 { |
|
935 activeTime = CalenDateUtils::DefaultTime( activeTimeRef ); |
|
936 } |
|
937 else if(context.InstanceId().iType != CCalEntry::EAppt) |
|
938 { |
|
939 activeTime = CalenDateUtils::DefaultTime( activeTimeRef ); |
|
940 } |
|
941 else |
|
942 { |
|
943 activeTime += CalenDateUtils::TimeOfDay( |
|
944 context.FocusDateAndTimeL().TimeLocalL().DateTime() ); |
|
945 } |
|
946 } |
|
947 else |
|
948 {*/ |
|
949 // use Today @ 8 am |
|
950 activeTime = CalenDateUtils::Today(); |
|
951 activeTime = CalenDateUtils::DefaultTime(context.FocusDateAndTimeL().TimeLocalL()); // 8 am |
|
952 //} |
|
953 |
|
954 TRACE_EXIT_POINT; |
|
955 return activeTime; |
|
956 } |
|
957 |
|
958 // ----------------------------------------------------------------------------- |
|
959 // CCalenEditUi::IsEditorActive |
|
960 // Tells framework whether editor is active or not |
|
961 // ----------------------------------------------------------------------------- |
|
962 // |
|
963 TBool CCalenEditUi::IsEditorActive() |
|
964 { |
|
965 return isEditorActive; |
|
966 } |
207 } |
967 // End of file |
208 // End of file |