// this function is called when your application is starting up boolean PocketRocketForBrew_InitAppData(PocketRocketForBrew* pMe) { AECHAR os[] = {'B','r','e','w','\0'}; char resx[5]; char resy[5]; AECHAR wresx[5]; AECHAR wresy[5]; AECHAR url[512]; char curl[512]; AECHAR fchunk[] = {'?','O','S','=','B','r','e','w','&','H','E','I','G','H','T','=','\0'}; AECHAR schunk[] = {'&','W','I','D','T','H','=','\0'}; AECHAR tchunk[] = {'&','I','D','=','1','\0'}; // 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); // std::string a; STRCPY(url,XID_URL); // str itoa((int)pMe->DeviceInfo.cyScreen,resx,10); itoa((int)pMe->DeviceInfo.cxScreen,resy,10); STRTOWSTR(wresx,resx,strlen(resx)); STRTOWSTR(wresy,resy,strlen(resy)); //strcp STRCAT(url,fchunk); STRCAT(url,wresy); STRCAT(url,schunk); STRCAT(url,wresx); STRCAT(url,tchunk); WSTRTOSTR(curl,url,strlen(curl)); printf(url); //strcat( // Insert your code here for initializing or allocating resources... //XOsApplication *xosApplication = new XOsApplication("Testing"); // if there have been no failures up to this point then return success return TRUE; }
bool CContactInfo::SetValue(AECHAR **pwzValue, char *pszXml, char *pszTag) { FREEIF(*pwzValue); char *pszTmp=NULL; if ( SetValue(&pszTmp, pszXml, pszTag)) { if ( NULL!=pszTmp ) { int nLen = STRLEN(pszTmp); *pwzValue = (AECHAR*)MALLOC( (nLen+1)*sizeof(AECHAR)); if ( NULL==*pwzValue ) { FREEIF(pszTmp); return false; } STRTOWSTR(pszTmp, *pwzValue, (nLen+1)*sizeof(AECHAR)); FREEIF(pszTmp); } } return true; }
void test_sn_scene_draw(Bff *bff, Bff_Scene *scene) { /*clear screen*/ IDisplay *display = BFF_DISPLAY_OF(bff); AECHAR IMSI[50]; ITAPI* tapi = NULL; TestSceneData* data; data = (TestSceneData*)scene->getData(scene); IDISPLAY_SetColor(display, CLR_USER_BACKGROUND, MAKE_RGB(0xdd,0xdd,0xdd)); IDISPLAY_ClearScreen(display); if(ISHELL_CreateInstance(BFF_SHELL(), AEECLSID_TAPI, (void **)&tapi)==SUCCESS) { TAPIStatus status; if(ITAPI_GetStatus(tapi,&status)==SUCCESS) { STRTOWSTR(status.szMobileID,IMSI,sizeof(IMSI)*sizeof(AECHAR)); } ITAPI_Release(tapi); } drawString(IMSI,20,20,MAKE_RGB(0xFF,0xFF,0xFF),MAKE_RGB(0x00,0x00,0x00),AEE_FONT_NORMAL,IDS_LEFT|IDS_TOP); //TODO IDISPLAY_Update(BFF_DISPLAY_OF(bff)); }
void COMMON_WriteString(Common* common, const char* str) { int size = (STRLEN(str) + 1) * sizeof(AECHAR); AECHAR* wstr = (AECHAR*)MALLOC(size); STRTOWSTR(str, wstr, size); WSTRLCAT(common->message, wstr, common->size * sizeof(AECHAR)); FREE(wstr); return; }
/*=========================================================================== This function format double num to AECHAR, 3 pos hold ===========================================================================*/ AECHAR* TS_FLT2SZ_3(AECHAR* szBuf, double val) { #if 1 double tmp = 0, tt = 0, min = 0; int d = 0, m = 0; int zero_pad = 0; char strZero[4]; AECHAR szZero[16]; if (szBuf == NULL) return NULL; tmp = FABS(val); if (FCMP_GE(tmp, 0.001)) { tt = FFLOOR(tmp); d = FLTTOINT(tt); m = FLTTOINT(FMUL(FSUB(tmp, tt), 10000.0)); m = (m % 10 >= 5) ? (m + 10) / 10 : m / 10; if (m > 0) { if (m < 100) //0.012 { zero_pad++; } if (m < 10) //0.001 { zero_pad++; } //补充后面的0 if (zero_pad > 0) { STRNCPY(strZero, "000", zero_pad); strZero[zero_pad] = 0; STRTOWSTR(strZero, szZero, 16); } } } else { d = 0; m = 0; } if (zero_pad > 0) WSPRINTF(szBuf, 32, L"%d.%s%d", d, szZero, m); else WSPRINTF(szBuf, 32, L"%d.%d", d, m); return szBuf; #else FLOATTOWSTR(val, szBuf, 32); #endif }
bool CContactInfo::SetMultiValue(AECHAR **pwsValue, char *pszXml, char *pszMultiTag, char *pszSingleTag) { FREEIF(*pwsValue); char *pszData=NULL; if ( !SetValue(&pszData, pszXml, pszMultiTag)) return false; //<emls><eml>[email protected]</eml><eml>[email protected]</eml></emls> if ( NULL!=pszData ) { //create a temporary buffer char *pszTmp = (char*)MALLOC(STRLEN(pszData));//need to change this 100 add. we r adding null characters at the end of each if ( NULL==pszTmp ) return false; char pszT[20]; SPRINTF(pszT, "<%s>", pszSingleTag); AECHAR pwzNewTag[]=NEW_FIELD; char pszNewtag[10]; SPRINTF(pszNewtag, "%S", pwzNewTag); char *pszFound=NULL; char *pszNext = pszData; bool bCount=false; int nBufLen=0; while ( NULL != (pszFound=STRSTR(pszNext, pszT))) { if ( bCount ) { //add null charachter at the end //STRCAT(pszTmp, "\0"); //add new tag STRCAT(pszTmp, pszNewtag); } bCount = true; //find the end position SPRINTF(pszT, "</%s>", pszSingleTag); char *pszEndTag=NULL; pszEndTag=STRSTR(pszFound, pszT); if ( NULL==pszEndTag ) return false; int nLen=0; SPRINTF(pszT, "<%s>", pszSingleTag); int nTagLen = STRLEN(pszT); nLen = STRLEN(pszFound)-STRLEN(pszEndTag)-nTagLen; // len of <id>3 nBufLen = STRLEN(pszTmp); STRLCAT(pszTmp+nBufLen, pszFound+nTagLen, nLen+1); nBufLen = STRLEN(pszTmp); pszNext = pszFound+1; } DBGPRINTF(pszTmp); nBufLen = STRLEN(pszTmp); //convert and copy to return buffer *pwsValue = (AECHAR*)MALLOC((nBufLen+1)*sizeof(AECHAR)); if ( NULL==(*pwsValue) ) { FREEIF(pszData); FREEIF(pszTmp); return false; } STRTOWSTR(pszTmp, *pwsValue, (nBufLen+1)*sizeof(AECHAR)); FREEIF(pszData); FREEIF(pszTmp); } return true; }
/*======================================================================= Function: SamplePosDet_QosSettings_HandleEvent() Description: Event handler function for the QoS settings menu. Prototype: boolean SamplePosDet_QosSettings_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam) Parameters: pMe: [in]. CSamplePosDet instance. eCode: [in]. Event code. wParam: [in]. Event wParam. dwParam: [in]. Event dwParam. Return Value: TRUE - If the event was handled by this menu. FALSE - If the event was not handled. Comments: None Side Effects: None See Also: None =======================================================================*/ boolean SamplePosDet_QosSettings_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam) { boolean bHandled = FALSE; CTextCtlData *ptcd = SamplePosDet_GetScreenData( pMe ); ITextCtl *pTextCtl = NULL; IMenuCtl *pSoftKeyMenu = NULL; char * pszStr; AECHAR * pQos; uint32 nResult; if (ptcd) { pSoftKeyMenu = ptcd->pSoftKey; pTextCtl = ptcd->pTextCtl; } switch( eCode ) { case EVT_SCREEN: if( wParam == SCREEN_PARAM_INIT ) { if( pTextCtl ) { /* This is not expected to happen */ SamplePosDet_DrawScreen( pMe, 0 ); bHandled = TRUE; } else { if( ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_TEXTCTL, (void **)&pTextCtl ) == SUCCESS ) { if (ISHELL_CreateInstance(pMe->theApp.m_pIShell, AEECLSID_SOFTKEYCTL, (void **)&pSoftKeyMenu) == SUCCESS) { IMENUCTL_AddItem( pSoftKeyMenu, SAMPLEPOSDET_RES_FILE, IDS_SOFTKEY_SAVE, IDS_SOFTKEY_SAVE, NULL, (uint32)pSoftKeyMenu ); ITEXTCTL_SetSoftKeyMenu( pTextCtl, pSoftKeyMenu ); ITEXTCTL_SetTitle( pTextCtl, SAMPLEPOSDET_RES_FILE, IDS_QOS_SETTINGS_TITLE, NULL ); ITEXTCTL_SetInputMode( pTextCtl, AEE_TM_NUMBERS ); // Load the current QoS value, if it exists pszStr = MALLOC(50); pQos = MALLOC(100); SPRINTF(pszStr, "%d", pMe->gpsSettings.qos); STRTOWSTR(pszStr, pQos, 100); ITEXTCTL_SetText(pTextCtl, pQos, -1); FREE(pszStr); FREE(pQos); ptcd = MALLOC( sizeof(CTextCtlData) ); ptcd->pSoftKey = pSoftKeyMenu; ptcd->pTextCtl = pTextCtl; SamplePosDet_SetScreenData( pMe, (void *)ptcd ); SamplePosDet_DrawScreen( pMe, 0 ); bHandled = TRUE; } } } } else if( wParam == SCREEN_PARAM_CLOSE ) { ITEXTCTL_Release( pTextCtl ); IMENUCTL_Release( pSoftKeyMenu ); FREE( ptcd ); SamplePosDet_SetScreenData( pMe, 0 ); pMe->currentHandler = 0; bHandled = TRUE; } else if( wParam == SCREEN_PARAM_PAINT ) { if( ITEXTCTL_IsActive( pTextCtl ) ) { ITEXTCTL_Redraw( pTextCtl ); } else { ITEXTCTL_SetActive( pTextCtl, TRUE ); /* Also causes a menu draw */ } } break; case EVT_KEY: case EVT_KEY_PRESS: case EVT_KEY_RELEASE: bHandled = ITEXTCTL_HandleEvent( pTextCtl, eCode, wParam, dwParam ); if (!bHandled) { bHandled = IMENUCTL_HandleEvent( pSoftKeyMenu, eCode, wParam, dwParam ); if(!bHandled && wParam == AVK_CLR && eCode == EVT_KEY) { SamplePosDet_GotoScreen( pMe, SCREENID_CONFIG, 0 ); bHandled = TRUE; } } break; case EVT_COMMAND: bHandled = ITEXTCTL_HandleEvent( pTextCtl, eCode, wParam, dwParam ); if (!bHandled) { if (IDS_SOFTKEY_SAVE == wParam) { // Need to validate and save the Port settings here pQos = ITEXTCTL_GetTextPtr(pTextCtl); pszStr = MALLOC(50); WSTRTOSTR(pQos, pszStr, 50); nResult = STRTOUL(pszStr, NULL, 10); if (nResult >= 0 && nResult <= 255) { pMe->gpsSettings.qos = (AEEGPSQos)nResult; SamplePosDet_SaveGPSSettings(pMe); SamplePosDet_GotoScreen(pMe, SCREENID_CONFIG, 0); } else { ITEXTCTL_SetTitle(pTextCtl, SAMPLEPOSDET_RES_FILE, IDS_QOS_SETTINGS_INVALID, NULL); ITEXTCTL_Redraw(pTextCtl); } FREE(pszStr); bHandled = TRUE; } } break; } return bHandled; }
/*======================================================================= Function: SamplePosDet_PDESettings_HandleEvent() Description: Event handler function for the PDE settings menu. Prototype: boolean SamplePosDet_PDESettings_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam) Parameters: pMe: [in]. CSamplePosDet instance. eCode: [in]. Event code. wParam: [in]. Event wParam. dwParam: [in]. Event dwParam. Return Value: TRUE - If the event was handled by this menu. FALSE - If the event was not handled. Comments: None Side Effects: None See Also: None =======================================================================*/ boolean SamplePosDet_PDESettings_HandleEvent(CSamplePosDet *pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam) { AECHAR * pServer; uint32 nResult; boolean bHandled = FALSE; CTextCtlData *ptcd = SamplePosDet_GetScreenData( pMe ); ITextCtl *pTextCtl = NULL; IMenuCtl *pSoftKeyMenu = NULL; char * pszStr; if (ptcd) { pSoftKeyMenu = ptcd->pSoftKey; pTextCtl = ptcd->pTextCtl; } switch( eCode ) { case EVT_SCREEN: if( wParam == SCREEN_PARAM_INIT ) { if( pTextCtl ) { /* This is not expected to happen */ SamplePosDet_DrawScreen( pMe, 0 ); bHandled = TRUE; } else { if( ISHELL_CreateInstance( pMe->theApp.m_pIShell, AEECLSID_TEXTCTL, (void **)&pTextCtl ) == SUCCESS ) { if (ISHELL_CreateInstance(pMe->theApp.m_pIShell, AEECLSID_SOFTKEYCTL, (void **)&pSoftKeyMenu) == SUCCESS) { IMENUCTL_AddItem( pSoftKeyMenu, SAMPLEPOSDET_RES_FILE, IDS_SOFTKEY_SAVE, IDS_SOFTKEY_SAVE, NULL, (uint32)pSoftKeyMenu ); ITEXTCTL_SetSoftKeyMenu( pTextCtl, pSoftKeyMenu ); ITEXTCTL_SetTitle( pTextCtl, SAMPLEPOSDET_RES_FILE, IDS_PDE_SETTINGS_TITLE, NULL ); ITEXTCTL_SetInputMode( pTextCtl, AEE_TM_NUMBERS ); // Load the current IP address, if it exists if (AEEGPS_SERVER_IP == pMe->gpsSettings.server.svrType) { pszStr = MALLOC(50); INET_NTOA(pMe->gpsSettings.server.svr.ipsvr.addr, pszStr, 50); pServer = MALLOC(100); STRTOWSTR(pszStr, pServer, 100); ITEXTCTL_SetText(pTextCtl, pServer, -1); FREE(pszStr); FREE(pServer); } ptcd = MALLOC( sizeof(CTextCtlData) ); ptcd->pSoftKey = pSoftKeyMenu; ptcd->pTextCtl = pTextCtl; SamplePosDet_SetScreenData( pMe, (void *)ptcd ); SamplePosDet_DrawScreen( pMe, 0 ); bHandled = TRUE; } } } } else if( wParam == SCREEN_PARAM_CLOSE ) { ITEXTCTL_Release( pTextCtl ); IMENUCTL_Release( pSoftKeyMenu ); FREE( ptcd ); SamplePosDet_SetScreenData( pMe, 0 ); pMe->currentHandler = 0; bHandled = TRUE; } else if( wParam == SCREEN_PARAM_PAINT ) { if( ITEXTCTL_IsActive( pTextCtl ) ) { ITEXTCTL_Redraw( pTextCtl ); } else { ITEXTCTL_SetActive( pTextCtl, TRUE ); /* Also causes a menu draw */ } } break; case EVT_KEY: case EVT_KEY_PRESS: case EVT_KEY_RELEASE: bHandled = ITEXTCTL_HandleEvent( pTextCtl, eCode, wParam, dwParam ); if (!bHandled) { bHandled = IMENUCTL_HandleEvent( pSoftKeyMenu, eCode, wParam, dwParam ); if(!bHandled && wParam == AVK_CLR && eCode == EVT_KEY) { SamplePosDet_GotoScreen( pMe, SCREENID_SERVER_SETTINGS, 0 ); bHandled = TRUE; } } break; case EVT_COMMAND: bHandled = ITEXTCTL_HandleEvent( pTextCtl, eCode, wParam, dwParam ); if (!bHandled) { if (IDS_SOFTKEY_SAVE == wParam) { // Save the new IP address pServer = ITEXTCTL_GetTextPtr(pTextCtl); pszStr = MALLOC(50); WSTRTOSTR(pServer, pszStr, 50); if (INET_ATON(pszStr, &nResult)) { pMe->gpsSettings.server.svrType = AEEGPS_SERVER_IP; pMe->gpsSettings.server.svr.ipsvr.addr = nResult; SamplePosDet_SaveGPSSettings(pMe); SamplePosDet_GotoScreen(pMe, SCREENID_PORT_SETTINGS, 0); } else { ITEXTCTL_SetTitle(pTextCtl, SAMPLEPOSDET_RES_FILE, IDS_PDE_SETTINGS_INVALID, NULL); ITEXTCTL_Redraw(pTextCtl); } FREE(pszStr); // add code to save the new PDE IP address bHandled = TRUE; } } break; } return bHandled; }
/*============================================================================= FUNCTION c_SampleCameraApp_PrintStatus DESCRIPTION This is a helper function that will print to the screen the status for the application as well as the command that the soft keys control. PROTOTYPE: static void c_SampleCameraApp_PrintStatus(SampleCameraApp* pMe) PARAMETERS: pMe: Pointer to the applet data stucture DEPENDENCIES none RETURN VALUE none SIDE EFFECTS none =============================================================================*/ static void c_SampleCameraApp_PrintStatus(c_samplecamera* pMe) { int nErr = AEE_EFAILED; char *pszBuf = NULL; char pszBuf2[100]; AECHAR wszBuf[100]; int32 nMode = 0; //clear the screen IDisplay_ClearScreen(pMe->Applet.m_pIDisplay); //If zoom is supported update the screen with Zoom information if (pMe->bSupportZoom) { AEEParmInfo ZoomInfo; int32 nCurrentZoom; // retrieve the current setting and the parameter information nErr = ICAMERA_GetParm(pMe->pICamera, CAM_PARM_ZOOM, &nCurrentZoom, (int32 *)&ZoomInfo); if (nErr) DBGPRINTF("Unable to get CAM_PARM_ZOOM %d", pMe->nPreviewType); // create a string with the current value and the range of possible values SNPRINTF(pszBuf2, sizeof(pszBuf2), "Zoom %d(%d to %d)", nCurrentZoom, ZoomInfo.nMin, ZoomInfo.nMax); STRTOWSTR(pszBuf2, wszBuf, sizeof(wszBuf)); IDisplay_DrawText(pMe->Applet.m_pIDisplay, AEE_FONT_NORMAL, wszBuf, -1, pMe->ZoomStatusTextRect.x, pMe->ZoomStatusTextRect.y, &pMe->ZoomStatusTextRect, IDF_ALIGN_LEFT | IDF_ALIGN_TOP); //print our directions on how to control the zoom STRTOWSTR("Up/Dn to Zoom", wszBuf, sizeof(wszBuf)); IDisplay_DrawText(pMe->Applet.m_pIDisplay, AEE_FONT_NORMAL, wszBuf, -1, pMe->ZoomTextRect.x, pMe->ZoomTextRect.y, &pMe->ZoomTextRect, IDF_ALIGN_CENTER | IDF_ALIGN_TOP); } //Print out the current camera mode to the screen pszBuf = c_SampleCameraApp_GetModeStr(pMe); SNPRINTF(pszBuf2, sizeof(pszBuf2), "Mode: %s", pszBuf); STRTOWSTR(pszBuf2, wszBuf, sizeof(wszBuf)); IDisplay_DrawText(pMe->Applet.m_pIDisplay, AEE_FONT_NORMAL, wszBuf, -1, pMe->Status1TextRect.x, pMe->Status1TextRect.y, &pMe->Status1TextRect, IDF_ALIGN_LEFT | IDF_ALIGN_TOP); // Depending on the preview type display the file name that will store the // output of the camera's snapshot or video if (pMe->nPreviewType == CAM_PREVIEW_MOVIE) SNPRINTF(pszBuf2, sizeof(pszBuf2), "File Name: %s", MOVIE_FILE_NAME); else if (pMe->nPreviewType == CAM_PREVIEW_SNAPSHOT) SNPRINTF(pszBuf2, sizeof(pszBuf2), "File Name: %s", SNAPSHOT_FILE_NAME); STRTOWSTR(pszBuf2, wszBuf, sizeof(wszBuf)); IDisplay_DrawText(pMe->Applet.m_pIDisplay, AEE_FONT_NORMAL, wszBuf, -1, pMe->Status2TextRect.x, pMe->Status2TextRect.y, &pMe->Status2TextRect, IDF_ALIGN_LEFT | IDF_ALIGN_TOP); //Get the current mode of the camera, and update the screen to specify what // commands the first soft key controls ICAMERA_GetMode(pMe->pICamera, &nMode, NULL); if (nMode == CAM_MODE_READY) { if (pMe->nPreviewType == CAM_PREVIEW_MOVIE) pszBuf = "Switch to Snapshot"; else pszBuf = "Switch to Movie"; } else pszBuf = "Stop"; STRTOWSTR(pszBuf, wszBuf, sizeof(wszBuf)); IDisplay_DrawText(pMe->Applet.m_pIDisplay, AEE_FONT_NORMAL, wszBuf, -1, pMe->SoftKey1TextRect.x, pMe->SoftKey1TextRect.y, &pMe->SoftKey1TextRect, IDF_ALIGN_LEFT | IDF_ALIGN_BOTTOM); //Update the screen to specify what commands the second soft key controls switch (nMode) { case CAM_MODE_READY: pszBuf = "Preview"; break; case CAM_MODE_PREVIEW: { if (pMe->nPreviewType == CAM_PREVIEW_MOVIE) pszBuf = "RecordMovie"; else pszBuf = "RecordSnapshot"; break; } case CAM_MODE_MOVIE: pszBuf = ""; break; case CAM_MODE_SNAPSHOT: pszBuf = ""; break; } STRTOWSTR(pszBuf, wszBuf, sizeof(wszBuf)); IDisplay_DrawText(pMe->Applet.m_pIDisplay, AEE_FONT_NORMAL, wszBuf, -1, pMe->SoftKey2TextRect.x, pMe->SoftKey2TextRect.y, &pMe->SoftKey2TextRect, IDF_ALIGN_RIGHT | IDF_ALIGN_BOTTOM); // Update the screen with all of the changes IDisplay_Update(pMe->Applet.m_pIDisplay); }