#if !defined(OEMSMS_H)
#define OEMSMS_H
/*======================================================
                    IMPORTANT NOTICE

                  OEM DISTRIBUTION ONLY

FILE:  OEMSMS.h

SERVICES:  AEE OEM SMS Interface header

GENERAL DESCRIPTION:

This file contains all of the function prototypes for
routines that are required by the AEE to function with
SMS.

        Copyright © 1999-2004 QUALCOMM Incorporated.
               All Rights Reserved.
            QUALCOMM Proprietary/GTDR
=====================================================*/
#include "AEE.h"
#include "AEESMS.h"

#define FARF_SMS              0

#ifdef FARF
#undef FARF
#endif // FARF

#define FARF(x, p)  if (1 == FARF_##x) DBGPRINTF p

// Maximum address denoted by number of AECHAR
#define MAX_DEVICE_ADDRESS             32
								
// Maximum Label Size for a Broadcast Service
#define OEMSMS_MAX_LABEL_SIZE          30

typedef struct _OEMSMSMgr OEMSMSMgr;

// This struct is used to pass message payload between AEE and OEM layer
// Filelds specific to mobile originated or mobile terminated messages are
// indicated by MO and MT respectively.
typedef struct
{
   int                                 nEncoding;                 // Encoding
   int                                 nBytes;                    // Number of bytes
   int                                 nPadding;                  // Padding bits (MO)
   byte                                data[1];                   // Data Buffer
} OEMMsgPayload;

// This struct is used to pass message information between AEE and OEM layer
// Filelds specific to mobile originated or mobile terminated messages are
// indicated by MO and MT respectively.
typedef struct
{
   int                        ts;                                 // Teleservice
   int                        nPriority;                          // Priority
   int                        nPrivacy;                           // Privacy
   int                        nNumMsgs;                           // Message count in voice mail message (MT)
   boolean                    bRequestDLAck;                      // Request Delivery Ack (MO)
   boolean                    bRequestUserAck;                    // Request User Ack
   boolean                    bRequestReadAck;                    // Request Read Ack
   boolean                    bIsDLAck;                           // Message is Delivery Ack
   boolean                    bIsUserAck;                         // Message is User Ack
   boolean                    bIsReadAck;                         // Message is Read Ack
   boolean                    bIsMOSMS;                           // TRUE - MO, FALSE - MT
   boolean                    bIsSCAddress;                       // TRUE - SC Address, FALSE -  Callback
   boolean                    bIsBREWDirectedSMS;                 // TRUE - Message is BREW directed
   uint32                     dwLang;                             // Language
   uint32                     dwTimeStamp;                        // Time Stamp (MT), Relative Validity (MO)
   char                       szMOFromMTTo[MAX_DEVICE_ADDRESS];   // MT - From Address, MO - To Address
   char                       szCallback[MAX_DEVICE_ADDRESS];     // Callback Number
   uint32                     dwTag;                              // Message Tag
   uint32                     dwMsgID;                            // Message ID
   int                        nBytes;                             // User Data Header Bytes
   byte                       data[1];                            // User Data Header
} OEMMsgData;

// Structure to unpack ISMSBCSrvOpts
typedef struct
{
   AEESMSBCSrvID          sSrvID;                                 // Service ID
   boolean                bSelected;                              // Is service selected
   AEEMSGPriority         nPriority;                              // Service Priority Threshold
   char                   szLabel[OEMSMS_MAX_LABEL_SIZE];         // Service Label
   int                    nLabelEncoding;                         // Service Label Encoding
   AEESMSBCAlertType      nAlert;                                 // Service Alert Type
   byte                   nMaxMessages;                           // Limit on maximum messages which can be stored for the service
} OEMSMSBCSrvInfo;

