/*
 *	KDDI Brew Application Infrared Protocol Service APIs
 *	Copyright (C) 2004 Link Evolution Corp.
 *	Create : 2004/4/13   Gontaro Kitazumi (Link Evolution)
 *	Modify : 2004/5/10   Gontaro Kitazumi (Link Evolution)
 *	$Id$
 */

#ifndef ___IIR_IRFM___
#define ___IIR_IRFM___

#include "IIrObex.h"
#include "IIRFM.BID"
#include "IIRFMEXT.BID"

/********************************************** IIRFM Interface *************************************************/
typedef struct IIrFm IIrFm;
typedef enum mIIRFM_PROFILE {
	IIRFM_USER_APP = 0,
	IIRFM_CORE_PROF,
	IIRFM_TEST_PROF,
	IIRFM_PAYMENT_PROF,
	IIRFM_LOYALTY_PROF,
	IIRFM_VOUCHER_PROF,
	IIRFM_RECEIPT_PROF
} IIRFM_PROFILE;

typedef int32 (*PFNIIRFM_EVENTHANDLER)(		IIRAPI_Handle hProfileHandle, void *pContext );
typedef int32 (*PFNIIRFM_CIPHANDLER)(		IIRAPI_Handle hProfileHandle ,void *pContext, boolean bMustResponse, uint8 *pszCipName, uint8 *pElements, uint32 nElements );
typedef int32 (*PFNIIRFM_CIPQUERYHANDLER)(	IIRAPI_Handle hProfileHandle, void *pContext, uint8 *pszCipName, uint8 **ppElements, uint32 *pnElements );
typedef int32 (*PFNIIRFM_CIPSETHANDLER)(	IIRAPI_Handle hProfileHandle, void *pContext, uint8 *pszCipName, uint8 *pElements, uint32 nElements );
typedef int32 (*PFNIIRFM_CIPCHECKHANDLER)(	IIRAPI_Handle hProfileHandle, void*pContext, uint8 *pszCipName, uint8 **ppElements, uint32 *pnElements);

typedef struct tIIRFM_FUNCS {
	PFNIIRFM_EVENTHANDLER		pfnCbBeginInd;
	PFNIIRFM_EVENTHANDLER		pfnCbEndInd;
	PFNIIRFM_CIPHANDLER			pfnCbCipHandler;
	PFNIIRFM_CIPQUERYHANDLER	pfnCbCipQuery;
	PFNIIRFM_CIPSETHANDLER		pfnCbCipSet;
} IIRFM_FUNCS, *PIIRFM_FUNCS;

AEEINTERFACE(IIrFm)
{
	INHERIT_IBase(IIrFm);
	IIRAPI_Handle (*Create)( 			IIrFm *pIIRFM, void *pContext, uint8 *pszClassName, IIRFM_PROFILE nCategory, uint8 nUUID[16], PIIRFM_FUNCS	pFuncsTable );
	int32 (*Delete)(					IIrFm *pIIRFM, IIRAPI_Handle hProfileHandle );
	int32 (*CIPHandlerRsp)( 			IIrFm *pIIRFM, IIRAPI_Handle hProfileHandle, uint8* pElements, uint32 nElements);
	int32 (*QueryCIPElement)(			IIrFm *pIIRFM, IIRAPI_Handle hProfileHandle, IIRFM_PROFILE nCategory, uint8 nUUID[16], uint8 *pszCipName, uint8 **ppElements, uint32 *pnElements );
	int32 (*SetCIPElement)(			IIrFm *pIIRFM, IIRAPI_Handle hProfileHandle, IIRFM_PROFILE nCategory, uint8 nUUID[16], uint8 *pszCipName, uint8 **ppElements, uint32 *pnElements );
	int32 (*SetSessionCapability)(		IIrFm *pIIRFM, IIRAPI_Handle hProfileHandle, uint16 nCategory, void* pCapability );
	int32 (*SetTransportCapability)(	IIrFm *pIIRFM, IIRAPI_Handle hProfileHandle, uint16 nCategory, void* pCapability );
	int32 (*ForceDisconnectReq)( 		IIrFm *pIIRFM, IIRAPI_Handle hProfileHandle, uint16 nReason );
	int32 (*InitializeService)(		IIrFm *pIIRFM, IIRAPI_Handle hProfileHandle );
	int32 (*StartService)(				IIrFm *pIIRFM, IIRAPI_Handle hProfileHandle );
	int32 (*StopService)( 				IIrFm *pIIRFM, IIRAPI_Handle hProfileHandle );
};

#define	IIRFM_TP_IR	0	// Transport (IRDA) 

