2,851
社区成员




//这里一组操作,基本上都是一起的,以成组出现的。
LISTENER_Cancel(&me->modelListener);
LISTENER_Init(&me->modelListener, BitmapWidget_ModelChanged, me);
nErr = IMODEL_AddListener(me->base.piModel, &me->modelListener);
#include "AEEModGen.h"
#include "AEEAppGen.h"
#include "AEEShell.h"
#include "AEE.h"
#include "AEETapi.h"
#include "AEEStdlib.h"
#include "AEESMS.h"
#include "AEEAddrBook.h"
#include "brew_phone_number.bid"
typedef struct _brew_phone_number {
AEEApplet a ;
AEEDeviceInfo DeviceInfo;
IShell *pIShell;
ITAPI *pITAPI;
ISMS *pISMS;
ISMSMsg *pISMSMsg;
IAddrBook *pIADDR_RUIM;
IAddrBook *pIADDR;
ISMSStorage *pISMSStorage;
uint32 p_er;
IModel *pIModel;
ModelListener *pIModelLst;
AEECallback cb;
boolean m_bGoBg;
} brew_phone_number;
static boolean brew_phone_number_HandleEvent(brew_phone_number* pMe,
AEEEvent eCode, uint16 wParam,
uint32 dwParam);
boolean brew_phone_number_InitAppData(brew_phone_number* pMe);
void brew_phone_number_FreeAppData(brew_phone_number* pMe);
void delete_cb(void *po);
int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj)
{
*ppObj = NULL;
if( ClsId == AEECLSID_BREW_PHONE_NUMBER )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(brew_phone_number),
ClsId,
pIShell,
po,
(IApplet**)ppObj,
(AEEHANDLER)brew_phone_number_HandleEvent,
(PFNFREEAPPDATA)brew_phone_number_FreeAppData) ) // the FreeAppData function is called after sending EVT_APP_STOP to the HandleEvent function
{
//Initialize applet data, this is called before sending EVT_APP_START
// to the HandleEvent function
if(brew_phone_number_InitAppData((brew_phone_number*)*ppObj))
{
//Data initialized successfully
return(AEE_SUCCESS);
}
else
{
//Release the applet. This will free the memory allocated for the applet when
// AEEApplet_New was called.
IAPPLET_Release((IApplet*)*ppObj);
return EFAILED;
}
} // end AEEApplet_New
}
return(EFAILED);
}
static boolean brew_phone_number_HandleEvent(brew_phone_number* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
int res;
int len;
len = 20;
switch (eCode)
{
case EVT_APP_START:
res = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_SMSSTORAGE , (void**)&pMe->pISMSStorage);
if(res != SUCCESS)
DBGPRINTF("create instance returns %d !\n",res);
DBGPRINTF("NOW STRING..........\n");
if(pMe->m_bGoBg) {
ISHELL_CloseApplet(pMe->pIShell, FALSE);
}
res = ISMSSTORAGE_QueryInterface (pMe->pISMSStorage, AEEIID_MODEL , (void **)&pMe->pIModel);
DBGPRINTF("____________res = %d!\n",res);
res = IModel_AddListener(pMe->pIModel, pMe->pIModelLst);
DBGPRINTF("____________res = %d!\n",res);
ISMSSTORAGE_DeleteAll(pMe->pISMSStorage, (AEESMSStorageType)AEESMS_NV_CDMA, &(pMe->cb), &(pMe->p_er));
DBGPRINTF("________________delete error: %d\n",pMe->p_er);
return(TRUE);
case EVT_MDL_SMSSTORAGE_DELETE_ALL:
DBGPRINTF("recv delete all event!!!!!!!!!!!!!!!!!!!!!!!\n");
return(TRUE);
// App is told it is exiting
case EVT_APP_STOP:
// Add your code here...
if(pMe->m_bGoBg) {
*((boolean*) dwParam) = FALSE;
}
return(TRUE);
// App is being suspended
case EVT_APP_SUSPEND:
// Add your code here...
return(TRUE);
// App is being resumed
case EVT_APP_RESUME:
// Add your code here...
return(TRUE);
case EVT_NOTIFY:
{
AEENotify* temp = (AEENotify*)dwParam;
if (temp && (temp->cls == AEECLSID_SHELL)) // event sender
{
if ((temp->dwMask & NMASK_SHELL_INIT) == NMASK_SHELL_INIT)
{
// AEECLSID_SHELLINIT ?本?用
ISHELL_StartApplet(pMe->a.m_pIShell, AEECLSID_BREW_PHONE_NUMBER);
}
}
return TRUE;
}
case EVT_APP_MESSAGE:
// Add your code here...
DBGPRINTF("in APP message\n");
return(TRUE);
case EVT_KEY:
// Add your code here...
return(TRUE);
default:
break;
}
return FALSE;
}
boolean brew_phone_number_InitAppData(brew_phone_number* pMe)
{
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
pMe->pIShell = pMe->a.m_pIShell;
pMe->pITAPI = NULL;
pMe->pISMS = NULL;
pMe->pISMSMsg = NULL;
pMe->pISMSStorage = NULL;
pMe->pIModelLst = (ModelListener*)MALLOC(sizeof(ModelListener));
pMe->m_bGoBg = 1;
CALLBACK_Init(&pMe->cb, delete_cb, pMe);
return TRUE;
}
void brew_phone_number_FreeAppData(brew_phone_number* pMe)
{
}
void delete_cb(void *po)
{
brew_phone_number *pMe = (brew_phone_number*)po;
DBGPRINTF("_______________delete_cb\n");
}
FILE: brew_phone_number.c
#include "AEEModGen.h" // Module interface definitions
#include "AEEAppGen.h" // Applet interface definitions
#include "AEEShell.h" // Shell interface definitions
#include "AEE.h"
#include "AEETapi.h" // TAPI Interface definitions
#include "AEEStdlib.h"
#include "AEESMS.h"
#include "AEEAddrBook.h"
#include "brew_phone_number.bid"
typedef struct _brew_phone_number {
AEEApplet a ; // First element of this structure must be AEEApplet
AEEDeviceInfo DeviceInfo; // always have access to the hardware device information
IShell *pIShell;
ITAPI *pITAPI;
ISMS *pISMS;
ISMSMsg *pISMSMsg;
IAddrBook *pIADDR_RUIM;
IAddrBook *pIADDR;
ISMSStorage *pISMSStorage;
uint32 p_er;
IModel *pIModel;
ModelListener *pIModelLst;
boolean m_bGoBg;
// add your own variables here...
} brew_phone_number;
//#define NMASK_SMS_TYPE 0x0001
static boolean brew_phone_number_HandleEvent(brew_phone_number* pMe,
AEEEvent eCode, uint16 wParam,
uint32 dwParam);
boolean brew_phone_number_InitAppData(brew_phone_number* pMe);
void brew_phone_number_FreeAppData(brew_phone_number* pMe);
void delete_cb(brew_phone_number *pMe);
static boolean brew_phone_number_HandleEvent(brew_phone_number* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
int res;
int len;
uint32 num;
byte buf[20];
len = 20;
switch (eCode)
{
// App is told it is starting up
case EVT_APP_START:
res = ISHELL_CreateInstance(pMe->pIShell, AEECLSID_SMSSTORAGE , (void**)&pMe->pISMSStorage);
if(res != SUCCESS)
DBGPRINTF("create instance returns %d !\n",res);
// Add your code here...
DBGPRINTF("NOW STRING..........\n");
if(pMe->m_bGoBg) {
ISHELL_CloseApplet(pMe->pIShell, FALSE);
}
res = ISMSSTORAGE_QueryInterface (pMe->pISMSStorage, AEEIID_MODEL , (void **)&pMe->pIModel);
DBGPRINTF("____________res = %d!\n",res);
res = IModel_AddListener(pMe->pIModel, pMe->pIModelLst);
DBGPRINTF("____________res = %d!\n",res);
ISMSSTORAGE_DeleteAll(pMe->pISMSStorage, (AEESMSStorageType)AEESMS_NV_CDMA, (AEECallback *)delete_cb, &(pMe->p_er));
DBGPRINTF("________________delete error: %d\n",pMe->p_er);
return(TRUE);
case EVT_MDL_SMSSTORAGE_DELETE_ALL:
DBGPRINTF("recv delete all event!!!!!!!!!!!!!!!!!!!!!!!\n");
return(TRUE);
// App is told it is exiting
case EVT_APP_STOP:
// Add your code here...
if(pMe->m_bGoBg) {
*((boolean*) dwParam) = FALSE;
}
return(TRUE);
// App is being suspended
case EVT_APP_SUSPEND:
// Add your code here...
return(TRUE);
// App is being resumed
case EVT_APP_RESUME:
// Add your code here...
return(TRUE);
case EVT_NOTIFY:
{
AEENotify* temp = (AEENotify*)dwParam;
if (temp && (temp->cls == AEECLSID_SHELL)) // event sender
{
if ((temp->dwMask & NMASK_SHELL_INIT) == NMASK_SHELL_INIT)
{
// AEECLSID_SHELLINIT 为本应用
ISHELL_StartApplet(pMe->a.m_pIShell, AEECLSID_BREW_PHONE_NUMBER);
}
}
return TRUE;
}
case EVT_APP_MESSAGE:
// Add your code here...
DBGPRINTF("in APP message\n");
return(TRUE);
case EVT_KEY:
// Add your code here...
return(TRUE);
// If nothing fits up to this point then we'll just break out
default:
break;
}
return FALSE;
}
boolean brew_phone_number_InitAppData(brew_phone_number* pMe)
{
pMe->pIShell = pMe->a.m_pIShell;
pMe->pITAPI = NULL;
pMe->pISMS = NULL;
pMe->pISMSMsg = NULL;
pMe->pISMSStorage = NULL;
pMe->pIModelLst = (ModelListener*)MALLOC(sizeof(ModelListener));
pMe->m_bGoBg = 1;
// if there have been no failures up to this point then return success
return TRUE;
}
void delete_cb(brew_phone_number *pMe)
{
DBGPRINTF("_______________delete_cb\n");
}