📄 extensions.c
字号:
}
if(wParam == AVK_2)
{
pMe->m_bValid = 0;
//IAPPLETCTL_Stop(pMe->m_pAppletCtl,AEECLSID_BKGAPPLET);
//ISHELL_CloseApplet(pMe->a.m_pIShell,FALSE);
}
if(wParam == AVK_3)
{
ISHELL_Notify(pMe->a.m_pIShell,AEECLSID_FRONTAPPLET,NOTIFY_MASK_FRONT_IDLE_EVENT,NULL);
}
return(TRUE);
// If nothing fits up to this point then we'll just break out
default:
break;
}
return FALSE;
}
// this function is called when your application is starting up
boolean extensions_InitAppData(FrontApplet* pMe)
{
// Get the device information for this handset.
// Reference all the data by looking at the pMe->DeviceInfo structure
// Check the API reference guide for all the handy device info you can get
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
pMe->m_pcBuffer = MALLOC(MAX_FILE_LENGTH*sizeof(AECHAR*));
pMe->m_iBufferSize = MAX_FILE_LENGTH;
ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_EXT2,&(pMe->pIExtension2));
ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_EXT1,&(pMe->pIExtension1));
ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_APPLETCTL,&(pMe->m_pAppletCtl));
pMe->m_bValid = 1;
CALLBACK_Init(&pMe->m_cbRedraw, (PFNNOTIFY)FrontApplet_RedrawNotify, pMe);
// Insert your code here for initializing or allocating resources...
// if there have been no failures up to this point then return success
return TRUE;
}
// this function is called when your application is exiting
void extensions_FreeAppData(FrontApplet* pMe)
{
FrontApplet *po = (FrontApplet*)pMe;
FREEIF(po->m_pcBuffer);
EXTENSION_CancelRedraw(po);
EXTENSION_RELEASEIF(po->m_pAppletCtl);
if(NULL != po->pIExtension1)
{
IExtension1_Release(po->pIExtension1);
}
if(NULL != po->pIExtension2)
{
IExtension2_Release(po->pIExtension2);
}
}
static void FrontApplet_DrawText(FrontApplet* pMe,AECHAR* pcBuffer)
{
AEEPoint point ;
point.x = 10;
point.y = 10;
// ISHELL_SetTimer(pMe->a.m_pIShell, FRONT_DRAW_TIMER, (PFNNOTIFY)FrontApplet_DrawText, pMe);
//pcBuffer = IExtension1_GetStoredData(pMe->pIExtension1);
IExtension2_DrawHello(pMe->pIExtension2,point,pMe->m_pcBuffer);
return;
}
static void FrontApplet_RedrawNotify(FrontApplet* pMe)
{
DBGPRINTF("current num is aaaa " );
FrontApplet_DrawText(pMe,NULL);
FrontApplet_Redraw(pMe);
}
static void FrontApplet_Redraw(FrontApplet* pMe)
{
//ISHELL_SetTimer(pMe->a.m_pIShell, FRONT_DRAW_TIMER, (PFNNOTIFY)FrontApplet_Redraw, pMe);
if(pMe->m_bValid)
{
ISHELL_Resume(pMe->a.m_pIShell,&pMe->m_cbRedraw);
}
}
static boolean BkgApplet_HandleEvent(BkgApplet* pMe, AEEEvent eCode,
uint16 wParam, uint32 dwParam)
{
switch (eCode)
{
// App is told it is starting up
case EVT_APP_START:
if(pMe->m_bGoBg)
{
ISHELL_CloseApplet(pMe->a.m_pIShell, FALSE); // send applet to background
}
return(TRUE);
case EVT_BKG_REFRESH_FILE:
//restart save files
pMe->m_iPosition = 0;
return (TRUE);
case EVT_NOTIFY:
if(pMe->m_bGoBg)
{
pMe->m_bGoBg = FALSE;
ISHELL_StartApplet(pMe->a.m_pIShell, AEECLSID_BKGAPPLET); // make applet active
}
else
{
pMe->m_bGoBg = TRUE;
ISHELL_CloseApplet(pMe->a.m_pIShell, FALSE); // trigger EVT_APP_STOP to send app to
// background
}
return (TRUE);
case EVT_APP_START_BACKGROUND:
/*start timer to refresh data in buffer*/
ISHELL_SetTimer(pMe->a.m_pIShell, BKG_DRAW_TIMER, (PFNNOTIFY)BkgApplet_RefreshData, pMe);
return TRUE;
// App is told it is exiting
case EVT_APP_STOP:
if(pMe->m_bGoBg)
{
*((boolean*) dwParam) = FALSE; // set dwParam to run in bg
}
// Add your code here...
ISHELL_CancelTimer(pMe->a.m_pIShell, (PFNNOTIFY)BkgApplet_RefreshData, pMe);
// BkgApplet_FreeAppData(pMe);
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);
// An SMS message has arrived for this app. Message is in the dwParam above as (char *)
// sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
case EVT_APP_MESSAGE:
// Add your code here...
return(TRUE);
// A key was pressed. Look at the wParam above to see which key was pressed. The key
// codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed.
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;
}
static void BkgApplet_RefreshData(BkgApplet* pMe)
{
int iPos = 0;
int iDataLen = 10;
AECHAR* pszBuffer = NULL;
uint32 iResult = SUCCESS;
if(pMe->m_iPosition >= MAX_FILE_LENGTH)
{
pMe->m_iPosition = 0;
}
//start timer again.
iResult = ISHELL_SetTimer(pMe->a.m_pIShell, BKG_DRAW_TIMER, (PFNNOTIFY)BkgApplet_RefreshData, pMe);
DBGPRINTF("current file position is %d",pMe->m_iPosition);
if(SUCCESS == iResult)
{
iResult = IExtension1_ReadFromFile(pMe->pIExtension1,"test.txt",pMe->m_iPosition,iDataLen);
}
if(SUCCESS == iResult)
{
pMe->m_iPosition += iDataLen;//next read start
pszBuffer = IExtension1_GetStoredData(pMe->pIExtension1);
if(NULL != pszBuffer)
{
iResult == SUCCESS;
}
}
if(SUCCESS == iResult)
{
//assure the AEECLSID_FRONTAPPLET is the top active applet before redraw operation.
if(AEECLSID_FRONTAPPLET != ISHELL_ActiveApplet(pMe->a.m_pIShell))
{
ISHELL_StartApplet(pMe->a.m_pIShell,AEECLSID_FRONTAPPLET);
}
}
if(SUCCESS == iResult)
{
ISHELL_PostEvent(pMe->a.m_pIShell,AEECLSID_FRONTAPPLET,EVT_BKG_REFRESH_DATA,(uint16)iDataLen,(uint32)pszBuffer);
}
return;
}
boolean BkgApplet_InitAppData(BkgApplet* pMe)
{
pMe->m_iPosition = 0;
pMe->m_bGoBg = TRUE;
ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_EXT1,(void*)&(pMe->pIExtension1));
ISHELL_RegisterNotify(pMe->a.m_pIShell,AEECLSID_BKGAPPLET,AEECLSID_FRONTAPPLET,NOTIFY_MASK_FRONT_IDLE_EVENT);
return TRUE;
}
void BkgApplet_FreeAppData(BkgApplet* pMe)
{
BkgApplet *po = pMe;
if(NULL != pMe->pIExtension1)
{
IExtension1_Release(pMe->pIExtension1);
}
return;
}
/*===========================================================================
This function releases IBase.
===========================================================================*/
static void Extension_FreeIF(IBase ** ppif)
{
if (ppif && *ppif)
{
IBASE_Release(*ppif);
*ppif = NULL;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -