testexecmgmt/ucc/Source/Uccs.v2/ServiceStubs/Internal/CInternalStub.cpp
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 * System Includes
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <assert.h>
       
    21 #include <winsock2.h>
       
    22 #include <windows.h>
       
    23 
       
    24 /*******************************************************************************
       
    25  *
       
    26  * Local Includes
       
    27  *
       
    28  ******************************************************************************/
       
    29 #include "..\..\Core\UCCS_ServiceValues.h"
       
    30 #include "..\..\Core\UCCS_ErrorCodes.h"
       
    31 #include "CInternalStub.h"
       
    32 #include "..\..\..\include\penstd.h"
       
    33 
       
    34 /*******************************************************************************
       
    35  *
       
    36  * Definitions
       
    37  *
       
    38  ******************************************************************************/
       
    39 
       
    40 /*******************************************************************************
       
    41  *
       
    42  * Macro Functions
       
    43  *
       
    44  ******************************************************************************/
       
    45 																		
       
    46 /*******************************************************************************
       
    47  *
       
    48  * Constructor / Destructor
       
    49  *
       
    50  ******************************************************************************/
       
    51 CInternalStub::CInternalStub()
       
    52 {
       
    53 }
       
    54 
       
    55 
       
    56 CInternalStub::~CInternalStub()
       
    57 {
       
    58 }
       
    59 
       
    60 
       
    61 /*******************************************************************************
       
    62  *
       
    63  * Startup / Shutdown
       
    64  *
       
    65  ******************************************************************************/
       
    66 int CInternalStub::StartUccsService( char *aHostName, int *aLocalError, int *aRemoteError )
       
    67 {
       
    68 	*aLocalError = *aRemoteError = 0;
       
    69 	return 0;
       
    70 }
       
    71 
       
    72 
       
    73 int CInternalStub::StopUccsService( int *aLocalError, int *aRemoteError )
       
    74 {
       
    75 	*aLocalError = *aRemoteError = 0;
       
    76 	return 0;
       
    77 }
       
    78 
       
    79 
       
    80 /*******************************************************************************
       
    81  *
       
    82  * IssueCommand
       
    83  *
       
    84  ******************************************************************************/
       
    85 CDataRecord* CInternalStub::IssueCommand( CDataRecord* aRequest )
       
    86 {
       
    87 	int err;
       
    88 	int method_id;
       
    89 	int sarg_integer;
       
    90 	char *sarg_string;
       
    91 	CDataRecord *request_reply;
       
    92 
       
    93 	// check params
       
    94 	assert( aRequest != NULL );
       
    95 
       
    96 	// create a standard reply 
       
    97 	request_reply = CreateBaseReply( aRequest );
       
    98 	assert( request_reply != NULL );
       
    99 
       
   100 	// get and check the method_id
       
   101 	err = request_reply->GetFieldAsInt( "METHODID", &method_id );
       
   102 	assert( err == UCCS_OK );
       
   103 	if( method_id == -1 ) {
       
   104 		UpdateCompletionCode( request_reply, ERR_INVALID_METHOD );
       
   105 		return request_reply;
       
   106 	}
       
   107 
       
   108 	// now dispatch and call the appropriate method
       
   109 	switch( method_id ) {
       
   110 
       
   111 	// pause
       
   112 	case 1:
       
   113 		// extract the parameters
       
   114 		GETINTEGERARGUMENT( "PERIOD", &sarg_integer, 1, 0, aRequest, request_reply );
       
   115 
       
   116 		// implement the call
       
   117 		Sleep( sarg_integer );
       
   118 
       
   119 		// update the result
       
   120 		UpdateCompletionCode( request_reply, ERR_NONE );
       
   121 		break;
       
   122 		
       
   123 	// print message 
       
   124 	case 3:
       
   125 		// extract the parameters
       
   126 		GETSTRINGARGUMENT( "MSG", &sarg_string, 1, 0, aRequest, request_reply );
       
   127 
       
   128 		// implement the call
       
   129 		fprintf( stderr, "%s\n", sarg_string );
       
   130 		fflush( stderr );
       
   131 
       
   132 		// update the result
       
   133 		UpdateCompletionCode( request_reply, ERR_NONE );
       
   134 		break;
       
   135 
       
   136 	// null
       
   137 	case 4:
       
   138 		UpdateCompletionCode( request_reply, ERR_NONE );
       
   139 		break;
       
   140 
       
   141 	// Any other method id results in an invalid method id result
       
   142 	default:
       
   143 		UpdateCompletionCode( request_reply, ERR_INVALID_METHOD );
       
   144 		break;
       
   145 	}
       
   146 
       
   147 	// everything should be handled above 
       
   148 	return request_reply;
       
   149 }
       
   150 
       
   151 
       
   152 /*******************************************************************************
       
   153  *
       
   154  * GetStatus()
       
   155  *
       
   156  ******************************************************************************/
       
   157 int CInternalStub::GetStatus()
       
   158 {
       
   159 	assert( !"GetStatus() - is not implemented" );
       
   160 	return -1;
       
   161 }