serviceproviders/sapi_applicationmanager/src/appmanagerservicehandler.cpp
changeset 5 989d2f495d90
equal deleted inserted replaced
1:a36b1e19a461 5:989d2f495d90
       
     1 /*
       
     2 * Copyright (c) 2007-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 the License "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:  This Class provides the interface for
       
    15 *				 calling the functionality to Application Manager SAPI
       
    16 *  Interface
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include <ecom/implementationproxy.h>
       
    22 #include <utf.h>
       
    23 
       
    24 #include "appmanagerservicehandler.h"
       
    25 #include "appmanagerinterface.h"
       
    26 #include "serviceerrno.h"
       
    27 #include "appserviceerrmsg.hrh"
       
    28 
       
    29 //Input Keys
       
    30 _LIT8(KAppManager, "IAppManager");
       
    31 
       
    32 //Output Keys/arguments
       
    33 _LIT8(KErrorCode,"ErrorCode");
       
    34 _LIT8(KCommand, "cmd");
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CAppManagerServiceHandler::NewL
       
    38 // Returns the instance of CAppManagerServiceHandler
       
    39 // -----------------------------------------------------------------------------
       
    40 
       
    41 CAppManagerServiceHandler* CAppManagerServiceHandler::NewL()
       
    42     {
       
    43     return new ( ELeave ) CAppManagerServiceHandler();
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CAppManagerServiceHandler::~CAppManagerServiceHandler
       
    48 // Class destructor
       
    49 // -----------------------------------------------------------------------------
       
    50 
       
    51 CAppManagerServiceHandler::~CAppManagerServiceHandler()
       
    52     {
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CAppManagerServiceHandler::InitialiseL
       
    57 // Initialises provider with necessary information
       
    58 // -----------------------------------------------------------------------------
       
    59 
       
    60 void CAppManagerServiceHandler::InitialiseL(MLiwNotifyCallback& /*aFrameworkCallback*/,
       
    61                     const RCriteriaArray& /*aInterest*/)
       
    62     {
       
    63 
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CAppManagerServiceHandler::HandleServiceCmdL
       
    68 // Executes generic service commands included in criteria.
       
    69 // -----------------------------------------------------------------------------
       
    70 void CAppManagerServiceHandler::HandleServiceCmdL(const TInt& aCmdId,
       
    71                     const CLiwGenericParamList& aInParamList,
       
    72                     CLiwGenericParamList& aOutParamList,
       
    73                     TUint aCmdOptions,
       
    74                     const MLiwNotifyCallback* aCallback)
       
    75     {
       
    76     if( ( aCallback ) ||  ( 0 != aCmdOptions  ) )
       
    77   	    {
       
    78   	      // report error if request is anything other than synchronous
       
    79   	      //or user sends a callback parameter
       
    80   	    aOutParamList.AppendL(TLiwGenericParam( KErrorCode , TLiwVariant( TInt32( SErrServiceNotSupported ) ) ) );
       
    81   	    // return from function
       
    82   	    return;
       
    83   	    }
       
    84 
       
    85   	TPtrC8 cmdName;
       
    86     const TLiwGenericParam* cmd = NULL;
       
    87 
       
    88 	if ( aCmdId == KLiwCmdAsStr )
       
    89 	    {
       
    90         TInt pos = 0;
       
    91         cmd = aInParamList.FindFirst( pos, KCommand );
       
    92      	if ( NULL != cmd )
       
    93      	    {
       
    94        	    cmdName.Set( cmd->Value().AsData() );
       
    95        	    }
       
    96        	else
       
    97        	    {
       
    98        	     aOutParamList.AppendL(
       
    99   	         TLiwGenericParam( KErrorCode, TLiwVariant( TInt32( SErrServiceNotSupported ) ) ) );
       
   100   	         aOutParamList.AppendL(TLiwGenericParam( KErrorMsg, TLiwVariant( KInterfaceNameMissing ) ) );
       
   101        	    }
       
   102         }
       
   103     else
       
   104         {
       
   105          aOutParamList.AppendL(
       
   106          TLiwGenericParam(KErrorCode, TLiwVariant( TInt32( SErrServiceNotSupported ) ) ) );
       
   107         }
       
   108 
       
   109 
       
   110     if( 0 == cmdName.CompareF( KAppManager ) )
       
   111         {
       
   112         //Create interface pointer and return the output param
       
   113         CAppManagerInterface* ifp =CAppManagerInterface::NewL();
       
   114         CleanupClosePushL( *ifp );
       
   115         aOutParamList.AppendL( TLiwGenericParam(KAppManager, TLiwVariant( ifp ) ) );
       
   116         CleanupStack::Pop( ifp );
       
   117         return;
       
   118         }
       
   119      else
       
   120         {
       
   121          aOutParamList.AppendL(
       
   122   	     TLiwGenericParam( KErrorCode, TLiwVariant( TInt32( SErrServiceNotSupported ) ) ) );
       
   123   	     
       
   124   	     aOutParamList.AppendL(TLiwGenericParam( KErrorMsg, TLiwVariant( KInterfaceNotSupported ) ) );
       
   125         }
       
   126     }
       
   127 
       
   128 //
       
   129 // Rest of the file is for ECom initialization.
       
   130 //
       
   131 
       
   132 // Map the interface UIDs to implementation factory functions
       
   133 const TImplementationProxy ImplementationTable[] =
       
   134     {
       
   135     IMPLEMENTATION_PROXY_ENTRY(0x2000CFB9, CAppManagerServiceHandler::NewL)
       
   136     };
       
   137 
       
   138 // ---------------------------------------------------------
       
   139 // Exported proxy for instantiation method resolution
       
   140 // ---------------------------------------------------------
       
   141 //
       
   142 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
       
   143     {
       
   144     aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
       
   145     return ImplementationTable;
       
   146     }