devencdiskutils/DevEncStarter/src/DevEncStarterUtils.cpp
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2007 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:  DevEncStarter utilities
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "DevEncStarterUtils.h"
       
    20 #include "DevEncLog.h"
       
    21 
       
    22 // ================= MEMBER FUNCTIONS =======================
       
    23 //
       
    24 // ----------------------------------------------------------
       
    25 // CDevEncStarterUtils::CDevEncStarterUtils()
       
    26 // ----------------------------------------------------------
       
    27 //
       
    28 CDevEncStarterUtils::~CDevEncStarterUtils()
       
    29     {
       
    30     if (iAppStarter)
       
    31         {
       
    32         delete iAppStarter;
       
    33         iAppStarter = NULL;
       
    34         }
       
    35     }
       
    36 
       
    37 // ----------------------------------------------------------
       
    38 // CDevEncStarterUtils::NewL
       
    39 // ----------------------------------------------------------
       
    40 //
       
    41 CDevEncStarterUtils* CDevEncStarterUtils::NewL()
       
    42     {
       
    43     CDevEncStarterUtils* self = new ( ELeave ) CDevEncStarterUtils();
       
    44     CleanupStack::PushL( self );
       
    45     self->ConstructL();
       
    46     CleanupStack::Pop();
       
    47     return self;
       
    48     }
       
    49 
       
    50 // ----------------------------------------------------------
       
    51 // CDevEncStarterUtils::CDevEncStarterUtils()
       
    52 // ----------------------------------------------------------
       
    53 //
       
    54 CDevEncStarterUtils::CDevEncStarterUtils()
       
    55     {
       
    56     
       
    57     }
       
    58 
       
    59 // ----------------------------------------------------------
       
    60 // CDevEncStarterUtils::ConstructL()
       
    61 // ----------------------------------------------------------
       
    62 //
       
    63 void CDevEncStarterUtils::ConstructL()
       
    64     {
       
    65     
       
    66     }
       
    67 
       
    68 // ----------------------------------------------------------
       
    69 // CDevEncStarterUtils::StartAppL()
       
    70 //
       
    71 // ----------------------------------------------------------
       
    72 //
       
    73 void CDevEncStarterUtils::StartAppL( const TUint32& aUid,
       
    74                                      MUtilsCallback* aCallback )
       
    75     {
       
    76     DFLOG( "CDevEncStarterUtils::StartAppL" );
       
    77     if ( aCallback )
       
    78         {
       
    79         // The calling class wants to know when the application is started
       
    80         if ( iCallback )
       
    81             {
       
    82             User::Leave( KErrInUse );
       
    83             }
       
    84         else
       
    85             {
       
    86             // Used in CDevEncStarterUtils::AppStarted()
       
    87             DFLOG( "Callback stored" );
       
    88             iCallback = aCallback;
       
    89             }
       
    90         }
       
    91 
       
    92     if ( !iAppStarter )
       
    93         {
       
    94         iAppStarter = CDevEncStarterStarter::NewLC( this );
       
    95         CleanupStack::Pop( iAppStarter ); // member variable, no cleanupstack
       
    96         DFLOG( "Starter created" );
       
    97         }
       
    98 
       
    99     if ( !iAppStarter->IsActive() )
       
   100         {
       
   101         iAppStarter->StartAppL( aUid );
       
   102         DFLOG( "StartAppL called" );
       
   103         }
       
   104     else
       
   105         {
       
   106         DFLOG( "CDevEncStarterUtils::StartAppL: App starter already active" );
       
   107         }
       
   108     }
       
   109 
       
   110 
       
   111 // ----------------------------------------------------------
       
   112 // CDevEncStarterUtils::AppStarted()
       
   113 //
       
   114 // ----------------------------------------------------------
       
   115 //
       
   116 void CDevEncStarterUtils::AppStarted( const TUint32& aUid )
       
   117     {
       
   118     DFLOG( "CDevEncStarterUtils::AppStarted" );
       
   119     if ( iCallback )
       
   120         {
       
   121         DFLOG2( "CDevEncStarterUtils::AppStarted %x", aUid );
       
   122         iCallback->AppStarted( aUid );
       
   123         iCallback = NULL;
       
   124         }
       
   125     }
       
   126 
       
   127 // End of file
       
   128