/*******************************************************************************
*                              Openwave Systems.                               *
*                            Device Products Group                             *
*                            Melbourne,  AUSTRALIA                             *
****************************************************************************//**
   @file
   This is the API for the Openwave Flash IMedia wrapper.  This extension has
   the same methods as the IMedia API, with some additions as declared in this
   file.

*//*
   REVISION HISTORY:
   Date:       Who:               Email:
      - Details:
--------------------------------------------------------------------------------
   20 Dec 2004 Richard Willis     richard.willis@openwave.com
      - Initial version

*******************************************************************************/
/*******************************************************************************
*                  Copyright (c) Openwave Systems 1995-2004                    *
*                            All rights reserved.                              *
*                                                                              *
*     THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Openwave Systems Inc.     *
*               The copyright notice above does not evidence any               *
*              actual or intended publication of such source code.             *
*******************************************************************************/

#ifndef _MEDFLASH_H
#define _MEDFLASH_H


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

	INCLUDES

==============================================================================*/
#include <aee.h>
#include <aeemedia.h>
#include <aeeinterface.h>


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

	DEFINES

==============================================================================*/
//custom commands for IMEDIA_SetMediaParm & IMEDIA_GetMediaParm
#define MM_MEDFLASH_PARM_BASE    MM_PARM_USER_BASE + 0x80 //make sure our parms don't conflict with anyone else's
#define MM_PARM_BGCOLOUR         MM_MEDFLASH_PARM_BASE
#define MM_PARM_QUALITY          MM_MEDFLASH_PARM_BASE + 0x01
#define MM_PARM_KEY_EVENT        MM_MEDFLASH_PARM_BASE + 0x02
#define MM_PARM_USER_TEXT        MM_MEDFLASH_PARM_BASE + 0x03 //Use the IMEDFLASH_Text macro.

//custom responses for the PFNMEDIANOTIFY callback function
#define MM_MEDFLASH_CMD_BASE     MM_CMD_USER_BASE + 0x80 //make sure our commands don't conflist with anyone else's
#define MM_CMD_GOTO_URL          MM_MEDFLASH_CMD_BASE
#define MM_CMD_GO_BACK           MM_MEDFLASH_CMD_BASE + 1
#define MM_CMD_DO_TEXT_INPUT     MM_MEDFLASH_CMD_BASE + 2 //the flash object is requesting user input.  The user string is returned via the IMEDFLASH_Text macro
#define MM_CMD_ERROR             MM_MEDFLASH_CMD_BASE + 3 //the flash object is requesting user input.  The user string is returned via the IMEDFLASH_Text macro

//custom capabilities that are enabled via MM_PARM_ENABLE
#define MM_CAPS_INTERACTIVE      0x10000000  //enable interactive mode so Keystrokes, GetURL, DoFsCommand etc all work (disabled by default)
#define MM_CAPS_VIBRATOR         0x20000000  //enable control of the vibrator

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

	TYPES

==============================================================================*/
typedef enum
{
   keMEDFLASH_Q_Low = 0,
   keMEDFLASH_Q_Medium = 1,
   keMEDFLASH_Q_High = 2
}teMEDFLASH_Quality;

typedef enum
{
   keMEDFLASH_KS_Down = 0x10,
   keMEDFLASH_KS_Press = 0x12,
   keMEDFLASH_KS_Up = 0x11
}teMEDFLASH_KeyState;

typedef struct
{
   const char  *kpczURL;
   const uint8 *kpbPostData;
   uint32      lwPostDataLength;
}tsMEDFLASH_GotoURL;

typedef enum
{
   keMEDFLASH_IS_InputTextPassword        = 0x0001,
   keMEDFLASH_IS_InputTextMultiline       = 0x0002,
   keMEDFLASH_IS_InputTextNumeric         = 0x0004,
   keMEDFLASH_IS_InputTextAlpha           = 0x0008,
   keMEDFLASH_IS_InputTextAlphaNumeric    = 0x0010,
   keMEDFLASH_IS_InputTextLatin           = 0x0020,
   keMEDFLASH_IS_InputTextNonLatin        = 0x0040,
   keMEDFLASH_IS_InputTextNoRestriction   = 0x0000
}teMEDFLASH_InputSpec;

