serviceproviders/sapi_logging/src/loggingservicehandler.cpp
changeset 5 989d2f495d90
child 23 50974a8b132e
equal deleted inserted replaced
1:a36b1e19a461 5:989d2f495d90
       
     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:  Implements logging service handler (This will be part of 
       
    15 *									Ecom plugin.
       
    16 *
       
    17 */
       
    18 
       
    19 #include <liwserviceifbase.h>
       
    20 #include <LiwCommon.h>
       
    21 #include <logwrap.h>
       
    22 #include <ecom/ImplementationProxy.h>
       
    23 #include "LOGCLIENTCHANGEOBSERVER.H"
       
    24 #include "logiter.h"
       
    25 #include "loggingservicehandler.h"
       
    26 #include "logginginterface.h"
       
    27 
       
    28 /**
       
    29 * @Default constructor 
       
    30 */ 
       
    31 CLogServiceHandler :: CLogServiceHandler()
       
    32     {
       
    33     }
       
    34 
       
    35 /**
       
    36 * @Default destructor 
       
    37 */ 
       
    38 CLogServiceHandler :: ~CLogServiceHandler()
       
    39     {
       
    40     }
       
    41 
       
    42 /**
       
    43 * Two phased constructor implementation
       
    44 */
       
    45 EXPORT_C CLogServiceHandler* CLogServiceHandler :: NewL()
       
    46     {
       
    47     CLogServiceHandler* self = CLogServiceHandler::NewLC();
       
    48     CleanupStack::Pop(self);
       
    49     return self; 
       
    50     }
       
    51 
       
    52 /**
       
    53 * Two phased constructor implementation
       
    54 */
       
    55 CLogServiceHandler* CLogServiceHandler :: NewLC() 
       
    56     {
       
    57     CLogServiceHandler* self = new (ELeave) CLogServiceHandler();
       
    58     CleanupStack::PushL(self);
       
    59     return self;
       
    60     }
       
    61 
       
    62 /**
       
    63 * Called by the AIW framework to initialise provider with necessary information 
       
    64 * from the Service Handler. This method is called when the consumer makes 
       
    65 * the attach operation.         
       
    66 *
       
    67 * @param aFrameworkCallback callback handle function
       
    68 * @param aInterest consumer application's intrest
       
    69 */
       
    70 void CLogServiceHandler::InitialiseL( MLiwNotifyCallback& /*aFrameworkCallback*/,
       
    71                                       const RCriteriaArray& aInterest )
       
    72     {
       
    73     TInt count = aInterest.Count() ;
       
    74     for ( TInt i = 0; i < count; i++ )
       
    75         {
       
    76         if ( aInterest[i]->ContentType() == KLoggingContents ) 
       
    77             {
       
    78             iContentType = KLoggingContents;
       
    79             return;
       
    80             }
       
    81         }
       
    82     User::Leave( KErrNotFound );
       
    83     }
       
    84 
       
    85 /**
       
    86 * Executes generic service commands included in criteria, derived from CLiwServiceIfBase
       
    87 * 
       
    88 * @param aCmdId Command to be executed.
       
    89 * @param aInParamList Input parameters, can be an empty list.
       
    90 * @param aOutParamList Output parameters, can be an empty list.
       
    91 * @param aCmdOptions Options for the command, see KLiwOpt* in LiwCommon.hrh.
       
    92 * @param aCallback Callback for asynchronous command handling, parameter checking, etc.
       
    93 */
       
    94 void CLogServiceHandler :: HandleServiceCmdL( const TInt& aCmdId,
       
    95                                               const CLiwGenericParamList& aInParamList,
       
    96                                               CLiwGenericParamList& aOutParamList,
       
    97                                               TUint aCmdOptions,
       
    98                                               const MLiwNotifyCallback* aCallback )
       
    99     {
       
   100     TRAPD( error , CmdExecuteL( aCmdId , aInParamList, aOutParamList ,aCmdOptions , aCallback ) ) ;
       
   101     
       
   102     if ( error )
       
   103     	{
       
   104     	TInt sapierror = CLoggingInterface::ConvertToSapiError( error );
       
   105     	aOutParamList.AppendL( TLiwGenericParam( KErrorCode , TLiwVariant( sapierror ) ) ) ;	
       
   106     	}
       
   107     else
       
   108     	{
       
   109     	aOutParamList.AppendL( TLiwGenericParam( KErrorCode , TLiwVariant( error ) ) ) ;
       
   110     	}
       
   111     }
       
   112 
       
   113 /**
       
   114 * CLogServiceHandler::CmdExecuteL, this method is called by CLogServiceHandler::HandleCmdL()
       
   115 * to catch any leaves that might occur during execution of a LiwCommand. 
       
   116 */
       
   117 void CLogServiceHandler::CmdExecuteL( const TInt& aCmdId,
       
   118         	                          const CLiwGenericParamList& aInParamList,
       
   119         	                          CLiwGenericParamList& aOutParamList,
       
   120         	                          TUint /*aCmdOptions */,
       
   121         	                          const MLiwNotifyCallback* /*aCallback*/ )
       
   122     {
       
   123     TLiwGenericParam r;
       
   124     const TLiwGenericParam* p = NULL;
       
   125     CLoggingInterface *interfaceLogging ;
       
   126     aOutParamList.Reset() ;
       
   127     
       
   128     if ( aCmdId == KLiwCmdAsStr ) 
       
   129         {
       
   130         TInt pos = 0;
       
   131         p = aInParamList.FindFirst(pos, _L8("cmd")); 
       
   132         }
       
   133     
       
   134     if ( p && ( p->Value().AsData() == KDsInterfaceName ) ) 
       
   135         {
       
   136         if ( iContentType == KLoggingContents )
       
   137     		{
       
   138     		interfaceLogging  = CLoggingInterface :: NewL() ;
       
   139     		CleanupStack :: PushL( interfaceLogging ) ;
       
   140     		aOutParamList.AppendL(TLiwGenericParam(KDsInterfaceName , TLiwVariant(interfaceLogging))) ;
       
   141     		}//End of KLoggingContents
       
   142     	} //End of KLsInterface
       
   143     
       
   144     else 
       
   145         {
       
   146         aOutParamList.AppendL(TLiwGenericParam(KErrorCode , TLiwVariant((TInt32)KErrGeneral)));
       
   147         aOutParamList.AppendL(TLiwGenericParam(KErrorMessage,TLiwVariant(KInterfaceMissing())));
       
   148         }
       
   149       
       
   150     aOutParamList.AppendL( TLiwGenericParam( KErrorCode , TLiwVariant( KErrNone ) ) ) ;
       
   151     CleanupStack :: Pop ( interfaceLogging ) ;
       
   152         
       
   153     return;
       
   154     }
       
   155 
       
   156 /**
       
   157 *   Map the interface UIDs to implementation factory functions
       
   158 */       
       
   159 const TImplementationProxy ImplementationTable[] =
       
   160 {
       
   161 IMPLEMENTATION_PROXY_ENTRY( 0x2000CFC1, CLogServiceHandler::NewL )
       
   162 };
       
   163 
       
   164 /**
       
   165 *  Exported proxy for instantiation method resolution
       
   166 */   
       
   167 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
       
   168     {
       
   169     aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
       
   170     return ImplementationTable;
       
   171     }