// ================================================================================ // FUNCTION : AppendFieldTo // DESCRIPTION : Append AECHAR from source to destination // ================================================================================ bool CContactInfo::AppendFieldTo(AECHAR **psDes, AECHAR *psScr) { int nLen = WSTRLEN( psScr ); if ( NULL==*psDes ){ if ( !CopyFieldTo(psDes, psScr ) ) return false; } else { AECHAR* pBuf=NULL; AECHAR szNew[] = NEW_FIELD; int nDesLen = WSTRLEN( *psDes ); int newBufLen = nDesLen+ nLen+ WSTRLEN(szNew); pBuf = (AECHAR*)REALLOC( (void*)*psDes, (newBufLen+1)*sizeof(AECHAR) ); if ( NULL==pBuf ) return false; WSTRCAT( pBuf, szNew); WSTRLCAT(pBuf+ nDesLen+ WSTRLEN(szNew), psScr, nLen+1); *psDes = pBuf; } return true; }
/*=========================================================================== FUNCTION: ABR_AddContactRec DESCRIPTION: This function add a record to address book PARAMETERS: pMe [in] - Pointer to the CAddrBookRuim structure. This structure contains information specific to this applet. pTextName[in]- name field of record pTextNum[in]- telephone number field of record DEPENDENCIES: None RETURN VALUE: AEE_SUCCESS - IADDRBOOK_CreateRec () invocation was successful other - fail SIDE EFFECTS: None ===========================================================================*/ int32 ABR_AddContactRec( CAddrBookRuim *pMe, AEECLSID ContactCLS, AECHAR *pTextName, AECHAR *pTextNum) { AEEAddrField field[2]; // fields of a record int32 nRet = 0; // return code IAddrBook *pAddrBook; // check point if(pMe==NULL || pMe->pIShell==NULL || pTextName==NULL || pTextNum==NULL) { return -1; } // create instance of ADDRESS BOOK for RUIM if(!ISHELL_CreateInstance(pMe->pIShell, ContactCLS, (void **)&pAddrBook)) { IAddrRec *pRec; //Num field[0].fID = (ContactCLS==AEECLSID_ADDRBOOK_RUIM)? AEE_ADDRFIELD_PHONE_GENERIC:AEE_ADDRFIELD_PHONE_WORK; field[0].fType = AEEDB_FT_PHONE; field[0].pBuffer= pTextNum; field[0].wDataLen = (WSTRLEN(pTextNum)+1)*sizeof(AECHAR); //Name field[1].fID = AEE_ADDRFIELD_NAME; field[1].fType = AEEDB_FT_STRING; field[1].pBuffer= pTextName; field[1].wDataLen = (WSTRLEN(pTextName)+1)*sizeof(AECHAR); // create a record with 2 fields pRec = IADDRBOOK_CreateRec(pAddrBook, AEE_ADDR_CAT_NONE, (AEEAddrField*)field, 2); if(pRec) { IADDRREC_Release(pRec); nRet=0; // success } else { nRet=2; // IADDRBOOK_CreateRec fail; } IADDRBOOK_Release(pAddrBook); } else { nRet=1; // error : ISHELL_CreateInstance fail } DBGPRINTF("Add contact nRet = %d", nRet); return nRet; }
void CContactInfo::CountMultiFields(AECHAR *pwzField, int &nCount) { if (NULL==pwzField ) return; nCount++; AECHAR pwzNewTag[]=NEW_FIELD; char pszNewtag[10]; SPRINTF(pszNewtag, "%S", pwzNewTag); char *pszTmp=NULL; int nLen=WSTRLEN(pwzField); pszTmp = (char*)MALLOC(nLen+1); if ( NULL==pszTmp ) return; WSTRTOSTR(pwzField, pszTmp, nLen+1); char *pNext=pszTmp; char *pFound=NULL; while ( NULL!=(pFound=STRSTR(pNext, pszNewtag))) { nCount++; pNext = pFound+1; } FREEIF(pszTmp); }
void Tooltip_Redraw(Tooltip *me) { if (!me->bShown || (0 == WSTRLEN(me->pwsz))) { return; } me->rc.dx = IDISPLAY_MeasureText(me->piDisplay,AEE_FONT_NORMAL,me->pwsz)+4; me->rc.x = me->nX + (((me->nDx-me->rc.dx)*me->nXPercent)/100); me->rc.x = CONSTRAIN(me->rc.x, me->nX, (me->nX + me->nDx) - me->rc.dx); IDISPLAY_DrawText(me->piDisplay,AEE_FONT_NORMAL,me->pwsz,-1, me->rc.x+2,me->rc.y+2, &me->rc,IDF_RECT_FILL|IDF_RECT_FRAME); }
// ================================================================================ // FUNCTION : CopyFieldTo // DESCRIPTION : Create and copy a AECHAR from source to destination // ================================================================================ bool CContactInfo::CopyFieldTo(AECHAR **psDes, AECHAR *psScr) { int nLen = 0; if ( NULL==psScr ) return false; if ( NULL==(*psDes) ){ nLen = WSTRLEN( psScr ); *psDes = (AECHAR*)MALLOC( (nLen+1)*sizeof(AECHAR) ); if ( NULL==(*psDes) ) return false; WSTRLCPY(*psDes, psScr, nLen+1); } else return false; return true; }
/*=========================================================================== This function fits the text within the IStatic rectangle so that the scroll bar is not drawn. ===========================================================================*/ void TS_FitStaticText(IDisplay * pd, IStatic * ps, AEEFont font, AECHAR * pszText) { int nFits; AEERect rect; int nLen = WSTRLEN(pszText); AECHAR chSave = (AECHAR)0; ISTATIC_GetRect(ps, &rect); IDISPLAY_MeasureTextEx(pd, font, pszText, -1, rect.dx, &nFits); if (nFits < nLen) { chSave = pszText[nFits]; pszText[nFits] = (AECHAR)0; } ISTATIC_SetText(ps, NULL, pszText, AEE_FONT_NORMAL, font); if (nFits < nLen) pszText[nFits] = chSave; ISTATIC_Redraw(ps); }
void COMMON_Draw(Common* common) { IDisplay* d = common->display; int i = 0; int j = 0; int len = WSTRLEN(common->message); IDISPLAY_ClearScreen(d); common->lines = 0; while ((i < len - 1) && ((common->lines - common->start_line) * common->font_height < common->height)) { AECHAR t; int l; IDISPLAY_MeasureTextEx(d, AEE_FONT_NORMAL, common->message + i, len - i, common->width, &j); for (l = 0; l < j; l++) { if (common->message[i + l] == 0x0D || common->message[i + l] == '\n') { j = l; break; } } t = common->message[i + j]; common->message[i + j] = 0; if (common->start_line <= common->lines) { IDISPLAY_DrawText(d, AEE_FONT_NORMAL, common->message + i, -1, 0, (common->lines - common->start_line) * common->font_height, NULL, IDF_ALIGN_LEFT); } common->message[i + j] = t; i += j; if (t == 0x0D) { i += 2; } if (t == '\n') { i++; } common->lines++; } IDISPLAY_Update(d); return; }
// ================================================================================ // FUNCTION : IsSmsMatched // DESCRIPTION : Check wheather the sms matched with the filtered phone number.. // ================================================================================ boolean CDbHandler::IsSmsMatched(AECHAR *pszPhoneNo, char **pFilterAr, int nNo) { if ( 0==nNo ) return TRUE; char *pszTemp=NULL; int nLen= WSTRLEN(pszPhoneNo)+1; pszTemp = (char*)MALLOC(nLen); if (NULL==pszTemp) return FALSE; WSTRTOSTR(pszPhoneNo, pszTemp, nLen); //search the phone no in array for (int i=0; i<nNo; i++) { if ( 0==STRCMP(pFilterAr[i], pszTemp)) { FREEIF(pszTemp); return TRUE; } } FREEIF(pszTemp); return FALSE; }
void CContactInfo::FillMultiField(AEEAddrField *pField, int &nPos, AECHAR *pwzName, AEEAddrFieldID type) { // pwzName = [email protected]<NEW>[email protected] if (NULL==pwzName ) return; AECHAR pwzNewTag[]=NEW_FIELD; char pszNewtag[10]; SPRINTF(pszNewtag, "%S", pwzNewTag); int nTagLen = STRLEN(pszNewtag); char *pszTmp=NULL; int nLen=WSTRLEN(pwzName); pszTmp = (char*)MALLOC(nLen+1); if ( NULL==pszTmp ) return; WSTRTOSTR(pwzName, pszTmp, nLen+1); char *pNext=pszTmp; char *pFound=NULL; char *pValue=NULL; char *pEnd=NULL; int nValueLen =0; int nBufferPos=0; pValue = pNext; DBGPRINTF("%s", pValue); while ( NULL!=(pFound=STRSTR(pNext, pszNewtag))) { pField[nPos].fID = type; pField[nPos].fType = AEEDB_FT_STRING; nBufferPos = STRLEN(pszTmp)-STRLEN(pValue); pField[nPos].pBuffer = pwzName+ nBufferPos; //value lenth nValueLen = STRLEN(pValue)-STRLEN(pFound); DBGPRINTF("%s", pValue); pField[nPos].wDataLen = (nValueLen+1)*sizeof(AECHAR); nPos++; pNext = pFound+1; pValue = pFound+ nTagLen; } DBGPRINTF("%s", pValue); pField[nPos].fID = type; pField[nPos].fType = AEEDB_FT_STRING; nBufferPos = STRLEN(pszTmp)-STRLEN(pValue); pField[nPos].pBuffer = pwzName+ nBufferPos; nValueLen=STRLEN(pValue); pField[nPos].wDataLen = (nValueLen+1)*sizeof(AECHAR); nPos++; FREEIF(pszTmp); AECHAR *pwzSart=pwzName; AECHAR *pwzEnd=NULL; AECHAR pwzNull = '\0'; while ( NULL!=(pwzEnd=WSTRCHR(pwzSart, '<'))) { *pwzEnd='\0'; pwzSart = pwzEnd+4; } }
THREAD_RETURN WOLFSSH_THREAD client_test(void* args) { WOLFSSH_CTX* ctx = NULL; WOLFSSH* ssh = NULL; SOCKET_T sockFd = WOLFSSH_SOCKET_INVALID; SOCKADDR_IN_T clientAddr; socklen_t clientAddrSz = sizeof(clientAddr); char rxBuf[80]; int ret; int ch; word16 port = wolfSshPort; char* host = (char*)wolfSshIp; const char* username = NULL; const char* password = NULL; const char* cmd = NULL; byte imExit = 0; byte nonBlock = 0; byte keepOpen = 0; #ifdef USE_WINDOWS_API byte rawMode = 0; #endif int argc = ((func_args*)args)->argc; char** argv = ((func_args*)args)->argv; ((func_args*)args)->return_code = 0; while ((ch = mygetopt(argc, argv, "?NP:h:p:u:xc:Rtz")) != -1) { switch (ch) { case 'h': host = myoptarg; break; case 'z': #ifdef WOLFSSH_SHOW_SIZES wolfSSH_ShowSizes(); exit(EXIT_SUCCESS); #endif break; case 'p': port = (word16)atoi(myoptarg); #if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API) if (port == 0) err_sys("port number cannot be 0"); #endif break; case 'u': username = myoptarg; break; case 'P': password = myoptarg; break; case 'x': /* exit after successful connection without read/write */ imExit = 1; break; case 'N': nonBlock = 1; break; #if !defined(SINGLE_THREADED) && !defined(WOLFSSL_NUCLEUS) case 'c': cmd = myoptarg; break; #ifdef USE_WINDOWS_API case 'R': rawMode = 1; break; #endif /* USE_WINDOWS_API */ #endif #ifdef WOLFSSH_TERM case 't': keepOpen = 1; break; #endif case '?': ShowUsage(); exit(EXIT_SUCCESS); default: ShowUsage(); exit(MY_EX_USAGE); } } myoptind = 0; /* reset for test cases */ if (username == NULL) err_sys("client requires a username parameter."); #ifdef SINGLE_THREADED if (keepOpen) err_sys("Threading needed for terminal session\n"); #endif ctx = wolfSSH_CTX_new(WOLFSSH_ENDPOINT_CLIENT, NULL); if (ctx == NULL) err_sys("Couldn't create wolfSSH client context."); if (((func_args*)args)->user_auth == NULL) wolfSSH_SetUserAuth(ctx, wsUserAuth); else wolfSSH_SetUserAuth(ctx, ((func_args*)args)->user_auth); ssh = wolfSSH_new(ctx); if (ssh == NULL) err_sys("Couldn't create wolfSSH session."); if (password != NULL) wolfSSH_SetUserAuthCtx(ssh, (void*)password); wolfSSH_CTX_SetPublicKeyCheck(ctx, wsPublicKeyCheck); wolfSSH_SetPublicKeyCheckCtx(ssh, (void*)"You've been sampled!"); ret = wolfSSH_SetUsername(ssh, username); if (ret != WS_SUCCESS) err_sys("Couldn't set the username."); build_addr(&clientAddr, host, port); tcp_socket(&sockFd); ret = connect(sockFd, (const struct sockaddr *)&clientAddr, clientAddrSz); if (ret != 0) err_sys("Couldn't connect to server."); if (nonBlock) tcp_set_nonblocking(&sockFd); ret = wolfSSH_set_fd(ssh, (int)sockFd); if (ret != WS_SUCCESS) err_sys("Couldn't set the session's socket."); if (cmd != NULL) { ret = wolfSSH_SetChannelType(ssh, WOLFSSH_SESSION_EXEC, (byte*)cmd, (word32)WSTRLEN((char*)cmd)); if (ret != WS_SUCCESS) err_sys("Couldn't set the channel type."); } #ifdef WOLFSSH_TERM if (keepOpen) { ret = wolfSSH_SetChannelType(ssh, WOLFSSH_SESSION_TERMINAL, NULL, 0); if (ret != WS_SUCCESS) err_sys("Couldn't set the terminal channel type."); } #endif if (!nonBlock) ret = wolfSSH_connect(ssh); else ret = NonBlockSSH_connect(ssh); if (ret != WS_SUCCESS) { printf("err = %s\n", wolfSSH_get_error_name(ssh)); err_sys("Couldn't connect SSH stream."); } #if !defined(SINGLE_THREADED) && !defined(WOLFSSL_NUCLEUS) if (keepOpen) /* set up for psuedo-terminal */ SetEcho(2); if (cmd != NULL || keepOpen == 1) { #if defined(_POSIX_THREADS) thread_args arg; pthread_t thread[2]; arg.ssh = ssh; wc_InitMutex(&arg.lock); pthread_create(&thread[0], NULL, readInput, (void*)&arg); pthread_create(&thread[1], NULL, readPeer, (void*)&arg); pthread_join(thread[1], NULL); pthread_cancel(thread[0]); #elif defined(_MSC_VER) thread_args arg; HANDLE thread[2]; arg.ssh = ssh; arg.rawMode = rawMode; wc_InitMutex(&arg.lock); thread[0] = CreateThread(NULL, 0, readInput, (void*)&arg, 0, 0); thread[1] = CreateThread(NULL, 0, readPeer, (void*)&arg, 0, 0); WaitForSingleObject(thread[1], INFINITE); CloseHandle(thread[0]); CloseHandle(thread[1]); #else err_sys("No threading to use"); #endif if (keepOpen) SetEcho(1); } else #endif if (!imExit) { ret = wolfSSH_stream_send(ssh, (byte*)testString, (word32)strlen(testString)); if (ret <= 0) err_sys("Couldn't send test string."); do { ret = wolfSSH_stream_read(ssh, (byte*)rxBuf, sizeof(rxBuf) - 1); if (ret <= 0) { ret = wolfSSH_get_error(ssh); if (ret != WS_WANT_READ && ret != WS_WANT_WRITE) err_sys("Stream read failed."); } } while (ret == WS_WANT_READ || ret == WS_WANT_WRITE); rxBuf[ret] = '\0'; printf("Server said: %s\n", rxBuf); } ret = wolfSSH_shutdown(ssh); WCLOSESOCKET(sockFd); wolfSSH_free(ssh); wolfSSH_CTX_free(ctx); if (ret != WS_SUCCESS) err_sys("Closing stream failed. Connection could have been closed by peer"); #if defined(HAVE_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS) wc_ecc_fp_free(); /* free per thread cache */ #endif return 0; }
/*============================================================================= FUNCTION: CDialerApp_RecallDlg_Init DESCRIPTION: Initializes the controls for Calling dialog PARAMETERS: *pMe: CDialerApp object pointer RETURN VALUE: boolean: Returns TRUE if successful COMMENTS: SIDE EFFECTS: SEE ALSO: =============================================================================*/ boolean CDialerApp_RecallDlg_Init(CDialerApp *pMe) { #if defined(FEATURE_WCDMA) || defined(FEATURE_GSM) IDialog *pActiveDlg; IStatic *pIStatic; IMenuCtl *pISoftKeyMenu; AEERect StaticRect; AEERect MenuRect; AECHAR *pszRecall = NULL; AECHAR *pszName = NULL; CRecallDlgInfo *pDlgInfo = NULL; PRINT_FUNCTION_NAME(); // error checking if(pMe == NULL) { return FALSE; } pActiveDlg = CDialerApp_GetActiveDlg(pMe); // error checking if (pActiveDlg == NULL) { DIALER_ERR("Null pointer", 0,0,0); return FALSE; } pDlgInfo = (CRecallDlgInfo*) CDialerApp_GetActiveDlgInfo(pMe); // Get controls in dialog pIStatic = (IStatic*) IDIALOG_GetControl(pActiveDlg, IDC_STATIC_RECALL); pISoftKeyMenu = (IMenuCtl*)IDIALOG_GetControl(pActiveDlg, IDC_SK_RECALL); if((pIStatic == NULL) || (pISoftKeyMenu == NULL)) { DIALER_ERR("Null pointer", 0,0,0); return FALSE; // error } // init buffer pszRecall = (AECHAR*) MALLOC ((DIALERAPP_MAX_STR_SIZE)*sizeof(AECHAR)); if(pszRecall == NULL) { DIALER_ERR("No memory", 0,0,0); return FALSE; } pszName = (AECHAR*) MALLOC ((DIALERAPP_MAX_STR_SIZE)*sizeof(AECHAR)); if(pszName == NULL) { DIALER_ERR("No memory", 0,0,0); FREEIF(pszRecall); return FALSE; } // Update the softkey menu (void) IMENUCTL_DeleteAll(pISoftKeyMenu); if(AEECM_IS_VOICECALL_CONNECTED(pMe->m_pICM)) { (void) IMENUCTL_AddItem(pISoftKeyMenu, DIALERAPP_RES_FILE, IDS_HOLD_N_ACCEPT, IDL_RECALL_SK_HOLD_N_ACCEPT, NULL, 0); (void) IMENUCTL_AddItem(pISoftKeyMenu, DIALERAPP_RES_FILE, IDS_REL_N_ACCEPT, IDL_RECALL_SK_REL_N_ACCEPT, NULL, 0); } else { (void) IMENUCTL_AddItem(pISoftKeyMenu, DIALERAPP_RES_FILE, IDS_CALL, IDL_RECALL_SK_CALL, NULL, 0); } (void) IMENUCTL_AddItem(pISoftKeyMenu, DIALERAPP_RES_FILE, IDS_CANCEL, IDL_RECALL_SK_CANCEL, NULL, 0); SetDefaultSoftkeyLook(pMe->a.m_pIShell, pISoftKeyMenu); // Set Static control size ISTATIC_GetRect(pIStatic, &StaticRect); IMENUCTL_GetRect(pISoftKeyMenu, &MenuRect); SETAEERECT(&StaticRect, 10, 10, pMe->m_rc.dx-20, pMe->m_rc.dy-MenuRect.dy-20); // Static Info Properties ISTATIC_SetRect(pIStatic, &StaticRect); ISTATIC_SetActive(pIStatic, FALSE); ISTATIC_SetProperties(pIStatic, ST_MIDDLETEXT | ST_CENTERTEXT | ST_NOSCROLL); // Display name or number if(CheckAEEReturnStatus(ICM_GetCallInfo(pMe->m_pICM,pDlgInfo->callID, &(pMe->m_CallInfo), sizeof(AEECMCallInfo))) == TRUE) { CDialerApp_FormatNumberDisplayString(pMe, &(pMe->m_CallInfo), pszName, DIALERAPP_MAX_STR_SIZE, pMe->m_bNVAutoHyphen); (void) ISTATIC_SetText(pIStatic, pszName, NULL, AEE_FONT_BOLD, AEE_FONT_NORMAL); if(WSTRLEN(pMe->m_CallInfo.other_party_no) != 0) { if(pMe->m_bNVAutoHyphen == TRUE) { AECHAR *pszHyphen = CDialerApp_HyphenateNumberString( pMe->m_CallInfo.other_party_no); if(WSTRCMP(pszHyphen, pszName) != 0) { // want the phone number if it is not null and already being displayed (void) ISTATIC_SetTextEx(pIStatic, (byte*) "\n", NULL, TRUE); (void) ISTATIC_SetTextEx(pIStatic, (byte*) pszHyphen, NULL, TRUE); } FREEIF(pszHyphen); } else { if(WSTRCMP(pMe->m_CallInfo.other_party_no, pszName) != 0) { // want the phone number if it is not null and already being displayed (void) ISTATIC_SetTextEx(pIStatic, (byte*) "\n", NULL, TRUE); (void) ISTATIC_SetTextEx(pIStatic, (byte*) pMe->m_CallInfo.other_party_no, NULL, TRUE); } } } } (void) ISHELL_LoadResString(pMe->a.m_pIShell, DIALERAPP_RES_FILE, IDS_AVAILABLE, pszRecall, ((DIALERAPP_MAX_STR_SIZE)*sizeof(AECHAR))); (void) ISTATIC_SetTextEx(pIStatic, (byte*) pszRecall, NULL, TRUE); (void) IDIALOG_SetFocus(pActiveDlg, IDC_SK_RECALL); FREEIF(pszRecall); FREEIF(pszName); return TRUE; #else return FALSE; #endif // defined(FEATURE_WCDMA) || defined(FEATURE_GSM) }
/*============================================================================= FUNCTION: CDialerApp_CallingDlg_DisplayRefresh DESCRIPTION: Refreshes the calling dialog display PARAMETERS: *pMe: CDialerApp object pointer RETURN VALUE: boolean: Returns TRUE if successful COMMENTS: SIDE EFFECTS: SEE ALSO: =============================================================================*/ boolean CDialerApp_CallingDlg_DisplayRefresh(void *pUser) { CDialerApp *pMe = (CDialerApp*) pUser; IDialog *pActiveDlg; IStatic *pIStatic; AECHAR szCUGFormat[] = {'%','s',':',' ','%','u','\0'}; AECHAR *pszCUGBuf = NULL; AECHAR *pszName = NULL; PRINT_FUNCTION_NAME(); // error checking if(pMe == NULL) { DIALER_ERR("Null pointer", 0,0,0); return FALSE; } pActiveDlg = CDialerApp_GetActiveDlg(pMe); // error checking if (pActiveDlg == NULL) { DIALER_ERR("Null pointer", 0,0,0); return FALSE; } if(CDialerApp_GetActiveDlgID(pMe) != IDD_CALLING) { DIALER_ERR("Calling Dialog is not active", 0,0,0); return FALSE; } // Get controls in dialog pIStatic = (IStatic*) IDIALOG_GetControl(pActiveDlg, IDC_STATIC_CALLING); if(pIStatic == NULL) { DIALER_ERR("Null pointer", 0,0,0); return FALSE; // error } // init buffer pszName = (AECHAR*) MALLOC ((DIALERAPP_MAX_STR_SIZE)*sizeof(AECHAR)); pszCUGBuf = (AECHAR*) MALLOC ((DIALERAPP_MAX_STR_SIZE)*sizeof(AECHAR)); if((pszName== NULL) || (pszCUGBuf == NULL)) { DIALER_ERR("No memory", 0,0,0); FREEIF(pszName); FREEIF(pszCUGBuf); return FALSE; } // display all of the needed info to the screen if(CheckAEEReturnStatus(ICM_GetCallInfo(pMe->m_pICM, pMe->m_byCurrOrigCall, &(pMe->m_CallInfo), sizeof(AEECMCallInfo))) == FALSE) { DIALER_ERR("ICM_GetCallInfo FAILED", 0, 0, 0); FREEIF(pszName); FREEIF(pszCUGBuf); return TRUE; } // display the other party number and name if any in contacts CDialerApp_FormatNumberDisplayString(pMe, &(pMe->m_CallInfo), pszName, DIALERAPP_MAX_STR_SIZE, pMe->m_bNVAutoHyphen); (void) ISTATIC_SetTextEx(pIStatic, (byte*) pszName, NULL, FALSE); if(WSTRLEN(pMe->m_CallInfo.other_party_no) != 0) { if(pMe->m_bNVAutoHyphen == TRUE) { AECHAR *pszHyphen = CDialerApp_HyphenateNumberString(pMe->m_CallInfo.other_party_no); if(WSTRCMP(pszHyphen, pszName) != 0) { // want the phone number if it is not null and already being displayed (void) ISTATIC_SetTextEx(pIStatic, (byte*) "\n", NULL, TRUE); (void) ISTATIC_SetTextEx(pIStatic, (byte*) pszHyphen, NULL, TRUE); } FREEIF(pszHyphen); } else { if(WSTRCMP(pMe->m_CallInfo.other_party_no, pszName) != 0) { // want the phone number if it is not null and already being displayed (void) ISTATIC_SetTextEx(pIStatic, (byte*) "\n", NULL, TRUE); (void) ISTATIC_SetTextEx(pIStatic, (byte*) pMe->m_CallInfo.other_party_no, NULL, TRUE); } } } // check for CUG info if(pMe->m_CallInfo.forward_cug_info.cm_cug_index.present == TRUE) { // display CUG info (void) ISHELL_LoadResString(pMe->a.m_pIShell, DIALERAPP_RES_FILE, IDS_USERGROUP, pszName, ((DIALERAPP_MAX_STR_SIZE) * sizeof(AECHAR))); WSPRINTF(pszCUGBuf, (DIALERAPP_MAX_STR_SIZE)*sizeof(AECHAR), szCUGFormat, pszName, ((uint16)((pMe->m_CallInfo.forward_cug_info.cm_cug_index.msb << 8)|(pMe->m_CallInfo.forward_cug_info.cm_cug_index.lsb)))); (void) ISTATIC_SetTextEx(pIStatic, (byte*) "\n", NULL, TRUE); (void) ISTATIC_SetTextEx(pIStatic, (byte*) "\n", NULL, TRUE); (void) ISTATIC_SetTextEx(pIStatic, (byte*) pszCUGBuf, NULL, TRUE); } // check for alpha if(WSTRLEN(pMe->m_CallInfo.alpha) > 0) { // display alpha (void) ISTATIC_SetTextEx(pIStatic, (byte*) "\n", NULL, TRUE); (void) ISTATIC_SetTextEx(pIStatic, (byte*) "\n", NULL, TRUE); (void) ISTATIC_SetTextEx(pIStatic, (byte*) pMe->m_CallInfo.alpha, NULL, TRUE); } if(pMe->m_CallInfo.call_type == AEECM_CALL_TYPE_EMERGENCY) { AEECMSSInfo SSInfo; // reset the timer (void) ISHELL_SetTimer(pMe->a.m_pIShell, 1000, (PFNNOTIFY) CDialerApp_CallingDlg_DisplayRefresh, (void*) pMe); if(CheckAEEReturnStatus(ICM_GetSSInfo(pMe->m_pICM, &SSInfo, sizeof(AEECMSSInfo))) == TRUE) { if(SSInfo.srv_status == AEECM_SRV_STATUS_NO_SRV) { // we want to display looking for service (void) ISHELL_LoadResString(pMe->a.m_pIShell, DIALERAPP_RES_FILE, IDS_LOOKINGFOREMERGENCY, pszName, (DIALERAPP_MAX_STR_SIZE * sizeof(AECHAR))); (void) ISTATIC_SetTextEx(pIStatic, (byte*) "\n", NULL, TRUE); (void) ISTATIC_SetTextEx(pIStatic, (byte*) "\n", NULL, TRUE); (void) ISTATIC_SetTextEx(pIStatic, (byte*) pszName, NULL, TRUE); } } } IDIALOG_Redraw(pActiveDlg); // free memory FREE(pszName); FREE(pszCUGBuf); return TRUE; }
/*============================================================================= FUNCTION: CDialerApp_SSRequestDlg_Init DESCRIPTION: Initializes the controls for SS Request dialog PARAMETERS: *pMe: CDialerApp object pointer RETURN VALUE: boolean: Returns TRUE if successful COMMENTS: SIDE EFFECTS: SEE ALSO: =============================================================================*/ boolean CDialerApp_SSRequestDlg_Init(CDialerApp *pMe) { #if defined(FEATURE_WCDMA) || defined(FEATURE_GSM) IDialog *pActiveDlg; IStatic *pIStatic; IMenuCtl *pISoftKeyMenu; AEERect StaticRect; AEERect MenuRect; AECHAR *pszStrBeg = NULL; AECHAR *pszStrEnd = NULL; AECHAR *pszBuf = NULL; AECHAR szFormat[] = {'%','s',' ','%','s','\0'}; CSSRequestDlgInfo *pDlgInfo = NULL; uint16 wIDSOp; PRINT_FUNCTION_NAME(); // error checking if(pMe == NULL) { return FALSE; } pActiveDlg = CDialerApp_GetActiveDlg(pMe); // error checking if (pActiveDlg == NULL) { DIALER_ERR("Null pointer", 0,0,0); return FALSE; } pDlgInfo = (CSSRequestDlgInfo*) CDialerApp_GetActiveDlgInfo(pMe); if(pDlgInfo == NULL) { DIALER_ERR("NULL Pointer", 0,0,0); return FALSE; } // Get controls in dialog pIStatic = (IStatic*) IDIALOG_GetControl(pActiveDlg, IDC_STATIC_SSREQUEST); pISoftKeyMenu = (IMenuCtl*)IDIALOG_GetControl(pActiveDlg, IDC_SK_SSREQUEST); if((pIStatic == NULL) || (pISoftKeyMenu == NULL)) { DIALER_ERR("Null pointer", 0,0,0); return FALSE; // error } // init buffer pszBuf = (AECHAR*) MALLOC ((DIALERAPP_MAX_STR_SIZE+DIALERAPP_MAX_NOTIF_BUFFER_SIZE)*sizeof(AECHAR)); pszStrBeg = (AECHAR*) MALLOC ((DIALERAPP_MAX_NOTIF_BUFFER_SIZE)*sizeof(AECHAR)); pszStrEnd = (AECHAR*) MALLOC ((DIALERAPP_MAX_STR_SIZE)*sizeof(AECHAR)); if((pszBuf == NULL) || (pszStrBeg == NULL) || (pszStrEnd == NULL)) { DIALER_ERR("No memory", 0,0,0); FREEIF(pszBuf); FREEIF(pszStrBeg); FREEIF(pszStrEnd); return FALSE; } switch(pDlgInfo->ssCode) { case AEESUPPSVC_CLIP: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_CLIP; break; case AEESUPPSVC_CLIR: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_CLIR; break; case AEESUPPSVC_COLP: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_COLP; break; case AEESUPPSVC_COLR: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_COLR; break; case AEESUPPSVC_ALL_FORWARDING_SS: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_ALL_FORWARDING_SS; break; case AEESUPPSVC_CFU: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_CFU; break; case AEESUPPSVC_ALL_CONDFWD_SS: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_ALL_CONDFWD_SS; break; case AEESUPPSVC_CFB: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_CFB; break; case AEESUPPSVC_CFNRY: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_CFNRY; break; case AEESUPPSVC_CFNRC: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_CFNRC; break; case AEESUPPSVC_CW: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_CW; break; case AEESUPPSVC_ALL_CALL_RSTRCT_SS: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_ALL_CALL_RSTRCT_SS; break; case AEESUPPSVC_BARRING_OUTGOING_CALLS: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_BARRING_OUTGOING_CALLS; break; case AEESUPPSVC_BAOC: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_BAOC; break; case AEESUPPSVC_BOIC: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_BOIC; break; case AEESUPPSVC_BOIC_EXHC: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_BOIC_EXHC; break; case AEESUPPSVC_BARRING_OF_INCOMING_CALLS: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_BARRING_OF_INCOMING_CALLS; break; case AEESUPPSVC_BAIC: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_BAIC; break; case AEESUPPSVC_BICROAM: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_BICROAM; break; case AEESUPPSVC_CCBS: wIDSOp = IDS_SUPPSYS_SS_CODE_E_TYPE_CCBS; break; default: wIDSOp = IDS_SS; break; } (void) ISHELL_LoadResString(pMe->a.m_pIShell, DIALERAPP_RES_FILE, wIDSOp, pszStrBeg, ((DIALERAPP_MAX_NOTIF_BUFFER_SIZE)*sizeof(AECHAR))); (void) ISHELL_LoadResString(pMe->a.m_pIShell, DIALERAPP_RES_FILE, IDS_REQUESTING, pszStrEnd, ((DIALERAPP_MAX_STR_SIZE)*sizeof(AECHAR))); WSPRINTF(pszBuf, (sizeof(AECHAR)*(DIALERAPP_MAX_NOTIF_BUFFER_SIZE+DIALERAPP_MAX_STR_SIZE)), szFormat, pszStrBeg, pszStrEnd); // Update the softkey menu (void) IMENUCTL_DeleteAll(pISoftKeyMenu); (void) IMENUCTL_AddItem(pISoftKeyMenu, DIALERAPP_RES_FILE, IDS_CANCELSSREQUEST, IDL_SK_SSREQUEST_CANCEL, NULL, 0); SetDefaultSoftkeyLook(pMe->a.m_pIShell, pISoftKeyMenu); // Set Static control size ISTATIC_GetRect(pIStatic, &StaticRect); IMENUCTL_GetRect(pISoftKeyMenu, &MenuRect); SETAEERECT(&StaticRect, 10, 10, pMe->m_rc.dx-20, pMe->m_rc.dy-MenuRect.dy-20); // Static Info Properties ISTATIC_SetRect(pIStatic, &StaticRect); ISTATIC_SetActive(pIStatic, FALSE); ISTATIC_SetProperties(pIStatic, ST_MIDDLETEXT | ST_CENTERTEXT | ST_NOSCROLL); // check if alpha should be displayed if(WSTRLEN(pDlgInfo->szAlpha) > 0) { (void) ISTATIC_SetText(pIStatic, NULL, pDlgInfo->szAlpha, AEE_FONT_BOLD, AEE_FONT_BOLD); } else { (void) ISTATIC_SetText(pIStatic, NULL, pszBuf, AEE_FONT_BOLD, AEE_FONT_BOLD); } (void) IDIALOG_SetFocus(pActiveDlg, IDC_SK_SSREQUEST); FREE(pszBuf); FREE(pszStrBeg); FREE(pszStrEnd); return TRUE; #else return FALSE; #endif /* defined(FEATURE_WCDMA) || defined(FEATURE_GSM) */ }
/*=========================================================================== FUNCTION: DisplayOutput DESCRIPTION This function displays an output string at a given line number on the screen. If the nline parameter is a negative value (-1) the string is displayed in the middle of the screen. If the "nline" value is larger than or equal to zero the "nline" value is multiplied by 15 and the resulting value in pixels is set to the y-coordinate of the start of the string display on the screen. If the string does not fit on one line the string wraps around to the next line (spaced rougly 10-15 pixels apart). By default 5 is used as the starting the x-coordinate of a displayed string. How many characters that fit on one line is calculated for each line that is wrapped around to the next line. Note: depending on the phone screen size and the fonts used for characters the output might differ on different handsets (devices). Where some handsets will have a smaller screen and large default fonts which will cause partial overlapping of lines. This function does not try to address these issues (this is meant as a simple display function). PROTOTYPE: int DisplayOutput(IShell *pIShell, IDisplay *pDisplay, int nline, char *pszStr, AECHAR *pszwStr, boolean isWideChar) PARAMETERS: pIShell: [in]: Contains a pointer to the IShell interface. pIDisplay: [in]: Contains a pointer to the IDisplay interface. nline: [in]: Contains the line number to start displaying the text. The line numbers are by default spaced 15 pixels apart along the y-axis. pszStr: [in]: The character string to be displayed on the screen. DEPENDENCIES None RETURN VALUE Number of lines written to the screen. SIDE EFFECTS None ===========================================================================*/ static int DisplayOutput(IShell *pIShell, IDisplay *pIDisplay, int nline, char *pszStr, AECHAR *pszwStr, boolean isWideChar) { AEEDeviceInfo di; // Device Info AECHAR * szBuf; // a buffer that supports 200 char string AECHAR * psz = NULL; int charHeight = 0; // Stores the char height in pixels for given font int pnAscent = 0; // Stores the ascent in number of pixels int pnDescent = 0; // Stores the descent in number of pixels int pixelWidth; AEEFont font = AEE_FONT_NORMAL; int pnFits = 0, dy; int totalCh = 0; int numLinesPrinted = 0; // Make sure the pointers we'll be using are valid if (pIShell == NULL || pIDisplay == NULL) { return 0; } if ((szBuf = (AECHAR *) MALLOC(TEXT_BUFFER_SIZE)) == NULL) { return 0; } // Get device information ISHELL_GetDeviceInfo(pIShell,&di); // Get the font metrics info charHeight = IDISPLAY_GetFontMetrics (pIDisplay, AEE_FONT_NORMAL, &pnAscent, &pnDescent); if(isWideChar) { WSTRCPY(szBuf,pszwStr); } else { // Convert to wide string (unicode) STR_TO_WSTR ((char *)pszStr, szBuf, TEXT_BUFFER_SIZE); } // If nlines is zero then print this string starting around the middle of // the screen. Or else multiply nlines by charheight to decide the y coordinate of // the start of the string. if (nline < 0) { dy = di.cyScreen*2/5; } else{ dy = nline * charHeight + 5; } // psz keeps track of the point from which to write from the string buffer // in case the string does not fit one line and needs to wrap around in the // next line. psz = szBuf; // Need to calculate the lotal string length to decide if any wrapping // around is needed. if(isWideChar) { totalCh = 2*WSTRLEN (pszwStr); } else { totalCh = STRLEN ((char *)pszStr); } // Keep displaying text string on multiple lines if the string can't be displayed // on one single line. Lines are spaced 15 pixels apart. while ((totalCh > 0) && (*psz != NULL)) { // Get information on how many characters will fit in a line. // Give the pointer to the buffer to be displayed, and the number of // pixels along the x axis you want to display the string in (max number) // pnFits will have the max number of chars that will fit in the maxWidth // number of pixels (given string can't fit in one line), or the number of // chars in the string (if it does fit in one line). pnWidth gives the // number of pixels that will be used to display pnFits number of chars. pixelWidth = IDISPLAY_MeasureTextEx(pIDisplay, font, (AECHAR *) psz, // Start of the buffer to display, -1, di.cxScreen - 5, // maxWidth &pnFits); // Number of chars that will fit a line // If pnFits is zero there is something wrong in the input to above function. // Normally this scenario should not occur. But, have the check anyway. if (pnFits == 0) { FREE(szBuf); return 0; } IDISPLAY_DrawText(pIDisplay, AEE_FONT_NORMAL, psz, pnFits, 5 /*start dx*/, dy, 0 /* use default rectangle coordinates */, 0); psz += pnFits; // move pointer to the next segment to be displayed totalCh -= pnFits; // reduce the total number of characters to still display dy += charHeight; // Place next line charHeight pixels below the // previous line. ++numLinesPrinted; IDISPLAY_Update(pIDisplay); //, TRUE); if (totalCh < pnFits) pnFits = totalCh; // if total number is less than pnFits, adjust pnFits } FREE(szBuf); return numLinesPrinted; } // End of DisplayOutput
/*=========================================================================== FUNCTION: IFileUsage DESCRIPTION This function executes the usage example selected from the main menu by the user. It takes as input the app data pointer and the ID of the example the user selected. After clearing the screen, the selected example is executed. Each example is a self-contained code block that contains any local variables needed to execute the example. Each code block also creates and releases any BREW interfaces that are required, and will exit if any errors are detected. Once the example has been executed, this function prints a heading at the top of the screen to indicate which example was selected, and a message at the bottom of the screen instructing the user how to return to the main menu to execute another example. PROTOTYPE: static void IFileUsage(ISmsApp * pMe, uint16 wParam) PARAMETERS: pMe: [in]: Contains a pointer to the usage app data structure. wParam: [in]: Identifier of the selected example (example IDs are specified when the main usage app menu is created). DEPENDENCIES None RETURN VALUE None SIDE EFFECTS None ===========================================================================*/ static void ISmsAppUsage (ISmsApp * pMe, uint16 wParam) { // Make sure the pointers we'll be using are valid if (pMe == NULL || pMe->a.m_pIShell == NULL || pMe->a.m_pIDisplay == NULL) return; // Erase screen first for display output purposes. DisplayEvent (pMe, USAGE_ERASE_SCREEN); IMENUCTL_SetProperties(pMe->m_pIMenu, MP_NO_REDRAW); IMENUCTL_SetActive(pMe->m_pIMenu, FALSE); // Initialize line number where we will start the output // of each test pMe->m_cLineNum = 1; switch (wParam) { case USAGE_SMS_TX_ASCII: { int nErr; WebOpt awo[6]; /* ***IMPORTANT**** grow this if you add more WebOpts here, or shrink it and call AddOpt() multiple times */ int i = 0; uint32 nReturn=0; nErr =ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SMSMSG, (void **)&pMe->m_pISMSMsg); DBGPRINTF("CreateInstance of AEECLSID_SMSMSG ret %d", nErr); if(nErr != AEE_SUCCESS) { break; } /* NULL terminated string providing destination device number. '+' as first character signifies international number. */ awo[i].nId = MSGOPT_TO_DEVICE_SZ ; awo[i].pVal = (void *)DESTINATION_NUMBER; i++; /* ascii text to be send */ awo[i].nId = MSGOPT_PAYLOAD_SZ ; awo[i].pVal = (void *)MO_TEXT_ASCII; i++; /* encoding */ awo[i].nId = MSGOPT_PAYLOAD_ENCODING; awo[i].pVal = (void *)AEE_ENC_ISOLATIN1; i++; awo[i].nId = MSGOPT_MOSMS_ENCODING; awo[i].pVal = (void *)AEESMS_ENC_ASCII; i++; #if 0 /* user ack */ awo[i].nId = MSGOPT_USER_ACK; awo[i].pVal = (void *)TRUE; i++; #endif /* this is absolutely necessary, do not remove, marks the end of the array of WebOpts */ awo[i].nId = WEBOPT_END; /* add 'em */ nErr =ISMSMSG_AddOpt(pMe->m_pISMSMsg, awo); DBGPRINTF("ISMSMSG_AddOpt ret %d", nErr); CALLBACK_Init(&pMe->m_cb, SMSCallBack_Send, pMe); ISMS_SendMsg(pMe->m_pISMS, pMe->m_pISMSMsg, &pMe->m_cb, &nReturn); // Higher 16 bits specify error type specified as AEESMS_ERRORTYPE_XXX // lower 16 bits specify error specified as AEESMS_ERROR_XXX DBGPRINTF("ISMS_SendMsg ret 0x%x", nReturn); } break; case USAGE_SMS_TX_UNICODE: { int nErr; WebOpt awo[6]; /* ***IMPORTANT**** grow this if you add more WebOpts here, or shrink it and call AddOpt() multiple times */ int i = 0; uint32 nReturn=0; AECHAR pszBuf[100]; nErr =ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SMSMSG, (void **)&pMe->m_pISMSMsg); DBGPRINTF("CreateInstance of AEECLSID_SMSMSG ret %d", nErr); if(nErr != AEE_SUCCESS) { break; } /* NULL terminated string providing destination device number. '+' as first character signifies international number. */ awo[i].nId = MSGOPT_TO_DEVICE_SZ ; awo[i].pVal = (void *)DESTINATION_NUMBER; i++; /* unicode text to be send */ awo[i].nId = MSGOPT_PAYLOAD_WSZ ; ISHELL_LoadResString(pMe->a.m_pIShell, ISMS_RES_FILE, IDS_MO_TEXT_UNICODE, pszBuf, sizeof(pszBuf)); awo[i].pVal = (void *)pszBuf; i++; /* encoding */ awo[i].nId = MSGOPT_PAYLOAD_ENCODING; awo[i].pVal = (void *)AEE_ENC_UNICODE ; i++; awo[i].nId = MSGOPT_MOSMS_ENCODING; awo[i].pVal = (void *)AEESMS_ENC_UNICODE; i++; #if 0 /* user ack */ awo[i].nId = MSGOPT_READ_ACK; awo[i].pVal = (void *)TRUE; i++; #endif /* this is absolutely necessary, do not remove, marks the end of the array of WebOpts */ awo[i].nId = MSGOPT_END; /* add 'em */ nErr =ISMSMSG_AddOpt(pMe->m_pISMSMsg, awo); DBGPRINTF("ISMSMSG_AddOpt ret %d", nErr); CALLBACK_Init(&pMe->m_cb, SMSCallBack_Send, pMe); ISMS_SendMsg(pMe->m_pISMS, pMe->m_pISMSMsg, &pMe->m_cb, &nReturn); // Higher 16 bits specify error type specified as AEESMS_ERRORTYPE_XXX // lower 16 bits specify error specified as AEESMS_ERROR_XXX DBGPRINTF("ISMS_SendMsg ret 0x%x", nReturn); } break; case USAGE_SMS_TX_UTF8: { int nErr; WebOpt awo[6]; /* ***IMPORTANT**** grow this if you add more WebOpts here, or shrink it and call AddOpt() multiple times */ int i = 0; uint32 nReturn=0; char utf8_Buf_Sending[302]; uint16 count; // in utf-8 "数组19英文English混合" with heading of two bytes for length -0x0010 // The length is little-endian, low byte first. char cTextUTF8[142]= {0xFF, 0xFE, 0x70, 0x65,0x57, 0x5B, 0x31, 0x0, 0x39, 0x0, 0xF1, 0x82, 0x87, 0x65, 0x45, 0x0, 0x6E, 0x0, 0x67, 0x0, 0x6c, 0x0, 0x69, 0x0, 0x73, 0x0, 0x68, 0x0, 0xF7, 0x6D, 0x08, 0x54, 0x0, 0x0 }; //char cTextUTF8[142]={0x1e, 0x0, // 0xEF, 0xBB, 0xBF, 0xE6,0x95, 0xB0, 0xE7, 0xBB, 0x84, 0x31, 0x39, 0xE8, 0x8B, 0x8B, 0xB1, 0xE6, 0x96, // 0x87, 0x45, 0x6E, 0x67, 0x6c, 0x69, 0x73, 0x68, 0xE6, 0xB7, 0xB7, 0xE5, 0x90, 0x88 }; nErr =ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SMSMSG, (void **)&pMe->m_pISMSMsg); DBGPRINTF("CreateInstance of AEECLSID_SMSMSG ret %d", nErr); if(nErr != AEE_SUCCESS) { break; } /* NULL terminated string providing destination device number. '+' as first character signifies international number. */ awo[i].nId = MSGOPT_TO_DEVICE_SZ ; awo[i].pVal = (void *)DESTINATION_NUMBER; i++; /* unicode text to be send */ awo[i].nId = MSGOPT_PAYLOAD_BINARY; MEMSET(utf8_Buf_Sending, 0, sizeof(utf8_Buf_Sending)); WSTRTOUTF8((AECHAR *)cTextUTF8, WSTRLEN((AECHAR *)cTextUTF8), (byte *)&(utf8_Buf_Sending[2]), 300); count = STRLEN(&(utf8_Buf_Sending[2])); DBGPRINTF("WLen(%d)===> count=%d", WSTRLEN((AECHAR *)cTextUTF8),count); DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[0], utf8_Buf_Sending[1], utf8_Buf_Sending[2], utf8_Buf_Sending[3] ); DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[4], utf8_Buf_Sending[5], utf8_Buf_Sending[6], utf8_Buf_Sending[7] ); DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[8], utf8_Buf_Sending[9], utf8_Buf_Sending[10], utf8_Buf_Sending[11] ); DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[12], utf8_Buf_Sending[13], utf8_Buf_Sending[14], utf8_Buf_Sending[15] ); DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[16], utf8_Buf_Sending[17], utf8_Buf_Sending[18], utf8_Buf_Sending[19] ); utf8_Buf_Sending[0]=count & 0xff; utf8_Buf_Sending[1]=(count>>8) & 0xff; awo[i].pVal = (void *)utf8_Buf_Sending; i++; /* encoding */ awo[i].nId = MSGOPT_PAYLOAD_ENCODING; awo[i].pVal = (void *)AEE_ENC_UTF8 ; i++; awo[i].nId = MSGOPT_MOSMS_ENCODING; awo[i].pVal = (void *)AEESMS_ENC_OCTET; i++; #if 0 /* user ack */ awo[i].nId = MSGOPT_READ_ACK; awo[i].pVal = (void *)TRUE; i++; #endif /* this is absolutely necessary, do not remove, marks the end of the array of WebOpts */ awo[i].nId = MSGOPT_END; /* add 'em */ nErr =ISMSMSG_AddOpt(pMe->m_pISMSMsg, awo); DBGPRINTF("ISMSMSG_AddOpt ret %d", nErr); CALLBACK_Init(&pMe->m_cb, SMSCallBack_Send, pMe); ISMS_SendMsg(pMe->m_pISMS, pMe->m_pISMSMsg, &pMe->m_cb, &nReturn); // Higher 16 bits specify error type specified as AEESMS_ERRORTYPE_XXX // lower 16 bits specify error specified as AEESMS_ERROR_XXX DBGPRINTF("ISMS_SendMsg ret 0x%x", nReturn); } break; case USAGE_SMS_RX_TAPI_METHOD: { // 使用TAPI的notify机制接收短信 AEECLSID clsNotifier= AEECLSID_TAPI; // Event sender AEECLSID clsNotify = AEECLSID_ISMS; // Event listener // Set the notify event to be NOTIFY_MASK_EVENT. This event is used // as an example. uint32 dwMask = NMASK_TAPI_SMS_TEXT; int nErr; // Register a notification nErr = ISHELL_RegisterNotify (pMe->a.m_pIShell, clsNotify, clsNotifier, dwMask); DBGPRINTF("ISHELL_RegisterNotify ret %d", nErr); } break; case USAGE_SMS_RX_ISMS_METHOD: { // 使用新的AEECLSID_SMSNOTIFIER 的notify机制接收短信 AEECLSID clsNotifier= AEECLSID_SMSNOTIFIER; // Event sender AEECLSID clsNotify = AEECLSID_ISMS; // Event listener // Set the notify event to be NOTIFY_MASK_EVENT. This event is used // as an example. uint32 dwMask = ((AEESMS_TYPE_TEXT << 16) | NMASK_SMS_TYPE); int nErr; // Register a notification nErr = ISHELL_RegisterNotify (pMe->a.m_pIShell, clsNotify, clsNotifier, dwMask); DBGPRINTF("ISHELL_RegisterNotify ret %d", nErr); } break; case USAGE_SMS_STORE_STATUS: { CALLBACK_Cancel(&pMe->m_cb); CALLBACK_Init(&pMe->m_cb, OATSMS_StoreReadMsgStorageStatusCb, (void*)pMe); ISMSSTORAGE_GetStorageStatus(pMe->m_pISMSStorage, pMe->m_mt, pMe->m_tag, &pMe->m_cb, &pMe->m_ss, &pMe->m_dwStatus); } break; case USAGE_SMS_STORE_ENUM_READ: { CALLBACK_Cancel(&pMe->EnumMsgInitCb); CALLBACK_Init(&pMe->EnumMsgInitCb, OATSMS_EnumMsgInitCb, (void*)pMe); ISMSSTORAGE_EnumMsgInit(pMe->m_pISMSStorage, pMe->m_mt, pMe->m_tag, &pMe->EnumMsgInitCb, &pMe->m_dwStatus); } break; default: return; } // Display above event. DisplayEvent (pMe, wParam); return; }
/*=========================================================================== FUNCTION: ABR_UpdateContactRec DESCRIPTION: This function update record whose id is wID PARAMETERS: pMe [in] - Pointer to the CAddrBookRuim structure. This structure contains information specific to this applet. wID[in] - record id which is want to be update pTextName[in] - name field which record will change to pTextNum[in] - number field which record will change to DEPENDENCIES: None RETURN VALUE: AEE_SUCCESS - IADDRREC_UpdateAllFields operate successfully other - fail SIDE EFFECTS: None ===========================================================================*/ int32 ABR_UpdateContactRec( CAddrBookRuim *pMe, AEECLSID ContactCLS, uint16 wID, AECHAR *pTextName, AECHAR *pTextNum) { int nRet = 0; IAddrBook *pb; IAddrRec *pR; AEEAddrField field; boolean bFlgNameGet; boolean bFlgNumGet; if(pMe==NULL || pMe->pIShell==NULL || pTextName==NULL || pTextNum==NULL) { return (-1); } if(!ISHELL_CreateInstance(pMe->pIShell, ContactCLS, (void **)&pb)) { pR =IADDRBOOK_GetRecByID(pb, wID); if(pR) { int nFields; int i; AEEAddrField *ptr = NULL; bFlgNameGet = FALSE; bFlgNumGet = FALSE; nFields= IADDRREC_GetFieldCount(pR); for(i = 0; i < nFields; i++) { ptr = IADDRREC_GetField(pR,i); DBGPRINTF("lintao fID =%d", ptr->fID); DBGPRINTF("lintao fType=%d", ptr->fType); // find name field and save it; if ( ptr->fID == AEE_ADDRFIELD_NAME ||ptr->fID == AEE_ADDRFIELD_FIRSTNAME ||ptr->fID == AEE_ADDRFIELD_LASTNAME ||ptr->fID == AEE_ADDRFIELD_NICKNAME) { if(bFlgNameGet==FALSE) { bFlgNameGet = TRUE; field.fID = ptr->fID; field.fType = ptr->fType; field.pBuffer = pTextName; field.wDataLen = (WSTRLEN(pTextName)+1)*sizeof(AECHAR); IADDRREC_UpdateField(pR, i, &field); } } // find number field and save it; if ( ptr->fID >= AEE_ADDRFIELD_PHONE_WORK && ptr->fID <= AEE_ADDRFIELD_PHONE_OTHER) { if(bFlgNumGet==FALSE) { bFlgNumGet = TRUE; field.fID = ptr->fID; field.fType = ptr->fType; field.pBuffer = pTextNum; field.wDataLen = (WSTRLEN(pTextNum)+1)*sizeof(AECHAR); IADDRREC_UpdateField(pR, i, &field); } } } // ÐÕÃûºÍºÅÂë¾ùÓÐ if(bFlgNameGet && bFlgNumGet) { nRet=0; } else { nRet=4; } } else { nRet=2; // IADDRBOOK_GetRecByID fail } IADDRBOOK_Release(pb); } else { nRet = 3; } DBGPRINTF("nRet=%d", nRet); return nRet; }
// ================================================================================ // FUNCTION : SetField // DESCRIPTION : Set addressbook field from a contact // ================================================================================ bool CContactInfo::SetField(AEEAddrField *pField) { int nLen=0; switch (pField->fID){ case SM_ADDRFIELD_FIRSTNAME: if ( !CopyFieldTo(&m_psFName, (AECHAR*)pField->pBuffer) ) return false; break; case SM_ADDRFIELD_MIDDLENAME://append the middle name to first name. bcos RV xml hasnt got a tag for middle name nLen = WSTRLEN( (AECHAR*)pField->pBuffer ); if ( NULL==m_psFName ){ if ( !CopyFieldTo(&m_psFName, (AECHAR*)pField->pBuffer) ) return false; } else { AECHAR* pName=NULL; int nFNameLen = WSTRLEN( m_psFName );//for space and endline char pName= (AECHAR*)REALLOC( (void*)m_psFName, (nFNameLen+ nLen+ 2)*sizeof(AECHAR)); if ( NULL==pName ) return false; AECHAR szSpace[] = {' ', '\0'}; WSTRCAT( pName, szSpace); WSTRCAT(pName+ nFNameLen+ 1, (AECHAR*)pField->pBuffer); m_psFName = pName; } break; case SM_ADDRFIELD_LASTNAME: if ( !CopyFieldTo(&m_psLName, (AECHAR*)pField->pBuffer) ) return false; break; case SM_ADDRFIELD_EMAIL: if ( !AppendFieldTo(&m_psEmail, (AECHAR*)pField->pBuffer) ) return false; break; case SM_ADDRFIELD_EMAIL_HOME: if ( !AppendFieldTo(&m_psEmailH, (AECHAR*)pField->pBuffer) ) return false; break; case SM_ADDRFIELD_EMAIL_WORK: if ( !AppendFieldTo(&m_psEmailW, (AECHAR*)pField->pBuffer) ) return false; break; case SM_ADDRFIELD_FAX: if ( !AppendFieldTo(&m_psFax, (AECHAR*)pField->pBuffer) ) return false; break; case SM_ADDRFIELD_FAX_HOME: if ( !AppendFieldTo(&m_psFaxH, (AECHAR*)pField->pBuffer) ) return false; break; case SM_ADDRFIELD_FAX_WORK: if ( !AppendFieldTo(&m_psFaxW, (AECHAR*)pField->pBuffer) ) return false; break; case SM_ADDRFIELD_MOBILE: if ( !AppendFieldTo(&m_psMobile, (AECHAR*)pField->pBuffer) ) return false; break; case SM_ADDRFIELD_MOBILE_HOME: if ( !AppendFieldTo(&m_psMobileH, (AECHAR*)pField->pBuffer) ) return false; break; case SM_ADDRFIELD_MOBILE_WORK: if ( !AppendFieldTo(&m_psMobileW, (AECHAR*)pField->pBuffer) ) return false; break; case SM_ADDRFIELD_PHONE_HOME: if ( !AppendFieldTo(&m_psTelephoneH, (AECHAR*)pField->pBuffer) ) return false; break; case SM_ADDRFIELD_PHONE: if ( !AppendFieldTo(&m_psTelephone, (AECHAR*)pField->pBuffer) ) return false; break; case SM_ADDRFIELD_PHONE_WORK: if ( !AppendFieldTo(&m_psTelephoneW, (AECHAR*)pField->pBuffer) ) return false; break; default: break; } return true; }
bool CContactInfo::FillAddrFields(AEEAddrField **pField, int &nSize) { nSize = CountValidFields(); *pField = new AEEAddrField[nSize]; if ( NULL==(*pField) ) return true; int nCount=0; if ( NULL!=m_psFName ) { (*pField)[nCount].fID = SM_ADDRFIELD_FIRSTNAME; // fill in first name field (*pField)[nCount].fType = AEEDB_FT_STRING; (*pField)[nCount].pBuffer = m_psFName; (*pField)[nCount].wDataLen = (WSTRLEN(m_psFName)+1)*sizeof(AECHAR); nCount++; } else { //sometime we get id=null records with empy fields. delete [] (*pField); (*pField) = NULL; return false; } if ( NULL!=m_psLName ) { (*pField)[nCount].fID = SM_ADDRFIELD_LASTNAME; // fill in last name field (*pField)[nCount].fType = AEEDB_FT_STRING; (*pField)[nCount].pBuffer = m_psLName; (*pField)[nCount].wDataLen = (WSTRLEN(m_psLName)+1)*sizeof(AECHAR); nCount++; } if ( NULL!=m_psCompany ) { (*pField)[nCount].fID = SM_ADDRFIELD_COMPANY; // fill in last name field (*pField)[nCount].fType = AEEDB_FT_STRING; (*pField)[nCount].pBuffer = m_psCompany; (*pField)[nCount].wDataLen = (WSTRLEN(m_psCompany)+1)*sizeof(AECHAR); nCount++; } if ( NULL!=m_psJTitle ) { (*pField)[nCount].fID = SM_ADDRFIELD_JOBTITLE; // fill in last name field (*pField)[nCount].fType = AEEDB_FT_STRING; (*pField)[nCount].pBuffer = m_psJTitle; (*pField)[nCount].wDataLen = (WSTRLEN(m_psJTitle)+1)*sizeof(AECHAR); nCount++; } if ( NULL!=m_psEmail ) { FillMultiField((*pField), nCount, m_psEmail, SM_ADDRFIELD_EMAIL); } if ( NULL!=m_psFax ) { (*pField)[nCount].fID = SM_ADDRFIELD_FAX; // fill in last name field (*pField)[nCount].fType = AEEDB_FT_STRING; (*pField)[nCount].pBuffer = m_psFax; (*pField)[nCount].wDataLen = (WSTRLEN(m_psFax)+1)*sizeof(AECHAR); nCount++; } if ( NULL!=m_psTelephone ) { (*pField)[nCount].fID = SM_ADDRFIELD_PHONE; // fill in last name field (*pField)[nCount].fType = AEEDB_FT_STRING; (*pField)[nCount].pBuffer = m_psTelephone; (*pField)[nCount].wDataLen = (WSTRLEN(m_psTelephone)+1)*sizeof(AECHAR); nCount++; } if ( NULL!=m_psTelephoneH ) { (*pField)[nCount].fID = SM_ADDRFIELD_PHONE_HOME; // fill in last name field (*pField)[nCount].fType = AEEDB_FT_STRING; (*pField)[nCount].pBuffer = m_psTelephoneH; (*pField)[nCount].wDataLen = (WSTRLEN(m_psTelephoneH)+1)*sizeof(AECHAR); nCount++; } if ( NULL!=m_psMobile ) { (*pField)[nCount].fID = SM_ADDRFIELD_MOBILE; // fill in last name field (*pField)[nCount].fType = AEEDB_FT_STRING; (*pField)[nCount].pBuffer = m_psMobile; (*pField)[nCount].wDataLen = (WSTRLEN(m_psMobile)+1)*sizeof(AECHAR); nCount++; } return true; }