?? cfwmanager.cpp
字號:
{ if(gContext==NULL) { // First call only TAPIManager::setGContext(newGContext); writeGlobalStore(TAPI_PIN1_VALUE, xstrdup(initialPIN), TAPI_STATYPE_STRING); slicer = (EBSliceMsgs*) newGContext->getThreadRef() ; if (slicer) slicer->scheduleMessage(0,CFWManager_sliced_poller,gContext,this,0,0,0);#ifdef DEV_DEBUG else Verbose(VERB_LEV_ERROR, "%s: there is no slicer defined here !!!\n", "TAPI");#endif // def DEV_DEBUG // STK-TODO find better to initialise the SETUP MENU SmallArrayList* stkRequest = resetSmallArrayList(TAPI_STK_SETUP); char* tmp = getContext()->getTmpBuffer(); makeQueryString(tmp, "IS", STK_FIELD_TYPE, STK_TYP_SETUP_MENU, STK_FIELD_TITLE, "NEW BOUYGTEL") ; stkRequest->add(xstrdup(tmp)); makeQueryString(tmp, "IIS", STK_FIELD_OPT_IDX, 1, STK_FIELD_OPT_TYP, STK_ITEM_TYPE_TXT, STK_FIELD_OPT_VAL, "FIRST menu") ; stkRequest->add(xstrdup(tmp)); /* We set Loading SIM progression to unavailable */ writeGlobalStore(TAPI_PBK_PROGRESSION,(void*)-1,TAPI_STATYPE_INT); }}CFWManager::~CFWManager() { #if defined(DEV_DEBUG) && defined(DEBUG_MODULE_TAPI) Verbose( VERB_LEV_DEBUG, "%s: CFWManager deleted...\n", DEBUG_MODULE_TAPI) ;#endif // def DEV_DEBUG if (temporaryPhoneBookList) freeLines(&temporaryPhoneBookList,true); if (temporarySMSList) freeLines(&temporarySMSList,true); SmallArrayList* sms_list=(SmallArrayList*)readGlobalStore(TAPI_SMS_ALL); if (sms_list) freeLines(&sms_list,true); // We delete tmpBuffer : the one we xmalloc 'ed in ctrs. SAFE_FREE(tmpBuffer); SAFE_DELETE(messagesTranslations); } boolean CFWManager::fetchPDU_SMS(char* status, char* alpha, char* msglen, char* buffer) { unsigned char* pduData = (unsigned char*) xmalloc(TMP_COMMAND_BUFFER*sizeof(char)); int pduLen=0; if(extractLineFromCurrentBuffer((char*) pduData, &pduLen)) // TODO: the msg's len could be precised. {#if GSMUTILS_DEACTIVATED decodePDUMessage(pduData, (unsigned char*) buffer, status, alpha, msglen);#endif SAFE_FREE(pduData); return true; } SAFE_FREE(pduData); return false; }void CFWManager::addUnreadSMS(char* queryString) { SmallArrayList* toRead = (SmallArrayList*) readGlobalStore(TAPI_SMS_TOREAD) ; if(!toRead) { toRead = XNEW (SmallArrayList)(3); writeGlobalStore(TAPI_SMS_TOREAD,toRead, TAPI_STATYPE_SMALLARRAYLIST); }#ifdef DEV_DEBUG Verbose(VERB_LEV_DEBUG, "TAPI: adding SMS to read /%d >%s<\n", toRead->size()+1, queryString) ;#endif // def DEV_DEBUG toRead->add(xstrdup(queryString)) ; return ; } int CFWManager::update_call_property(char* propertyName, boolean forceWrite, unsigned long newMsgOK, unsigned long newMsgERROR,KALEIDO_TIME_TYPE timeout){ if(!strcmp(propertyName, TAPI_CALL_SEND_NUMBER)) { if (forceWrite) { char* str_to_send=(char*)readGlobalStore(TAPI_CALL_SEND_NUMBER); sprintf(tmpBuffer,"AT+CHLD=%s",str_to_send); requestWriteTSS(tmpBuffer,newMsgOK,newMsgERROR,timeout); return TAPI_PROPERTY_REFRESHING; }#ifdef DEV_DEBUG else { Verbose(VERB_LEV_ERROR,"CFWManager::update_call_property(TAPI_CALL_SEND_NUMBER) : Reading not allowed.\n"); return TAPI_PROPERTY_INVALID; }#endif } if(!strcmp(propertyName, TAPI_CLOSE_ALL_CALL)) { requestWriteTSS("ATH",newMsgOK,newMsgERROR,timeout); return TAPI_PROPERTY_REFRESHING; } // Not Handled. return TAPI_PROPERTY_UNIMPLEMENTED;}/* * This function allows to request the update of a property. This update induces a synchronisation between the modem (or any equivalent device) * and the values known in the global store. * propertyName : a string containing the name of the concerned property. Please use the TAPI_** constants defined in TAPIManager.h * forceWrite : ==false -> the value currently used by the device must update the one known in the global store * !=false -> the value currently known in the global store must update the one used in the device * newMsgOK : !=0 -> if the update is correctly processed, this action will be sent * newMsgERROR : !=0 -> if the update is NOT correctly processed, this action will be sent * timeout : the update must be processed in a maximum delay of "timeout" milliseconds. When this delay is reached, the update is considered as failed. * BEWARE: in this case, there is no guaranty that the value known in the global store is synchronized with the one used by the modem * * This function may return: * TAPI_PROPERTY_AVAILABLE : The property is available and accurate * TAPI_PROPERTY_REFRESHING : The property is being refreshed * TAPI_PROPERTY_UNIMPLEMENTED : The property is not yet implemented * TAPI_PROPERTY_UNKNOWN : The property is unknown * TAPI_PROPERTY_INVALID : This action is not possible with this property * TAPI_PROPERTY_BADPARAM : A parameter is invalid or missing * */int CFWManager::updateProperty(char* propertyName, boolean forceWrite, unsigned long newMsgOK, unsigned long newMsgERROR, KALEIDO_TIME_TYPE timeout){ Verbose(1, "CFWManager::updateProperty %s\n", propertyName); /* We check first specials implementation */ int call_prop_result = update_call_property(propertyName,forceWrite,newMsgOK,newMsgERROR,timeout); if (call_prop_result != TAPI_PROPERTY_UNIMPLEMENTED) { return call_prop_result; } if(!strcmp(propertyName, TAPI_NETWORK_NAME)) // TAPI_STATYPE_STRING [R] { if(!forceWrite) { char* networkName = (char*) readGlobalStore(TAPI_NETWORK_NAME) ; if(networkName==NULL) writeGlobalStore(TAPI_NETWORK_NAME, xstrdup("NO NETWORK"), TAPI_STATYPE_STRING); return TAPI_PROPERTY_REFRESHING; } return TAPI_PROPERTY_INVALID; } if(!strcmp(propertyName, TAPI_MANUAL_NETWORK)) // TAPI_STATYPE_STRING [W] { char* selNetwork = (char*) readGlobalStore(TAPI_MANUAL_NETWORK) ; if(!selNetwork || !*selNetwork) { // Automatic network selection requestWriteTSS("AT+COPS=0", newMsgOK, newMsgERROR, timeout); requestWriteTSS("AT+COPS=3,1"); requestWriteTSS("AT+COPS?"); } else { // Manual network selection char tmp[100] ; *tmpBuffer=0; if(getArgValByName(selNetwork, OPER_FIELD_IDENT, tmp)) // The network is defined by its code sprintf(tmpBuffer, "AT+COPS=1,2,\"%s\"", tmp); else if(getArgValByName(selNetwork, OPER_FIELD_SNAME, tmp)) // The network is defined by its short name sprintf(tmpBuffer, "AT+COPS=1,1,\"%s\"", tmp); else if(getArgValByName(selNetwork, OPER_FIELD_LNAME, tmp)) // The network is defined by its long name sprintf(tmpBuffer, "AT+COPS=1,0,\"%s\"", tmp); if(!*tmpBuffer) { // There is no correct network's definition to use if(newMsgERROR) sendSlowQueue(gContext,MSG_ACTION, newMsgERROR, 0) ; return TAPI_PROPERTY_BADPARAM; } requestWriteTSS(tmpBuffer, newMsgOK, newMsgERROR, timeout); requestWriteTSS("AT+COPS=3,1"); requestWriteTSS("AT+COPS?"); } return TAPI_PROPERTY_REFRESHING; } if(!strcmp(propertyName, TAPI_NETWORK_LIST)) // TAPI_STATYPE_SMALLARRAYLIST [R] { // AT+COPS=? // Reset the current list SmallArrayList* operatorList = (SmallArrayList*) readGlobalStore(TAPI_NETWORK_LIST) ; if(operatorList) { freeLines(&operatorList, false) ; operatorList->clear() ; } else { operatorList = XNEW (SmallArrayList)(10); writeGlobalStore(TAPI_NETWORK_LIST, operatorList, TAPI_STATYPE_SMALLARRAYLIST) ; } requestWriteTSS("AT+COPS=?", newMsgOK, newMsgERROR, 50000); // TODO: check the time-out suggested by the caller return TAPI_PROPERTY_UNIMPLEMENTED; } // GSM Specific definitions properties. else if(!strcmp(propertyName, TAPI_PIN1_VALUE)) // TAPI_STATYPE_STRING [W] { char* pinCode = (char*) readGlobalStore(propertyName) ; sprintf(tmpBuffer, "AT+CPIN=\"%s\"", pinCode); // TODO: the callers setting the property should include an action for SUCCESS/FAIL requestWriteTSS(tmpBuffer, newMsgOK, newMsgERROR); return TAPI_PROPERTY_REFRESHING; } if (!strcmp(propertyName,TAPI_PUK1_VALUE)) { int rslt = TAPI_PROPERTY_BADPARAM; char* tmp = getContext()->getTmpBuffer(); char* request = (char*) readGlobalStore(propertyName) ; /* We remove reference from GC. */ writeGlobalStore(propertyName,NULL,TAPI_STATYPE_INT); if(!request || !*request) return rslt; char* pwd = NULL; if(getArgValByName(request, PWD_FIELD_PWD,tmp)) pwd = xstrdup(tmp); if(pwd) // Assign & activate { char* npwd = NULL; if(getArgValByName(request, PWD_FIELD_NPWD,tmp)) npwd = xstrdup(tmp); if(npwd) { if (!strcmp(npwd,"\"\"")) { SAFE_FREE(npwd); npwd=xstrdup(""); } if (!strcmp(pwd,"\"\"")) { SAFE_FREE(pwd); pwd=xstrdup(""); } sprintf(tmp, "AT+CPIN=\"%s\",\"%s\"", pwd, npwd); requestWriteTSS(tmp, newMsgOK, newMsgERROR); /* We ask an update. */ /* requestWriteTSS("AT+CPIN?", newMsgOK, newMsgERROR);*/ rslt = TAPI_PROPERTY_REFRESHING; } SAFE_FREE(npwd); } SAFE_FREE(pwd); SAFE_FREE(request); return rslt; } // Value of the last PIN1 code suggested by the user if(!strcmp(propertyName, TAPI_PIN1_STATE)) // TAPI_STATYPE_INT [R] { return TAPI_PROPERTY_REFRESHING; // CFW automatically check. UINT32 ret = ERR_SUCCESS; // 0x00000000: unknown // 0x00000001: PIN OK // 0x0000001x: x failed attemps // 0x00000020: SIM blocked // requestWriteTSS("AT+CPIN?", newMsgOK, newMsgERROR); ret = CFW_SimGetAuthenticationStatus(CFW_SIM_UTI); // Check SIM PIN1 State [2007-6-7:shenhankun] if(ret != ERR_SUCCESS) return TAPI_PROPERTY_INVALID; else return TAPI_PROPERTY_REFRESHING; } if(!strcmp(propertyName, TAPI_PIN2_VALUE)) // TAPI_STATYPE_STRING [W] { return TAPI_PROPERTY_UNIMPLEMENTED; } // Value of the last PIN2 code suggested by the user if(!strcmp(propertyName, TAPI_PIN2_STATE)) // TAPI_STATYPE_INT [R] { // 0x00000000: unknown // 0x00000001: PIN OK // 0x0000001x: x failed attemps // 0x00000020: SIM blocked return TAPI_PROPERTY_UNIMPLEMENTED; } // Update (set/unset/modify) the PIN1 code if(!strcmp(propertyName, TAPI_PIN1_UPDATE)) // TAPI_STATYPE_STRING [W] { int rslt = TAPI_PROPERTY_BADPARAM; char* tmp = getContext()->getTmpBuffer(); char* request = (char*) readGlobalStore(propertyName) ; /* We remove reference from GC. */ writeGlobalStore(propertyName,NULL,TAPI_STATYPE_INT); if(!request || !*request) return rslt; char* pwd = NULL; if(getArgValByName(request, PWD_FIELD_PWD,tmp)) pwd = xstrdup(tmp); if(pwd) // Assign & activate { char* npwd = NULL; if(getArgValByName(request, PWD_FIELD_NPWD,tmp)) npwd = xstrdup(tmp); if(npwd) { if (!strcmp(npwd,"\"\"")) { SAFE_FREE(npwd); npwd=xstrdup(""); } if (!strcmp(pwd,"\"\"")) { SAFE_FREE(pwd); pwd=xstrdup(""); } sprintf(tmp, "AT+CPIN=\"%s\",\"%s\"", pwd, npwd); requestWriteTSS(tmp, newMsgOK, newMsgERROR); rslt = TAPI_PROPERTY_REFRESHING; } SAFE_FREE(npwd); } SAFE_FREE(pwd); SAFE_FREE(request); return rslt; } if(!strcmp(propertyName, TAPI_BATTERY_LEVEL)) // TAPI_STATYPE_INT [R] { // 0x00000000: unknown // 0x000001xx: not plugged. xx=% of charge // 0x000002xx: plugged. xx=% of battery charge UINT8 uBcs = 0; UINT8 uBcl = 0; UINT16 uMpc = 0; UINT32 uKplBatInfo = TAPI_BATTERY_UNKNOWN; // Get the battery level from CSW. if (PM_GetBatteryInfo(&uBcs, &uBcl, &uMpc)) { if (uBcs == 0) uKplBatInfo = TAPI_BATTERY_UNPLUGGED; else uKplBatInfo = TAPI_BATTERY_PLUGGED; uKplBatInfo |= (TAPI_BATTERY_MASK_LEVEL & uBcl); }#ifdef DEV_DEBUG Verbose(1, " writeGlobalStore(TAPI_BATTERY_LEVEL, %X)\n", uKplBatInfo);#endif // Write the battery level in the global store. writeGlobalStore(TAPI_BATTERY_LEVEL, (void*)uKplBatInfo, TAPI_STATYPE_INT); return TAPI_PROPERTY_AVAILABLE; } if(!strcmp(propertyName, TAPI_NETWORK_LEVEL)) // TAPI_STATYPE_INT [R] { // 0x00000000: unknown // 0x000001xx: xx=% of network level requestWriteTSS("AT+CSQ", newMsgOK, newMsgERROR); return TAPI_PROPERTY_AVAILABLE; } if(!strcmp(propertyName, TAPI_CALLS_LIST_REQUEST)) // TAPI_STATYPE_STRING [W] { char* tmp = getContext()->getTmpBuffer(); SmallArrayList* callsList = (SmallArrayList*) getContext()->findData(propertyName) ; if (!callsList) return TAPI_PROPERTY_AVAILABLE; for(int i=0; i<callsList->size(); i++) { char* qString = (char*) callsList->get(i);#ifdef DEV_DEBUG//Verbose(VERB_LEV_DEBUG, "Processing >%s<\n", qString) ;#endif // def DEV_DEBUG int tid; *tmp=0; getArgValByName(qString,CALL_FIELD_TID,tmp); if (*tmp) tid=a2i(tmp); if(getArgValByName(qString, CALL_FIELD_STATE, tmp)) { // BEWARE: these comments may noy be up-to-date. Check these values in TAPIManager.h. // States that are currently not handled by CFWManager: // CALL_STATE_MMIESTABLISHED -> used only by MMI // CALL_STATE_MMIHELD -> used only by MMI // CALL_STATE_MMIRELEASED -> used only by MMI // States that are handled by incoming AT commands: // CALL_STATE_RINGING -> Handled by: msgRING and msgCLIP // CALL_STATE_ESTABLISHED -> Handled by: ??? // CALL_STATE_HELD -> Handled by: ??? // CALL_STATE_RELEASED -> Handled by: ??? // CALL_STATE_ABORTED -> Handled by: ??? if(forceWrite) { // Here, we handle the states that are set by the MMI
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -