homemedia/homemedia/src/homemediadocument.cpp
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /*
       
     2 * Copyright (c) 2008 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:      Main document class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include "homemediaappui.h"
       
    25 #include "homemediadocument.h"
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ============================
       
    28 
       
    29 // --------------------------------------------------------------------------
       
    30 // CHomeMediaDocument::NewL()
       
    31 // Two-phased constructor.
       
    32 // --------------------------------------------------------------------------
       
    33 //
       
    34 CHomeMediaDocument* CHomeMediaDocument::NewL( CEikApplication& aApp )
       
    35     {
       
    36     CHomeMediaDocument* self = NewLC( aApp );
       
    37     CleanupStack::Pop(self);
       
    38     return self;
       
    39     }
       
    40 
       
    41 // --------------------------------------------------------------------------
       
    42 // CHomeMediaDocument::NewLC()
       
    43 // Two-phased constructor.
       
    44 // --------------------------------------------------------------------------
       
    45 //
       
    46 CHomeMediaDocument* CHomeMediaDocument::NewLC( CEikApplication& aApp )
       
    47     {
       
    48     CHomeMediaDocument* self = new ( ELeave ) CHomeMediaDocument( aApp );
       
    49     CleanupStack::PushL( self );
       
    50     self->ConstructL();
       
    51     return self;
       
    52     }
       
    53 
       
    54 // --------------------------------------------------------------------------
       
    55 // CHomeMediaDocument::ConstructL()
       
    56 // Symbian 2nd phase constructor can leave.
       
    57 // --------------------------------------------------------------------------
       
    58 //
       
    59 void CHomeMediaDocument::ConstructL()
       
    60     {
       
    61     // No implementation required
       
    62     }
       
    63 
       
    64 // --------------------------------------------------------------------------
       
    65 // CHomeMediaDocument::CHomeMediaDocument()
       
    66 // C++ default constructor can NOT contain any code, that might leave.
       
    67 // --------------------------------------------------------------------------
       
    68 //
       
    69 CHomeMediaDocument::CHomeMediaDocument( CEikApplication& aApp ) :
       
    70     CAknDocument( aApp ),
       
    71     iEcomDestructorKeys( 1 )
       
    72     {
       
    73     // No implementation required
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // CHomeMediaDocument::~CHomeMediaDocument()
       
    78 // Destructor.
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 CHomeMediaDocument::~CHomeMediaDocument()
       
    82     {
       
    83     // Destroyes registered ecom plugin implementations.
       
    84     TInt count = iEcomDestructorKeys.Count();
       
    85     if ( count )
       
    86         {
       
    87         for ( TInt i = 0; i < count; i++ )
       
    88             {
       
    89             REComSession::DestroyedImplementation( iEcomDestructorKeys[i] );
       
    90             }
       
    91         }
       
    92     iEcomDestructorKeys.Close();
       
    93     
       
    94     // Tears down ECom framework. Probably application enviroment does the same
       
    95     // thing but it doesn't cause any harm it it is here as well.
       
    96     REComSession::FinalClose();
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CHomeMediaDocument::CreateAppUiL()
       
   101 // Constructs CreateAppUi.
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 CEikAppUi* CHomeMediaDocument::CreateAppUiL()
       
   105     {
       
   106     // Create the application user interface, and return a pointer to it;
       
   107     // the framework takes ownership of this object
       
   108     return new ( ELeave )CHomeMediaAppUi;
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // CHomeMediaDocument::RegisterEcomDestructorKeyL()
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void CHomeMediaDocument::RegisterEcomDestructorKeyL( const TUid& aDestructorKey )
       
   116     {
       
   117     // Checks the given destructor key, does it exist already.
       
   118     TInt idx = KErrNotFound;
       
   119     TInt count = iEcomDestructorKeys.Count();
       
   120     for ( TInt i = 0; i < count; i++ )
       
   121         {
       
   122         if ( iEcomDestructorKeys[i] == aDestructorKey )
       
   123             {
       
   124             // Given TUid exists already.
       
   125             idx = i;
       
   126             break;
       
   127             }
       
   128         }
       
   129     
       
   130     if ( idx <= KErrNotFound )
       
   131         {
       
   132         // Appends new TUid in the list.
       
   133         iEcomDestructorKeys.AppendL( aDestructorKey );
       
   134         }
       
   135     }
       
   136 
       
   137 // End of File