testexecmgmt/ucc/Source/Uccs.v2/ServiceStubs/CommonServiceStub/CServiceAgentBase.h
changeset 0 3da2a79470a7
equal deleted inserted replaced
-1:000000000000 0:3da2a79470a7
       
     1 /*
       
     2 * Copyright (c) 2005-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 * CServiceAgentBase
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __CSERVICEAGENTBASE_H__
       
    22 #define __CSERVICEAGENTBASE_H__
       
    23 
       
    24 
       
    25 /*******************************************************************************
       
    26  *
       
    27  * System Includes
       
    28  *
       
    29  ******************************************************************************/
       
    30 #include <rpc/rpc.h>
       
    31 #include <rpc/types.h>
       
    32 
       
    33 
       
    34 /*******************************************************************************
       
    35  *
       
    36  * Local Includes
       
    37  *
       
    38  ******************************************************************************/
       
    39 #include "../../Core/UCCS_Interfaces.h"
       
    40 #include "../../Core/UCCS_ServiceValues.h"
       
    41 
       
    42 
       
    43 /*******************************************************************************
       
    44  *
       
    45  * Macro Functions
       
    46  *
       
    47  ******************************************************************************/
       
    48 #define GETSTRINGARGUMENT(field,token,index,optional,request,reply)		{	int _err; \
       
    49 																			_err = GetStringArgument(field,token,index,optional,request,reply); \
       
    50 																			if( _err != 0 ) \
       
    51 																				break; \
       
    52 																		}
       
    53 
       
    54 
       
    55 #define GETINTEGERARGUMENT(fieldname,var,index,optional,request,reply)		{	int _err; \
       
    56 						 														_err = GetIntegerArgument(fieldname,var,index,optional,request,reply); \
       
    57 																				if( _err != 0 ) \
       
    58 																					break; \
       
    59 																			}
       
    60 
       
    61 
       
    62 #define SETINTEGERRESULT( client_call_result, success_value, result, request)			{	int _err; \
       
    63 																							if( client_call_result == success_value ) { \
       
    64 																								_err = request->NewField( "RESULT", result ); \
       
    65 																								assert( _err == UCCS_OK ); \
       
    66 																							} \
       
    67 																						} 
       
    68 
       
    69 
       
    70 /*******************************************************************************
       
    71  *
       
    72  * Definitions
       
    73  *
       
    74  ******************************************************************************/
       
    75 #define STD_REPLY_FIELD_SERVICE_ID					"SVCID"
       
    76 #define STD_REPLY_FIELD_SERVICE_HOST				"SVCHOST"
       
    77 #define STD_REPLY_FIELD_SERVICE_NAME				"SVCNAME"
       
    78 #define STD_REPLY_FIELD_METHODID					"METHODID"
       
    79 #define STD_REPLY_FIELD_CALL						"CALL"
       
    80 #define STD_REPLY_FIELD_REQUESTCOMPLETIONCODE		"REQUESTCOMPLETIONCODE"
       
    81 #define STD_REPLY_FIELD_REQUESTCOMPLETIONDESC		"REQUESTCOMPLETIONDESC"
       
    82 
       
    83 #define STD_REPLY_FIELD_RESULT						"RESULT"
       
    84 
       
    85 
       
    86 /*******************************************************************************
       
    87  *
       
    88  * CServiceAgentBase
       
    89  *
       
    90  ******************************************************************************/
       
    91 class CServiceAgentBase
       
    92 {
       
    93 public:
       
    94 	CServiceAgentBase();
       
    95 	~CServiceAgentBase();
       
    96 
       
    97 protected:
       
    98 
       
    99 	// Stateless data transformers
       
   100 	char *IntToAddress( int aAddr );
       
   101 	int AddressToInt( char *aAddress );
       
   102 
       
   103 	// Extract named arguments from a record 
       
   104 	int GetStringArgument( char *aFieldName, char **aOutput, int aParamIndex, int aOptional, CDataRecord *aRequest, CDataRecord *aReply );
       
   105 	int GetIntegerArgument( char *aFieldName, int *aOutput, int aParamIndex, int aOptional, CDataRecord *aRequest, CDataRecord *aReply );
       
   106 
       
   107 	// Add return values to reply record
       
   108 	void AddIteratedIntegerFieldName( char *aFieldname, int aIndex, int aValue, CDataRecord *aReply );
       
   109 	void AddIteratedStringFieldName( char *aFieldname, int aIndex, char *aValue, CDataRecord *aReply );
       
   110 
       
   111 	// Update the standard fields of a reply record
       
   112 	CDataRecord *CreateBaseReply( CDataRecord *aRequest );
       
   113 	void UpdateCompletionCode( CDataRecord *aReply, int aPenStdErrorCode );
       
   114 	virtual char *GetLastRPCError( int *aRpcErrorInt );
       
   115 
       
   116 	// Misc helpers
       
   117 	void XdrFree( char **ptr, int *len );
       
   118 
       
   119 private:
       
   120 //	void AddCompletionCodeDesc( CDataRecord *aReply, TRequestCompletionCode aResult );
       
   121 	char iAddressString[32];
       
   122 };
       
   123 
       
   124 #endif //__CSERVICEAGENTBASE_H__