#define IIRFM_AddRef(p)							     	AEEGETPVTBL((p),IIrFm)->AddRef((p))
#define IIRFM_Release(p)								AEEGETPVTBL((p),IIrFm)->Release((p))
#define IIRFM_Create(p, c, cn, nc, u, f)				AEEGETPVTBL((p),IIrFm)->Create((p), (c), (cn), (nc), (u), (f))
#define IIRFM_Delete(p, h)								AEEGETPVTBL((p),IIrFm)->Delete((p), (h))
#define IIRFM_CIPHandlerRsp(p, h, pe, ne)				AEEGETPVTBL((p),IIrFm)->CIPHandlerRsp((p), (h), (pe), (ne))
#define IIRFM_QueryCIPElement(p, h, c, u, cn, pe, ne)	AEEGETPVTBL((p),IIrFm)->QueryCIPElement((p), (h), (c), (u), (cn), (pe), (ne))
#define IIRFM_SetCIPElement(p, h, c, u, cn, pe, ne)		AEEGETPVTBL((p),IIrFm)->SetCIPElement((p), (h), (c), (u), (cn), (pe), (ne))
#define IIRFM_SetSessionCapability(p, h, nc,pc)			AEEGETPVTBL((p),IIrFm)->SetSessionCapability((p), (h), (nc),(pc))
#define IIRFM_SetTransportCapability(p, h, nc, pc)		AEEGETPVTBL((p),IIrFm)->SetTransportCapability((p), (h), (nc), (pc))
#define IIRFM_ForceDisconnectReq(p, h, r)				AEEGETPVTBL((p),IIrFm)->ForceDisconnectReq((p), (h), (r))
#define IIRFM_InitializeService(p, h)					AEEGETPVTBL((p),IIrFm)->InitializeService((p), (h))
#define IIRFM_StartService(p, h)						AEEGETPVTBL((p),IIrFm)->StartService((p), (h))
#define IIRFM_StopService(p, h)							AEEGETPVTBL((p),IIrFm)->StopService((p), (h))

/********************************************** IIRFMEXT Interface *************************************************/
typedef struct IIrFmExt IIrFmExt;
typedef enum mIIRFMEXT_BRAND {
	IIRFMEXT_BRAND_IRDA = 0,
	IIRFMEXT_BRAND_VISA,
	IIRFMEXT_BRAND_JCB
} IIRFMEXT_BRAND;

typedef int32	 (*PFNIIRAPI_IND)(IIRAPI_Handle hObexHandle, void * pContext, int32 nReason);

AEEINTERFACE(IIrFmExt)
{
	INHERIT_IBase(IIrFmExt);
	IIRAPI_Handle (*Create)(		IIrFmExt *pIIRFMEXT, void *pContext, IIRFMEXT_BRAND nBrand, PFNIIRAPI_IND pfnBegEnd );
	int32 (*Delete)(				IIrFmExt *pIIRFMEXT, IIRAPI_Handle hProfHandle );
	int32 (*RegisterCIPElement)(	IIrFmExt *pIIRFMEXT, IIRAPI_Handle hProfHandle, uint8 *pszCipName, uint8 *pElements, uint32 nElements );
	int32 (*RegisterCIPHandler)(	IIrFmExt *pIIRFMEXT, IIRAPI_Handle hProfHandle, uint8 *pszCipName, PFNIIRFM_CIPHANDLER pfnCbCipHandler, PFNIIRFM_CIPCHECKHANDLER pfnCbCipCheck );
	int32 (*CIPHandlerRsp)(		IIrFmExt *pIIRFMEXT, IIRAPI_Handle hProfHandle, uint8 *pElements, uint32 nElements );
	int32 (*Activate)(				IIrFmExt *pIIRFMEXT, IIRAPI_Handle hProfHandle, boolean nStartStop );
};

#define IIRFMEXT_AddRef(p)							    AEEGETPVTBL((p),IIrFmExt)->AddRef((p))
#define IIRFMEXT_Release(p)								AEEGETPVTBL((p),IIrFmExt)->Release((p))
#define IIRFMEXT_Create(p, c, b, f)						AEEGETPVTBL((p),IIrFmExt)->Create((p), (c), (b), (f))
#define IIRFMEXT_Delete(p, h)							AEEGETPVTBL((p),IIrFmExt)->Delete((p), (h))
#define IIRFMEXT_RegisterCIPElement(p, h, n, pe, ne)	AEEGETPVTBL((p),IIrFmExt)->RegisterCIPElement((p), (h), (n), (pe), (ne))
#define IIRFMEXT_RegisterCIPHandler(p, h, n, pfh, pfc)	AEEGETPVTBL((p),IIrFmExt)->RegisterCIPHandler((p), (h), (n), (pfh), (pfc))
#define IIRFMEXT_CIPHandlerRsp(p, h, pe, ne)			AEEGETPVTBL((p),IIrFmExt)->CIPHandlerRsp((p), (h), (pe), (ne))
#define IIRFMEXT_Activate(p, h, s)						AEEGETPVTBL((p),IIrFmExt)->Activate((p), (h), (s))

#endif  // ifndef ___IIR_IRFM___
