sapi_sysinfo/inc/sysinfointerface.h
changeset 0 14df0fbfcc4e
equal deleted inserted replaced
-1:000000000000 0:14df0fbfcc4e
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  CSysInfoInterface class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __SYSINFOINTERFACE_H__
       
    20 #define __SYSINFOINTERFACE_H__
       
    21 
       
    22 const TInt  KMaxErrMsg = 1024;
       
    23 
       
    24 //INCLUDES
       
    25 #include <e32def.h>
       
    26 #include <e32base.h>
       
    27 #include <liwvariant.h>
       
    28 
       
    29 #include "sysinfoservice.h"
       
    30 //FORWARD DECLARATION
       
    31 class CSysInfoObserver;
       
    32 class CSysInfoCallbackMap;
       
    33 /**
       
    34 * CSysInfoInterface
       
    35 * This class inherits from MAiwInterface and implements the
       
    36 * ExecuteCmdL( const TDesC8& aCmdName,
       
    37 *              const CLiwGenericParamList& aInParamList,
       
    38 *              CLiwGenericParamList& aOutParamList, TUint aCmdOptions = 0,
       
    39 *              MLiwNotifyCallback* aCallback = 0) and
       
    40 * Close() functions. The member functions of this class parses the input parameters,
       
    41 * constructs proper structures and calls the corresponding service class functions
       
    42 * based on the input arguments.
       
    43 */
       
    44 // CLASS DECLARATION
       
    45 NONSHARABLE_CLASS(CSysInfoInterface): public CBase, public MLiwInterface
       
    46     {
       
    47         enum TIndex
       
    48         {
       
    49         EIndex0 = 0,        
       
    50         EIndex1,
       
    51         EIndex2,
       
    52         EIndex3
       
    53         };	
       
    54 
       
    55     public://New Methods
       
    56 
       
    57     /**
       
    58     * NewL.
       
    59     * Two-phased constructor.
       
    60     * Create a CSysInfoInterface object.
       
    61     * @return A pointer to the created instance of CSysInfoInterface.
       
    62     */
       
    63     static CSysInfoInterface* NewL();
       
    64 
       
    65     public: // from MAiwInterface
       
    66 
       
    67     /**
       
    68     * The consumer application should call this method to execute a service
       
    69     * command directly on the interface. The service provider should
       
    70     * provide a concrete implementation for the supported service
       
    71     * command aCmdName. The consumer application should fill in the necessary
       
    72     * parameters in \em aInParamList.
       
    73     */
       
    74     void ExecuteCmdL( const TDesC8& aCmdName,
       
    75                         const CLiwGenericParamList& aInParamList,
       
    76                         CLiwGenericParamList& aOutParamList, 
       
    77                         TUint aCmdOptions = 0,
       
    78                         MLiwNotifyCallback* aCallback = 0);
       
    79 
       
    80     /**
       
    81     * The service provider should provide a concrete implementation
       
    82     * for this method. The internal state of the service provider
       
    83     * implemeting \c MAiwInterface can be reset within this method.
       
    84     * The consumer application should call this method if there
       
    85     * are no more service commands to be executed on the interface.
       
    86     */
       
    87     void Close();
       
    88 
       
    89     /**
       
    90     * Callback
       
    91     * This function returns the callback for the corresponding asynchronous 
       
    92     * request whose transaction id is passed.
       
    93     *
       
    94     * @param aTransactionId Transaction id of asynchronous request whose 
       
    95     *                       callback is required.
       
    96     * @return The callback of the asynchronous request.
       
    97     */
       
    98     MLiwNotifyCallback* GetCallback( TInt32 aTransactionId );
       
    99 
       
   100     /**
       
   101     * Callback
       
   102     * This function returns the callback for the corresponding asynchronous request whose
       
   103     * transaction id is passed and removes the callback entry.
       
   104     *
       
   105     * @param aTransactionId Transaction id of asynchronous request 
       
   106     *                       whose callback is required.
       
   107     * @return The callback of the asynchronous request.
       
   108     */
       
   109     MLiwNotifyCallback* GetCallbackAndRemove( TInt32 aTransactionId );
       
   110 
       
   111     /**
       
   112     * SapiError
       
   113     * This function maps sapi error.
       
   114     *
       
   115     * @param aSymbianErr symbian error code.
       
   116     *
       
   117     */       
       
   118     TInt SapiError( TInt aSymbianErr );
       
   119 
       
   120     /**
       
   121     * ConvertSysData2AiwParamL
       
   122     * This function converts system data aInSysData to aOutMapParam
       
   123     * 
       
   124     * @param aInSysData the input parameter sysdata.
       
   125     * @param [out] aOutMapParam aiw map representation of sysdata.
       
   126     *
       
   127     *
       
   128     * @see CLiwMap
       
   129     * @see CSysData
       
   130     *
       
   131     */     		
       
   132     static void ConvertSysData2AiwParamL(const CSysData* aInSysData,
       
   133                                             CLiwMap*& aOutMapParam);
       
   134 
       
   135     private:
       
   136 
       
   137     /**
       
   138     * ConstructL
       
   139     * 2nd phase constructor.
       
   140     * Perform the second phase construction of CSysInfoInterface object.
       
   141     */
       
   142     void ConstructL();
       
   143 
       
   144     /**
       
   145     * C++ default constructor.
       
   146     * By default Symbian OS constructor is private.
       
   147     */
       
   148     CSysInfoInterface();
       
   149 
       
   150     /**
       
   151     * ~CSysInfoInterface
       
   152     * Destructor.
       
   153     */
       
   154     ~CSysInfoInterface();
       
   155 
       
   156     private:// delegator functions
       
   157 
       
   158     /**
       
   159     * SwitchCmdL
       
   160     * This function delegates the control to other functions based on the command.
       
   161     *
       
   162     * @param aCmdName the name of the service command which the consumer wants to invoke.
       
   163     * @param aInParamList the input parameter list.
       
   164     * @param [in,out] aOutParamList the output parameter list, can be empty list or may contain the errors.
       
   165     * @param aCmdOptions Options for the command, see TAiwServiceCmdOptions in liwcommon.hrh.
       
   166     * @param aCallback callback to be registered by consumer application
       
   167     *
       
   168     *
       
   169     *
       
   170     * @see TAiwServiceCmdOptions
       
   171     * @see CLiwGenericParamList
       
   172     * @see MLiwNotifyCallback
       
   173     *
       
   174     */
       
   175     void SwitchCmdL( const TDesC8& aCmdName,
       
   176                     const CLiwGenericParamList& aInParamList,
       
   177                     CLiwGenericParamList& aOutParamList, 
       
   178                     TUint aCmdOptions,
       
   179                     MLiwNotifyCallback* aCallback );
       
   180 
       
   181     private:
       
   182     /**
       
   183     * SetInfoL
       
   184     * This function modifies a specified system attribute value by calling core class
       
   185     * function SetInfoL.
       
   186     *
       
   187     * @param aInParamList the input parameter list.
       
   188     *
       
   189     * @see CLiwGenericParamList
       
   190     *
       
   191     */
       
   192     void SetInfoL(const CLiwGenericParamList& aInParamList);
       
   193 
       
   194     /**
       
   195     * GetInfoL
       
   196     * This function reads a specified system attribute by calling GetInfoL core class.
       
   197     * funtion.
       
   198     * 
       
   199     * @param aInParamList the input parameter list.
       
   200     * @param [in,out] aOutParamList the output parameter list, is an empty list.
       
   201     * @param aCmdOptions Options for the command, see TAiwServiceCmdOptions in liwcommon.hrh.
       
   202     * @param aCallback callback to be registered by consumer application
       
   203     *
       
   204     *
       
   205     *
       
   206     * @see TAiwServiceCmdOptions
       
   207     * @see CLiwGenericParamList
       
   208     * @see MLiwNotifyCallback
       
   209     *
       
   210     */     
       
   211     void GetInfoL( const CLiwGenericParamList& aInParamList,
       
   212                     CLiwGenericParamList& aOutParamList, 
       
   213                     TUint aCmdOptions,
       
   214                     MLiwNotifyCallback* aCallback );
       
   215 
       
   216     /**
       
   217     * GetNotificationL
       
   218     * This function registers a callback for notification on specified system attribute by.
       
   219     * calling core class function GetNotificationL.
       
   220     * 
       
   221     * @param aInParamList the input parameter list.
       
   222     * @param [in,out] aOutParamList the output parameter list, is an empty list.
       
   223     * @param aCmdOptions Options for the command, see TAiwServiceCmdOptions in liwcommon.hrh.
       
   224     * @param aCallback callback to be registered by consumer application
       
   225     *
       
   226     *
       
   227     *
       
   228     * @see TAiwServiceCmdOptions
       
   229     * @see CLiwGenericParamList
       
   230     * @see MLiwNotifyCallback
       
   231     *
       
   232     */     
       
   233     void GetNotificationL( const CLiwGenericParamList& aInParamList,
       
   234                             CLiwGenericParamList& aOutParamList, 
       
   235                             TUint aCmdOptions,
       
   236                             MLiwNotifyCallback* aCallback );
       
   237 
       
   238     /**
       
   239     * ReadInputParamsL
       
   240     * This function reads input parameters specified in aInParamList.
       
   241     * 
       
   242     * @param aInParamList the input parameter list.
       
   243     * @param [out] aEntity input param entity.
       
   244     * @param [out] aKey input param key.
       
   245     * @param [out] aInputData optional data specified.
       
   246     *
       
   247     *
       
   248     * @see CLiwGenericParamList
       
   249     * @see CSysData
       
   250     *
       
   251     */     
       
   252     void ReadInputParamsL(const CLiwGenericParamList& aInParamList,
       
   253                             TPtrC& aEntity, TPtrC& aKey,
       
   254                             CSysData*& aInputData);
       
   255 
       
   256     /**
       
   257     * Convert2SysDataL
       
   258     * This function converts system data specified in aInputParam
       
   259     * to aSysData.
       
   260     * 
       
   261     * @param aInputParam the input parameter.
       
   262     * @param [out] aSysData input param sysdata.
       
   263     *
       
   264     *
       
   265     * @see TLiwGenericParam
       
   266     * @see CSysData
       
   267     *
       
   268     */     
       
   269     void Convert2SysDataL(const TLiwGenericParam& aInputParam,
       
   270                                             CSysData*& aSysData);
       
   271 
       
   272     /**
       
   273     * Cancel
       
   274     * This function cancels a previously requested aynchronous request
       
   275     * based on transaction id.
       
   276     *
       
   277     * @param aInParamList the input parameter list.
       
   278     * @param [in,out] aOutParamList the output parameter list, is an empty list.
       
   279     * @param aCmdOptions Options for the command, see TAiwServiceCmdOptions in liwcommon.hrh.
       
   280     * @param aCallback callback to be registered by consumer application
       
   281     *
       
   282     *
       
   283     *
       
   284     * @see TAiwServiceCmdOptions
       
   285     * @see CLiwGenericParamList
       
   286     * @see MLiwNotifyCallback
       
   287     *
       
   288     */
       
   289     void CancelL( const CLiwGenericParamList& aInParamList,
       
   290                     CLiwGenericParamList& aOutParamList, 
       
   291                     TUint aCmdOptions,
       
   292                     MLiwNotifyCallback* aCallback );
       
   293 
       
   294     private:// Data
       
   295 
       
   296     /**
       
   297     * iService
       
   298     * The handle to the CSysInfoService object.
       
   299     */
       
   300     CSysInfoService* iService;
       
   301     /**
       
   302     * iObserver
       
   303     * ISystemObserver instance.
       
   304     */
       
   305     CSysInfoObserver* iObserver;
       
   306 
       
   307     /**
       
   308     * iCallbackMap
       
   309     * Array of CSysInfoCallbackMap objects.
       
   310     */
       
   311     RPointerArray<CSysInfoCallbackMap> iCallbackMap;
       
   312 
       
   313     /**
       
   314     * Error Message buffer.
       
   315     */
       
   316     TBuf<KMaxErrMsg>  iErrBuf;
       
   317     };
       
   318 
       
   319 #endif // __SYSINFOINTERFACE_H__