sapi_sensor/src/sensorprovider.cpp
changeset 0 14df0fbfcc4e
equal deleted inserted replaced
-1:000000000000 0:14df0fbfcc4e
       
     1 /*
       
     2 * Copyright (c) 2006-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:   Loads the sensor service
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <ecom/ImplementationProxy.h>
       
    20 #include "sensorservicehandler.h"
       
    21 #include "sensorinterface.h"
       
    22 #include "serviceerrno.h"
       
    23 #include "sensorcallback.h"
       
    24 //Constant for sensor servicecommand.
       
    25 _LIT8( KIfaceSensor , "ISensor" );
       
    26 _LIT8( KCmdId , "cmd" );
       
    27 
       
    28 using namespace LIW;
       
    29 
       
    30 /*
       
    31 -----------------------------------------------------------------------------
       
    32     CSensorProvider::CSensorProvider()
       
    33     Description          : Constructor
       
    34     Return values        : N/A
       
    35 -----------------------------------------------------------------------------
       
    36 */
       
    37 CSensorProvider::CSensorProvider()                     
       
    38     {
       
    39 
       
    40     }
       
    41 /*
       
    42 -----------------------------------------------------------------------------
       
    43     CSensorProvider* CSensorProvider::NewL()
       
    44     Description                                 : Two-phased constructor.
       
    45     Return values                               : CSensorProvider object pointer
       
    46 -----------------------------------------------------------------------------
       
    47 */
       
    48 CSensorProvider* CSensorProvider::NewL()
       
    49     {
       
    50     return new( ELeave ) CSensorProvider();
       
    51     }
       
    52 /*
       
    53 -----------------------------------------------------------------------------
       
    54     CSensorProvider::~CSensorProvider()
       
    55     Description          : Destructor, free allocated resources
       
    56     Return values        : N/A
       
    57 -----------------------------------------------------------------------------
       
    58 */
       
    59 CSensorProvider::~CSensorProvider()
       
    60     {
       
    61     }
       
    62 /*
       
    63 -----------------------------------------------------------------------------
       
    64     void CSensorProvider::InitialiseL()
       
    65     Description               : CLiwServiceIfBase Method called by Liw Framework
       
    66                                 when AttachL is called.
       
    67     Return values             : N/A
       
    68 -----------------------------------------------------------------------------
       
    69 */
       
    70 void CSensorProvider::InitialiseL( MLiwNotifyCallback& /*aFrameworkCallback*/,
       
    71                                    const RCriteriaArray& /*aInterest*/ )
       
    72     {
       
    73     // Not needed.
       
    74     }
       
    75 
       
    76 /*
       
    77 -----------------------------------------------------------------------------
       
    78     void CSensorProvider::HandleServiceCmdL()
       
    79     Description               : CLiwServiceIfBase Method called by Liw Framework.
       
    80                                 Executes generic service commands included in criteria.
       
    81     Return values             : N/A
       
    82 -----------------------------------------------------------------------------
       
    83 */
       
    84 void CSensorProvider::HandleServiceCmdL( const TInt& aCmdId,
       
    85                                          const CLiwGenericParamList& aInParamList,
       
    86                                          CLiwGenericParamList& aOutParamList,
       
    87                                          TUint /*aCmdOptions*/,
       
    88                                          const MLiwNotifyCallback* /*aCallback*/ )
       
    89     {
       
    90 
       
    91     TPtrC8 lCmdName;
       
    92     TLiwGenericParam result;
       
    93     const TLiwGenericParam* cmd = NULL;
       
    94     MLiwInterface* interface = NULL;
       
    95 
       
    96     if ( aCmdId == KLiwCmdAsStr )
       
    97         {
       
    98         TInt pos = 0;
       
    99         cmd = aInParamList.FindFirst( pos , KCmdId );
       
   100         if ( NULL != cmd )
       
   101             {
       
   102             lCmdName.Set( cmd->Value().AsData() );
       
   103             }
       
   104         }
       
   105     if( lCmdName.CompareF( KIfaceSensor ) == 0 )    
       
   106         {
       
   107         //Create interface pointer and return the output param
       
   108         result.SetNameL( KIfaceSensor );
       
   109         interface = CSensorInterface::NewL();
       
   110         CleanupStack::PushL( interface );
       
   111         result.Value().Set( interface );
       
   112         }
       
   113     else
       
   114         {
       
   115 		result.SetSemanticId( EGenericParamError );
       
   116 		result.Value().Set( (TInt32) SErrInvalidServiceArgument );
       
   117         }
       
   118 
       
   119 	aOutParamList.AppendL( result );
       
   120 	if( interface )
       
   121     	{
       
   122     	CleanupStack::Pop( interface );    
       
   123     	}
       
   124 	result.Reset();
       
   125 	return;
       
   126     }
       
   127 
       
   128 // Map the interface UIDs to implementation factory functions
       
   129 const TImplementationProxy ImplementationTable[] =
       
   130     {
       
   131     	//need to change this UID
       
   132     IMPLEMENTATION_PROXY_ENTRY( 0x2000CFBE, CSensorProvider::NewL )
       
   133     };
       
   134 
       
   135 /*
       
   136  ---------------------------------------------------------
       
   137  Exported proxy for instantiation method resolution
       
   138  ---------------------------------------------------------
       
   139 */
       
   140 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   141     {
       
   142     aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
       
   143     return ImplementationTable;
       
   144     }
       
   145 
       
   146