calendarui/controller/src/calencontroller.cpp
branchRCL_3
changeset 30 bd7edf625bdd
parent 29 12af337248b1
child 31 97232defd20e
equal deleted inserted replaced
29:12af337248b1 30:bd7edf625bdd
    14 * Description:  Calendar controller
    14 * Description:  Calendar controller
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include <e32std.h>
    19 #include <aknnotewrappers.h>            // CAknInformationNote
    20 #include <hbmainwindow.h>
    20 #include <aknViewAppUi.h>               // CAknViewAppUi
    21 #include <hbwidget.h>
    21 #include <StringLoader.h>               // Loads strings from resource
    22 #include <hbinstance.h>
    22 #include <aknappui.h>
    23 #include <hbapplication.h> //Activity Manager
    23 #include <bautils.h>
    24 #include <xqserviceutil.h> // service utils
    24 #include <data_caging_path_literals.hrh>
    25 
    25 #include <pathinfo.h>
    26 // User includes
    26 #include <avkon.hrh>
       
    27 #include "calenviewinfo.h"              // View information
       
    28 #include <Calendar.rsg>                 // Calendar resourcess
       
    29 #include <missedalarmstore.h>           // missed alarm store
       
    30 #include <calsession.h>
       
    31 #include <calencommandhandler.h>
       
    32 #include <calencontext.h>
       
    33 #include <calenconstants.h>             // KCalenLostAlarms etc
       
    34 #include <calcalendarinfo.h>
       
    35 
       
    36 #include "calendarui_debug.h"           // Debug macros
    27 #include "calencontroller.h"            // CCalenController
    37 #include "calencontroller.h"            // CCalenController
    28 #include "calenviewmanager.h"           // Responsible for all view activations        
    38 #include "calenactionui.h"              // Default command handling
       
    39 #include "calennotifier.h"              // Broadcasts system events
       
    40 #include "calenviewmanager.h"           // Responsible for all view activations
       
    41 #include "calenalarmmanager.h" 			// Alarm Manager
    29 #include "calenservicesimpl.h"          // MCalenServices implementation
    42 #include "calenservicesimpl.h"          // MCalenServices implementation
    30 #include "calenactionui.h"              // Default command handling
    43 #include "calensetting.h"
       
    44 #include "calencmdlinelauncher.h"       // Command line launcher
    31 #include "calencustomisationmanager.h"  // Customisation Manager
    45 #include "calencustomisationmanager.h"  // Customisation Manager
    32 #include "calennotificationhandler.h"
       
    33 #include "calennotifier.h"
       
    34 #include "hb_calencommands.hrh"
       
    35 #include "calendarui_debug.h"           // Debug macros
       
    36 #include "calenstatemachine.h"
    46 #include "calenstatemachine.h"
    37 #include "calenservicesimpl.h"          // Calendar service implementation
    47 #include "calenicons.h"
    38 #include "CalenUid.h"
    48 #include "calentoolbarimpl.h"
    39 #include "calencontextimpl.h"
    49 #include "calenmultipledbmanager.h"
    40 #include "OstTraceDefinitions.h"
    50 #include "calenattachmentmodel.h"
    41 #ifdef OST_TRACE_COMPILER_IN_USE
    51 
    42 #include "calencontrollerTraces.h"
       
    43 #endif
       
    44 
       
    45 
       
    46 // Constants
       
    47 const TInt KCustomCommandRangeStart     = ECalenLastCommand; 
    52 const TInt KCustomCommandRangeStart     = ECalenLastCommand; 
    48 const TInt KNumberOfCommandsPerServices = 100;
    53 const TInt KNumberOfCommandsPerServices = 100;
    49 
    54 _LIT( KResourceFile, "calencommonui.rsc" );
    50 // ----------------------------------------------------------------------------
    55 
    51 // CCalenController::CCalenController
    56 // ----------------------------------------------------------------------------
    52 // Constructor
    57 // CCalenController::NewL
    53 // (other items were commented in a header).
    58 // First stage construction. This will leave if an instance of the controller
    54 // ----------------------------------------------------------------------------
    59 // already exists.  All access to an instance of the controller should be
    55 //
    60 // through the InstanceL function, except for the initial construction
    56 CCalenController::CCalenController()
    61 // which should be handled by the appui.
    57 {
    62 // This is to prevent usage of this API through the services dll when Calendar
    58     OstTraceFunctionEntry0( CCALENCONTROLLER_CCALENCONTROLLER_ENTRY );
    63 // application is not running.
    59     
    64 // (other items were commented in a header).
    60 	// Check the Application Startup reason, set iIsFromServiceFrmWrk if application
    65 // ----------------------------------------------------------------------------
    61 	// is started by service framework, false otherwise
    66 //
    62     /*Hb::ActivationReasonService == qobject_cast<HbApplication*>(qApp)->activateReason() ? 
    67 EXPORT_C CCalenController* CCalenController::NewL( CAknViewAppUi& aAppUi )
    63         iIsFromServiceFrmWrk = true:
    68     {
    64         iIsFromServiceFrmWrk = false; */
    69     TRACE_ENTRY_POINT;
    65     
    70 
    66     // Check if calendar is launched thru XQService framework
    71     CCalenController* self = NULL;
    67     iIsFromServiceFrmWrk = XQServiceUtil::isService(); // Since activateReason 
    72     TAny* tlsPtr = Dll::Tls();
    68     //of hbapplication is not returning right value if the activity is started 
    73 
    69     //as services so using the above line temporarily untill a fix is available in 
    74     // Check Thread local storage
    70     // hbappliacation. Need to remove this line after the fix is available for hbapplcation
    75     if( !tlsPtr )
    71     
    76         {
    72     iNextServicesCommandBase = KCustomCommandRangeStart;
    77         // TLS is NULL, so no CCalenController has been created yet.
    73     iRefCount = 0;
    78         self = new( ELeave ) CCalenController( aAppUi );
    74     mAgendaUtil = 0;
    79         CleanupStack::PushL( self );
    75     
    80         // Store a self pointer in TLS
    76     OstTraceFunctionExit0( CCALENCONTROLLER_CCALENCONTROLLER_EXIT );
    81         User::LeaveIfError( Dll::SetTls( static_cast<TAny*>( self ) ) );
    77 }
    82         // Increment ref count right away. If we don't do it here, and someone
    78 
    83         // calls Controller::InstanceL in ConstructL and then ConstructL
    79 // ----------------------------------------------------------------------------
    84         // leaves, we will double delete the controller.
    80 // CCalenController::constuctController
    85         ++self->iRefCount;
    81 // Construct the controller completely
    86         self->ConstructL();
    82 // (other items were commented in a header).
    87         CleanupStack::Pop( self );
    83 // ----------------------------------------------------------------------------
    88         }
    84 //
    89     else
    85 void CCalenController::constructController()
    90         {
    86 {
    91         // An instance of the controller exists already.
    87 	OstTraceFunctionEntry0( CCALENCONTROLLER_CONSTRUCTCONTROLLER_ENTRY );
    92         // This function should only have been called once, by CCalenAppUi
    88 	// Store the pointer in tls, also avoid multiple creations
    93         User::Leave( KErrAlreadyExists );
    89 	checkMultipleCreation();
    94         }
    90 
    95 
    91 	// Get an instance of AgendaUtil interface class
    96     TRACE_EXIT_POINT;
    92 	// This will take care of 
    97     return self;
    93 	mAgendaUtil = new AgendaUtil();
    98     }
    94 
       
    95 	iStateMachine = CCalenStateMachine::NewL( *this );
       
    96 
       
    97 	// Create the notifier.
       
    98 	iNotifier = new( ELeave )CalenNotifier( *iStateMachine );
       
    99 
       
   100 	// Construct the context
       
   101 	mContext = new CalenContextImpl(iNotifier);
       
   102 
       
   103 	// Set the default context.Once will start use of calencmdlinelauncher,
       
   104 	// Then need to remove this function
       
   105 	SetDefaultContext();
       
   106 
       
   107 	RArray<TCalenNotification> notificationArray;
       
   108 	// Complete construction of the notifier and register the
       
   109 	// global data for notifications
       
   110 	iNotifier->ConstructL();
       
   111 
       
   112 	// Create the services
       
   113 	iServices = CalenServicesImpl::NewL();
       
   114 	// Create the customisation manager, and register for 
       
   115 	// notifications
       
   116 	iCustomisationManager = CCalenCustomisationManager::NewL( *this,
       
   117 	                                                          *iServices );
       
   118 	// Create the view manager, and register for notifications
       
   119 	iViewManager = new CalenViewManager(*this);
       
   120 
       
   121 	iViewManager->SecondPhaseConstruction();
       
   122 
       
   123 	hbInstance->allMainWindows().first()->show();
       
   124 
       
   125 	// Create the action uis.
       
   126 	iActionUi = CCalenActionUi::NewL( *this );
       
   127 
       
   128 	notificationArray.Append(ECalenNotifySettingsChanged);
       
   129 	notificationArray.Append(ECalenNotifyCheckPluginUnloading);
       
   130 	notificationArray.Append(ECalenNotifyEComRegistryChanged);
       
   131 	notificationArray.Append(ECalenNotifySystemLanguageChanged);
       
   132 
       
   133 	RegisterForNotificationsL( iCustomisationManager,notificationArray);
       
   134 	notificationArray.Reset();
       
   135 
       
   136 	notificationArray.Append(ECalenNotifyViewPopulationComplete);
       
   137 	notificationArray.Append(ECalenNotifyExternalDatabaseChanged);
       
   138 	notificationArray.Append(ECalenNotifyMultipleEntriesDeleted);
       
   139 	notificationArray.Append(ECalenNotifyDialogClosed);
       
   140 	notificationArray.Append(ECalenNotifyEntrySaved);
       
   141 	notificationArray.Append(ECalenNotifyEntryDeleted);
       
   142 	notificationArray.Append(ECalenNotifyInstanceDeleted);
       
   143 	notificationArray.Append(ECalenNotifySystemLocaleChanged);
       
   144 	notificationArray.Append(ECalenNotifySystemLanguageChanged);
       
   145 	notificationArray.Append(ECalenNotifySystemTimeChanged);
       
   146 	notificationArray.Append(ECalenNotifyEntryClosed);
       
   147 	notificationArray.Append(ECalenNotifySettingsClosed);
       
   148 
       
   149 	RegisterForNotificationsL( iViewManager, notificationArray );
       
   150 	notificationArray.Reset();  
       
   151 	notificationArray.Close();
       
   152 	
       
   153 	OstTraceFunctionExit0( CCALENCONTROLLER_CONSTRUCTCONTROLLER_EXIT );
       
   154 }
       
   155 
       
   156 void CCalenController::checkMultipleCreation()
       
   157 {
       
   158 	OstTraceFunctionEntry0( CCALENCONTROLLER_CHECKMULTIPLECREATION_ENTRY );
       
   159 	TAny* tlsPtr = Dll::Tls();
       
   160 
       
   161 	// Check Thread local storage
       
   162 	if( !tlsPtr )
       
   163 		{
       
   164 		// Store a self pointer in TLS
       
   165 		User::LeaveIfError( Dll::SetTls( static_cast<TAny*>( this ) ) );
       
   166 		// Increment ref count right away. If we don't do it here, and someone
       
   167 		// calls Controller::InstanceL in ConstructL and then ConstructL
       
   168 		// leaves, we will double delete the controller.
       
   169 		++this->iRefCount;
       
   170 		}
       
   171 	else
       
   172 		{
       
   173 		// An instance of the controller exists already.
       
   174 		// This function should only have been called once, by CCalenAppUi
       
   175 		User::Leave( KErrAlreadyExists );
       
   176 		}	
       
   177 	OstTraceFunctionExit0( CCALENCONTROLLER_CHECKMULTIPLECREATION_EXIT );
       
   178 }
       
   179 
    99 
   180 // ----------------------------------------------------------------------------
   100 // ----------------------------------------------------------------------------
   181 // CCalenController::InstanceL
   101 // CCalenController::InstanceL
   182 // Returns a pointer to the single instance of the Calendar Controller.
   102 // Returns a pointer to the single instance of the Calendar Controller.
   183 // Leaves with KErrNotReady if the controller has not already been created
   103 // Leaves with KErrNotReady if the controller has not already been created
   184 // using NewL.  A leave here means that the Calendar application is not running
   104 // using NewL.  A leave here means that the Calendar application is not running
   185 // but someone is trying to use the services API.
   105 // but someone is trying to use the services API.
   186 // (other items were commented in a header).
   106 // (other items were commented in a header).
   187 // ----------------------------------------------------------------------------
   107 // ----------------------------------------------------------------------------
   188 //
   108 //
   189 CCalenController* CCalenController::InstanceL()
   109 EXPORT_C CCalenController* CCalenController::InstanceL()
   190     {
   110     {
   191     OstTraceFunctionEntry0( CCALENCONTROLLER_INSTANCEL_ENTRY );
   111     TRACE_ENTRY_POINT;
   192     
   112 
   193     CCalenController* self = NULL;
   113     CCalenController* self = NULL;
   194     TAny* tlsPtr = Dll::Tls();
   114     TAny* tlsPtr = Dll::Tls();
   195 
   115 
   196     // Check Thread local storage
   116     // Check Thread local storage
   197     if( !tlsPtr )
   117     if( !tlsPtr )
   206         self = static_cast<CCalenController*>( tlsPtr );
   126         self = static_cast<CCalenController*>( tlsPtr );
   207         }
   127         }
   208 
   128 
   209     ++self->iRefCount;
   129     ++self->iRefCount;
   210 
   130 
   211     
   131     TRACE_EXIT_POINT;
   212     OstTraceFunctionExit0( CCALENCONTROLLER_INSTANCEL_EXIT );
   132     return self;
   213     return self;    
   133     }
   214     }
   134 
   215 
   135 // ----------------------------------------------------------------------------
   216 // ----------------------------------------------------------------------------
   136 // CCalenController::ConstructL
   217 // CCalenController::ReleaseCustomisations
   137 // 2nd phase of construction
   218 // Releases any plugins by deleting the customisation manager
   138 // (other items were commented in a header).
   219 // should only be called on exiting by the application.
   139 // ----------------------------------------------------------------------------
   220 // (other items were commented in a header).
   140 //
   221 // ----------------------------------------------------------------------------
   141 void CCalenController::ConstructL()
   222 //
   142     {
   223 void CCalenController::ReleaseCustomisations()
   143     TRACE_ENTRY_POINT;
   224     {
   144     
   225     OstTraceFunctionEntry0( CCALENCONTROLLER_RELEASECUSTOMISATIONS_ENTRY );
   145        	TFileName fileName;
   226     
   146 	// Get the complate path of the DLL from where it is currently loaded
   227     delete iCustomisationManager;
   147 	Dll::FileName( fileName );
   228     iCustomisationManager = NULL;
   148 	
   229     
   149 	TFileName resFile;
   230     OstTraceFunctionExit0( CCALENCONTROLLER_RELEASECUSTOMISATIONS_EXIT );
   150 	
       
   151 	// Append the Drive letters ex., Z: or C:
       
   152 	resFile.Append(fileName.Mid(0,2));
       
   153 	resFile.Append(KDC_RESOURCE_FILES_DIR);
       
   154     resFile.Append(KResourceFile);
       
   155     
       
   156     BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), resFile );
       
   157     
       
   158 	iResourceFileOffset = CEikonEnv::Static()->AddResourceFileL( resFile );
       
   159 	
       
   160     
       
   161 	iStateMachine = CCalenStateMachine::NewL( *this );
       
   162     // Create the notifier.
       
   163     iNotifier = new( ELeave )CCalenNotifier( *this );
       
   164 
       
   165     // Get an instance of the global data
       
   166     iGlobalData = CCalenGlobalData::NewL( *iNotifier, iNotifier, iNotifier );
       
   167     iGlobalData->InitializeGlobalDataL();
       
   168     
       
   169     RArray<TCalenNotification> notificationArray;
       
   170     // Complete construction of the notifier and register the
       
   171     // global data for notifications
       
   172     iNotifier->ConstructL();
       
   173     
       
   174     notificationArray.Append(ECalenNotifyEntryInstanceViewCreated);
       
   175     notificationArray.Append(ECalenNotifyEntryInstanceViewCreationFailed);
       
   176     notificationArray.Append(ECalenNotifyDeleteInstanceView);
       
   177     notificationArray.Append(ECalenNotifyRealExit);
       
   178     notificationArray.Append(ECalenNotifyCalendarInfoCreated);
       
   179     notificationArray.Append(ECalenNotifyCalendarInfoUpdated);
       
   180     
       
   181 
       
   182     RegisterForNotificationsL( iGlobalData,notificationArray);
       
   183     notificationArray.Reset();
       
   184     
       
   185     // Create the cmd line handler
       
   186     iCmdLineLauncher = CCalenCmdLineLauncher::NewL( *this, iAppUi );
       
   187     
       
   188     // Create the services
       
   189     iServices = CCalenServicesImpl::NewL();
       
   190     
       
   191     // Create the action uis.
       
   192     iActionUi = CCalenActionUi::NewL( *this );
       
   193     
       
   194     // Create the settings
       
   195     iSetting = CCalenSetting::InstanceL();
       
   196     
       
   197     // Create the view manager, and register for notifications
       
   198     iViewManager = CCalenViewManager::NewL( iAppUi, *this );
       
   199     
       
   200     notificationArray.Append(ECalenNotifySettingsChanged);
       
   201     notificationArray.Append(ECalenNotifySettingsClosed);
       
   202     notificationArray.Append(ECalenNotifySystemLocaleChanged);
       
   203     notificationArray.Append(ECalenNotifyPluginEnabledDisabled);
       
   204     notificationArray.Append(ECalenNotifyEntrySaved);
       
   205     notificationArray.Append(ECalenNotifyEntryDeleted);
       
   206     notificationArray.Append(ECalenNotifyInstanceDeleted);
       
   207     notificationArray.Append(ECalenNotifyMultipleEntriesDeleted);
       
   208     notificationArray.Append(ECalenNotifyExternalDatabaseChanged);
       
   209     notificationArray.Append(ECalenNotifyDeleteFailed);
       
   210     notificationArray.Append(ECalenNotifyEntryClosed);
       
   211 	notificationArray.Append(ECalenNotifyCancelDelete);
       
   212     notificationArray.Append(ECalenNotifySystemTimeChanged);
       
   213     notificationArray.Append(ECalenNotifyAppForegrounded);
       
   214     notificationArray.Append(ECalenNotifyDayViewClosed);
       
   215     notificationArray.Append(ECalenNotifyWeekViewClosed);
       
   216     notificationArray.Append(ECalenNotifyAppBackgrounded);
       
   217     notificationArray.Append(ECalenNotifyViewPopulationComplete);
       
   218     notificationArray.Append(ECalenNotifyCalendarFieldChanged);
       
   219     notificationArray.Append(ECalenNotifyCancelStatusUpdation);
       
   220     notificationArray.Append(ECalenNotifyMarkedEntryCompleted);
       
   221     notificationArray.Append(ECalenNotifyAttachmentAdded);
       
   222     notificationArray.Append(ECalenNotifyAttachmentViewerClosed);
       
   223     notificationArray.Append(ECalenNotifyAttachmentRemoved);
       
   224     notificationArray.Append(ECalenNotifyCalendarInfoCreated);
       
   225     notificationArray.Append(ECalenNotifyCalendarInfoUpdated);
       
   226     notificationArray.Append(ECalenNotifyCalendarFileDeleted);
       
   227     
       
   228     RegisterForNotificationsL( iViewManager, notificationArray );
       
   229     notificationArray.Reset();
       
   230                                                          
       
   231     // Create the customisation manager, and register for 
       
   232     // notifications
       
   233     iCustomisationManager = CCalenCustomisationManager::NewL( *this,
       
   234                                                               iSetting->PluginAvailability(),
       
   235                                                               *iServices,
       
   236                                                               iViewManager->ViewInfoArray() );
       
   237                                                                     
       
   238     notificationArray.Append(ECalenNotifySettingsChanged);
       
   239     notificationArray.Append(ECalenNotifyCheckPluginUnloading);
       
   240     notificationArray.Append(ECalenNotifyEComRegistryChanged);
       
   241     
       
   242     RegisterForNotificationsL( iCustomisationManager,notificationArray);
       
   243     notificationArray.Reset();
       
   244     
       
   245     // Some plugins may have been added or removed - update the settings.
       
   246     iSetting->UpdatePluginListL( *iCustomisationManager );
       
   247     
       
   248     // View manager constructs the custom views using the
       
   249     // customisation manager
       
   250     iViewManager->ConstructCustomViewsL( *iCustomisationManager );
       
   251     
       
   252     // for handling missed alarms/msk improvements for alarm
       
   253     iAlarmManager = CCalenAlarmManager::NewL(*this); 
       
   254     
       
   255     notificationArray.Append(ECalenNotifyLostAlarms);
       
   256     notificationArray.Append(ECalenNotifyMissedAlarmViewClosed);
       
   257     notificationArray.Append(ECalenNotifyClearMissedAlarms);
       
   258     notificationArray.Append(ECalenNotifyMissedEventViewClosed);
       
   259     notificationArray.Append(ECalenNotifyEntryDeleted);
       
   260     notificationArray.Append(ECalenNotifyInstanceDeleted);
       
   261     notificationArray.Append(ECalenNotifyEntrySaved);
       
   262     notificationArray.Append(ECalenNotifyMultipleEntriesDeleted);
       
   263     notificationArray.Append(ECalenNotifySystemTimeChanged);
       
   264     notificationArray.Append(ECalenNotifyAlarmStopped);
       
   265     notificationArray.Append(ECalenNotifyAlarmSnoozed);
       
   266     notificationArray.Append(ECalenNotifyEntryClosed);
       
   267     notificationArray.Append(ECalenNotifyAppForegrounded);
       
   268     
       
   269     RegisterForNotificationsL( iAlarmManager, notificationArray );
       
   270     notificationArray.Reset();
       
   271 
       
   272     //iMultipleDbmanager = CCalenMultipleDbManager::NewL();
       
   273     
       
   274     iAttachmentData = CCalenAttachmentModel::NewL();
       
   275     
       
   276     notificationArray.Close();
       
   277     
       
   278     TRACE_EXIT_POINT;
       
   279     }
       
   280 
       
   281 // ----------------------------------------------------------------------------
       
   282 // CCalenController::CCalenController
       
   283 // C++ default constructor.
       
   284 // (other items were commented in a header).
       
   285 // ----------------------------------------------------------------------------
       
   286 //
       
   287 CCalenController::CCalenController( CAknViewAppUi& aAppUi )
       
   288     : iAppUi( aAppUi ),
       
   289       iNextServicesCommandBase( KCustomCommandRangeStart ),
       
   290       iFasterApp( EFalse )
       
   291     {
       
   292     TRACE_ENTRY_POINT;
       
   293     TRACE_EXIT_POINT;
       
   294     }
       
   295 
       
   296 // ----------------------------------------------------------------------------
       
   297 // CCalenController::~CCalenController
       
   298 // Private destructor, called from Release() when reference count is 0.
       
   299 // Frees all resources.
       
   300 // (other items were commented in a header).
       
   301 // ----------------------------------------------------------------------------
       
   302 //
       
   303 CCalenController::~CCalenController()
       
   304     {    
       
   305     TRACE_ENTRY_POINT;
       
   306 
       
   307     if(iSystemTimeChangedMsgDelayer)
       
   308         {
       
   309         iSystemTimeChangedMsgDelayer->Cancel();
       
   310         delete iSystemTimeChangedMsgDelayer;
       
   311         iSystemTimeChangedMsgDelayer = NULL;
       
   312         }
       
   313     
       
   314     if(iAttachmentData)
       
   315         {
       
   316         delete iAttachmentData;
       
   317         iAttachmentData = NULL;
       
   318         }
       
   319 
       
   320     if( iAlarmManager )
       
   321         {
       
   322         delete iAlarmManager;
       
   323         }
       
   324 
       
   325     if( iCustomisationManager )
       
   326         {
       
   327         delete iCustomisationManager;
       
   328         }
       
   329 
       
   330     if( iViewManager )
       
   331         {
       
   332         delete iViewManager;
       
   333         }
       
   334 
       
   335     if ( iSetting )
       
   336         {
       
   337         iSetting->Release();
       
   338         }
       
   339 
       
   340     if( iActionUi )
       
   341         {
       
   342         delete iActionUi;
       
   343         }
       
   344 
       
   345     if ( iServices )
       
   346         {
       
   347         iServices->Release();
       
   348         }
       
   349 
       
   350     if( iCmdLineLauncher )
       
   351         {
       
   352         delete iCmdLineLauncher;
       
   353         }
       
   354 
       
   355     if( iGlobalData )
       
   356         {
       
   357         iGlobalData->Release();
       
   358         }
       
   359 
       
   360     if( iNotifier )
       
   361         {
       
   362         delete iNotifier;
       
   363         }
       
   364 
       
   365     if( iStateMachine )
       
   366         {
       
   367         delete iStateMachine;
       
   368         }
       
   369 
       
   370    if( iResourceFileOffset )
       
   371        {
       
   372        CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset );
       
   373        }
       
   374     Dll::SetTls( NULL );
       
   375     
       
   376     TRACE_EXIT_POINT;
   231     }
   377     }
   232 
   378 
   233 // ----------------------------------------------------------------------------
   379 // ----------------------------------------------------------------------------
   234 // CCalenController::Release
   380 // CCalenController::Release
   235 // Decrement the reference count of this singleton.
   381 // Decrement the reference count of this singleton.
   236 // When the reference count is 0, the controller will self delete and free
   382 // When the reference count is 0, the controller will self delete and free
   237 // all resources
   383 // all resources
   238 // (other items were commented in a header).
   384 // (other items were commented in a header).
   239 // ----------------------------------------------------------------------------
   385 // ----------------------------------------------------------------------------
   240 //
   386 //
   241 void CCalenController::Release()
   387 EXPORT_C void CCalenController::Release()
   242     {
   388     {
   243     OstTraceFunctionEntry0( CCALENCONTROLLER_RELEASE_ENTRY );
   389     TRACE_ENTRY_POINT;
   244     
   390 
   245     --iRefCount;
   391     --iRefCount;
   246     
   392     
   247     // The controller owns its own instance of the services, therefore the
   393     // The controller owns its own instance of the services, therefore the
   248     // reference count will be one, immediatley before deletion.
   394     // reference count will be one, immediatley before deletion.
   249     if (iRefCount == 1)
   395     if (iRefCount == 1)
   250         {
   396         {
   251         delete this;
   397         delete this;
   252         }
   398         }
   253     
   399 
   254     OstTraceFunctionExit0( CCALENCONTROLLER_RELEASE_EXIT );
   400     TRACE_EXIT_POINT;
   255     }
   401     }
   256 
   402     
   257 // ----------------------------------------------------------------------------
   403 // ----------------------------------------------------------------------------
   258 // CCalenController::~CCalenController
   404 // CCalenController::ReleaseCustomisations
   259 // Private destructor, called from Release() when reference count is 0.
   405 // Releases any plugins by deleting the customisation manager
   260 // Frees all resources.
   406 // should only be called on exiting by the document.
   261 // (other items were commented in a header).
   407 // (other items were commented in a header).
   262 // ----------------------------------------------------------------------------
   408 // ----------------------------------------------------------------------------
   263 //
   409 //
   264 CCalenController::~CCalenController()
   410 EXPORT_C void CCalenController::ReleaseCustomisations()
   265     {
   411     {
   266     OstTraceFunctionEntry0( DUP1_CCALENCONTROLLER_CCALENCONTROLLER_ENTRY );
   412     TRACE_ENTRY_POINT;
   267 
   413     
   268     if(iStateMachine) {
   414     delete iCustomisationManager;
   269     	delete iStateMachine;
   415     iCustomisationManager = NULL;
   270     	iStateMachine = NULL;
   416     
   271     }
   417     TRACE_EXIT_POINT;
   272 
   418     }
   273     if ( iServices )
       
   274         {
       
   275         iServices->Release();
       
   276         }
       
   277     
       
   278     if( mContext )
       
   279 		{
       
   280 		delete mContext;
       
   281 		mContext = NULL;
       
   282 		}
       
   283     // iActionUi has to be deleted before iNotifier
       
   284     // as the unregistering of the notifications has to be done
       
   285     if( iActionUi )
       
   286  	   {
       
   287  	   delete iActionUi;
       
   288  	   iActionUi = NULL;
       
   289  	   }
       
   290     
       
   291     if( iNotifier )
       
   292 		{
       
   293     	delete iNotifier;
       
   294     	iNotifier = NULL;
       
   295 		}
       
   296     
       
   297     if( iViewManager )
       
   298 		{
       
   299     	delete iViewManager;
       
   300     	iViewManager = NULL;
       
   301 		}
       
   302     
       
   303     if( iCustomisationManager )
       
   304 		{
       
   305     	delete iCustomisationManager;
       
   306     	iCustomisationManager = NULL;
       
   307 		}
       
   308 		
       
   309     if (mAgendaUtil) {
       
   310         delete mAgendaUtil;
       
   311         mAgendaUtil = 0;
       
   312     }
       
   313     
       
   314     Dll::SetTls( NULL );
       
   315     
       
   316     OstTraceFunctionExit0( DUP1_CCALENCONTROLLER_CCALENCONTROLLER_EXIT );
       
   317     }
       
   318 
       
   319 
   419 
   320 // ----------------------------------------------------------------------------
   420 // ----------------------------------------------------------------------------
   321 // CCalenController::IssueCommmandL
   421 // CCalenController::IssueCommmandL
   322 // Adds the passed command to the comand queue. Commands are handled
   422 // Adds the passed command to the comand queue. Commands are handled
   323 // asynchronously in HandleCommandL
   423 // asynchronously in HandleCommandL
   324 // Returns EFalse if the passed command is not in the issuers command range
   424 // Returns EFalse if the passed command is not in the issuers command range
   325 // (other items were commented in a header).
   425 // (other items were commented in a header).
   326 // ----------------------------------------------------------------------------
   426 // ----------------------------------------------------------------------------
   327 //
   427 //
   328 TBool CCalenController::IssueCommandL( TInt aCommand )
   428 EXPORT_C TBool CCalenController::IssueCommandL( TInt aCommand )
   329     {
   429     {
   330     OstTraceFunctionEntry0( CCALENCONTROLLER_ISSUECOMMANDL_ENTRY );
   430     TRACE_ENTRY_POINT;
   331     
       
   332     TCalenCommand cmd;
   431     TCalenCommand cmd;
   333     cmd.SetCommandAndContextL( aCommand ,context());
   432     
       
   433     if( aCommand == EAknCmdHideInBackground ||
       
   434 	  ( aCommand == EAknSoftkeyExit && iAppUi.ExitHidesInBackground() ) )
       
   435 	    {
       
   436 	    SetFasterAppFlag( ETrue );
       
   437 	    aCommand = ECalenFasterAppExit;
       
   438 	    }
       
   439     else if( aCommand == EAknCmdExit || aCommand == EEikCmdExit
       
   440              || aCommand == EAknSoftkeyExit )
       
   441         {
       
   442         if( iViewManager->CalenToolbar() )
       
   443             {
       
   444             iViewManager->CalenToolbar()->ResetCalendarToolbar();
       
   445             }
       
   446         }
       
   447     else
       
   448         {
       
   449         if((aCommand < ECalenViewCommandBase ) || (aCommand > iNextServicesCommandBase))
       
   450             {
       
   451             return EFalse;
       
   452             }
       
   453         }
       
   454     
       
   455     cmd.SetCommandAndContextL( aCommand, iGlobalData->Context() );
   334 
   456 
   335     TBool ret = iStateMachine->HandleCommandL( cmd );
   457     TBool ret = iStateMachine->HandleCommandL( cmd );
   336     
   458 
   337     OstTraceFunctionExit0( CCALENCONTROLLER_ISSUECOMMANDL_EXIT );
   459     TRACE_EXIT_POINT;
   338     return ret;
   460     return ret;
   339     }
   461     }
   340 
   462 
   341 // ----------------------------------------------------------------------------
   463 
   342 // CCalenController::Services
   464 // ----------------------------------------------------------------------------
   343 // Returns the services
   465 // CCalenController::RequestActivationL
   344 // (other items were commented in a header).
   466 // Request activation of a specific view
   345 // ----------------------------------------------------------------------------
   467 // (other items were commented in a header).
   346 //
   468 // ----------------------------------------------------------------------------
   347 MCalenServices& CCalenController::Services()
   469 //
   348     {
   470 void CCalenController::RequestActivationL( const TVwsViewId& aViewId )
   349     OstTraceFunctionEntry0( CCALENCONTROLLER_SERVICES_ENTRY );
   471     {
   350     
   472     TRACE_ENTRY_POINT;
   351     OstTraceFunctionExit0( CCALENCONTROLLER_SERVICES_EXIT );
   473 
   352     return *iServices;
   474     iViewManager->RequestActivationL( aViewId );
   353     }
   475 
   354 
   476     TRACE_EXIT_POINT;
   355 // ----------------------------------------------------------------------------
   477     }
   356 // CCalenController::ViewManager
   478 
   357 // Returns a reference to the view manager
   479 // ----------------------------------------------------------------------------
   358 // (other items were commented in a header).
   480 // CCalenController::BroadcastNotification
   359 // ----------------------------------------------------------------------------
       
   360 CalenViewManager& CCalenController::ViewManager()
       
   361     {
       
   362     OstTraceFunctionEntry0( CCALENCONTROLLER_VIEWMANAGER_ENTRY );
       
   363     
       
   364 	OstTraceFunctionExit0( CCALENCONTROLLER_VIEWMANAGER_EXIT );
       
   365 	return *iViewManager;
       
   366     }
       
   367     
       
   368 // ----------------------------------------------------------------------------
       
   369 // CCalenController::MainWindow
       
   370 // Returns a reference to the MainWindow
       
   371 // (other items were commented in a header).
       
   372 // ----------------------------------------------------------------------------
       
   373 HbMainWindow& CCalenController::MainWindow()
       
   374     {
       
   375     
       
   376     OstTraceFunctionEntry0( DUP1_CCALENCONTROLLER_MAINWINDOW_ENTRY );
       
   377 
       
   378     OstTraceFunctionExit0( DUP1_CCALENCONTROLLER_MAINWINDOW_EXIT );
       
   379     
       
   380     return *(hbInstance->allMainWindows().first());
       
   381 	
       
   382 	
       
   383     }    
       
   384 
       
   385 // ----------------------------------------------------------------------------
       
   386 // CCCalenController::BroadcastNotification
       
   387 // Passes the notification to the Calendar Notifier.  The notification will
   481 // Passes the notification to the Calendar Notifier.  The notification will
   388 // then be broadcast to all observers
   482 // then be broadcast to all observers
   389 // (other items were commented in a header).
   483 // (other items were commented in a header).
   390 // ----------------------------------------------------------------------------
   484 // ----------------------------------------------------------------------------
   391 //
   485 //
   392 void CCalenController::BroadcastNotification( TCalenNotification aNotification )
   486 EXPORT_C void CCalenController::BroadcastNotification( TCalenNotification aNotification )
   393     {
   487     {
   394     OstTraceFunctionEntry0( CCALENCONTROLLER_BROADCASTNOTIFICATION_ENTRY );
   488     TRACE_ENTRY_POINT;
   395 
   489     
   396     iNotifier->BroadcastNotification( aNotification );
   490     iNotifier->BroadcastNotification( aNotification );
   397 
   491         
   398     OstTraceFunctionExit0( CCALENCONTROLLER_BROADCASTNOTIFICATION_EXIT );
   492     TRACE_EXIT_POINT;
   399     }
   493     }
   400 
   494 
   401 // ----------------------------------------------------------------------------
   495 // ----------------------------------------------------------------------------
   402 // CCCalenController::RegisterForNotificationsL
   496 // CCalenController::RegisterForNotificationsL
   403 // Registers the passed notification handler with the Calendar Notifier
   497 // Registers the passed notification handler with the Calendar Notifier
   404 // (other items were commented in a header).
   498 // (other items were commented in a header).
   405 // ----------------------------------------------------------------------------
   499 // ----------------------------------------------------------------------------
   406 //
   500 //
   407 void CCalenController::RegisterForNotificationsL( MCalenNotificationHandler* aHandler,
   501 EXPORT_C void CCalenController::RegisterForNotificationsL( MCalenNotificationHandler* aHandler,
   408                                                             TCalenNotification aNotification )
   502                                                             TCalenNotification aNotification )
   409     {
   503     {
   410     OstTraceFunctionEntry0( CCALENCONTROLLER_REGISTERFORNOTIFICATIONSL_ENTRY );
   504     TRACE_ENTRY_POINT;
   411 
   505 
   412     iNotifier->RegisterForNotificationsL( aHandler, aNotification );
   506     iNotifier->RegisterForNotificationsL( aHandler, aNotification );
   413 
   507 
   414     OstTraceFunctionExit0( CCALENCONTROLLER_REGISTERFORNOTIFICATIONSL_EXIT );
   508     TRACE_EXIT_POINT;
   415     }
   509     }
   416 
   510 
   417 // ----------------------------------------------------------------------------
   511 // ----------------------------------------------------------------------------
   418 // CCCalenController::RegisterForNotificationsL
   512 // CCalenController::RegisterForNotificationsL
   419 // Registers the passed notification handler with the Calendar Notifier
   513 // Registers the passed notification handler with the Calendar Notifier
   420 // (other items were commented in a header).
   514 // (other items were commented in a header).
   421 // ----------------------------------------------------------------------------
   515 // ----------------------------------------------------------------------------
   422 //
   516 //
   423 void CCalenController::RegisterForNotificationsL( MCalenNotificationHandler* aHandler,
   517 EXPORT_C void CCalenController::RegisterForNotificationsL( MCalenNotificationHandler* aHandler,
   424                                                             RArray<TCalenNotification>& aNotifications )
   518                                                             RArray<TCalenNotification>& aNotifications )
   425     {
   519     {
   426     OstTraceFunctionEntry0( DUP1_CCALENCONTROLLER_REGISTERFORNOTIFICATIONSL_ENTRY );
   520     TRACE_ENTRY_POINT;
   427 
   521 
   428     iNotifier->RegisterForNotificationsL( aHandler, aNotifications );
   522     iNotifier->RegisterForNotificationsL( aHandler, aNotifications );
   429     
   523 
   430     OstTraceFunctionExit0( DUP1_CCALENCONTROLLER_REGISTERFORNOTIFICATIONSL_EXIT );
   524     TRACE_EXIT_POINT;
   431     }
   525     }
   432 
   526 
   433 // ----------------------------------------------------------------------------
   527 // ----------------------------------------------------------------------------
   434 // CCCalenController::CancelNotifications
   528 // CCalenController::CancelNotifications
   435 // Removes the passed handler from the notifier.
   529 // Removes the passed handler from the notifier.
   436 // (other items were commented in a header).
   530 // (other items were commented in a header).
   437 // ----------------------------------------------------------------------------
   531 // ----------------------------------------------------------------------------
   438 //
   532 //
   439 void CCalenController::CancelNotifications( MCalenNotificationHandler* aHandler )
   533 EXPORT_C void CCalenController::CancelNotifications( MCalenNotificationHandler* aHandler )
   440     {
   534     {
   441     OstTraceFunctionEntry0( CCALENCONTROLLER_CANCELNOTIFICATIONS_ENTRY );
   535     TRACE_ENTRY_POINT;
   442 
   536 
   443     iNotifier->CancelNotifications( aHandler );
   537     iNotifier->CancelNotifications( aHandler );
   444     
   538 
   445     OstTraceFunctionExit0( CCALENCONTROLLER_CANCELNOTIFICATIONS_EXIT );
   539     TRACE_EXIT_POINT;
   446     }
   540     }
   447 
   541 
   448 // ----------------------------------------------------------------------------
   542 // ----------------------------------------------------------------------------
   449 // CCCalenController::GetCommandHandlerL
   543 // CCalenController::GetCommandHandlerL
   450 // Searches for a command handler for a particular command.  Customisations
   544 // Searches for a command handler for a particular command.  Customisations
   451 // are searched first.  If no customisation wants to handle the command it is
   545 // are searched first.  If no customisation wants to handle the command it is
   452 // handled by the view manager or the action uis
   546 // handled by the view manager or the action uis
   453 // ----------------------------------------------------------------------------
   547 // ----------------------------------------------------------------------------
   454 MCalenCommandHandler* CCalenController::GetCommandHandlerL( TInt aCommand )
   548 MCalenCommandHandler* CCalenController::GetCommandHandlerL( TInt aCommand )
   455     {
   549     {
   456     OstTraceFunctionEntry0( CCALENCONTROLLER_GETCOMMANDHANDLERL_ENTRY );
   550     TRACE_ENTRY_POINT;
   457     
   551     
   458     MCalenCommandHandler* handler( NULL );
   552     MCalenCommandHandler* handler( NULL );
   459 
   553 
   460     // Stop non-published commands from being customised
   554     // Stop non-published commands from being customised
   461     if ( aCommand != ECalenShowSettings
   555     if ( aCommand != ECalenShowSettings
   464         // See if a plugin wants the command
   558         // See if a plugin wants the command
   465         handler = iCustomisationManager->GetCommandHandlerL( aCommand );
   559         handler = iCustomisationManager->GetCommandHandlerL( aCommand );
   466         }
   560         }
   467 
   561 
   468     // See if the view manager wants the command
   562     // See if the view manager wants the command
   469     if ( !handler )
   563     if(!handler)
   470         {
   564         {
   471         if (   aCommand >= ECalenViewCommandBase
   565         if( aCommand >= ECalenViewCommandBase
   472             && aCommand < ECalenEditCommandBase )
   566             && aCommand < ECalenEditCommandBase )
   473             {
   567             {
   474             handler = iViewManager;
   568             handler = iViewManager;
   475             }
   569             }
   476      	else if( aCommand >= ECalenMissedAlarmCommandBase
   570      	else if(aCommand >= ECalenMissedAlarmCommandBase
   477       		&& aCommand < ECalenLastCommand )
   571       		&& aCommand < ECalenAttachmentCommandBase )
   478 	    	{
   572 	    	{
   479 	    	//handler = iAlarmManager;
   573 	    	handler = iAlarmManager;
   480 	    	} 
   574 	    	} 
   481         else 
   575         else 
   482             {
   576             {
   483             handler = iActionUi->GetCommandHandlerL( aCommand );
   577             handler = iActionUi->GetCommandHandlerL(aCommand);
   484             }
   578             }
   485         }
   579         }
   486 
   580 
   487     // No command handler is an error  
   581     // No command handler is an error  
   488     
   582     
   489     OstTraceFunctionExit0( CCALENCONTROLLER_GETCOMMANDHANDLERL_EXIT );
       
   490     
       
   491     // return the handler
   583     // return the handler
       
   584     TRACE_EXIT_POINT;
   492     return handler;
   585     return handler;
   493     }
   586     }
   494 
   587 
   495 // ----------------------------------------------------------------------------
   588 // ----------------------------------------------------
   496 // CCCalenController::NewServicesL
   589 //  CCalenController::CheckSystemTimeAtStartUpL
       
   590 //  Check the system time change at the startup
       
   591 // ----------------------------------------------------
       
   592 //
       
   593 void CCalenController::CheckSystemTimeAtStartUpL()
       
   594     {
       
   595     TRACE_ENTRY_POINT;
       
   596 
       
   597     if(iSystemTimeChangedMsgDelayer)
       
   598         {
       
   599         iSystemTimeChangedMsgDelayer->Cancel();
       
   600         delete iSystemTimeChangedMsgDelayer;
       
   601         iSystemTimeChangedMsgDelayer = NULL;
       
   602         }
       
   603     
       
   604     // Introduce delay (CPeriodic) before showing the note 
       
   605     // to allow time for the active view to display before
       
   606     // note.
       
   607     
       
   608     TCallBack callback;
       
   609     callback = TCallBack( SystemTimeChangeCallback, this );
       
   610                                      
       
   611     iSystemTimeChangedMsgDelayer = new (ELeave) CAsyncCallBack(
       
   612                             callback, CActive::EPriorityStandard);
       
   613     iSystemTimeChangedMsgDelayer->CallBack();
       
   614 
       
   615     TRACE_EXIT_POINT;
       
   616     }
       
   617 
       
   618 // ----------------------------------------------------
       
   619 //  CCalenController::SystemTimeChangeCallback
       
   620 //  This function is called when the System time is changed.
       
   621 // ----------------------------------------------------
       
   622 //
       
   623 TInt CCalenController::SystemTimeChangeCallback(TAny* aThisPtr)
       
   624     {
       
   625     TRACE_ENTRY_POINT;
       
   626 
       
   627     PIM_TRAPD_HANDLE(
       
   628         static_cast<CCalenController*>(aThisPtr)->HandleSystemTimeChangeL());
       
   629 
       
   630     TRACE_EXIT_POINT;
       
   631     return 0;
       
   632     }
       
   633 
       
   634 // ----------------------------------------------------------------------------
       
   635 // CCalenController::HandleSystemTimeChangeL
       
   636 // Checks to see if the system time was changed while Calendar was
       
   637 // not running or in the background, potentially causing alarms to be missed
       
   638 // (other items were commented in a header).
       
   639 // ----------------------------------------------------------------------------
       
   640 //
       
   641 void CCalenController::HandleSystemTimeChangeL()
       
   642     {
       
   643     TRACE_ENTRY_POINT;
       
   644     
       
   645     // get the system time change info
       
   646     TInt timeChanged = iNotifier->SystemTimeChangedL();
       
   647 
       
   648     switch( timeChanged )
       
   649         {
       
   650         case KCalenTimeZoneChanged:
       
   651             {
       
   652             ShowSystemChangeInfoNoteL( R_QTN_CALE_NOTE_SYSTEM_TIME_CHANGED );
       
   653             }
       
   654             break;
       
   655         case KCalenLostAlarms:
       
   656             {
       
   657             // Not displayed since missed alarms are handled in missed alarms view.
       
   658             // No need to show the info note the user.
       
   659             // Part of alarm improvement REQ for calendar.
       
   660             //ShowSystemChangeInfoNoteL( R_QTN_CALE_NOTE_MISSED_ALARMS );
       
   661             }
       
   662             break;
       
   663         case KNoUserInfoNoteDisplay:
       
   664         default:
       
   665             break;
       
   666         }
       
   667     
       
   668     // update system time change info to the cenrep
       
   669     iNotifier->UpdateSytemTimeChangeInfoL();
       
   670  
       
   671     TRACE_EXIT_POINT;
       
   672     }
       
   673 
       
   674 // ----------------------------------------------------------------------------
       
   675 // CCalenController::ShowSystemChangeInfoNoteL
       
   676 // Displays an information note if the system time changed while Calendar
       
   677 // was inactive
       
   678 // (other items were commented in a header).
       
   679 // ----------------------------------------------------------------------------
       
   680 //
       
   681 void CCalenController::ShowSystemChangeInfoNoteL( TInt aResourceId )
       
   682     {
       
   683     TRACE_ENTRY_POINT;
       
   684 
       
   685     HBufC* buf = StringLoader::LoadLC( aResourceId, CEikonEnv::Static() );
       
   686     CAknInformationNote* dialog = new( ELeave ) CAknInformationNote();
       
   687 
       
   688     dialog->ExecuteLD( *buf );
       
   689 
       
   690     CleanupStack::PopAndDestroy( buf );
       
   691 
       
   692     TRACE_EXIT_POINT;
       
   693     }
       
   694 
       
   695 // ----------------------------------------------------------------------------
       
   696 // CCalenController::NewServicesL
   497 // Factory function for creating new MCalenServices objects
   697 // Factory function for creating new MCalenServices objects
   498 // (other items were commented in a header).
   698 // (other items were commented in a header).
   499 // ----------------------------------------------------------------------------
   699 // ----------------------------------------------------------------------------
   500 //
   700 //
   501 MCalenServices* CCalenController::NewServicesL()
   701 EXPORT_C MCalenServices* CCalenController::NewServicesL()
   502     {
   702     {
   503     OstTraceFunctionEntry0( CCALENCONTROLLER_NEWSERVICESL_ENTRY );
   703     TRACE_ENTRY_POINT;
   504     
   704 
   505     TInt commandRangeStart = iNextServicesCommandBase;
   705     TInt commandRangeStart = iNextServicesCommandBase;
   506     TInt commandRangeEnd = commandRangeStart + KNumberOfCommandsPerServices;
   706     TInt commandRangeEnd = commandRangeStart + KNumberOfCommandsPerServices;
   507     iNextServicesCommandBase = commandRangeEnd + 1;
   707     iNextServicesCommandBase = commandRangeEnd + 1;
   508 
   708 
   509     CalenServicesImpl* svc = CalenServicesImpl::NewL( commandRangeStart,commandRangeEnd );
   709     CCalenServicesImpl* svc = CCalenServicesImpl::NewL( commandRangeStart,
   510     
   710                                                                               commandRangeEnd );
   511     OstTraceFunctionExit0( CCALENCONTROLLER_NEWSERVICESL_EXIT );
   711     TRACE_EXIT_POINT;
   512     return svc;
   712     return svc;
       
   713     }
       
   714 
       
   715 // ----------------------------------------------------------------------------
       
   716 // CCalenController::ProcessCommandParametersL
       
   717 // Takes care of commandline parameters.
       
   718 // (other items were commented in a header).
       
   719 // ----------------------------------------------------------------------------
       
   720 //
       
   721 EXPORT_C void CCalenController::ProcessCommandParametersL( TApaCommand aCommand,
       
   722                                                        TFileName& aDocumentName,
       
   723                                                        const TDesC8& aTail )
       
   724     {
       
   725     TRACE_ENTRY_POINT;
       
   726 
       
   727     iCmdLineLauncher->ProcessCommandParametersL( aCommand, aDocumentName, aTail );
       
   728 
       
   729     TRACE_EXIT_POINT;
   513     }
   730     }
   514 
   731 
   515 // ----------------------------------------------------------------------------
   732 // ----------------------------------------------------------------------------
   516 // CCalenController::Notifier
   733 // CCalenController::Notifier
   517 // Returns the notifier.
   734 // Returns the notifier.
   518 // (other items were commented in a header).
   735 // (other items were commented in a header).
   519 // ----------------------------------------------------------------------------
   736 // ----------------------------------------------------------------------------
   520 //
   737 //
   521 CalenNotifier& CCalenController::Notifier()
   738 CCalenNotifier& CCalenController::Notifier()
   522     {
   739     {
   523     OstTraceFunctionEntry0( CCALENCONTROLLER_NOTIFIER_ENTRY );
   740     TRACE_ENTRY_POINT;
   524     
   741     TRACE_EXIT_POINT;
   525     OstTraceFunctionExit0( CCALENCONTROLLER_NOTIFIER_EXIT );
       
   526     return *iNotifier;
   742     return *iNotifier;
   527     }
   743     }
   528     
   744 
       
   745 // ----------------------------------------------------------------------------
       
   746 // CCalenController::SetExitOnDialogFlag
       
   747 // (other items were commented in a header).
       
   748 // ----------------------------------------------------------------------------
       
   749 //
       
   750 void CCalenController::SetExitOnDialogFlag( TBool aFlag )
       
   751     {
       
   752     TRACE_ENTRY_POINT;
       
   753     
       
   754     iCmdLineLauncher->SetExitOnDialogclose( aFlag );
       
   755     
       
   756     TRACE_EXIT_POINT;
       
   757     }
       
   758 
       
   759 // ----------------------------------------------------------------------------
       
   760 // CCalenController::GetExitOnDialogFlag
       
   761 // (other items were commented in a header).
       
   762 // ----------------------------------------------------------------------------
       
   763 //
       
   764 TBool CCalenController::GetExitOnDialogFlag()
       
   765     {
       
   766     TRACE_ENTRY_POINT;
       
   767 
       
   768     TBool tempVal;
       
   769     tempVal = iCmdLineLauncher->GetExitOnDialogStatus();
       
   770     return tempVal;
       
   771 
       
   772     TRACE_EXIT_POINT;
       
   773     }
       
   774     
       
   775 // ----------------------------------------------------------------------------
       
   776 // CCalenController::Services
       
   777 // Returns the services
       
   778 // (other items were commented in a header).
       
   779 // ----------------------------------------------------------------------------
       
   780 //
       
   781 MCalenServices& CCalenController::Services()
       
   782     {
       
   783     TRACE_ENTRY_POINT;
       
   784     TRACE_EXIT_POINT;
       
   785     return *iServices;
       
   786     }
       
   787 
       
   788 // ----------------------------------------------------------------------------
       
   789 // CCalenController::OfferMenuPaneL
       
   790 // Offers the menu pane to plugins for customisation.
       
   791 // Acts as a conduit between the services and the customisation manager.
       
   792 // (other items were commented in a header).
       
   793 // ----------------------------------------------------------------------------
       
   794 //
       
   795 EXPORT_C void CCalenController::OfferMenuPaneL( TInt aResourceId,
       
   796                                                                      CEikMenuPane* aMenuPane )
       
   797     {
       
   798     TRACE_ENTRY_POINT;
       
   799 
       
   800     iCustomisationManager->OfferMenuPaneL( aResourceId, aMenuPane );
       
   801 
       
   802     if( aResourceId == R_CALENDAR_CHANGE_VIEW_MENUPANE )
       
   803         {
       
   804         // The cascading view switch menu is being displayed
       
   805         // therefore the view manager needs to be asked to remove
       
   806         // the current view
       
   807         iViewManager->RemoveCurrentViewFromMenu( aMenuPane );
       
   808         }
       
   809     
       
   810     TUint32 missedAlarmsCount(0);
       
   811     // get the count from missed alarm store
       
   812     iAlarmManager->MissedAlarmStore()->CountL(missedAlarmsCount);
       
   813     
       
   814     //For adding "Missed Alarms" menu item for native views menu pane
       
   815     if(!missedAlarmsCount)
       
   816         {
       
   817         if( aResourceId == R_CALENDAR_MONTH_MENUPANE
       
   818             || aResourceId == R_CALENDAR_DAY_MENUPANE
       
   819             || aResourceId == R_CALENDAR_WEEK_MENUPANE
       
   820             || aResourceId == R_TODO_LIST_MENUPANE )
       
   821                 {
       
   822                 aMenuPane->DeleteMenuItem(ECalenMissedAlarmsView);
       
   823                 }
       
   824         }
       
   825 
       
   826     TRACE_EXIT_POINT;
       
   827     }
       
   828 
   529 // ----------------------------------------------------------------------------
   829 // ----------------------------------------------------------------------------
   530 // CCalenController::Infobar
   830 // CCalenController::Infobar
   531 // Descriptor passed to plugins to get customised info bar text.
   831 // Descriptor passed to plugins to get customised info bar text.
   532 // Acts as a conduit between the services and the customisation manager.
   832 // Acts as a conduit between the services and the customisation manager.
   533 // (other items were commented in a header).
   833 // (other items were commented in a header).
   534 // ----------------------------------------------------------------------------
   834 // ----------------------------------------------------------------------------
   535 //
   835 //
   536 HbWidget* CCalenController::Infobar()
   836 EXPORT_C CCoeControl* CCalenController::Infobar( const TRect& aRect )
   537     {
   837     {
   538     OstTraceFunctionEntry0( DUP1_CCALENCONTROLLER_INFOBAR_ENTRY );
   838     TRACE_ENTRY_POINT;
   539     
   839     TRACE_EXIT_POINT;
   540     OstTraceFunctionExit0( DUP1_CCALENCONTROLLER_INFOBAR_EXIT );
   840     return iCustomisationManager->Infobar( aRect );
       
   841     }
       
   842 
       
   843 // ----------------------------------------------------------------------------
       
   844 // CCalenController::Infobar
       
   845 // Descriptor passed to plugins to get customised info bar text.
       
   846 // Acts as a conduit between the services and the customisation manager.
       
   847 // (other items were commented in a header).
       
   848 // ----------------------------------------------------------------------------
       
   849 //
       
   850 EXPORT_C const TDesC& CCalenController::Infobar()
       
   851     {
       
   852     TRACE_ENTRY_POINT;
       
   853     TRACE_EXIT_POINT;
   541     return iCustomisationManager->Infobar();
   854     return iCustomisationManager->Infobar();
   542     }
   855     }
   543 // ----------------------------------------------------------------------------
   856 
   544 // CCalenController::InfobarTextL
   857 // ----------------------------------------------------------------------------
   545 // @returns info bar text
   858 // CCalenController::PreviewPane
   546 // (other items were commented in a header).
   859 // Descriptor passed to plugins to get customised preview pane text.
   547 // ----------------------------------------------------------------------------
   860 // Acts as a conduit between the services and the customisation manager.
   548 //
   861 // (other items were commented in a header).
   549 QString* CCalenController::InfobarTextL()
   862 // ----------------------------------------------------------------------------
   550     {
   863 //
   551     OstTraceFunctionEntry0( CCALENCONTROLLER_INFOBARTEXTL_ENTRY );
   864 EXPORT_C CCoeControl* CCalenController::PreviewPane( TRect& aRect )
   552     
   865     {
   553     OstTraceFunctionExit0( CCALENCONTROLLER_INFOBARTEXTL_EXIT );
   866     TRACE_ENTRY_POINT;
   554     return iCustomisationManager->InfobarTextL();
   867     TRACE_EXIT_POINT;
   555     }
   868     return iCustomisationManager->PreviewPane( aRect );
       
   869     }
       
   870 
       
   871 // ----------------------------------------------------------------------------
       
   872 // CCalenController::CustomPreviewPaneL
       
   873 // Return custom preview pane
       
   874 // (other items were commented in a header).
       
   875 // ----------------------------------------------------------------------------
       
   876 //
       
   877 EXPORT_C MCalenPreview* CCalenController::CustomPreviewPaneL( TRect& aRect )
       
   878     {
       
   879     TRACE_ENTRY_POINT;
       
   880     TRACE_EXIT_POINT;
       
   881     return iCustomisationManager->CustomPreviewPaneL(aRect);
       
   882     }
       
   883 
   556 // ----------------------------------------------------------------------------
   884 // ----------------------------------------------------------------------------
   557 // CCalenController::CustomisationManager
   885 // CCalenController::CustomisationManager
   558 // Returns a reference to the customisation manager
   886 // Returns a reference to the customisation manager
   559 // (other items were commented in a header).
   887 // (other items were commented in a header).
   560 // ----------------------------------------------------------------------------
   888 // ----------------------------------------------------------------------------
   561 //
   889 //
   562 CCalenCustomisationManager& CCalenController::CustomisationManager()
   890 CCalenCustomisationManager& CCalenController::CustomisationManager()
   563     {
   891     {
   564     OstTraceFunctionEntry0( CCALENCONTROLLER_CUSTOMISATIONMANAGER_ENTRY );
   892     TRACE_ENTRY_POINT;
   565     
   893     TRACE_EXIT_POINT;
   566     OstTraceFunctionExit0( CCALENCONTROLLER_CUSTOMISATIONMANAGER_EXIT );
       
   567     return *iCustomisationManager;
   894     return *iCustomisationManager;
   568     }
   895     }
   569 
   896 
   570 // ----------------------------------------------------------------------------
   897 // ----------------------------------------------------------------------------
   571 // CCalenController::SetDefaultContext
   898 // CCalenController::ViewManager
   572 // Sets the default context for today
   899 // Returns a reference to the view manager
   573 // (other items were commented in a header).
   900 // (other items were commented in a header).
   574 // ----------------------------------------------------------------------------
   901 // ----------------------------------------------------------------------------
   575 //       
   902 CCalenViewManager& CCalenController::ViewManager()
   576 void CCalenController::SetDefaultContext()
   903     {
   577     {
   904     TRACE_ENTRY_POINT;
   578     OstTraceFunctionEntry0( CCALENCONTROLLER_SETDEFAULTCONTEXT_ENTRY );
   905     TRACE_EXIT_POINT;
   579       
   906     return *iViewManager;
   580     QDateTime focusTime = mContext->defaultCalTimeForViewsL();
   907     }
   581     mContext->setFocusDateAndTime(focusTime);
   908 
   582     
   909 // ----------------------------------------------------------------------------
   583     OstTraceFunctionExit0( CCALENCONTROLLER_SETDEFAULTCONTEXT_EXIT );
   910 // CCalenController::MissedAlarmStore
   584     }
   911 // Returns a reference to the Missed Alarm Store
   585 
   912 // ----------------------------------------------------------------------------
   586 // ----------------------------------------------------------------------------
   913 CMissedAlarmStore* CCalenController::MissedAlarmStore()
   587 // CCalenController::OfferMenu
   914     {
   588 // Offers the menu to plugins for customisation.
   915     TRACE_ENTRY_POINT;
   589 // Acts as a conduit between the services and the customisation manager.
   916     TRACE_EXIT_POINT;
   590 // (other items were commented in a header).
   917 
   591 // ----------------------------------------------------------------------------
   918     return iAlarmManager->MissedAlarmStore();
   592 
   919     }
   593 void CCalenController::OfferMenu(HbMenu* aHbMenu)
   920 
   594     {
   921 // ----------------------------------------------------------------------------
   595     OstTraceFunctionEntry0( CCALENCONTROLLER_OFFERMENU_ENTRY );
   922 // CCalenController::IsFasterAppFlagEnabled
   596     
   923 // Returns ETrue if the application is fake exited
   597     iCustomisationManager->OfferMenu(aHbMenu);
   924 // else return EFalse.
   598     
   925 // (other items were commented in a header).
   599     OstTraceFunctionExit0( CCALENCONTROLLER_OFFERMENU_EXIT );
   926 // ----------------------------------------------------------------------------
   600     }
   927 TBool CCalenController::IsFasterAppFlagEnabled()
   601 
   928     {
   602 // ----------------------------------------------------------------------------
   929     TRACE_ENTRY_POINT;
   603 // CCalenController::agendaInterface
   930     TRACE_EXIT_POINT;
   604 // returns the interface to the agenda database
   931 	return iFasterApp;
   605 // (other items were commented in a header).
   932     }
   606 // ---------------------------------------------------------------------------
   933 
   607 //
   934 // ----------------------------------------------------------------------------
   608 AgendaUtil* CCalenController::agendaInterface()
   935 // CCalenController::SetFasterAppFlag
   609     {
   936 // Set the flag 'iFasterApp' to ETrue if application is fake exited
   610     OstTraceFunctionEntry0( CCALENCONTROLLER_AGENDAINTERFACE_ENTRY );
   937 // and to EFalse once the application comes to foreground.
   611     
   938 // (other items were commented in a header).
   612     
   939 // ----------------------------------------------------------------------------
   613     OstTraceFunctionExit0( CCALENCONTROLLER_AGENDAINTERFACE_EXIT );
   940 void CCalenController::SetFasterAppFlag( TBool aFlag )
   614     return mAgendaUtil;
   941 	{
   615     }
   942     TRACE_ENTRY_POINT;
   616 
   943     TRACE_EXIT_POINT;
   617 // ----------------------------------------------------------------------------
   944 	iFasterApp = aFlag;
   618 // CCalenController::context
   945 	}
   619 // returns the calendar context
   946 
   620 // (other items were commented in a header).
   947 // ----------------------------------------------------------------------------
   621 // ---------------------------------------------------------------------------
   948 // CCalenController::AppUi
   622 //
   949 // Returns a reference to the appui
   623 MCalenContext& CCalenController::context()
   950 // (other items were commented in a header).
   624     {
   951 // ----------------------------------------------------------------------------
   625 	OstTraceFunctionEntry0( CCALENCONTROLLER_CONTEXT_ENTRY );
   952 //
       
   953 CAknViewAppUi& CCalenController::AppUi()
       
   954     {
       
   955     TRACE_ENTRY_POINT;
       
   956     TRACE_EXIT_POINT;
       
   957     return iAppUi;
       
   958     }
       
   959 
       
   960 // ----------------------------------------------------------------------------
       
   961 // CCalenController::GetMissedAlarmsList
       
   962 // Returns the missed alarms list
       
   963 // ----------------------------------------------------------------------------
       
   964 void CCalenController::GetMissedAlarmsList(RArray<TCalenInstanceId>& aMissedAlarmsList)
       
   965     {
       
   966     TRACE_ENTRY_POINT;
       
   967     iAlarmManager->GetMissedAlarmsList(aMissedAlarmsList);
       
   968     TRACE_EXIT_POINT;
       
   969     }
       
   970 
       
   971 // ----------------------------------------------------------------------------
       
   972 // CCalenController::Settings
       
   973 // Returns a reference to the calendar settings
       
   974 // ----------------------------------------------------------------------------
       
   975 CCalenSetting& CCalenController::Settings()
       
   976     {
       
   977     TRACE_ENTRY_POINT;
       
   978     TRACE_EXIT_POINT;
       
   979     return *iSetting;
       
   980     }
       
   981 
       
   982 // ----------------------------------------------------------------------------
       
   983 // CCalenController::GetIconL
       
   984 // Get icon of specific type
       
   985 // ----------------------------------------------------------------------------
       
   986 //
       
   987 CGulIcon* CCalenController::GetIconL( MCalenServices::TCalenIcons aIndex, const TInt aViewId ) 
       
   988     {
       
   989     TRACE_ENTRY_POINT;
       
   990     
       
   991     // if view requests next view icon
       
   992     if(aIndex == MCalenServices::ECalenNextViewIcon)
       
   993         {
       
   994         return (iViewManager->GetNextViewIconL());
       
   995         }
       
   996     
       
   997     TRACE_EXIT_POINT;
       
   998     return iViewManager->IconsL().GetIconL(aIndex,aViewId);
       
   999     }
       
  1000 
       
  1001 // ----------------------------------------------------------------------------
       
  1002 // CCalenController::MultipleDbManager
       
  1003 // Returns a reference to the CCalenMultipleDbManager
       
  1004 // (other items were commented in a header).
       
  1005 // ----------------------------------------------------------------------------
       
  1006 //
       
  1007 CCalenMultipleDbManager& CCalenController::MultipleDbManager()
       
  1008     {
       
  1009     TRACE_ENTRY_POINT
       
  1010     CCalenMultipleDbManager* tmp = NULL;
       
  1011     TRACE_EXIT_POINT
       
  1012     return *tmp;
       
  1013     }
       
  1014 
       
  1015 // ----------------------------------------------------------------------------
       
  1016 // CCalenController::StateMachine
       
  1017 // Returns a reference to the CCalenStateMachine
       
  1018 // (other items were commented in a header).
       
  1019 // ----------------------------------------------------------------------------
       
  1020 //
       
  1021 CCalenStateMachine& CCalenController::StateMachine()
       
  1022     {
       
  1023     TRACE_ENTRY_POINT
       
  1024     TRACE_EXIT_POINT
       
  1025     return *iStateMachine;
       
  1026     }
       
  1027 
       
  1028 
       
  1029 // -----------------------------------------------------------------------------
       
  1030 // CCalenController::GetActiveCollectionidsL
       
  1031 // -----------------------------------------------------------------------------
       
  1032 //
       
  1033 void CCalenController::GetActiveCollectionidsL(
       
  1034                                            RArray<TInt>& aCollectionIds)
       
  1035     {
       
  1036     TRACE_ENTRY_POINT
       
  1037     RPointerArray<CCalCalendarInfo> calendarInfoList;
       
  1038     CleanupClosePushL(calendarInfoList);
       
  1039     iGlobalData->GetAllCalendarInfoL(calendarInfoList);
       
  1040     
       
  1041     for(TInt index=0;index<calendarInfoList.Count();index++)
       
  1042         {
       
  1043         if(calendarInfoList[index]->Enabled())
       
  1044             {
       
  1045             HBufC* calendarFileName = 
       
  1046                 calendarInfoList[index]->FileNameL().AllocLC();
       
  1047             aCollectionIds.Append(
       
  1048                  iGlobalData->CalSessionL(*calendarFileName).CollectionIdL());
       
  1049             CleanupStack::PopAndDestroy(calendarFileName);
       
  1050             }
       
  1051         }
       
  1052     
       
  1053     CleanupStack::PopAndDestroy(&calendarInfoList);
       
  1054     TRACE_EXIT_POINT
       
  1055     }
       
  1056 
       
  1057 // -----------------------------------------------------------------------------
       
  1058 // CCalenController::AttachmentData
       
  1059 // Returns a reference to the CCalenAttachmentModel
       
  1060 // ----------------------------------------------------------------------------
       
  1061 //
       
  1062 CCalenAttachmentModel& CCalenController::AttachmentData()
       
  1063     {
       
  1064     TRACE_ENTRY_POINT;
       
  1065     TRACE_EXIT_POINT;
       
  1066     return *iAttachmentData;
       
  1067     }
   626 	
  1068 	
   627     OstTraceFunctionExit0( CCALENCONTROLLER_CONTEXT_EXIT );
  1069 // -----------------------------------------------------------------------------
   628     return *mContext;
  1070 // CCalenController::IsEditorActive
   629     }
  1071 // Tells framework whether editor is active or not
   630 
  1072 // -----------------------------------------------------------------------------
   631 // ----------------------------------------------------------------------------
  1073 //
   632 // CCalenController::handleServiceManagerSlot
  1074 TBool CCalenController::IsEditorActive()
   633 // Launches the requested view 
  1075     {
   634 // (other items were commented in a header).
  1076     return (iActionUi->IsEditorActive());
   635 // ---------------------------------------------------------------------------
  1077     }
   636 //
  1078 
   637 void CCalenController::handleServiceManagerSlot(int view, const QDateTime& dateTime)
  1079 // -----------------------------------------------------------------------------
   638 {
  1080 // CCalenController::AddCalendarL
   639 	OstTraceFunctionEntry0( CCALENCONTROLLER_HANDLESERVICEMANAGERSLOT_ENTRY );
  1081 // Adds a new calendar file with metadata set
   640 	
  1082 // -----------------------------------------------------------------------------
   641 	if (iIsFromServiceFrmWrk) {
  1083 //
   642 		// Set the context properly
  1084 void CCalenController::AddCalendarL(CCalCalendarInfo* aCalendarInfo)
   643 		mContext->setFocusDateAndTime(dateTime);
  1085     {
   644 		// launch the appropriate view
  1086     TRACE_ENTRY_POINT;
   645 		iViewManager->constructAndActivateView(view);
  1087     iGlobalData->AddCalendarL(aCalendarInfo);
   646 		
  1088     TRACE_EXIT_POINT;
   647 		iIsFromServiceFrmWrk = false;
  1089     }
   648 		
  1090 
   649 	} else { // Calendar was in backgroung but now its being brought to foreground
  1091 // -----------------------------------------------------------------------------
   650 		// If current state is editing state or printing state
  1092 // CCalenController::UpdateCalendarL
   651 		// or deleting state or sending state, then dont do anything as
  1093 // Updates calendar file with new calendar info
   652 		// user might loose the data
  1094 // -----------------------------------------------------------------------------
   653 		CCalenStateMachine::TCalenStateIndex currentState = iStateMachine->CurrentState();
  1095 //
   654 		if ((currentState == CCalenStateMachine::ECalenDeletingState) ||
  1096 void CCalenController::UpdateCalendarL(CCalCalendarInfo* aCalendarInfo)
   655 			(currentState == CCalenStateMachine::ECalenPrintingState) ||
  1097     {
   656 			(currentState == CCalenStateMachine::ECalenSendingState)) {
  1098     TRACE_ENTRY_POINT;
   657 			// simply return - we dont have anything to do
  1099     iGlobalData->UpdateCalendarL(aCalendarInfo);
   658 		} 
  1100     TRACE_EXIT_POINT;
   659 
  1101     }
   660 		else if (currentState == CCalenStateMachine::ECalenViewingState) {
  1102 
   661              if(iViewManager->isEventViewerActive()){
  1103 // -----------------------------------------------------------------------------
   662 		         iViewManager->closeAgendaEventView();
  1104 // CCalenController::RemoveCalendarL
   663 		        }
  1105 // Removes calendar file based on calendar file name
   664 		}
  1106 // -----------------------------------------------------------------------------
   665 		else if (currentState == CCalenStateMachine::ECalenEditingState) {
  1107 //
   666 			// close the editor and save the entry if application is in background
  1108 void CCalenController::RemoveCalendarL(const TDesC& aCalendarFileName)
   667             //and launch the desired view
  1109     {
   668             if(iViewManager->isEventViewerActive()){
  1110     TRACE_ENTRY_POINT;
   669                 iViewManager->saveAndCloseEditor();
  1111     iGlobalData->RemoveCalendarL(aCalendarFileName);
   670                 iViewManager->closeAgendaEventView();
  1112     TRACE_EXIT_POINT;
   671                }
  1113     }
   672             else{
  1114 
   673                 iActionUi->saveAndCloseEditor();
  1115 // -----------------------------------------------------------------------------
   674             }
  1116 // CCalenController::RemoveCalendarL
   675 		} 
  1117 // Removes all dead calendar files from the file system
   676 
  1118 // -----------------------------------------------------------------------------
   677 		else if (currentState == CCalenStateMachine::ECalenSettingsState){
  1119 //
   678             iViewManager->removeSettingsView();
  1120 void CCalenController::RemoveDeadCalendarsL()
   679 	        }
  1121     {
   680  
  1122     TRACE_ENTRY_POINT;
   681 		// Set the context properly
  1123     iGlobalData->RemoveDeadCalendarsL();
   682 		mContext->setFocusDateAndTime(dateTime);
  1124     TRACE_EXIT_POINT;
   683 		IssueCommandL(view);
  1125     }
   684             
  1126 // -----------------------------------------------------------------------------
   685 		// connect to raise the window to foreground once the view is ready
  1127 // CCalenController::GetAllCalendarInfoL
   686 		connect(&MainWindow(), SIGNAL(viewReady()), 
  1128 // Get all available calendar info
   687 		        this, SLOT(raiseWindow()));
  1129 // -----------------------------------------------------------------------------
   688 	}
  1130 //
   689 
  1131 void CCalenController::GetAllCalendarInfoL(
   690 }
  1132                 RPointerArray<CCalCalendarInfo>& aCalendarInfoList)
   691 void CCalenController::raiseWindow()
  1133     {
   692     {
  1134     TRACE_ENTRY_POINT;
   693     MainWindow().raise();
  1135     iGlobalData->GetAllCalendarInfoL(aCalendarInfoList);
   694     disconnect(&MainWindow(), SIGNAL(viewReady()), 
  1136     TRACE_EXIT_POINT;
   695                         this, SLOT(raiseWindow()));
  1137     }
   696     }
  1138 
   697 // ----------------------------------------------------------------------------
  1139 // -----------------------------------------------------------------------------
   698 // CCalenController::getFirstView
  1140 // CCalenController::SetLaunchFromExternalApp
   699 // returns the first view with which calendar has been launched
  1141 //
   700 // (other items were commented in a header).
  1142 // (other items were commented in a header).
   701 // ---------------------------------------------------------------------------
  1143 // -----------------------------------------------------------------------------
   702 //
  1144 //
   703 int CCalenController::getFirstView()
  1145 void CCalenController::SetLaunchFromExternalApp( TBool aFlag )
   704 {
  1146     {
   705 	OstTraceFunctionEntry0( CCALENCONTROLLER_GETFIRSTVIEW_ENTRY );
  1147     TRACE_ENTRY_POINT;
   706 	
  1148     
   707 	OstTraceFunctionExit0( CCALENCONTROLLER_GETFIRSTVIEW_EXIT );
  1149     iLaunchFromExternalApp = aFlag;
   708 	
  1150     TRACE_EXIT_POINT;
   709 	return iViewManager->getFirstView();
  1151     }
   710 	
  1152 
   711 }
  1153 // -----------------------------------------------------------------------------
   712 
  1154 // CCalenController::SetLaunchFromExternalApp
   713 // ----------------------------------------------------------------------------
  1155 //
   714 // CCalenController::eventFilter
  1156 // (other items were commented in a header).
   715 // Filters and handles the changes in events
  1157 // -----------------------------------------------------------------------------
   716 // (other items were commented in a header).
  1158 //
   717 // ---------------------------------------------------------------------------
  1159 TBool CCalenController::IsLaunchFromExternalApp()
   718 //
  1160     {
   719 bool CCalenController::eventFilter(QObject *object, QEvent *event)
  1161     TRACE_ENTRY_POINT;
   720 {
  1162     TRACE_EXIT_POINT;
   721     OstTraceFunctionEntry0( CCALENCONTROLLER_EVENTFILTER_ENTRY );
  1163     
   722     
  1164     return iLaunchFromExternalApp;
   723     switch (event->type())
  1165     }
   724         {
  1166 // End of file
   725         case QEvent::LanguageChange:
  1167 
   726         	//TODO: Unload the translator and install the locale specific translator
       
   727         	iNotifier->BroadcastNotification( ECalenNotifySystemLanguageChanged );
       
   728             break;
       
   729         case QEvent::LocaleChange:
       
   730         	// TODO: handle the locale changes
       
   731             break;
       
   732         default:
       
   733             break;
       
   734         }
       
   735     OstTraceFunctionExit0( CCALENCONTROLLER_EVENTFILTER_EXIT );
       
   736 
       
   737     return QObject::eventFilter(object, event);
       
   738 }
       
   739 
       
   740 /*
       
   741  * Emits the appReady signal.
       
   742  */
       
   743 void CCalenController::emitAppReady()
       
   744 {
       
   745 	emit appReady();
       
   746 }
       
   747 
       
   748 // End of file	--Don't remove this.