logsui/AppSrc/CLogsDocument.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *     Logs document class
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <aknapp.h>
       
    22 
       
    23 #include "CLogsDocument.h"
       
    24 #include "CLogsEngine.h"
       
    25 #include "CLogsAppUi.h"
       
    26 #include "LogsUID.h"
       
    27 #include <featmgr.h>    //Feature manager
       
    28 
       
    29 #include "LogsDebug.h"
       
    30 #include "LogsTraces.h"
       
    31 
       
    32 // EXTERNAL DATA STRUCTURES
       
    33 
       
    34 // EXTERNAL FUNCTION PROTOTYPES  
       
    35 
       
    36 // CONSTANTS
       
    37 
       
    38 // MACROS
       
    39 
       
    40 // LOCAL CONSTANTS AND MACROS
       
    41 
       
    42 // MODULE DATA STRUCTURES
       
    43 
       
    44 // LOCAL FUNCTION PROTOTYPES
       
    45 
       
    46 // ==================== LOCAL FUNCTIONS ====================
       
    47 
       
    48 // ================= MEMBER FUNCTIONS =======================
       
    49 
       
    50 // ----------------------------------------------------------------------------
       
    51 // CLogsDocument::CLogsDocument
       
    52 // ----------------------------------------------------------------------------
       
    53 //
       
    54 CLogsDocument::CLogsDocument( CAknApplication& aApp )
       
    55     : CAknDocument( aApp )
       
    56     {
       
    57     TRACE_ENTRY_POINT;
       
    58     TRACE_EXIT_POINT;
       
    59     }
       
    60 
       
    61 // ----------------------------------------------------------------------------
       
    62 // CLogsDocument::ConstructL
       
    63 // ----------------------------------------------------------------------------
       
    64 //
       
    65 void CLogsDocument::ConstructL()
       
    66     {
       
    67     TRACE_ENTRY_POINT;
       
    68     CCoeEnv::Static()->AddForegroundObserverL( *this ); 
       
    69     iEngine = CLogsEngine::NewL();
       
    70 
       
    71     //Set up  FeatureManager
       
    72     //This must be called in the scope of the thread before calling
       
    73     //any other FeatureManager methods. 
       
    74     FeatureManager::InitializeLibL();
       
    75     
       
    76     TRACE_EXIT_POINT;
       
    77     }
       
    78 
       
    79 // ----------------------------------------------------------------------------
       
    80 // CLogsDocument::NewL
       
    81 // ----------------------------------------------------------------------------
       
    82 //
       
    83 CLogsDocument* CLogsDocument::NewL( CAknApplication& aApp )
       
    84     {
       
    85     TRACE_ENTRY_POINT;
       
    86     CLogsDocument* self = new( ELeave ) CLogsDocument( aApp );
       
    87     CleanupStack::PushL( self );
       
    88     self->ConstructL();
       
    89     CleanupStack::Pop();  // self
       
    90     
       
    91     TRACE_EXIT_POINT;
       
    92     return self;
       
    93     }
       
    94 
       
    95 // ----------------------------------------------------------------------------
       
    96 // CLogsDocument::~CLogsDocument
       
    97 // ----------------------------------------------------------------------------
       
    98 //
       
    99 CLogsDocument::~CLogsDocument()
       
   100     {
       
   101     TRACE_ENTRY_POINT;
       
   102     CCoeEnv::Static()->RemoveForegroundObserver( *this );
       
   103     delete iEngine;
       
   104 
       
   105     //Free allocated FeatureManager
       
   106     FeatureManager::UnInitializeLib();
       
   107 
       
   108     //ECom clear up (done here  as in CLogsAppUi dtor is too early as view framework 
       
   109     //destroys the view only after appui has been destroyed).
       
   110 
       
   111     //Signal the destruction of interface implementation to ECOM.
       
   112     REComSession::DestroyedImplementation( TUid::Uid(ELogSettingsViewId) ); 
       
   113 
       
   114     //Direct users of ECOM plugins must call REComSession::FinalClose() method when all 
       
   115     //implementations they have created have been destroyed.
       
   116     REComSession::FinalClose();
       
   117     
       
   118     TRACE_EXIT_POINT;
       
   119     }
       
   120 
       
   121 // ----------------------------------------------------------------------------
       
   122 // CLogsDocument::CreateAppUiL
       
   123 // ----------------------------------------------------------------------------
       
   124 //
       
   125 CEikAppUi* CLogsDocument::CreateAppUiL()
       
   126     {
       
   127     TRACE_ENTRY_POINT;
       
   128     TRACE_EXIT_POINT;
       
   129     return ( new( ELeave ) CLogsAppUi( iEngine ) ); //Ownership  transferred to framework.
       
   130     }
       
   131 
       
   132 
       
   133 // ----------------------------------------------------------------------------
       
   134 // CLogsDocument::Engine
       
   135 // ----------------------------------------------------------------------------
       
   136 //
       
   137 CLogsEngine* CLogsDocument::Engine()
       
   138     {
       
   139     TRACE_ENTRY_POINT;
       
   140     TRACE_EXIT_POINT;
       
   141     return iEngine; 
       
   142     }
       
   143 
       
   144 // ----------------------------------------------------------------------------
       
   145 // CLogsDocument::HandleGainingForeground
       
   146 // ----------------------------------------------------------------------------
       
   147 //
       
   148 void CLogsDocument::HandleGainingForeground()   //Non-leaving wrapper 
       
   149     {
       
   150     TRACE_ENTRY_POINT;
       
   151     TRAPD( err, HandleGainingForegroundL() );
       
   152     if( err ) 
       
   153         {
       
   154         CCoeEnv::Static()->HandleError( err );
       
   155         }
       
   156     
       
   157     TRACE_EXIT_POINT;
       
   158     }
       
   159 
       
   160 // ----------------------------------------------------------------------------
       
   161 // CLogsDocument::HandleGainingForegroundL
       
   162 // ----------------------------------------------------------------------------
       
   163 //
       
   164 void CLogsDocument::HandleGainingForegroundL()  //Leaving 
       
   165     {
       
   166     TRACE_ENTRY_POINT;
       
   167     CLogsAppUi* ptr = STATIC_CAST(CLogsAppUi*, iAppUi);
       
   168    
       
   169 
       
   170     //Reset execution mode back to foreground
       
   171     ptr->SetExecutionMode( ELogsInForeground );
       
   172         
       
   173     //Update process name from the caption (calls eventually CLogsDocument::UpdateTaskNameL)        
       
   174     CEikonEnv::Static()->UpdateTaskNameL();     
       
   175     TRACE_EXIT_POINT;
       
   176     }
       
   177 
       
   178 
       
   179 // ----------------------------------------------------------------------------
       
   180 // CLogsDocument::HandleLosingForeground
       
   181 // ----------------------------------------------------------------------------
       
   182 //
       
   183 void CLogsDocument::HandleLosingForeground()    //Non-leaving wrapper
       
   184     {
       
   185     TRACE_ENTRY_POINT;
       
   186    
       
   187     TRAPD( err, HandleLosingForegroundL() );
       
   188     if( err ) 
       
   189         {
       
   190         CCoeEnv::Static()->HandleError( err );
       
   191         }
       
   192     TRACE_EXIT_POINT;
       
   193     }
       
   194 
       
   195 // ----------------------------------------------------------------------------
       
   196 // CLogsDocument::HandleLosingForegroundL
       
   197 // ----------------------------------------------------------------------------
       
   198 //
       
   199 void CLogsDocument::HandleLosingForegroundL()   //Leaving version
       
   200     {
       
   201     TRACE_ENTRY_POINT;
       
   202     //Update process name from the caption (calls eventually CLogsDocument::UpdateTaskNameL)        
       
   203     CEikonEnv::Static()->UpdateTaskNameL(); 
       
   204     
       
   205     CLogsAppUi* ptr = STATIC_CAST( CLogsAppUi*, iAppUi );
       
   206     
       
   207     if ( ptr->ExecutionMode() == ELogsInBackground_ExitOrEndPressed )
       
   208         {
       
   209         iEngine->FreeResourcesForBGModeL();  //Deletes objects to free some memory
       
   210         }
       
   211    
       
   212     
       
   213     TRACE_EXIT_POINT;
       
   214     }
       
   215 
       
   216 // ----------------------------------------------------------------------------
       
   217 // CLogsDocument::UpdateTaskNameL
       
   218 // ----------------------------------------------------------------------------
       
   219 //
       
   220 void CLogsDocument::UpdateTaskNameL( CApaWindowGroupName* aWgName )
       
   221     {
       
   222     TRACE_ENTRY_POINT;
       
   223     CEikDocument::UpdateTaskNameL( aWgName );   //Updates the task name from application's caption
       
   224     TRACE_EXIT_POINT;
       
   225     }
       
   226 
       
   227 //  End of File
       
   228