diff -r 12af337248b1 -r bd7edf625bdd calendarui/controller/src/calenactionui.cpp --- a/calendarui/controller/src/calenactionui.cpp Tue Aug 31 15:13:43 2010 +0300 +++ b/calendarui/controller/src/calenactionui.cpp Wed Sep 01 12:32:31 2010 +0100 @@ -17,20 +17,28 @@ // INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "calendarui_debug.h" #include "calenactionui.h" #include "calencontroller.h" #include "calendeleteui.h" #include "caleneditui.h" +#include "calenlocationui.h" +#include "calensettingsui.h" #include "calennotifier.h" -#include "calenservices.h" -#include "calensettingsview.h" +#include "calenmultipledbui.h" +#include "calenattachmentui.h" +#include "CalenUid.h" #include "calenviewmanager.h" -#include -#include "OstTraceDefinitions.h" -#ifdef OST_TRACE_COMPILER_IN_USE -#include "calenactionuiTraces.h" -#endif // ---------------------------------------------------------------------------- // CCalenActionUi::NewL @@ -40,14 +48,14 @@ // CCalenActionUi* CCalenActionUi::NewL( CCalenController& aController ) { - OstTraceFunctionEntry0( CCALENACTIONUI_NEWL_ENTRY ); - + TRACE_ENTRY_POINT; + CCalenActionUi* self = new( ELeave ) CCalenActionUi( aController ); CleanupStack::PushL( self ); self->ConstructL(); CleanupStack::Pop( self ); - OstTraceFunctionExit0( CCALENACTIONUI_NEWL_EXIT ); + TRACE_EXIT_POINT; return self; } @@ -60,9 +68,8 @@ CCalenActionUi::CCalenActionUi( CCalenController& aController ) : iController( aController ) { - OstTraceFunctionEntry0( CCALENACTIONUI_CCALENACTIONUI_ENTRY ); - - OstTraceFunctionExit0( CCALENACTIONUI_CCALENACTIONUI_EXIT ); + TRACE_ENTRY_POINT; + TRACE_EXIT_POINT; } // ---------------------------------------------------------------------------- @@ -73,9 +80,8 @@ // void CCalenActionUi::ConstructL() { - OstTraceFunctionEntry0( CCALENACTIONUI_CONSTRUCTL_ENTRY ); - - OstTraceFunctionExit0( CCALENACTIONUI_CONSTRUCTL_EXIT ); + TRACE_ENTRY_POINT; + TRACE_EXIT_POINT; } // ---------------------------------------------------------------------------- @@ -86,12 +92,14 @@ // CCalenActionUi::~CCalenActionUi() { - OstTraceFunctionEntry0( DUP1_CCALENACTIONUI_CCALENACTIONUI_ENTRY ); - + TRACE_ENTRY_POINT; + delete iDeleteUi; - delete iEditUi; - - OstTraceFunctionExit0( DUP1_CCALENACTIONUI_CCALENACTIONUI_EXIT ); + delete iEditUi; + delete iLocationUi; + delete iAttachmentUi; + + TRACE_EXIT_POINT; } // ---------------------------------------------------------------------------- @@ -101,41 +109,96 @@ // MCalenCommandHandler* CCalenActionUi::GetCommandHandlerL( TInt aCommand ) { - OstTraceFunctionEntry0( CCALENACTIONUI_GETCOMMANDHANDLERL_ENTRY ); - MCalenCommandHandler* handler = NULL; - if ( aCommand >= ECalenEditCommandBase - && aCommand < ECalenDeleteCommandBase ) + if( aCommand >= ECalenEditCommandBase && + aCommand < ECalenDeleteCommandBase ) + { + if(!iEditUi) + { + iEditUi = CCalenEditUi::NewL(iController); + } + handler = iEditUi; + } + else if( aCommand >= ECalenDeleteCommandBase && + aCommand < ECalenSettingsCommandBase ) + { + if(!iDeleteUi) + { + iDeleteUi = CCalenDeleteUi::NewL( iController ); + } + handler = iDeleteUi; + } + else if( aCommand >= ECalenSettingsCommandBase && + aCommand < ECalenMapCommandBase ) + { + handler = this; + } + else if( aCommand >= ECalenMapCommandBase && + aCommand < ECalenAttachmentCommandBase ) + { + if(!iLocationUi) + { + iLocationUi = CCalenLocationUi::NewL( iController ); + } + handler = iLocationUi; + } + else if( aCommand >= ECalenAttachmentCommandBase && + aCommand < ECalenLastCommand ) + { + if(!iAttachmentUi) + { + iAttachmentUi = CCalenAttachmentUi::NewL(iController); + } + handler = iAttachmentUi; + } + + TRACE_EXIT_POINT; + return handler; + } + +// ---------------------------------------------------------------------------- +// CCalenActionUi::HandleCommmandL +// Handles Calendar commands. Delegates to appropriate action ui. +// (other items were commented in a header). +// ---------------------------------------------------------------------------- +// +/*TBool CCalenActionUi::HandleActionUiCommandL( TInt aCommand ) + { + TRACE_ENTRY_POINT; + + // Lazy initialisation for action uis. + TBool handled( EFalse ); + + if( aCommand >= ECalenEditCommandBase && aCommand < ECalenLastCommand ) { if( !iEditUi ) { iEditUi = CCalenEditUi::NewL( iController ); } - handler = iEditUi; - } - else if ( aCommand >= ECalenDeleteCommandBase - && aCommand < ECalenSettingsCommandBase ) - { - if( !iDeleteUi ) + handled = iEditUi->HandleActionUiCommandL( aCommand ); + + if( !handled ) { - iDeleteUi = CalenDeleteUi::NewL( iController ); + if( !iDeleteUi ) + { + iDeleteUi = CCalenDeleteUi::NewL( iController ); + } + handled = iDeleteUi->HandleActionUiCommandL( aCommand ); } - handler = iDeleteUi; + + if( !handled && aCommand == ECalenShowSettings ) + { + handled = ETrue; + + ShowSettingsL(); + } } - else if ( aCommand >= ECalenSettingsCommandBase - && aCommand < ECalenMapCommandBase ) - { - handler = this; - } - else if ( aCommand >= ECalenMapCommandBase - && aCommand < ECalenLastCommand ) - { - } - - OstTraceFunctionExit0( CCALENACTIONUI_GETCOMMANDHANDLERL_EXIT ); - return handler; - } + + TRACE_EXIT_POINT; + return handled; + }*/ + // ---------------------------------------------------------------------------- // CCalenActionUi::HandleCommandL @@ -145,26 +208,273 @@ // TBool CCalenActionUi::HandleCommandL( const TCalenCommand& aCommand ) { - OstTraceFunctionEntry0( CCALENACTIONUI_HANDLECOMMANDL_ENTRY ); - + TRACE_ENTRY_POINT; TBool continueCommand(EFalse); - - if(aCommand.Command()==ECalenShowSettings) - { - iController.ViewManager().launchSettingsView(); + + switch(aCommand.Command()) + { + case ECalenShowSettings: + { + ShowSettingsL(); + } + break; + case ECalenShowCalendars: + { + ShowCalendarsL(); + } + break; + default: + break; } - - OstTraceFunctionExit0( CCALENACTIONUI_HANDLECOMMANDL_EXIT ); - return continueCommand; + + TRACE_EXIT_POINT; + return continueCommand; + } + +// ---------------------------------------------------------------------------- +// CCalenActionUi::CalenCommandHandlerExtensionL +// Dummy implementation. +// (other items were commented in a header). +// ---------------------------------------------------------------------------- +// +TAny* CCalenActionUi::CalenCommandHandlerExtensionL( TUid /*aExtensionUid*/ ) + { + TRACE_ENTRY_POINT; + TRACE_EXIT_POINT; + return NULL; } // ---------------------------------------------------------------------------- -// CCalenActionUi::saveEntry -// save the entry from editor +// CCalenActionUi::ShowCalendarsL +// Shows the multiple db calendar's dialog +// (other items were commented in a header). +// ---------------------------------------------------------------------------- +// +void CCalenActionUi::ShowCalendarsL() + { + TRACE_ENTRY_POINT; + // Create settings own titlepane and navipane, and swap with existing ones + CEikStatusPane* sp = CEikonEnv::Static()->AppUiFactory()->StatusPane(); + + // Titlepane + CAknTitlePane* newtp = new( ELeave ) CAknTitlePane(); + CleanupStack::PushL( newtp ); + CCoeControl* oldtp = sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), newtp ); + CleanupStack::Pop( newtp ); // ownership is passed to statuspane + TRect oldRect( 0, 0, 0, 0 ); + if( oldtp ) + { + CleanupStack::PushL( oldtp ); + oldRect = oldtp->Rect(); + CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidTitle )); + newtp->SetContainerWindowL( *ctrl ); + newtp->ConstructL(); + newtp->SetRect(oldRect); + newtp->ActivateL(); + } + // NaviPane + CAknNavigationControlContainer* newnp = new( ELeave )CAknNavigationControlContainer(); + CleanupStack::PushL( newnp ); + CCoeControl* oldnp = sp->SwapControlL( TUid::Uid( EEikStatusPaneUidNavi ), newnp ); + CleanupStack::Pop( newnp ); // ownership is passed to statuspane + if( oldnp ) + { + CleanupStack::PushL( oldnp ); + oldRect = oldnp->Rect(); + CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidNavi ) ); + newnp->SetContainerWindowL( *ctrl ); + newnp->ConstructL(); + newnp->SetRect( oldRect ); + newnp->PushDefaultL(); + newnp->ActivateL(); + } + + // Hide the toolbar before we display settings menu + MCalenToolbar* toolbar = iController.Services().ToolbarOrNull(); + if(toolbar) + { + toolbar->SetToolbarVisibilityL(EFalse); + } + + // defer settings notifications before launching the settings + CCalenNotifier& notifier = iController.Notifier(); + notifier.DeferSettingsNotifications(); + + CCalenMultipleDbUi* dlg = CCalenMultipleDbUi::NewL(iController); + TInt retValue = KErrNone; + // Trap showing settings so settings watcher is always resumed. + PIM_TRAPD_HANDLE( retValue = dlg->ExecuteLD( R_CALEN_MULTIPLEDB_DIALOG ) ); + notifier.ResumeSettingsNotifications(); + + // Unhide the toolbar when manage calendar view is closed + TUid activeViewUid = iController.ViewManager().CurrentView(); + if(toolbar && (activeViewUid != KUidCalenMissedAlarmsView ) &&(activeViewUid != KUidCalenMissedEventView ) ) + { + toolbar->SetToolbarVisibilityL(ETrue); + } + + // When setting is closed, swap back old titlepane and navipane + if( oldnp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidNavi), oldnp ) ) + { + CleanupStack::Pop( oldnp ); + delete newnp; + oldnp->ActivateL(); + } + if( oldtp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), oldtp ) ) + { + CleanupStack::Pop( oldtp ); + delete newtp; + oldtp->ActivateL(); + } + + iController.BroadcastNotification( ECalenNotifyCalendarFieldChanged ); + + if( retValue == EAknCmdExit || + retValue == EKeyEscape ) + { + // iController.IssueCommandL( EAknCmdExit ); + // FIX ME :: + // Issuing the command from here will not exit the application properly + // because aknviewappui is not exited + // Calling ProcessCommandL of aknviewappui will exits the application + iController.AppUi().ProcessCommandL(EAknCmdExit); + } + else if(retValue == EAknSoftkeyExit) + { + // iController.IssueCommandL( EAknCmdExit ); + // FIX ME :: + // Issuing the command from here will not exit the application properly + // because aknviewappui is not exited + // Calling ProcessCommandL of aknviewappui will exits the application + iController.AppUi().ProcessCommandL(EAknSoftkeyExit); + } + + TRACE_EXIT_POINT; + } + +// ---------------------------------------------------------------------------- +// CCalenActionUi::ShowSettingsL +// Shows the settings dialog +// (other items were commented in a header). // ---------------------------------------------------------------------------- // -void CCalenActionUi::saveAndCloseEditor() +void CCalenActionUi::ShowSettingsL() { - iEditUi->saveAndCloseEditor(); + TRACE_ENTRY_POINT; + + // Create settings own titlepane and navipane, and swap with existing ones + CEikStatusPane* sp = CEikonEnv::Static()->AppUiFactory()->StatusPane(); + + // Titlepane + CAknTitlePane* newtp = new( ELeave ) CAknTitlePane(); + CleanupStack::PushL( newtp ); + CCoeControl* oldtp = sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), newtp ); + CleanupStack::Pop( newtp ); // ownership is passed to statuspane + TRect oldRect( 0, 0, 0, 0 ); + if( oldtp ) + { + CleanupStack::PushL( oldtp ); + oldRect = oldtp->Rect(); + CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidTitle )); + newtp->SetContainerWindowL( *ctrl ); + newtp->ConstructL(); + newtp->SetRect(oldRect); + newtp->ActivateL(); + } + + // NaviPane + CAknNavigationControlContainer* newnp = new( ELeave )CAknNavigationControlContainer(); + CleanupStack::PushL( newnp ); + CCoeControl* oldnp = sp->SwapControlL( TUid::Uid( EEikStatusPaneUidNavi ), newnp ); + CleanupStack::Pop( newnp ); // ownership is passed to statuspane + if( oldnp ) + { + CleanupStack::PushL( oldnp ); + oldRect = oldnp->Rect(); + CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidNavi ) ); + newnp->SetContainerWindowL( *ctrl ); + newnp->ConstructL(); + newnp->SetRect( oldRect ); + newnp->PushDefaultL(); + newnp->ActivateL(); + } + + // Hide the toolbar before we display settings menu + MCalenToolbar* toolbar = iController.Services().ToolbarOrNull(); + if(toolbar) + { + toolbar->SetToolbarVisibilityL(EFalse); + } + + // defer settings notifications before launching the settings + CCalenNotifier& notifier = iController.Notifier(); + notifier.DeferSettingsNotifications(); + + CCalenSettingsUi* dlg = CCalenSettingsUi::NewL(iController.CustomisationManager()); + TInt retValue = KErrNone; + // Trap showing settings so settings watcher is always resumed. + PIM_TRAPD_HANDLE( retValue = dlg->ExecuteLD( R_CALEN_SETTING_DIALOG ) ); + notifier.ResumeSettingsNotifications(); + + // Unhide the toolbar when settings is closed + TUid activeViewUid = iController.ViewManager().CurrentView(); + if(toolbar && (activeViewUid != KUidCalenMissedAlarmsView ) &&(activeViewUid != KUidCalenMissedEventView ) ) + { + toolbar->SetToolbarVisibilityL(ETrue); + } + + // When setting is closed, swap back old titlepane and navipane + if( oldnp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidNavi), oldnp ) ) + { + CleanupStack::Pop( oldnp ); + delete newnp; + oldnp->ActivateL(); + } + if( oldtp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), oldtp ) ) + { + CleanupStack::Pop( oldtp ); + delete newtp; + oldtp->ActivateL(); + } + + iController.BroadcastNotification( ECalenNotifySettingsClosed ); + + if( retValue == EAknCmdExit || + retValue == EKeyEscape ) + { + // iController.IssueCommandL( EAknCmdExit ); + // FIX ME :: + // Issuing the command from here will not exit the application properly + // because aknviewappui is not exited + // Calling ProcessCommandL of aknviewappui will exits the application + iController.AppUi().ProcessCommandL(EAknCmdExit); + } + else if(retValue == EAknSoftkeyExit) + { + // iController.IssueCommandL( EAknCmdExit ); + // FIX ME :: + // Issuing the command from here will not exit the application properly + // because aknviewappui is not exited + // Calling ProcessCommandL of aknviewappui will exits the application + iController.AppUi().ProcessCommandL(EAknSoftkeyExit); + } + + TRACE_EXIT_POINT; } + +// ----------------------------------------------------------------------------- +// CCalenActionUi::IsEditorActive +// Tells framework whether editor is active or not +// ----------------------------------------------------------------------------- +// +TBool CCalenActionUi::IsEditorActive() + { + if(iEditUi) + { + return(iEditUi->IsEditorActive()); + } + else + return EFalse; + } + // End of file