#ifdef __cplusplus
extern "C" {
#endif

AEE_EXPORTS int OEMSMS_New( OEMSMSMgr **ppme );
AEE_EXPORTS uint32 OEMSMS_AddRef( OEMSMSMgr *pme );
AEE_EXPORTS uint32 OEMSMS_Release( OEMSMSMgr *pme );
AEE_EXPORTS int OEMSMS_GetNewMsgInfo( OEMSMSMgr *pme, uint32 * pdwTransactionId, int * pts );
AEE_EXPORTS int OEMSMS_GetMsgPayload( OEMSMSMgr *pme, uint32 dwTransactionId, OEMMsgPayload * pOEMMsgPayload );
AEE_EXPORTS int OEMSMS_GetMsgData( OEMSMSMgr *pme, uint32 dwTransactionId, OEMMsgData * pOEMMsgData);
AEE_EXPORTS void OEMSMS_OnMTMessage( OEMSMSMgr *pme, AEECallback *pcb );
AEE_EXPORTS void OEMSMS_SendMessage( OEMSMSMgr *pme, OEMMsgData * pMsgData, OEMMsgPayload * pMsgPayload, uint32 *pdwStatus, AEECallback *pcb );
AEE_EXPORTS void OEMSMS_SetClientStatus(OEMSMSMgr *pme, uint32 cs, uint32 mt);
AEE_EXPORTS void OEMSMS_FreeMsg(OEMSMSMgr *pme, uint32 dwTransactionId);

void OEMSMSBCConfig_GetBCConfig(AEESMSMode mode, AEECallback *pcb, AEESMSBCConfig * pConfig, uint32 * pnErr);
void OEMSMSBCConfig_GetBCPref(AEESMSMode mode, AEECallback *pcb, AEESMSBCPref * pPref, uint32 * pnErr);
void OEMSMSBCConfig_SetBCPref(AEESMSMode mode, AEESMSBCPref nPref, AEECallback *pcb, uint32 * pnErr);
void OEMSMSBCConfig_GetNumberOfServiceIDs(AEESMSMode mode, AEECallback *pcb, uint32 * pnCount, uint32 * pnErr);
void OEMSMSBCConfig_GetServiceOpts(AEESMSMode mode, AEESMSBCSrvID *pSrvID, AEECallback *pcb, OEMSMSBCSrvInfo * pSrvInfo, uint32 * pnErr);
void OEMSMSBCConfig_SetServiceOpts(AEESMSMode mode, OEMSMSBCSrvInfo * pSrvInfo, AEECallback *pcb, uint32 * pnErr);
void OEMSMSBCConfig_GetNumberOfServiceOpts(AEESMSMode mode, AEECallback *pcb, uint32 * pnCount, uint32 * pnErr);
void OEMSMSBCConfig_DeleteService(AEESMSMode mode, AEESMSBCSrvID *pSrvID, AEECallback *pcb, uint32 * pnErr);
void OEMSMSBCConfig_FillServiceIDs(AEESMSBCSrvID *psid, uint32 dwBytes);
void OEMSMSBCConfig_FillServiceInfo(OEMSMSBCSrvInfo *pSrvInfo, uint32 dwBytes);

// Following APIs are not exposed to AEE. These are used within OEM layer
int OEMSMS_SetDomainPref(int gwDomainPref);
int OEMSMS_GetDomainPref(int * pgwDomainPref);
#ifdef _cplusplus
}
#endif
/*========================================================================
   DATA STRUCTURE DOCUMENTATION
==========================================================================

OEMMsgPayload

Description:
   This structure is used to pass message payload between AEE and OEM layer.
   Filelds specific to mobile originated or mobile terminated messages are
   indicated by MO and MT respectively.

Definition:

   typedef struct
   {
      int                                 nEncoding;                 // Encoding
      int                                 nBytes;                    // Number of bytes
      int                                 nPadding;                  // Padding bits (MO)
      byte                                data[1];                   // Data Buffer
   } OEMMsgPayload;


Comments:
   None.

See Also:
   None.

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

OEMMsgData

Description:
   This structure is used to pass message information between AEE and OEM layer.
   Filelds specific to mobile originated or mobile terminated messages are
   indicated by MO and MT respectively.

Definition:

   typedef struct
   {
      int                        ts;                                 // Teleservice
      int                        nPriority;                          // Priority
      int                        nPrivacy;                           // Privacy
      int                        nNumMsgs;                           // Message count in voice mail message (MT)
      boolean                    bRequestDLAck;                      // Request Delivery Ack (MO)
      boolean                    bRequestUserAck;                    // Request User Ack
      boolean                    bRequestReadAck;                    // Request Read Ack
      boolean                    bIsDLAck;                           // Message is Delivery Ack
      boolean                    bIsUserAck;                         // Message is User Ack
      boolean                    bIsReadAck;                         // Message is Read Ack
      boolean                    bIsMOSMS;                           // TRUE - MO, FALSE - MT
      boolean                    bIsSCAddress;                       // TRUE - SC Address, FALSE -  Callback
      boolean                    bIsBREWDirectedSMS;                 // TRUE - Message is BREW directed
      uint32                     dwLang;                             // Language
      uint32                     dwTimeStamp;                        // Time Stamp (MT), Relative Validity (MO)
      char                       szMOFromMTTo[MAX_DEVICE_ADDRESS];   // MT - From Address, MO - To Address
      char                       szCallback[MAX_DEVICE_ADDRESS];     // Callback Number
      uint32                     dwTag;                              // Message Tag
      uint32                     dwMsgID;                            // Message ID
      int                        nBytes;                             // User Data Header Bytes
      byte                       data[1];                            // User Data Header
   } OEMMsgData;

Comments:
   None.

See Also:
   None.

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

OEMSMSBCSrvInfo

Description:
   This structure is used to unpack ISMSBCSrvOpts and represents information
associated with a service.

Definition:

   typedef struct
   {
      AEESMSBCSrvID          sSrvID;                                 // Service ID
      boolean                bSelected;                              // Is service selected
      AEEMSGPriority         nPriority;                              // Service Priority Threshold
      char                   szLabel[OEMSMS_MAX_LABEL_SIZE];         // Service Label
      int                    nLabelEncoding;                         // Service Label Encoding
      AEESMSBCAlertType      nAlert;                                 // Service Alert Type
      byte                   nMaxMessages;                           // Limit on maximum messages which can be stored for the service
   } OEMSMSBCSrvInfo;

Comments:
   None.

See Also:
   None.

==========================================================================
  INTERFACES DOCUMENTATION
==========================================================================
Interface Name: OEMSMS
==========================================================================

Function: OEMSMS_New()

Description:
   Returns pointer to global OEMSMSMgr object.

Prototype:
   int OEMSMS_New( OEMSMSMgr **ppme )

Parameters:
   ppme: pointer to place holder for pointer to the global OEMSMSMgr object

Return Value:
   SUCCESS on SUCCESS
   If there is an error, this function should return an error
    from AEEError.h

Comments:
   None.

Side Effects:
   None.

See Also:
   None

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

Function: OEMSMS_AddRef()

Description:
   Increments reference count of the object.

Prototype:
   uint32 OEMSMS_AddRef( OEMSMSMgr *pme )

Parameters:
   pme: pointer to global OEMSMSMgr object

Return Value:
   Incremented reference count

Comments:
   None.

Side Effects:
   None.

See Also:
   OEMSMS_Release()

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

Function: OEMSMS_Release()

Description:
   Decrements the reference count of the object. Also frees it up when the
reference count reaches 0.

Prototype:
   uint32 OEMSMS_Release( OEMSMSMgr *pme )

Parameters:
   pme: pointer to global OEMSMSMgr object

Return Value:
   Decremented reference count

Comments:
   None.

Side Effects:
   None.

See Also:
   OEMSMS_AddRef()

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

Function: OEMSMS_GetNewMsgInfo()

Description:
   Scans SMS cache and provides transaction ID and teleservice ID of the new 
   messages.

Prototype:
   int OEMSMS_GetNewMsgInfo( OEMSMSMgr *pme, uint32 * pdwTransactionId, int * pts )

Parameters:
   pme: pointer to global OEMSMSMgr object
   pdwTransactionId: place holder for transaction ID
   pts: place holder for teleservice ID

Return Value:
   SUCCESS on SUCCESS
   If there is an error, this function should return an error
    from AEEError.h

Comments:
   On being notified of mobile terminated message, AEESMS calls this to 
   find transaction ID and teleservice ID of the new messages.

Side Effects:
   None.

See Also:
   None.

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

Function: OEMSMS_GetMsgPayload()

Description:
   Fills pOEMMsgPayload with payload data corresponding to the specified 
   transaction ID.

Prototype:
   int OEMSMS_GetMsgPayload( OEMSMSMgr *pme, uint32 dwTransactionId, OEMMsgPayload * pOEMMsgPayload )

Parameters:
   pme: pointer to global OEMSMSMgr object
   dwTransactionId: transaction ID
   pOEMMsgPayload: pointer to payload data

Return Value:
   SUCCESS on SUCCESS
   If there is an error, this function should return an error
    from AEEError.h

Comments:
   None.

Side Effects:
   None.

See Also:
   OEMMsgPayload

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

Function: OEMSMS_GetMsgData()

Description:
   Fills pOEMMsgData with message data corresponding to the specified 
   transaction ID.

Prototype:
   int OEMSMS_GetMsgData( OEMSMSMgr *pme, uint32 dwTransactionId, OEMMsgData * pOEMMsgData)

Parameters:
   pme: pointer to global OEMSMSMgr object
   dwTransactionId: transaction ID
   pOEMMsgData: pointer to message data

Return Value:
   SUCCESS on SUCCESS
   If there is an error, this function should return an error
    from AEEError.h

Comments:
   None.

Side Effects:
   None.

See Also:
   OEMMsgData

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

Function: OEMSMS_OnMTMessage()

Description:
   Registers a callback to be invoked to notify AEE layer about arrival of 
   mobile terminated messages.

Prototype:
   void OEMSMS_OnMTMessage( OEMSMSMgr *pme, AEECallback *pcb )

Parameters:
   pme: pointer to global OEMSMSMgr object
   pcb: pointer to callback

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   None.

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

Function: OEMSMS_SendMessage()

Description:
   Sends the message specified by pMsgData and pMsgPayload. Callback is invoked 
   at the end of the operation and message status is specified in pdwStatus.

Prototype:
   void OEMSMS_SendMessage( OEMSMSMgr *pme, OEMMsgData * pMsgData, OEMMsgPayload * pMsgPayload, uint32 *pdwStatus, AEECallback *pcb )

Parameters:
   pme: pointer to global OEMSMSMgr object
   pMsgData: pointer to message data
   pMsgPayload: pointer to payload data
   pdwStatus: place holder for message status
   pcb: pointer to callback

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   OEMMsgData, OEMMsgPayload

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

Function: OEMSMS_SetClientStatus()

Description:
   Enables a client to control how mobile terminated message of specified type 
   should be acked.

Prototype:
   void OEMSMS_SetClientStatus(OEMSMSMgr *pme, uint32 cs, uint32 mt)

Parameters:
   pme: pointer to global OEMSMSMgr object
   cs: client status
   mt: message type

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   None.

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

Function: OEMSMS_FreeMsg()

Description:
   Frees message corresponding to the specified transaction ID from the cache 
   of incoming messages.

Prototype:
   void OEMSMS_FreeMsg(OEMSMSMgr *pme, uint32 dwTransactionId)

Parameters:
   pme: pointer to global OEMSMSMgr object
   dwTransactionId: transaction ID of the message to be freed

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   None.

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

Function: OEMSMSBCConfig_GetBCConfig()

Description:
   Gets broadcast configuration corresponding to the specified mode. Callback is 
invoked at the end of the operation and return value and broadcast configuration 
are provided in pnErr and pConfig respectively.

Prototype:
   void OEMSMSBCConfig_GetBCConfig(AEESMSMode mode, AEECallback *pcb, AEESMSBCConfig * pConfig, uint32 * pnErr)

Parameters:
   mode: mode
   pcb: pointer to callback
   pConfig: place holder for configuration
   pnErr: place holder for return value

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   None.

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

Function: OEMSMSBCConfig_GetBCPref()

Description:
   Gets broadcast preference corresponding to the specified mode. Callback is 
invoked at the end of the operation and return value and broadcast preference 
are provided in pnErr and pPref respectively.

Prototype:
   void OEMSMSBCConfig_GetBCPref(AEESMSMode mode, AEECallback *pcb, AEESMSBCPref * pPref, uint32 * pnErr)

Parameters:
   mode: mode
   pcb: pointer to callback
   pPref: place holder for preference
   pnErr: place holder for return value

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   None.

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

Function: OEMSMSBCConfig_SetBCPref()

Description:
   Sets broadcast preference corresponding to the specified mode. Callback is 
invoked at the end of the operation and return value is provided in pnErr.

Prototype:
   void OEMSMSBCConfig_SetBCPref(AEESMSMode mode, AEESMSBCPref nPref, AEECallback *pcb, uint32 * pnErr)

Parameters:
   mode: mode
   nPref: preference
   pcb: pointer to callback
   pnErr: place holder for return value

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   None.

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

Function: OEMSMSBCConfig_GetNumberOfServiceIDs()

Description:
   Gets number of currently configured service identifiers corresponding to 
the specified mode. This is called to determine size of buffer to pass to 
OEMSMSBCConfig_FillServiceIDs().Callback is invoked at the end of the operation 
and return value and service ID count are provided in pnErr and pnCount respectively.

Prototype:
   void OEMSMSBCConfig_GetNumberOfServiceIDs(AEESMSMode mode, AEECallback *pcb, uint32 * pnCount, uint32 * pnErr)

Parameters:
   mode: mode
   pcb: pointer to callback
   pnCount: place holder for count of service IDs
   pnErr: place holder for return value

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   OEMSMSBCConfig_FillServiceIDs().

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

Function: OEMSMSBCConfig_GetServiceOpts()

Description:
   Gets detailed information corresponding to the specified service ID and 
mode. Callback is invoked at the end of the operation and return 
value and service information are provided in pnErr and pSrvInfo respectively.

Prototype:
   void OEMSMSBCConfig_GetServiceOpts(AEESMSMode mode, AEESMSBCSrvID *pSrvID, AEECallback *pcb, OEMSMSBCSrvInfo * pSrvInfo, uint32 * pnErr)

Parameters:
   mode: mode
   pSrvID: pointer to service ID
   pcb: pointer to callback
   pSrvInfo: place holder for service information
   pnErr: place holder for return value

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   None.

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

Function: OEMSMSBCConfig_SetServiceOpts()

Description:
   Updates information corresponding to pSrvInfo->sSrvID service ID of the
specified mode. If service is not already there in service configuration table,
its added there. Callback is invoked at the end of the operation and return 
value is provided in pnErr.

Prototype:
   void OEMSMSBCConfig_SetServiceOpts(AEESMSMode mode, OEMSMSBCSrvInfo * pSrvInfo, AEECallback *pcb, uint32 * pnErr);

Parameters:
   mode: mode
   pSrvInfo: pointer to service information
   pcb: pointer to callback
   pnErr: place holder for return value

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   None.

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

Function: OEMSMSBCConfig_GetNumberOfServiceOpts()

Description:
   Gets number of currently configured services. This is called to determine
size of buffer to pass to OEMSMSBCConfig_FillServiceInfo(). Callback is invoked 
at the end of the operation and return value and services count are provided in 
pnErr and pnCount respectively.

Prototype:
   void OEMSMSBCConfig_GetNumberOfServiceOpts(AEESMSMode mode, AEECallback *pcb, uint32 * pnCount, uint32 * pnErr)

Parameters:
   mode: mode
   pcb: pointer to callback
   pnCount: place holder for count of service IDs
   pnErr: place holder for return value

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   OEMSMSBCConfig_FillServiceInfo().

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

Function: OEMSMSBCConfig_DeleteService()

Description:
   Deletes the specified service from the configuration table. Callback is 
invoked at the end of the operation and return value is provided in pnErr.

Prototype:
   void OEMSMSBCConfig_DeleteService(AEESMSMode mode, AEESMSBCSrvID *pSrvID, AEECallback *pcb, uint32 * pnErr);

Parameters:
   mode: mode
   pSrvID: pointer to service ID
   pcb: pointer to callback
   pnErr: place holder for return value

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   None.

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

Function: OEMSMSBCConfig_FillServiceIDs()

Description:
   Fills psid buffer with the configured service IDs.

Prototype:
   void OEMSMSBCConfig_FillServiceIDs(AEESMSBCSrvID *psid, uint32 dwBytes)

Parameters:
   psid: pointer to buffer to be filled with service IDs
   dwBytes: size of buffer specified by psid in number of bytes

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   OEMSMSBCConfig_GetNumberOfServiceIDs()

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

Function: OEMSMSBCConfig_FillServiceInfo()

Description:
   Fills pSrvInfo buffer with the configured services information.

Prototype:
   void OEMSMSBCConfig_FillServiceInfo(OEMSMSBCSrvInfo *pSrvInfo, uint32 dwBytes)

Parameters:
   pSrvInfo: pointer to buffer to be filled with services information
   dwBytes: size of buffer specified by pSrvInfo in number of bytes

Return Value:
   None.

Comments:
   None.

Side Effects:
   None.

See Also:
   OEMSMSBCConfig_GetNumberOfServiceOpts(), OEMSMSBCSrvInfo

=========================================================================*/
#endif /*OEMSMS_H*/

