#ifndef AEEUNICODE_SJIS_H
#define AEEUNICODE_SJIS_H /* #ifndef AEEUNICODE_SJIS_H */
/*============================================================================

FILE:  AEEUnicode_SJIS.h

SERVICES:
        Conversion between Unicode and SJIS

GENERAL DESCRIPTION:

REVISION HISTORY:

============================================================================

               Copyright ｩ 2003 QUALCOMM Incorporated
                       All Rights Reserved.
                   QUALCOMM Proprietary/GTDR

============================================================================*/
/*===========================================================================

                        EDIT HISTORY FOR MODULE

When        Who    what, where, why
----------  -----  ----------------------------------------------------------
02/14/05           BREW3.1 SDK向けリリース   絵文字変換機能追加対応

=============================================================================*/
/******************************************************************************
//  [PTX-804改修履歴]
//		PTX-804 EMUI-20050221001 NJK 高橋 直美
//		        Brew3.1へのポーテイングのため
//		        BaseSouse :040819受領-PortingPackage
//		PTX-804 BREW-20050323001 NJK 高橋 直美
//		        050317受領-KDDI Extensionへのポーテイングのため
//		        BaseSource :050317受領-KDDI Extension
******************************************************************************/
/*===============================================================================
    INCLUDES AND VARIABLE DEFINITIONS
===============================================================================*/

/*-------------------------------------------------------------------
      Include Files
-------------------------------------------------------------------*/
#include "AEE.h"
#include "IUNICODE_SJIS.BID"

/*-------------------------------------------------------------------
      Type Declarations
-------------------------------------------------------------------*/

/* This is prototype of the notification function */

//-------------------------------------------------------------------
// Interface Definitions
//-------------------------------------------------------------------

typedef struct IUnicodeSjis IUnicodeSjis;

//********************************************************************************************************************************
//
// IFileCp Interface
//
//********************************************************************************************************************************

AEEINTERFACE(IUnicodeSjis) {
   DECLARE_IQIBASE(IUnicodeSjis);
   boolean (*UCS2toSJIS)(IUnicodeSjis *po, word * pwSrc, byte * pbyDst, int nSize);
   boolean (*SJIStoUCS2)(IUnicodeSjis *po, byte * pbySrc, word * pwDst, int nSize);
   uint32  (*IModeSJIStoSJIS)(IUnicodeSjis *po, int32 dwIMode);
};

// Access Macros for IFileCp interface

#define IUNICODESJIS_AddRef(p)                              AEEGETPVTBL((p),IUnicodeSjis)->AddRef((p))
#define IUNICODESJIS_Release(p)                             AEEGETPVTBL((p),IUnicodeSjis)->Release((p))
#define IUNICODESJIS_QueryInterface(p, id, pp)              AEEGETPVTBL((p),IUnicodeSjis)->QueryInterface((p),(id),(pp))
#define IUNICODESJIS_Unicode16toSjis(p, pwS, pbyD, nS)      AEEGETPVTBL((p),IUnicodeSjis)->UCS2toSJIS((p), (pwS), (pbyD), (nS))
#define IUNICODESJIS_SjistoUnicode16(p, pbyS, pwD, nS)      AEEGETPVTBL((p),IUnicodeSjis)->SJIStoUCS2((p), (pbyS), (pwD), (nS))
#define IUNICODESJIS_IModeSjisToSjis(p, dwI)                AEEGETPVTBL((p),IUnicodeSjis)->IModeSJIStoSJIS((p), (dwI))

#define UNICODE16TOSJIS(/*(IShell *)*/pIShell, /*(word *)*/pwSrc, /*(byte *)*/pbyDst, /*(int)*/nSize, /*(boolean *)*/pbErr) \
{ \
    IUnicodeSjis * po; \
    boolean      * pbRet = pbErr; \
    ISHELL_CreateInstance(pIShell, AEECLSID_IUNICODE_SJIS, (void **)&po); \
    *pbRet = IUNICODESJIS_Unicode16toSjis(po, pwSrc, pbyDst, nSize); \
    IUNICODESJIS_Release(po); \
}

