sysstatemgmt/systemstatereferenceplugins/clayer/inc/startupadaptation.inl
changeset 0 4e1aa6a622a0
child 5 1a73e8f1b64d
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2004-2009 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 * Name        : startupadaptation.inl
       
    16 * Part of     : System Startup / Starter
       
    17 * Interface   : Domain, Startup Adaptation API
       
    18 * Implementation for inline functions of CStartupAdaptation
       
    19 * class.
       
    20 * Version     : %version: ou1s60rt#7 %
       
    21 * This material, including documentation and any related computer
       
    22 * programs, is protected by copyright controlled by Nokia.  All
       
    23 * rights are reserved.  Copying, including reproducing, storing,
       
    24 * adapting or translating, any or all of this material requires the
       
    25 * prior written consent of Nokia.  This material also contains
       
    26 * confidential information which may not be disclosed to others
       
    27 * without the prior written consent of Nokia.
       
    28 * Template version: 4.0
       
    29 * Nokia Core OS *
       
    30 *
       
    31 */
       
    32 
       
    33 
       
    34 
       
    35 #include <ecom/ecom.h>
       
    36 
       
    37 /*
       
    38 * @file
       
    39 * @publishedPartner
       
    40 * @released
       
    41 */
       
    42 
       
    43 /**
       
    44 * Interface UID for StartupAdaptation interface.
       
    45 */
       
    46 static const TUid KStartupAdaptationIfUid = {0x101F8768};
       
    47 
       
    48 // ============================ MEMBER FUNCTIONS ===============================
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CStartupAdaptation::NewL
       
    52 //
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 inline CStartupAdaptation* CStartupAdaptation::NewL(
       
    56     MStartupAdaptationObserver& aObserver )
       
    57     {
       
    58     // Set resolve parameters to use in listing available implementations.
       
    59     TEComResolverParams resolverParams;
       
    60     resolverParams.SetGenericMatch( ETrue );
       
    61 
       
    62     // List available implementations.
       
    63     RImplInfoPtrArray implInfoArray;
       
    64     REComSession::ListImplementationsL(
       
    65         KStartupAdaptationIfUid,
       
    66         resolverParams,
       
    67         KRomOnlyResolverUid,
       
    68         implInfoArray );
       
    69 
       
    70     // There must be one and only one Startup Adaptation plug-in.
       
    71     if ( implInfoArray.Count() < 1 )
       
    72         {
       
    73         User::Leave( KErrNotFound );
       
    74         }
       
    75     if ( implInfoArray.Count() > 1 )
       
    76         {
       
    77         User::Leave( KErrGeneral );
       
    78         }
       
    79 
       
    80     // Create instance using ECom
       
    81     TUid dtorIDKey;
       
    82     TAny* ptr = REComSession::CreateImplementationL(
       
    83         implInfoArray[ 0 ]->ImplementationUid(),
       
    84         dtorIDKey,
       
    85         &aObserver );
       
    86 
       
    87     implInfoArray.ResetAndDestroy();
       
    88     implInfoArray.Close();
       
    89 
       
    90     CStartupAdaptation* plugin = reinterpret_cast<CStartupAdaptation*>( ptr );
       
    91     plugin->iDtorIDKey = dtorIDKey;
       
    92 
       
    93     return plugin;
       
    94     }
       
    95 
       
    96 
       
    97 // Destructor
       
    98 inline CStartupAdaptation::~CStartupAdaptation()
       
    99     {
       
   100     REComSession::DestroyedImplementation( iDtorIDKey );
       
   101     }