⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iringerusage.c

📁 c++结构的应用程序 其中包含写好的ringer类
💻 C
📖 第 1 页 / 共 2 页
字号:
/*===========================================================================  FILE: IRingerusage.c  SERVICES: Sample applet using AEE  DESCRIPTION  This file contains usage examples of IRingerMgr interface. IRingerMgr interface  functions allow the user to create/operate on IRingerMgr objects. IRingerMgr   interface offers basic ringer services.  PUBLIC CLASSES:    N/A  Copyright ?2000-2001 QUALCOMM Incorporated.  All Rights Reserved.  QUALCOMM Proprietary/GTDR  ===========================================================================*/   /*===============================================================================  INCLUDES AND VARIABLE DEFINITIONS  =============================================================================== */   #include "AEEModGen.h"    #include "AEEAppGen.h"    #include "AEEShell.h"    #include "AEEStdLib.h"    #include "RINGER_APP.bid"   #include "iringer_res.h"    #include "AEEImage.h"    #include "AEEFile.h"    #include "AEERinger.h"    #include "AEEMenu.h"    /*===========================================================================  PUBLIC DATA DECLARATIONS  ===========================================================================*/   /*-------------------------------------------------------------------  Type Declarations  -------------------------------------------------------------------*/   // MemStream app struct. This is the main struct for this applet. This will hold     // all the data members that needs 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 _CIRingerApp   {   	AEEApplet   a;        // Mandatory first AEEApplet data member    	boolean     bOn;   	boolean     bgColor;   	// Device parameters    	int             m_nLineHeight;   	AEEDeviceInfo   m_dInfo;   	IMenuCtl     *  m_pIMenu;   	boolean m_bSPActive;   	// ringer members     	IRingerMgr *  m_pIRingerMgr;   	IFile *m_pIFile;   	IFileMgr *m_pIFileMgr;   	IMemAStream *m_pMemStream;   	byte *      m_pBuff;   }CIRingerApp;   void CleanInterfaces(CIRingerApp *pMe)   {   	// Release ringermgr object if it is not released    	if (pMe->m_pIRingerMgr != NULL)   	{   		// Deregister Notify so that     		IRINGERMGR_RegisterNotify (pMe->m_pIRingerMgr, NULL, NULL);   		// Stop any songs being played at this time    		IRINGERMGR_Stop (pMe->m_pIRingerMgr);   		IRINGERMGR_Release (pMe->m_pIRingerMgr);   		pMe->m_pIRingerMgr = NULL;   	}   	if(pMe->m_pIFile != NULL)   	{   		IFILE_Release(pMe->m_pIFile);   		pMe->m_pIFile = NULL;   	}   	if(pMe->m_pIFileMgr != NULL)   	{   		IFILEMGR_Release(pMe->m_pIFileMgr);   		pMe->m_pIFileMgr = NULL;   	}   	if(pMe->m_pMemStream != NULL)   	{   		IMEMASTREAM_Release(pMe->m_pMemStream);   		pMe->m_pMemStream = NULL;   	}   }   int PlayRingerFile(CIRingerApp *pMe, const char * filename);   int CreateRinger(CIRingerApp *pMe, const char * ringername, const char * inputfile, AEESoundPlayerFile format);   /*-------------------------------------------------------------------  Function Prototypes  -------------------------------------------------------------------*/   // App Handle Event function    static boolean MemStreamApp_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam);   // App specific data alloc-init/free functions    static boolean IRinger_InitAppData(IApplet* pMe);   static void IRinger_FreeAppData(IApplet* pMe);   static void IRingerUsage (CIRingerApp * pMe, uint16 wParam);   static void BuildMainMenu(CIRingerApp *pMe);   /*-------------------------------------------------------------------  Global Constant Definitions  -------------------------------------------------------------------*/   // App Resource File    #define  APP_RES_FILE      "iringer.bar"    // App specific constants    #define USAGE_BASIC_USAGE           100    #define USAGE_REGISTERNOTIFY        101    #define USAGE_GETNUMBERFORMATS      102        #define USAGE_GETFORMATS            103    #define USAGE_SETRINGER             104    #define USAGE_ENUMCATEGORYINIT      105       #define USAGE_ENUMNEXTCATEGORY      106    #define USAGE_ENUMRINGERINIT        107     #define USAGE_ENUMNEXTRINGER        108    #define USAGE_GETRINGERID           109    #define USAGE_GETRINGERINFO         110    #define USAGE_CREATE                111    #define USAGE_REMOVE                112    #define USAGE_PLAYEX                113    #define USAGE_PLAY                  114         #define USAGE_PLAYFILE              115      #define USAGE_PLAYSTREAM            116    #define USAGE_STOP                  117            /*===============================================================================  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 IRinger_InitAppData().   This is done as follows: InitAppData() is called to initialize AppletData   instance. It is app developers responsibility to fill-in app data initialization   code of InitAppData(). App developer is also responsible to release memory   allocated for data contained in AppletData -- this can be done in   IRinger_FreeAppData().  PROTOTYPE:  int AEEClsCreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * po,void ** ppObj)  PARAMETERS:  clsID: [in]: Specifies the ClassID of the applet which is being loaded  pIShell: [in]: Contains pointer to the IShell object.   pIModule: pin]: Contains pointer to the IModule object to the current module to which  this app belongs  ppObj: [out]: On return, *ppObj must point to a valid IApplet structure. Allocation  of memory for this structure and initializing the base data members is done by AEEApplet_New().  DEPENDENCIES  none  RETURN VALUE  AEE_SUCCESS: If the app needs to be loaded and if AEEApplet_New() invocation was  successful  EFAILED: 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_RINGER_APP){   		if(AEEApplet_New(sizeof(CIRingerApp), ClsId, pIShell,po,(IApplet**)ppObj,   			(AEEHANDLER)MemStreamApp_HandleEvent,(PFNFREEAPPDATA)IRinger_FreeAppData)   			== TRUE)   		{   			if (IRinger_InitAppData((IApplet*)*ppObj) == TRUE)   			{   				return(AEE_SUCCESS);   			}   		}   	}   	return (EFAILED);   }   //Ringer Mgr callback function    void RingerMgrCBFn(void * pUser, AEERingerEvent evt, uint32 dwParm, int nErr)   {   }   /*===========================================================================  FUNCTION MemStreamApp_HandleEvent  DESCRIPTION  This is the EventHandler for this app. All events to this app are handled in this  function. All APPs must supply an Event Handler.  PROTOTYPE:  boolean MemStreamApp_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)  PARAMETERS:  pi: Pointer to the AEEApplet structure. This structure contains information specific  to this applet. It was initialized during the AEEClsCreateInstance() function.  ecode: Specifies the Event sent to this applet  wParam, dwParam: Event specific data.  DEPENDENCIES  none  RETURN VALUE  TRUE: If the app has processed the event  FALSE: If the app did not process the event  SIDE EFFECTS  none  ===========================================================================*/   static boolean MemStreamApp_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)   {     	CIRingerApp * pMe = (CIRingerApp*)pi;   	switch (eCode)    	{   	case EVT_COMMAND:   		// When a menu item is selected this applet receives the    		// EVT_COMMAND event in the wParam field.    		switch(wParam)   		{   		case USAGE_BASIC_USAGE:   		case USAGE_REGISTERNOTIFY:   		case USAGE_GETNUMBERFORMATS :      		case USAGE_GETFORMATS :   		case USAGE_SETRINGER  :   		case USAGE_ENUMCATEGORYINIT :   		case USAGE_ENUMRINGERINIT :    		case USAGE_ENUMNEXTRINGER:   		case USAGE_GETRINGERID:   		case USAGE_GETRINGERINFO:   		case USAGE_CREATE:   		case USAGE_REMOVE:   		case USAGE_PLAYEX:   		case USAGE_PLAY  :        		case USAGE_PLAYFILE:   		case USAGE_PLAYSTREAM:   		case USAGE_STOP  :    			IRingerUsage (pMe, wParam);   			return TRUE;   		default: return FALSE;    		}   	case EVT_APP_START:   		// Create the IMenu interface object. When the applet is started the     		// main menu is set up. When the user selects a menu item from the main     		// menu, an EVT_COMMAND event is received by this applet. The processing for     		// EVT_COMMAND event is found below.    		if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_MENUCTL, (void **)&pMe->m_pIMenu)   			!= SUCCESS)   		{   			return FALSE;   		}   		// Build the main menu    		BuildMainMenu(pMe);   		return(TRUE);   	case EVT_APP_STOP:   		return(TRUE);   	case EVT_KEY:   		CleanInterfaces(pMe);   		// The key is probably the Up/Down keys. In this case we should     		// call the IMenuCtl object so that the Up/Down key presses are    		// handled by the MenuCtl.    		if((pMe->m_pIMenu != NULL) && IMENUCTL_HandleEvent(pMe->m_pIMenu,    			EVT_KEY, wParam, 0))   		{   			return TRUE;   		}   		else   		{   			// We would have come here because the pressed key was not handled     			// by either the RingerPlayer or the MenuCtl HandleEvent functions (the     			// keys handled by the above controls are Up/Down/Select/Left/Right).    			//    			// Hence, we have reached here since 0-9, *, or # keys were    			// pressed. So redraw the main applet menu and return true.    			if (pMe->m_pIMenu)   				IMENUCTL_Redraw (pMe->m_pIMenu);   		}   		return TRUE;   		break;   	}   	return FALSE;   }   /*===========================================================================  FUNCTION IRinger_InitAppData  DESCRIPTION  This function initializes app specific data allocates memory for app data   (AppletData) and sets it to pAppData of AEEApplet. It also function .   App developer needs to fill-in the initialization code.  PROTOTYPE:  boolean IRinger_InitAppData(IApplet* pi);  PARAMETERS:  pi [in]: Pointer to the IApplet structure. This structure contains   information specific to this applet. It was initialized during the   AEEClsCreateInstance().  DEPENDENCIES  Assumes pi is not NULL  RETURN VALUE  TRUE: If the app has app data is allocated and initialized successfully  FALSE: Either app data could not be allocated or initialzied  SIDE EFFECTS  none  ===========================================================================*/   static boolean IRinger_InitAppData(IApplet* pi)   {   	CIRingerApp * pMe = (CIRingerApp*)pi;   	int pnAscent = 0;        // Stores the ascent in number of pixels    	int pnDescent = 0;       // Stores the descent in number of pixels    	// Initialize the MenuCtl and ringer pointers    	pMe->m_pIMenu = NULL;   	pMe->m_pIRingerMgr = NULL;   	pMe->m_bSPActive = FALSE;   	// Get the font metrics info    	pMe->m_nLineHeight = IDISPLAY_GetFontMetrics (pMe->a.m_pIDisplay, AEE_FONT_NORMAL,   		&pnAscent, &pnDescent);   	pMe->m_pIFile = NULL;   	pMe->m_pIFileMgr = NULL;   	pMe->m_pMemStream = NULL;   	pMe->m_pBuff = NULL;   	return TRUE;   }   /*===========================================================================  FUNCTION IRinger_FreeAppData  DESCRIPTION  Frees data contained in app data and memory for app data itself.  App developer needs to free data contained in AppletData.  PROTOTYPE:  void IRinger_FreeAppData(IApplet* pi);  PARAMETERS:  pi [in]: Pointer to the IApplet structure. This structure contains   information specific to this applet. It was initialized during the   AEEClsCreateInstance().  DEPENDENCIES  Assumes pi is not NULL  RETURN VALUE  None  SIDE EFFECTS  None  ===========================================================================*/   static void IRinger_FreeAppData(IApplet* pi)   {   	CIRingerApp * pMe = (CIRingerApp*)pi;   	CleanInterfaces(pMe);   	if(pMe->m_pIMenu != NULL)   	{   		IMENUCTL_Release(pMe->m_pIMenu);   		pMe->m_pIMenu = NULL;   	}   }   /*===============================================================================  APP HELPER FUNCTION DEFINITIONS  =============================================================================== */   /*===========================================================================  FUNCTION: IRingerUsage  DESCRIPTION  PROTOTYPE:  void IRingerUsage (CIRingerApp * pMe, uint16 wParam)  PARAMETERS:  DEPENDENCIES  none  RETURN VALUE  none  SIDE EFFECTS  none  ===========================================================================*/   static void IRingerUsage (CIRingerApp * pMe, uint16 wParam)   {   	switch(wParam)   	{      	case USAGE_GETNUMBERFORMATS :   		{   			int NumberOfFormats = -1;   			ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_RINGERMGR, (void **)&pMe->m_pIRingerMgr);    			if(pMe->m_pIRingerMgr == NULL)   			{   				return;   			}   			NumberOfFormats = IRINGERMGR_GetNumberFormats(pMe->m_pIRingerMgr);   			CleanInterfaces(pMe);   		}   		break;   	case USAGE_GETFORMATS :   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -