/******************************************************************************/
/*                 Copyright C 1998-2004 Broadcom Corporation                 */
/*                                                                            */
/* This material is the confidential trade secret and proprietary information */
/* of Broadcom Corporation.  It may not be reproduced, used, sold or          */
/* transferred to any third party without the prior written consent of        */
/* Broadcom Corporation.   All rights reserved.                               */
/******************************************************************************/
/*   FileName        : bcm_processResult.c                                    */
/*   Purpose         : Systematic analysis of HMI QA result                   */
/*   Limitations     : None                                                   */
/*   Author          : Emmanuel Hanssens                                      */
/*   Creation Date   : 27-Sep-2004                                            */
/*   History         : Compiled by CVS                                        */
/******************************************************************************/
/*   $Id: bcm_processResult.c,v 1.2 2004/10/25 11:58:44 hanssens Exp $  */
/******************************************************************************/

#include "bcm_processResult.h"
#include "bcm_errorHandler.h"
#include "bcm_hmiQA.h"

int processResult(int serviceResult, 
                  uint16 appId,
                  uint16 devId,
                  char const *service,
                  char *fileName, 
                  int line)
{
  switch (serviceResult)
  {
      case HMI_RESULT_SUCCESS:  /* success => can go on */
        return BCM_SUCCESS;
        break;
      case HMI_RESULT_UNKNOW_APPLICATION_ID:
        fatalError(fileName, line,
                   "Device %d: unknown application Id (%x) for service %s",
                   devId, appId, service);
        break;
      case HMI_RESULT_UNKNOW_COMMAND_ID:
        fatalError(fileName, line, 
                   "Device %d, appl %x: unknown command Id for service %s",
                   devId, appId, service);
        break;
      case HMI_RESULT_WRONG_MESSAGE_FORMAT:
        fatalError(fileName, line, 
                   "Device %d, appl %x: wrong message format for service %s",
                   devId, appId, service);
        break;
      case HMI_RESULT_REQUEST_DATA_NOT_VALID:
        fatalError(fileName, line,
                   "Device %d, appl %x: request data not valid for service %s",
                   devId, appId, service);
        break;
      case HMI_RESULT_CANT_PROCESS_REQUEST: 
        /* request cannot be performed in current state */
        /* => not fatal, will be handled */
#if BCM_PRINT_DEBUG_INFO > 2
        errorHandler(
          fileName, line, 0,
          "Device %d, appl %x: service %s not allowed in current state.", 
          devId, appId, service);
#endif
        break;
      case BCM_FAILURE:
        /* this is actually not the value returned by the service, but */
        /* rather the hmiQA function detecting an error condition */
        /* this should not be fatal, upper layer may handle it, so we just */
        /* return failure */
#if BCM_PRINT_DEBUG_INFO > 2
        errorHandler(fileName, line, 0,
                     "Device %d, appl %x: service %s failed.", 
                     devId, appId, service);
#endif
        break;
      default:
        fatalError(fileName, line, 
                   "Device %d, appl %x: unexpected error (%d) for service %s",
                   devId, appId, serviceResult, service);
        break;
  }
  return serviceResult;
}

