/*===========================================================================
FILE: ifileusage.c
SERVICES: Sample applet using AEE
DESCRIPTION
This file contains usage examples of the IFileMgr and IFile interfaces. The IFileMgr
interface functions include the creation and deletion of files and directories.
IFile interface functions consist of operations performed on files opened by the IFileMgr
interface. The following functions are illustrated in this usage example:
-IFILEMGR_EnumInit
-IFILEMGR_EnumNext
-IFILEMGR_GetFreeSpace
-IFILEMGR_GetInfo
-IFILEMGR_GetLastError
-IFILEMGR_MkDir
-IFILEMGR_OpenFile
-IFILEMGR_Remove
-IFILEMGR_Rename
-IFILEMGR_RmDir
-IFILEMGR_Test
-IFILE_GetInfo
-IFILE_Read
-IFILE_Release
-IFILE_Seek
-IFILE_Truncate
-IFILE_Write
PUBLIC CLASSES:
N/A
Copyright � 2000-2001 QUALCOMM Incorporated.
All Rights Reserved.
QUALCOMM Proprietary/GTDR
===========================================================================*/
/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */
// Mandatory includes
#include "AEEAppGen.h" // AEEApplet declaration
#include "AEEUsageAppIDs.h" // Class IDs of usage apps (including this one)
#include "AEE.h" // Standard AEE Declarations
#include "AEEShell.h" // AEE Shell Services
#include "AEEDisp.h" // AEE Display Services
// Services used by app
#include "AEEFile.h" // AEEFile Services
#include "AEEMenu.h" // Menu Services
#include "AEEStdLib.h" // AEE stdlib services
#include "AEEMCF.h" // AEE stdlib services
/*===========================================================================
PUBLIC DATA DECLARATIONS
===========================================================================*/
/*-------------------------------------------------------------------
Type Declarations
-------------------------------------------------------------------*/
// IFile app struct. This is the main struct for this applet. This will hold
// all the data members that need to be remembered throughout the life of
// the applet.
// THE FIRST DATA MEMBER OF THIS STRUCT MUST BE AN AEEApplet OBJECT.
// This is critical requirement which is related to an applet being
// dynamically loaded. The app developers should add their data members
// following the AEEApplet data member.
typedef struct _CIFileApp {
AEEApplet a;
IMenuCtl * m_pIMenu;
IFileMgr * m_pIFileMgr;
ISoundPlayer * m_pISoundPlayer;
boolean m_bSPActive;
AEERect m_rc;
int m_cLineNum; // screen line to be written to next
int m_cMaxLine; // max line number of screen on which output can be written
} CIFileApp;
/*-------------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------------*/
// Mandatory function:
// App Handle Event function
static boolean FileApp_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam);
// App specific data alloc-init/free functions
static boolean IFile_InitAppData(IApplet* pMe);
static void IFile_FreeAppData(IApplet* pMe);
static void BuildMainMenu(CIFileApp *pMe);
static void IFileUsage (CIFileApp *pMe, uint16 wParam);
static void DisplayEvent (CIFileApp *pMe, uint16 wParam);
static int DisplayOutput(IShell *pIShell, IDisplay *pIDisplay, int nline, char *pszStr);
static void WriteLine (CIFileApp *pMe, char *pszStr);
static void SoundPlayerCBFn( void * pUser, AEESoundPlayerCmd eCBType, AEESoundPlayerStatus eStatus, uint32 dwParam );
/*-------------------------------------------------------------------
Global Constant Definitions
-------------------------------------------------------------------*/
// App specific constants
#define USAGE_BASIC_USAGE 100
#define USAGE_FMGR_GETFREESPACE 101
#define USAGE_PLAY_MUSIC 102
#define USAGE_MUSIC_MCF 103
#define USAGE_MUSIC_MCF_ACCESS_FILE_DEMO_APP 104
#define USAGE_ERASE_SCREEN 119 // Special case to erase screen
#define AEEFS_OTHER_APP_DIR "fs:/~0x0100900F/my_aaa/"
// App Resource File
#define APP_RES_FILE AEEFS_CARD0_DIR"piano.mp3"
// Size of buffer used to hold text strings
#define TEXT_BUFFER_SIZE (100 * sizeof(AECHAR))
/*===============================================================================
FUNCTION DEFINITIONS
=============================================================================== */
/*===========================================================================
FUNCTION: AEEClsCreateInstance
DESCRIPTION
This function is invoked while the app is being loaded. All Modules must provide this
function. Ensure to retain the same name and parameters for this function.
In here, the module must verify the ClassID and then invoke the AEEApplet_New() function
that has been provided in AEEAppGen.c.
After invoking AEEApplet_New(), this function can do app specific initialization. In this
example, a generic structure is provided so that app developers need not change app specific
initialization section every time except for a call to IFile_InitAppData(). This is done as follows:
IFile_InitAppData() is called to initialize the applet's data. It is app developer's
responsibility to fill-in app data initialization code of IFile_InitAppData(). App developer
is also responsible to release memory allocated for data -- this can be
done in IFile_FreeAppData().
PROTOTYPE:
boolean AEEClsCreateInstance(AEECLSID ClsId, IShell* pIShell, IModule* pIModule,
void** ppObj)
PARAMETERS:
ClsId: [in]: Specifies the ClassID of the applet which is being loaded
pIShell: [in]: Contains pointer to the IShell interface.
pIModule: [in]: Contains pointer to the IModule interface to the current module to which
this app belongs
ppObj: [out]: On return, *ppObj must point to a valid AEEApplet structure. Allocation
of memory for this structure and initializing the base data members is done by AEEApplet_New().
DEPENDENCIES
none
RETURN VALUE
TRUE: If the app needs to be loaded and if AEEApplet_New() invocation was successful
FALSE: If the app does not need to be loaded or if errors occurred in AEEApplet_New().
If this function returns FALSE, the app will not be loaded.
SIDE EFFECTS
none
===========================================================================*/
int AEEClsCreateInstance(AEECLSID ClsId, IShell* pIShell, IModule* po, void** ppObj)
{
*ppObj = NULL;
// We want to load this App. So, invoke AEEApplet_New().To it, pass the
// address of the app-specific handle event function.
if(ClsId == AEECLSID_FILE_APP){
if (AEEApplet_New(sizeof(CIFileApp), ClsId, pIShell,po,(IApplet**)ppObj,
(AEEHANDLER)FileApp_HandleEvent,(PFNFREEAPPDATA)IFile_FreeAppData) == TRUE)
{
DBGPRINTF("lintao new passed");
if (IFile_InitAppData((IApplet*)*ppObj))
{
DBGPRINTF("lintao IFile_InitAppData passed");
return(AEE_SUCCESS);
}
}
}
return (EFAILED);
}
/*===========================================================================
FUNCTION FileApp_HandleEvent
DESCRIPTION
This is the EventHandler for this app. All events to this app are handled in this
function.
PROTOTYPE:
static boolean App_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
PARAMETERS:
pi: Pointer to the AEEApplet structure. This structure contains information specific
to this applet.