typedef struct
{
   const char           *kpczInitialString;
   uint32               lwStrLen;
   uint16               wMaxNumChars;
   teMEDFLASH_InputSpec eFlags; //each flag must be bit tested, as multiple flags may be set, with the excpetion of keMEDFLASH_IS_InputTextNoRestriction
}tsMEDFLASH_DoTextInput;

//these are the values returned in the MM_CMD_ERROR notificiation
typedef enum
{
   keMEDFLASH_Err_NoError                       = 0,
   keMEDFLASH_Err_OutOfMemoryError              = 1,
   keMEDFLASH_Err_StackLimitReachedError        = 2,
   keMEDFLASH_Err_CorruptSWFDataError           = 3,
   keMEDFLASH_Err_ActionScriptStuckError        = 4,
   keMEDFLASH_Err_ActionScriptProcessingError   = 5,
   keMEDFLASH_Err_InfiniteASLoopError           = 6,
   keMEDFLASH_Err_InvalidFrameBufferError       = 7,
   keMEDFLASH_Err_InvalidDisplayRectError       = 8,
   keMEDFLASH_Err_InvalidFrameNumberError       = 9,
   keMEDFLASH_Err_InvalidKeyError               = 10,
   keMEDFLASH_Err_BadJPEGDataError              = 11,
   keMEDFLASH_Err_BadSoundDataError             = 12,
   keMEDFLASH_Err_RootMovieUnloadedError        = 13
}teMEDFLASH_Error;


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

	INTERFACE

==============================================================================*/
//The interface is the same as IMedia


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

	CUSTOM VIRTUAL FUNCTION ACCESSORS

==============================================================================*/
#define IMEDFLASH_SetBGColour( psIMediaFlash, lwBREWColour ) \
   AEEGETPVTBL( (psIMediaFlash), IMedia )->SetMediaParm( psIMediaFlash, MM_PARM_BGCOLOUR, lwBREWColour, 0 )

#define IMEDFLASH_SetQuality( psIMediaFlash, eMEDFLASH_Quality ) \
   AEEGETPVTBL( (psIMediaFlash), IMedia )->SetMediaParm( psIMediaFlash, MM_PARM_QUALITY, eMEDFLASH_Quality, 0 )

#define IMEDFLASH_KeyEvent( psIMediaFlash, eBREWKey, eKeyState ) \
   AEEGETPVTBL( (psIMediaFlash), IMedia )->SetMediaParm( psIMediaFlash, MM_PARM_KEY_EVENT, eBREWKey, eKeyState )

#define IMEDFLASH_UserText( psIMediaFlash, kpczString, oEditted ) \
   AEEGETPVTBL( (psIMediaFlash), IMedia )->SetMediaParm( psIMediaFlash, MM_PARM_USER_TEXT, (int32)kpczString, oEditted )


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

	FUNCTION DECLARATIONS

==============================================================================*/
/**@ingroup grp_lifecycle
@DESCRIPTION
 This function is used by the BREW core to load an instance of the class.  It
 is never called directly by an application.  Instead, it is called by BREW when
 an application requests an instance of this class via ISHELL_CreateInstance().\n\n
 The OEM should add this function to the BREW class table to allow
 ISHELL_CreateInstance() to create an instance of this extension.
@PARAMETERS
 @param[in] psIShell Contains pointer to the IShell interface. 
 @param[in] lwClassID Specifies the ClassID of the applet which is being loaded
 @param[in] ppsMe On return, points to a valid instance of the class provided
   this function returns SUCCESS.  If an error occurs, this will return NULL.
@RETURNS
 SUCCESS if the extension initialised ok, otherwise an error explaining the
 reason for the initialisation failure.
*/
int IMediaFlash_New( IShell *psIShell, AEECLSID lwClassID, void **ppsMe );



#endif /* _MEDFLASH_H */