#define SJISTOUNICODE16(/*(IShell *)*/pIShell, /*(byte *)*/pbySrc, /*(word *)*/pwDst, /*(int)*/nSize, /*(boolean *)*/pbErr) \
{ \
    IUnicodeSjis * po; \
    boolean      * pbRet = pbErr; \
    ISHELL_CreateInstance(pIShell, AEECLSID_IUNICODE_SJIS, (void **)&po); \
    *pbRet = IUNICODESJIS_SjistoUnicode16(po, pbySrc, pwDst, nSize); \
    IUNICODESJIS_Release(po); \
}

#define IMODESJISTOSJIS(/*(IShell *)*/pIShell, /*int32*/ dwIMode, /*(uint32 *)*/dwKDDI) \
{ \
    IUnicodeSjis * po; \
    uint32       * pdwRet = &dwKDDI; \
    ISHELL_CreateInstance(pIShell, AEECLSID_IUNICODE_SJIS, (void **)&po); \
    *pdwRet = IUNICODESJIS_IModeSjisToSjis(po, dwIMode); \
    IUNICODESJIS_Release(po); \
}

/*=====================================================================
  MACRO DOCUMENTATION
=======================================================================
  Following functions are macros simply to use these services without a class operation.
  To call these functions, the header “AEEUnicode_SJIS.h” should be included in advance.
=======================================================================

Function:UNICODE16TOSJIS

Description:
   Converts specified Unicode(USC2) string to SJIS format.

Definition:
   #define UNICODE16TOSJIS(pIShell, pwSrc, pbyDst, nSize, pbErr)

Parameters:
   pIShell: Pointer to IShell interface
   pwSrc  : Pointer to Unicode format of text string terminated with NULL character.
   pbyDst : Pointer to the buffer that accommodates the converted SJIS format of the
            text string.
   nSize  : Size (Byte) of pbyDst buffer. (should be more than 0.)
   pbErr  : Buffer to accommodate the result; TRUE, if succeeded. FALSE, if failed.

Return Value:
   None

Comments:
   This function is defined as a macro.

Side Effects:
   None
=======================================================================

Function:SJISTOUNICODE16

Description:
   Converts specified SJIS string to Unicode (USC2) format.

Definition:
   #define SJISTOUNICODE16(pIShell, pbySrc, pwDst, nSize, pbErr)

Parameters:
   pIShell: Pointer to IShell interface
   pbySrc : Pointer to SJIS format of text string terminated with NULL character.
   pwDst  : Pointer to the buffer that accommodates the converted Unicode format of the text string.
   nSize  : Size (Byte) of pbyDst buffer. (should be more than 0.)
   pbErr  : Buffer to accommodate the result; TRUE, if succeeded. FALSE, if failed.

Return Value:
   None

Comments:
   This function is defined as a macro.

Side Effects:
   None
=======================================================================

Function:IMODESJISTOSJIS

Description:
   This function converts a i-mode emoticon character-code into a KDDI one.

Definition:
   #define IMODESJISTOSJIS(pIShell, dwIMode, dwKDDI)

Parameters:
   pIShell: Pointer to IShell interface
   dwIMode: The emoticon code of i-mode is specified. 
   dwKDDI : The buffer to be set converted character-code.
            If successful, returns the KDDI emoticon character-code.
            If not, returns dwIMode.

Return Value:
   None

Comments:
   This function is defined as a macro.

Side Effects:
   None
=======================================================================

=======================================================================
INTERFACES   DOCUMENTATION
=======================================================================
  Following is the interface as a class of brew API. Since it applies ordinary style of brew class
Interface, every Applet (including Dynamic Applet) can use this API without any restriction.
  To call the API, the header “AEEUnicode_SJIS.h” should be included in advance.
=======================================================================
Interface Name: IUnicodeSjis

Description:
   Provides a bi-directional conversion between two character sets; Unicode (USC2) and SJIS.

The following methods are supported in this interface:

IUNICODESJIS_AddRef
IUNICODESJIS_Release
IUNICODESJIS_QueryInterface
IUNICODESJIS_Unicode16toSjis
IUNICODESJIS_SjistoUnicode16
IUNICODESJIS_IModeSjisToSjis

===========================================================================

Function: IUNICODESJIS_AddRef()

Description:
   This function increments the reference count of the IUnicodeSjis
   Interface object, allowing the object to be shared by multiple callers.
   The object is freed when the reference count reaches 0 (zero).

Prototype:
   uint32 IUNICODESJIS_AddRef(IUnicodeSjis * po)

Parameters:
   po: Pointer to the IUnicodeSjis Interface object.

Return Value:
   Incremented reference count for the object.

Comments:
   A valid object returns a positive reference count.

Side Effects:

None

See Also:
   IUNICODESJIS_Release()
===========================================================================

Function: IUNICODESJIS_Release()

Description:
   This function decrements the reference count of the IUnicodeSjis
   Interface object. The object is freed from memory and is no longer valid
   when the reference count reaches 0 (zero).

Prototype:
   uint32 IUNICODESJIS_Release(IUnicodeSjis * po)

Parameters:
   po: Pointer to the IUnicodeSjis Interface object.

Return Value:
   Decremented reference count for the object.
   0 (zero), If the object has been freed and is no longer valid.

Comments:
   None

Side Effects:
   None

See Also:
   IUNICODESJIS_AddRef()
===========================================================================

Function: IUNICODESJIS_QueryInterface()

Description:
   Inquires an object for another API contract from the specified object.

Prototype:
   int IUNICODESJIS_QueryInterface(IUnicodeSjis *po, AEECLSID clsid, void **ppo)

Parameters:
   po   : Pointer to the object
   clsid: Requested class ID exposed by the object
   ppo  : The buffer to accommodate acquired object

Return Value:
   SUCCESS          - Interface found
   ENOMEMORY        - Not sufficient memory space
   ECLASSNOTSUPPORT - Requested interface is not supported

Comments:
   The address within *ppo is set to the new interface (with refcount accordingly positive), or
   NULL if the class ID is not supported by the object.

Side Effects:
   None

See Also:
   None
===========================================================================

Function: IUNICODESJIS_Unicode16toSjis()

Description:
   This function convert from unicode(USC2) to SJIS

Prototype:
   int IUNICODESJIS_Unicode16toSjis(IUnicodeSjis *po, word * pwSrc, byte * pbyDst, int nSize);

Parameters:
   po    : Pointer to the IUnicodeSjis object.
   pwSrc : Pointer to Unicode format of text string terminated with NULL character.
   pbyDst: Pointer to the buffer that accommodates the converted SJIS format of the text string.
   nSize : Size (Byte) of pbyDst buffer. (should be more than 0.)

Return Value:
   TRUE , succeeded
   FALSE, failed.

Comments:
   None

Side Effects:
   None
===========================================================================

Function: IUNICODESJIS_SjistoUnicode16()

Description:
   This function convert from SJIS to unicode(USC2)

Prototype:
   int IUNICODESJIS_SjistoUnicode16(IUnicodeSjis *po, byte * pbySrc, word * pwDst, int nSize);

Parameters:
   po    : Pointer to the IUnicodeSjis object.
   pbySrc: Pointer to SJIS format of text string terminated with NULL character.
   pwDst : Pointer to the buffer that accommodates the converted Unicode format of the text string.
   nSize : Size (Byte) of pbyDst buffer. (should be more than 0.)

Return Value:
   TRUE , succeeded
   FALSE, failed.

Comments:
   None

Side Effects:
   None
===========================================================================

Function: IUNICODESJIS_IModeSjisToSjis()

Description:
   This function converts a i-mode emoticon character-code into a KDDI one.

Prototype:
   int IUNICODESJIS_IModeSjisToSjis(IUnicodeSjis *po, int32 dwIMode);

Parameters:
   po     : Pointer to the IUnicodeSjis object.
   dwIMode: The emoticon code of i-mode is specified.

Return Value:
   If successful, returns the KDDI emoticon character-code.
   If not, returns dwIMode.

Comments:
   None

Side Effects:
   None
===========================================================================*/


#endif /* #ifndef AEEUNICODE_SJIS_H */



