void StatusBox_Dtor(StatusBox *me) { FREEIF(me->pStringData); CALLBACK_Cancel(&me->cb); RELEASEIF(me->piImage); ZEROAT(me); }
void Tooltip_Dtor(Tooltip *me) { FREEIF(me->pStringData); RELEASEIF(me->piDisplay); RELEASEIF(me->piShell); CALLBACK_Cancel(&me->cb); ZEROAT(me); }
/*======================================================================= Function: Loc_Init() =======================================================================*/ int Loc_Init( IShell *pIShell, IPosDet *pIPos, AEECallback *pcb, LocState **po ) { int nErr = SUCCESS; LocState *pts = NULL; if( !pIShell || !pIPos || !pcb || !po ) { nErr = EBADPARM; } else if( NULL == (pts = MALLOC( sizeof(LocState) )) ){ nErr = ENOMEMORY; } else { ZEROAT( pts ); pts->pShell = pIShell; ISHELL_AddRef( pIShell ); pts->pPos = pIPos; IPOSDET_AddRef( pIPos ); /* Install the notification cb */ CALLBACK_Cancel( pcb ); pts->pcbResp = pcb; pts->pcbResp->pfnCancel = Loc_Cancel; pts->pcbResp->pCancelData = pts; CALLBACK_Init( &pts->cbIntervalTimer, Loc_cbInterval, pts ); CALLBACK_Init( &pts->cbInfo, Loc_cbInfo, pts ); } *po = pts; return nErr; }
/*=========================================================================== FUNCTION CallDemoApp_InitAppData DESCRIPTION This function initializes app specific data. PROTOTYPE: static boolean CallDemoApp_InitAppData(IApplet* pi); PARAMETERS: pi [in]: Pointer to the IApplet structure. DEPENDENCIES None. RETURN VALUE TRUE: If the app has app data is allocated and initialized successfully FALSE: Either app data could not be allocated or initialized SIDE EFFECTS None. ===========================================================================*/ static boolean CallDemoApp_InitAppData(IApplet* pi) { CallDemoApp * pMe = (CallDemoApp*)pi; int charHeight, pnAscent, pnDescent; AEEDeviceInfo di; int nErr; // Make sure the pointers we'll be using are valid if (pMe == NULL || pMe->a.m_pIShell == NULL) return FALSE; pMe->m_pIMenu = NULL; // Determine the amount of available screen space ZEROAT(&di); di.wStructSize = sizeof(di); ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&di); pMe->m_rc.dx = di.cxScreen; pMe->m_rc.dy = di.cyScreen; // Determine the height of a line of text charHeight = IDISPLAY_GetFontMetrics (pMe->a.m_pIDisplay, AEE_FONT_NORMAL, &pnAscent, &pnDescent); // Number of available lines equals the available screen // space divided by the height of a line, minus 3 for the // lines we always print at the top and bottom of the screen pMe->m_cMaxLine = (di.cyScreen / charHeight) - 3; pMe->m_pCallMgr = NULL; pMe->m_pOutgoingCall = NULL; pMe->m_pIncomingCall = NULL; nErr =ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_CALLMGR, (void**) &pMe->m_pCallMgr); DBGPRINTF("CreateInst AEECLSID_CALLMGR ret %d", nErr); if(nErr != AEE_SUCCESS) { return FALSE; } if(SUCCESS != ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_TELEPHONE, (void **) &pMe->m_pTelephone)) { return FALSE; } if(SUCCESS != ITELEPHONE_QueryInterface(pMe->m_pTelephone, AEEIID_MODEL, (void **) &pMe->m_pModel)) { return FALSE; } LISTENER_Init((ModelListener *)&pMe->m_lisPhone, MyPhoneListener, (void *) pMe); IMODEL_AddListener(pMe->m_pModel, (ModelListener *) &pMe->m_lisPhone); #ifdef EVENT_AUTO_GET pMe->m_UserAnswerEvent = ISHELL_RegisterEvent(pMe->a.m_pIShell, "user anwser event", NULL ); pMe->m_UserRedirectEvent = ISHELL_RegisterEvent(pMe->a.m_pIShell, "user redirect event", NULL ); #endif pMe->m_isDTMFItem = FALSE; pMe->m_isParty3Item= FALSE; pMe->m_isRedirectItem = FALSE; return TRUE; }
/*=========================================================================== ===========================================================================*/ boolean SamplePosDet_GetGPSInfo_HandleEvent( CSamplePosDet *pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam ) { boolean bHandled = FALSE; struct _GetGPSInfo *pGetGPSInfo = SamplePosDet_GetScreenData( pMe ); switch( eCode ) { case EVT_SCREEN: if( wParam == SCREEN_PARAM_INIT ) { if( pGetGPSInfo == 0 ) { pGetGPSInfo = MALLOC( sizeof( struct _GetGPSInfo ) ); if( pGetGPSInfo ) { int nErr = SUCCESS; ZEROAT( pGetGPSInfo ); pGetGPSInfo->theInfo.server = pMe->gpsSettings.server; pGetGPSInfo->theInfo.qos = pMe->gpsSettings.qos; pGetGPSInfo->theInfo.optim = pMe->gpsSettings.optim; pGetGPSInfo->wMainMenuEntry = (uint16)dwParam; SamplePosDet_SetScreenData( pMe, (void *)pGetGPSInfo ); if( ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_POSDET, (void **)&pGetGPSInfo->pPosDet ) == SUCCESS ) { CALLBACK_Init( &pGetGPSInfo->cbPosDet, SamplePosDet_GetGPSInfo_Callback, pMe ); CALLBACK_Init( &pGetGPSInfo->cbProgressTimer, SamplePosDet_GetGPSInfo_SecondTicker, pMe ); nErr = Track_Init( pMe->theApp.m_pIShell, pGetGPSInfo->pPosDet, &pGetGPSInfo->cbPosDet, &pGetGPSInfo->pts ); if( pGetGPSInfo->wMainMenuEntry == MAINMENU_ITEM_ONE_SHOT ) { nErr = Track_Start( pGetGPSInfo->pts, TRACK_NETWORK, 1, 0, &pGetGPSInfo->theInfo ); } else if( pGetGPSInfo->wMainMenuEntry == MAINMENU_ITEM_TRACK_LOCAL ) { nErr = Track_Start( pGetGPSInfo->pts, TRACK_LOCAL, 0, 0, &pGetGPSInfo->theInfo ); } else if( pGetGPSInfo->wMainMenuEntry == MAINMENU_ITEM_TRACK_NETWORK ) { nErr = Track_Start( pGetGPSInfo->pts, TRACK_NETWORK, 0, 0, &pGetGPSInfo->theInfo ); } else if( pGetGPSInfo->wMainMenuEntry == MAINMENU_ITEM_TRACK_AUTO ) { nErr = Track_Start( pGetGPSInfo->pts, TRACK_AUTO, 0, 0, &pGetGPSInfo->theInfo ); } else { nErr = EFAILED; } SamplePosDet_DrawScreen( pMe, (uint32)GETGPSINFO_PAINT_ALL ); if( nErr != SUCCESS ) { pGetGPSInfo->theInfo.nErr = nErr; SamplePosDet_DrawScreen( pMe, (uint32)GETGPSINFO_PAINT_ERROR ); } else { ISHELL_SetTimerEx( pMe->theApp.m_pIShell, 1000, &pGetGPSInfo->cbProgressTimer ); } bHandled = TRUE; } } } if( !bHandled ) { SamplePosDet_GotoScreen( pMe, SCREENID_MAINMENU, 0 ); bHandled = TRUE; } } else if( wParam == SCREEN_PARAM_CLOSE ) { if( pGetGPSInfo ) { if( pGetGPSInfo->pPosDet ) { CALLBACK_Cancel( &pGetGPSInfo->cbProgressTimer ); CALLBACK_Cancel( &pGetGPSInfo->cbPosDet ); IPOSDET_Release( pGetGPSInfo->pPosDet ); } FREE( pGetGPSInfo ); } SamplePosDet_SetScreenData( pMe, 0 ); pMe->currentHandler = 0; bHandled = TRUE; } else if( wParam == SCREEN_PARAM_PAINT ) { if( !pGetGPSInfo->bPaused ) { SamplePosDet_GetGPSInfo_Paint( pMe, (GetGPSInfo_PaintRegions)dwParam ); } bHandled = TRUE; } break; case EVT_KEY: if( wParam == AVK_CLR || wParam == AVK_SOFT2) { Track_Stop(pGetGPSInfo->pts); if (pGetGPSInfo) { if (pGetGPSInfo->pPosDet) { CALLBACK_Cancel(&pGetGPSInfo->cbProgressTimer); CALLBACK_Cancel(&pGetGPSInfo->cbPosDet); IPOSDET_Release(pGetGPSInfo->pPosDet); } FREE(pGetGPSInfo); } SamplePosDet_GotoScreen( pMe, SCREENID_MAINMENU, 0 ); bHandled = TRUE; } break; case EVT_DIALOG_START: pGetGPSInfo->bPaused = TRUE; bHandled = TRUE; break; case EVT_DIALOG_END: pGetGPSInfo->bPaused = FALSE; SamplePosDet_DrawScreen( pMe, (uint32)GETGPSINFO_PAINT_ALL ); bHandled = TRUE; break; case EVT_COMMAND: break; } return bHandled; }
static int Config_Proxies(LCGIResp *me, AEEResBlob **ppBlob, int *pnBlobLen) { int nErr; BrewserProxyCfg cfgDef; const BrewserProxyCfg *pcfg = 0; ZEROAT(&cfgDef); nErr = IShell_LoadResBlob(me->plcgie->piShell, BREWSER_RES_FILE, IDX_CFGPROXY, ppBlob, pnBlobLen); if (SUCCESS == nErr) { nErr = Brewser_GetProxyCfgPtr(me->pbsr, &pcfg); if (SUCCESS != nErr) { pcfg = &cfgDef; } } if (SUCCESS == nErr) { const char *cpszHttpHost = pcfg->szStrings; const char *cpszFtpHost = cpszHttpHost + STRLEN(cpszHttpHost) + 1; const char *cpszGophHost = cpszFtpHost + STRLEN(cpszFtpHost) + 1; const char *cpszOthHost = cpszGophHost + STRLEN(cpszGophHost) + 1; const char *cpszOthSchm = cpszOthHost + STRLEN(cpszOthHost) + 1; char szHttpPort[6]; char szFtpPort[6]; char szGophPort[6]; char szOthPort[6]; if (0 != pcfg->usHttpPort) { SNPRINTF(szHttpPort,sizeof(szHttpPort),"%d",pcfg->usHttpPort); } else { szHttpPort[0] = '\0'; } if (0 != pcfg->usFtpPort) { SNPRINTF(szFtpPort,sizeof(szFtpPort),"%d",pcfg->usFtpPort); } else { szFtpPort[0] = '\0'; } if (0 != pcfg->usGophPort) { SNPRINTF(szGophPort,sizeof(szGophPort),"%d",pcfg->usGophPort); } else { szGophPort[0] = '\0'; } if (0 != pcfg->usOthPort) { SNPRINTF(szOthPort,sizeof(szOthPort),"%d",pcfg->usOthPort); } else { szOthPort[0] = '\0'; } /* Template: <html> <h2 align=center>Proxies</h2> <a href="lcgi:cfg.{invoke}.prox.reset">Reset to default</a> <form action="lcgi:cfg.{invoke}.prox.ok"> <input type=checkbox name=httpon {httpon}>Proxy HTTP<br> Host <b>:</b> Port<br> <input type=text size=13 name=httphost value="{httphost}"> <b>:</b> <input type=text size=5 name=httpport value="{httpport}"><br> <input type=checkbox name=ftpon {ftpon}>Proxy FTP<br> Host <b>:</b> Port<br> <input type=text size=13 name=ftphost value="{ftphost}"> <b>:</b> <input type=text size=5 name=ftpport value="{ftpport}"><br> <input type=checkbox name=gophon {gophon}>Proxy Gopher<br> Host <b>:</b> Port<br> <input type=text size=13 name=gophost value="{gophhost}"> <b>:</b> <input type=text size=5 name=gopport value="{gophport}"><br> <input type=checkbox name=othon {othon}>Proxy Other<br> Host <b>:</b> Port<br> <input type=text size=13 name=othhost value="{othhost}"> <b>:</b> <input type=text size=5 name=othport value="{othport}"><br> Schemes: (';' separated)<br> <input type=text size=50 name=othschm value="{othschm}"><br> <a href="x-submit:">Save</a> </form> </html> */ if (0 < AEEResBlob_StrRepl(ppBlob, pnBlobLen, "httpon%s\0httphost%Qs\0httpport%Qs\0" "ftpon%s\0ftphost%Qs\0ftpport%Qs\0" "gophon%s\0gophhost%Qs\0gophport%Qs\0" "othon%s\0othschm%Qs\0" "othhost%Qs\0othport%Qs\0", (pcfg->bHttpOn ? "checked" : ""), cpszHttpHost, szHttpPort, (pcfg->bFtpOn ? "checked" : ""), cpszFtpHost, szFtpPort, (pcfg->bGophOn ? "checked" : ""), cpszGophHost, szGophPort, (pcfg->bOthOn ? "checked" : ""), cpszOthSchm, cpszOthHost, szOthPort)) { nErr = ENOMEMORY; } } return nErr; }
void Slider_Dtor(Slider *me) { Slider_Stop(me); ZEROAT(me); }
/*=========================================================================== FUNCTION: CGMENUCTL_Redraw DESCRIPTION: Redraws the control on the device screen. If the control currently has focus, the control is drawn with a border. PARAMETERS: pCtl [in] - A pointer to a CGMeuCtl instance DEPENDENCIES: None RETURN VALUE: None SIDE EFFECTS: Updates the device screen. ===========================================================================*/ extern void CGMENUCTL_Redraw(CGMeuCtl* pMe) { AEEApplet* pApp = (AEEApplet*)GETAPPINSTANCE(); AEERect rRect; if (pMe) { int i, j, height, h, a, b; AEEImageInfo infSe, infIc; AEERect rec; int xx, yy, dxx, dyy; RGBVAL oldColor; GMenuItem * pData = NULL; TQueueList * p = pMe->m_pDataList; ZEROAT(&infSe); IDISPLAY_EraseRect(pApp->m_pIDisplay, &pMe->m_Rect); h = IDISPLAY_GetFontMetrics(pApp->m_pIDisplay, AEE_FONT_NORMAL, &a, &b); //绘制背景图 if (pMe->m_pImageBk) { IIMAGE_SetDrawSize(pMe->m_pImageBk, pMe->m_Rect.dx, pMe->m_Rect.dy); IIMAGE_Draw(pMe->m_pImageBk, pMe->m_Rect.x, pMe->m_Rect.y); } //确定菜单高度 if (pMe->m_pImageSe) { IIMAGE_GetInfo(pMe->m_pImageSe, &infSe); IIMAGE_SetDrawSize(pMe->m_pImageSe, pMe->m_Rect.dx, infSe.cy); } else { infSe.cx = pMe->m_Rect.dx; infSe.cy = h; } //绘制菜单项 i = 0; j = 0; height = pMe->m_Rect.y + 5; while (p) { AECHAR iTemText[256]; if (i < pMe->m_startIndex) { p = p->pNext; i++; continue; } if (j >= pMe->m_pageSize) { break; } pData = (GMenuItem*)p->pData; //加载菜单ICON if (pData->pImage == NULL && pData->pszResImage != NULL && pData->wImage != 0) { pData->pImage = ISHELL_LoadResImage(pApp->m_pIShell, pData->pszResImage, pData->wImage); } //加载菜单Text if (pData->pszResText != NULL && pData->wText != 0) { MEMSET(iTemText, 0, sizeof(AECHAR)*256); ISHELL_LoadResString(pApp->m_pIShell, pData->pszResText, pData->wText, iTemText, sizeof(AECHAR)* 256); pData->pText = iTemText; } if (i == pMe->m_Index) { if (pMe->m_pImageSe) IIMAGE_Draw(pMe->m_pImageSe, pMe->m_Rect.x, height + 2); ZEROAT(&infIc); if (pData->pImage) { IIMAGE_GetInfo(pData->pImage, &infIc); IIMAGE_Draw(pData->pImage, pMe->m_Rect.x, height + (infSe.cy - infIc.cy) / 2); } xx = pMe->m_Rect.x + infIc.cx + 2; yy = height + (infSe.cy - h) / 2 + 2; dxx = pMe->m_Rect.x + pMe->m_Rect.dx - xx; dyy = h; SETAEERECT(&rec, xx, yy, dxx, dyy); oldColor = IDISPLAY_SetColor(pApp->m_pIDisplay, CLR_USER_TEXT, pMe->m_Colors.cSelText); if (pMe->m_Properties & 0x02) IDISPLAY_DrawText(pApp->m_pIDisplay, AEE_FONT_NORMAL, pData->pText + pMe->m_textPos, -1, xx + 1, yy, &rec, IDF_TEXT_TRANSPARENT); IDISPLAY_DrawText(pApp->m_pIDisplay, AEE_FONT_NORMAL, pData->pText + pMe->m_textPos, -1, xx, yy, &rec, IDF_TEXT_TRANSPARENT); if (pMe->m_isActive) { if (IDISPLAY_MeasureText(pApp->m_pIDisplay, AEE_FONT_NORMAL, pData->pText) > dxx) { if (IDISPLAY_MeasureText(pApp->m_pIDisplay, AEE_FONT_NORMAL, pData->pText + pMe->m_textPos) > dxx) { pMe->m_textPos++; } else pMe->m_textPos = 0; //单行太长的话,动态显示 ISHELL_SetTimer(pApp->m_pIShell, 300, (PFNNOTIFY)CGMENUCTL_Redraw, (void*)pMe); } } height += infSe.cy; IDISPLAY_SetColor(pApp->m_pIDisplay, CLR_USER_TEXT, oldColor); } else { ZEROAT(&infIc); if (pData->pImage) { IIMAGE_GetInfo(pData->pImage, &infIc); IIMAGE_Draw(pData->pImage, pMe->m_Rect.x, height + (infSe.cy - infIc.cy) / 2); } xx = pMe->m_Rect.x + infIc.cx + 2; yy = height + (infSe.cy - h) / 2 + 2; dxx = pMe->m_Rect.x + pMe->m_Rect.dx - xx; dyy = h; SETAEERECT(&rec, xx, yy, dxx, dyy); oldColor = IDISPLAY_SetColor(pApp->m_pIDisplay, CLR_USER_TEXT, pMe->m_Colors.cText); if (pMe->m_Properties & 0x01) IDISPLAY_DrawText(pApp->m_pIDisplay, AEE_FONT_NORMAL, pData->pText, -1, xx + 1, yy, &rec, IDF_TEXT_TRANSPARENT); IDISPLAY_DrawText(pApp->m_pIDisplay, AEE_FONT_NORMAL, pData->pText, -1, xx, yy, &rec, IDF_TEXT_TRANSPARENT); height += infSe.cy; IDISPLAY_SetColor(pApp->m_pIDisplay, CLR_USER_TEXT, oldColor); } p = p->pNext; i++; j++; } IDISPLAY_Update(pApp->m_pIDisplay); return ; } }
/** || Function || -------- || static void StatusBox_Init(StatusBox *me) || || Description || ----------- || load the IImage, calculate rectangles || || Parameters || ---------- || StatusBox *me: the status box || || Returns || ------- || nothing || || Remarks || ------- || */ static void StatusBox_Init(StatusBox *me) { AEEImageInfo ii; ZEROAT(&ii); /* re-init this stuff every time */ if ((IImage *)0 != me->piImage) { IIMAGE_GetInfo(me->piImage, &ii); if ((ii.cx == 0) || (ii.cy == 0)) { /* IIMAGE barfed */ RELEASEIF(me->piImage); ZEROAT(&ii); } else if (ii.bAnimated) { me->bSelfAnimated = TRUE; me->nFrame = -1; IIMAGE_SetParm(me->piImage, IPARM_REDRAW, (int)me->pfnInvalidate, (int)me->pInvalidateData); } else { uint16 uFrameWidth; if (me->uFrameWidth != 0) { uFrameWidth = me->uFrameWidth; } else { /* use the height, for square frames */ uFrameWidth = ii.cy; } me->nFrames = MAX(1,ii.cx/uFrameWidth); if ((me->nFrames * uFrameWidth) != ii.cx) { /* not exact frames, don't animate */ me->nFrames = 1; } else { ii.cx = uFrameWidth; /* fake out rect calc stuff below */ } if (0 == me->uFrameDuration) { me->uFrameDuration = 150; } IIMAGE_SetFrameCount(me->piImage, me->nFrames); me->nFrame = 0; /* Don't do this, run animation myself for invalidation code to work animate over 1 second... IIMAGE_SetAnimationRate(me->piImage, 1000/nFrames); */ } } /* initialize status rectangles */ /* if we found the image above and it's non-empty...*/ if (0 != ii.cy) { me->rcImage.y = me->rcCenter.y + ((me->rcCenter.dy - ii.cy) / 2) - 1; me->rcImage.x = me->rcCenter.x + ((me->rcCenter.dx - ii.cx) / 2) - 1; /* insist on square */ me->rcImage.dy = ii.cy + 2; me->rcImage.dx = ii.cx + 2; /* image too big for screen, fuggedaboudit */ if ((me->rcImage.dy > me->rcCenter.dy) || (me->rcImage.dx > me->rcCenter.dx)) { RELEASEIF(me->piImage); ZEROAT(&me->rcImage); } } else {/* no image, just text box... */ ZEROAT(&me->rcImage); } { int nAscent; int nDescent; IDISPLAY_GetFontMetrics(me->piDisplay,AEE_FONT_NORMAL, &nAscent,&nDescent); me->rcText.dy = nAscent + nDescent + 4; } if ((0 == me->rcImage.dy) || (me->rcImage.dy + me->rcText.dy - 1 > me->rcCenter.dy)) { me->rcText.y = me->rcCenter.y + ((me->rcCenter.dy - me->rcText.dy) / 2); } else { me->rcImage.y -= me->rcText.dy/2; me->rcText.y = me->rcImage.y + me->rcImage.dy - 1; } }