/*激活码交互函数*/ void acceptActiveCode(char *buffer) { char *activeCodeId; char failReason[100] = {'\0'}; Role *role; char *userNme; map<int, Role*>::iterator role_it; MSG_BEGIN(buffer,g_msg_len); /*解析激活码*/ MSG_CHAR_END(activeCodeId); cout<<"come hero and activeCodeId:"<<activeCodeId<<endl; role_it = fd_to_pRole.find(sock_fd); if(role_it == fd_to_pRole.end()) { return; } role = role_it->second; userNme = role->getUserName(); if(userNme == NULL) { cout<<"userNme is NULL:"<<endl; return; } if(activeCodeId == NULL || strlen(activeCodeId) == 0) { cout<<"activeCodeId is NULL:"<<endl; return; } char key[60]={0}; strncpy(key,userNme,strlen(userNme)); strncat(key,activeCodeId,1); int size=0; char *result; result=cdkeyMemcached->get_mem_data(activeCodeId,&size); if (!result) { result=NULL; size=0; result=cdkeyMemcached->get_mem_data(key,&size); if (!result) { if (strlen(activeCodeId)==18) { cout<<"222222222222222222222222222222222"<<endl; memset(g_out_buf,0,sizeof(g_out_buf)); char temp[60]={0}; strncpy(temp,activeCodeId,12); cout<<"temp:"<<temp<<endl; strcat(temp,"1As8DSxfcfdas3d#@fdas-0jkduYHHfdXdfdaSDFDsseD"); cout<<"temp:"<<temp<<endl; MD5 *md5=new MD5(temp,strlen(temp)); string md5_string=md5->toString(); cout<<"md5_string:"<<md5_string<<endl; delete md5; if (strncmp(md5_string.substr(0,6).c_str(),activeCodeId+12,6)==0) { map<string,string>::iterator it; char cdkey[5]={0}; strncpy(cdkey,activeCodeId,4); cout<<"cdkey:"<<cdkey<<endl; it=cdkey_to_goodsid.find(cdkey); if (it==cdkey_to_goodsid.end()) { cout<<"cdkey config error in acceptActiveCode.cpp 95"<<endl; return; } else { char rewardGoodsId[20]={0}; strncpy(rewardGoodsId,(it->second).c_str(),sizeof(rewardGoodsId)-1); if (saveGoodsInBag(pg_hero,rewardGoodsId,1)) { // pg_hero->useActiveCode(activeCodeId,0); snprintf(g_out_buf,sizeof(g_out_buf),"%d,%d,3",28,3); send_msg(pg_hero->getFd(),g_out_buf); char account_msg[1024]={'\0'}; snprintf(account_msg,sizeof(account_msg),"%d,%d,%s,%d,%s,%s,%s,%s",20,0,server_name,(int)myTime.tv_sec,pg_hero->getIdentity(),pg_hero->getNickName(),pg_role->getUserName(),activeCodeId); write_log(account_msg); cdkeyMemcached->set_mem_data(activeCodeId,key,strlen(key)); cdkeyMemcached->set_mem_data(key,activeCodeId,strlen(activeCodeId)); } } } else { cout<<"官网验证码验证失败"<<endl; msg_error(g_out_buf,144); send_msg(pg_hero->getFd(),g_out_buf); } } else { cout<<"strlen(activeCodeId)::"<<strlen(activeCodeId)<<endl; msg_error(g_out_buf,144); send_msg(pg_hero->getFd(),g_out_buf); } } else { msg_error(g_out_buf,143); send_msg(pg_hero->getFd(),g_out_buf); } } else { //cdkey已经使用 msg_error(g_out_buf,142); send_msg(pg_hero->getFd(),g_out_buf); } }
void MmsPluginStorage::addMessage(MSG_MESSAGE_INFO_S *pMsgInfo, MSG_SENDINGOPT_INFO_S *pSendOptInfo, char *pFileData) { MSG_BEGIN(); msg_error_t err; MmsMsg mmsMsg; bzero(&mmsMsg, sizeof(mmsMsg)); mode_t file_mode = (S_IRUSR | S_IWUSR); if (pMsgInfo->msgType.subType == MSG_SENDREQ_MMS) { char szTemp[MAX_MSG_DATA_LEN + 1]; MMS_MESSAGE_DATA_S mmsMsgData; bzero(&mmsMsgData,sizeof(MMS_MESSAGE_DATA_S)); if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); THROW(MsgException::MMS_PLG_ERROR, "MMS Message Compose Error"); } char fileName[MSG_FILENAME_LEN_MAX+1] = {0,}; FILE *pFile = NULL; strcpy(szTemp,pMsgInfo->msgData); snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN+1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId); if (addMmsMsgToDB(&mmsMsg, pMsgInfo, _MsgMmsGetAttachCount(&mmsMsgData)) != MSG_SUCCESS) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error"); } strcpy((char *)pMsgInfo->msgData,szTemp); snprintf(fileName, MSG_FILENAME_LEN_MAX+1, MSG_DATA_PATH"%d", mmsMsg.msgID); pFile = MsgOpenMMSFile(fileName); if (!pFile) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); THROW(MsgException::MMS_PLG_ERROR, "MMS File open Error"); } if (fchmod(fileno(pFile), file_mode) < 0) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); MsgCloseFile(pFile); THROW(MsgException::MMS_PLG_ERROR, "chmod() error: %s", strerror(errno)); } if (_MmsEncodeSendReq(pFile, &mmsMsg) != true) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); MsgCloseFile(pFile); THROW(MsgException::MMS_PLG_ERROR, "MMS Message Encode Send Req Error"); } MsgFsync(pFile); //file is written to device immediately, it prevents missing file data from unexpected power off MsgCloseFile(pFile); _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); } else if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) { MSG_DEBUG("######## MmsPlgAddMessage -> MSG_NOTIFICATIONIND_MMS ###########"); MmsComposeNotiMessage(&mmsMsg, pMsgInfo->msgId); //Need to store mms specific data (contents location, TrID, ExpiryTime, Delivery Report, message ID) if (addMmsMsgToDB(&mmsMsg, pMsgInfo) != MSG_SUCCESS) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error"); } } else if (pMsgInfo->msgType.subType == MSG_SENDCONF_MMS || pMsgInfo->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS) { MmsMsg *pMsg = NULL; char szTemp[MAX_MSG_DATA_LEN + 1]= {0, }; if (!_MmsReadMsgBody(pMsgInfo->msgId, true, true, pFileData)) THROW(MsgException::MMS_PLG_ERROR, "_MmsReadMsgBody Error"); MmsPluginStorage::instance()->getMmsMessage(&pMsg); if (pMsgInfo->msgType.subType == MSG_SENDCONF_MMS) pMsgInfo->networkStatus = MSG_NETWORK_SEND_SUCCESS; else pMsgInfo->networkStatus = MSG_NETWORK_RETRIEVE_SUCCESS; strcpy(szTemp,pMsgInfo->msgData); memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1); strncpy(pMsgInfo->msgData, pFileData, MAX_MSG_DATA_LEN); MmsPluginStorage *pStorage = MmsPluginStorage::instance(); MMS_MESSAGE_DATA_S mmsMsgData; bzero(&mmsMsgData,sizeof(MMS_MESSAGE_DATA_S)); if (mmsHeader.msgType.type == MIME_MULTIPART_RELATED || mmsHeader.msgType.type == MIME_APPLICATION_VND_WAP_MULTIPART_RELATED) { char *pSmilDoc; MmsMsg *pMsg = NULL; char szFileName[MSG_FILENAME_LEN_MAX] = {0, }; mmsMsgData.regionCnt = 0; mmsMsgData.pageCnt = 0; mmsMsgData.attachCnt = 0; mmsMsgData.transitionCnt = 0; mmsMsgData.metaCnt = 0; memset(mmsMsgData.szSmilFilePath, 0, MSG_FILEPATH_LEN_MAX); pSmilDoc = MmsSmilGetPresentationData(pMsgInfo->msgId); MmsSmilParseSmilDoc(&mmsMsgData, pSmilDoc); MmsPluginStorage::instance()->getMmsMessage(&pMsg); strcpy(szFileName, pMsg->szFileName); err = pStorage->getMsgText(&mmsMsgData, pMsgInfo->msgText); err = pStorage->makeThumbnail(&mmsMsgData, pMsgInfo->thumbPath, szFileName); __MmsReleaseMmsLists(&mmsMsgData); } if (addMmsMsgToDB(pMsg, pMsgInfo) != MSG_SUCCESS) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error"); } memset(pMsgInfo->msgData, 0, MAX_MSG_DATA_LEN + 1); strcpy((char *)pMsgInfo->msgData,szTemp); _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); } else if (pMsgInfo->msgType.subType == MSG_READREPLY_MMS || pMsgInfo->msgType.subType == MSG_READRECIND_MMS) { MSG_DEBUG("######## MmsPlgAddMessage -> MSG_READREPLY_MMS || MSG_READRECIND_MMS ###########"); char filePath[MAX_FULL_PATH_SIZE+1] = {0, }; FILE *pFile = NULL; msg_read_report_status_t readStatus; msg_message_id_t selectedMsgId; int version; memcpy(&readStatus, pMsgInfo->msgData, sizeof(msg_read_report_status_t)); memcpy(&selectedMsgId, pMsgInfo->msgData + sizeof(msg_read_report_status_t), sizeof(msg_message_id_t)); version = MmsPluginStorage::instance()->getMmsVersion(selectedMsgId); snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN+1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId); MmsComposeReadReportMessage(&mmsMsg, pMsgInfo, selectedMsgId); if (addMmsMsgToDB(&mmsMsg, pMsgInfo) != MSG_SUCCESS) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error"); } snprintf(filePath, MAX_FULL_PATH_SIZE+1, MSG_DATA_PATH"%d", mmsMsg.msgID); pFile = MsgOpenMMSFile(filePath); if (!pFile) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); MsgCloseFile(pFile); pFile = NULL; THROW(MsgException::MMS_PLG_ERROR, "MsgOpenMMSFile error"); } if (fchmod(fileno(pFile), file_mode) < 0) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); MsgCloseFile(pFile); pFile = NULL; THROW(MsgException::MMS_PLG_ERROR, "chmod() error: %s", strerror(errno)); } if (version == 0x90) { MSG_DEBUG("### version 1.0 ###"); if (_MmsEncodeReadReport10(pFile, &mmsMsg, readStatus) != true) { MsgFreeAttrib(&mmsMsg.mmsAttrib); MsgCloseFile(pFile); pFile = NULL; THROW(MsgException::MMS_PLG_ERROR, "MMS Encode Read Report 1.0 Error"); } } else { MSG_DEBUG("### version 1.1 ###"); if (_MmsEncodeReadReport11(pFile, &mmsMsg, readStatus) != true) { MsgFreeAttrib(&mmsMsg.mmsAttrib); MsgCloseFile(pFile); pFile = NULL; THROW(MsgException::MMS_PLG_ERROR, "MMS Encode Read Report 1.1 Error"); } } MsgFsync(pFile); MsgCloseFile(pFile); pFile = NULL; _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); } else if (pMsgInfo->msgType.subType == MSG_FORWARD_MMS) { MSG_DEBUG("######## MmsPlgAddMessage -> MSG_FORWARD_MMS ###########"); char filePath[MAX_FULL_PATH_SIZE + 1] = {0, }; char szTemp[MAX_MSG_DATA_LEN + 1] = {0, }; FILE *pFile = NULL; MMS_MESSAGE_DATA_S mmsMsgData; if (MmsComposeMessage(&mmsMsg, pMsgInfo, pSendOptInfo, &mmsMsgData, pFileData) != true) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); THROW(MsgException::MMS_PLG_ERROR, "MMS Message Compose Error"); } strcpy(szTemp,pMsgInfo->msgData); snprintf((char *)pMsgInfo->msgData, MAX_MSG_DATA_LEN + 1, MSG_DATA_PATH"%d.mms", pMsgInfo->msgId); if (addMmsMsgToDB(&mmsMsg, pMsgInfo, _MsgMmsGetAttachCount(&mmsMsgData)) != MSG_SUCCESS) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); THROW(MsgException::MMS_PLG_ERROR, "MMS Stroage Error"); } strcpy((char *)pMsgInfo->msgData,szTemp); snprintf(filePath, MAX_FULL_PATH_SIZE + 1 , MSG_DATA_PATH"%d", mmsMsg.msgID); pFile = MsgOpenMMSFile(filePath); if (!pFile) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); MsgCloseFile(pFile); pFile = NULL; THROW(MsgException::MMS_PLG_ERROR, "MsgOpenMMSFile error"); } if (fchmod(fileno(pFile), file_mode) < 0) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); MsgCloseFile(pFile); pFile = NULL; THROW(MsgException::MMS_PLG_ERROR, "chmod() error: %s", strerror(errno)); } if (_MmsEncodeSendReq(pFile, &mmsMsg) != true) { _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); MsgCloseFile(pFile); pFile = NULL; THROW(MsgException::MMS_PLG_ERROR, "MMS Message Encode Send Req Error"); } MsgFsync(pFile); MsgCloseFile(pFile); pFile = NULL; _MsgFreeBody(&mmsMsg.msgBody, mmsMsg.msgType.type); MsgFreeAttrib(&mmsMsg.mmsAttrib); __MmsReleaseMmsLists(&mmsMsgData); } MSG_END(); }
void* MsgPlayThread(void *data) { MSG_BEGIN(); bool bSoundOn = false; bool bVibrationOn = false; int callStatus = 0; /* 0 - off, 1 - sound, 2 - vibration */ int alertOnCall = 0; char *msg_tone_file_path = NULL; AutoPtr<char> buf(&msg_tone_file_path); char *tmpFileFath = NULL; tmpFileFath = MsgSettingGetString(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR); if (tmpFileFath == NULL || MsgGetFileSize(tmpFileFath) < 1) { msg_tone_file_path = new char[MAX_SOUND_FILE_LEN]; strncpy(msg_tone_file_path, DEFAULT_FILE, MAX_SOUND_FILE_LEN-1); } else { msg_tone_file_path = new char[MAX_SOUND_FILE_LEN]; strncpy(msg_tone_file_path, tmpFileFath, MAX_SOUND_FILE_LEN-1); free(tmpFileFath); tmpFileFath = NULL; } MSG_DEBUG("Sound File [%s]", msg_tone_file_path); MsgSettingGetBool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &bSoundOn); MsgSettingGetBool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &bVibrationOn); int err = MM_ERROR_NONE; err = mm_session_init(MM_SESSION_TYPE_NOTIFY); if(err != MM_ERROR_NONE) MSG_DEBUG("MM Session Init Failed"); else MSG_DEBUG("MM Session Init Success : %d", err); hPlayerHandle = 0; err = mm_player_create(&hPlayerHandle); if (err != MM_ERROR_NONE) { MSG_DEBUG("creating the player handle failed"); return NULL; } /* Setting the call back function msg_callback */ mm_player_set_message_callback(hPlayerHandle, MsgSoundPlayCallback, (void *)hPlayerHandle); callStatus = MsgSettingGetInt(VCONFKEY_CALL_STATE); MSG_DEBUG("Call Status = %d", callStatus); if (callStatus > VCONFKEY_CALL_OFF && callStatus < VCONFKEY_CALL_STATE_MAX) { alertOnCall = MsgSettingGetInt(VCONFKEY_CISSAPPL_ALERT_ON_CALL_INT); MSG_DEBUG("Alert On Call = %d", alertOnCall); if (alertOnCall == 0) { MSG_DEBUG("Call is active & Alert on Call - Off"); } else if (alertOnCall == 1) { MSG_DEBUG("Call is active & Alert on Call - Sound"); if (bSoundOn) MsgSoundPlayMelody(msg_tone_file_path, false); } else if (alertOnCall == 2) { MSG_DEBUG("Call is active & Alert on Call - Vibration"); if (bVibrationOn) MsgSoundPlayVibration(); } } else{ MSG_DEBUG("Call is not active"); if (bVibrationOn) { MSG_DEBUG("Play vibration."); MsgSoundPlayVibration(); } if (bSoundOn) { MSG_DEBUG("Play sound."); MsgSoundPlayMelody(msg_tone_file_path, false); } } err = mm_session_finish(); if (err != MM_ERROR_NONE) MSG_DEBUG("MM Session Finish Failed"); else MSG_DEBUG("MM Session Finish Success : %d", err); if(!bPlaying && !bVibrating) worker_done(); MSG_END(); return NULL; }
void SmsPluginTransport::submitRequest(SMS_REQUEST_INFO_S *pReqInfo) { MSG_BEGIN(); SMS_TPDU_S tpdu; tpdu.tpduType = SMS_TPDU_SUBMIT; // Set SMS Send Options - Setting setSmsSendOptions(&(tpdu.data.submit)); // Set SMS Send Options - Each Message if (pReqInfo->sendOptInfo.bSetting == true) { tpdu.data.submit.bStatusReport = pReqInfo->sendOptInfo.bDeliverReq; tpdu.data.submit.bReplyPath = pReqInfo->sendOptInfo.option.smsSendOptInfo.bReplyPath; } // Set Coding Scheme for apps that use port number if (pReqInfo->msgInfo.msgPort.valid == true) { tpdu.data.submit.dcs.codingScheme = (SMS_CODING_SCHEME_T)pReqInfo->msgInfo.encodeType; MSG_DEBUG("DCS is changed by application : [%d]", tpdu.data.submit.dcs.codingScheme); } // Set SMSC Options SMS_ADDRESS_S smsc; setSmscOptions(&smsc); int i = 0; int j = 0; MSG_DEBUG("pReqInfo->msgInfo.nAddressCnt [%d]", pReqInfo->msgInfo.nAddressCnt); for (i = 0; i < pReqInfo->msgInfo.nAddressCnt; i++) { // Make SMS_SUBMIT_DATA_S from MSG_REQUEST_INFO_S SMS_SUBMIT_DATA_S submitData = {{0},}; msgInfoToSubmitData(&(pReqInfo->msgInfo), &submitData, &(tpdu.data.submit.dcs.codingScheme), i); // Encode SMSC Address unsigned char smscAddr[MAX_SMSC_LEN]; memset(smscAddr, 0x00, sizeof(smscAddr)); int smscLen = SmsPluginParamCodec::encodeSMSC(&smsc, smscAddr); if (smscLen <= 0) return; for (j = 0; j < smscLen; j++) { MSG_DEBUG("pSCAInfo [%02x]", smscAddr[j]); } int bufLen = 0, reqId = 0; char buf[MAX_TPDU_DATA_LEN]; int addLen = strlen(submitData.destAddress.address); tpdu.data.submit.destAddress.ton = submitData.destAddress.ton; tpdu.data.submit.destAddress.npi = submitData.destAddress.npi; if (addLen < MAX_ADDRESS_LEN) { memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, addLen); tpdu.data.submit.destAddress.address[addLen] = '\0'; } else { memcpy(tpdu.data.submit.destAddress.address, submitData.destAddress.address, MAX_ADDRESS_LEN); tpdu.data.submit.destAddress.address[MAX_ADDRESS_LEN] = '\0'; } for (unsigned int segCnt = 0; segCnt < submitData.segCount; segCnt++) { if (submitData.userData[segCnt].headerCnt > 0) { tpdu.data.submit.bHeaderInd = true; } else { tpdu.data.submit.bHeaderInd = false; } memset(&(tpdu.data.submit.userData), 0x00, sizeof(SMS_USERDATA_S)); memcpy(&(tpdu.data.submit.userData), &(submitData.userData[segCnt]), sizeof(SMS_USERDATA_S)); // Encode SMS-SUBMIT TPDU memset(buf, 0x00, sizeof(buf)); bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf); // Make Telephony Structure TelSmsDatapackageInfo_t pkgInfo; // Set TPDU data memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData)); memcpy((void*)pkgInfo.szData, buf, bufLen); pkgInfo.szData[bufLen] = 0; pkgInfo.MsgLength = bufLen; // Set SMSC data memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca)); memcpy((void*)pkgInfo.Sca, smscAddr, smscLen); pkgInfo.Sca[smscLen] = '\0'; SMS_SENT_INFO_S sentInfo = {}; bool bMoreMsg = FALSE; memcpy(&(sentInfo.reqInfo), pReqInfo, sizeof(SMS_REQUEST_INFO_S)); if ((segCnt+1) == submitData.segCount && (i+1)==pReqInfo->msgInfo.nAddressCnt) { sentInfo.bLast = true; bMoreMsg = FALSE; } else { sentInfo.bLast = false; bMoreMsg = TRUE; } SmsPluginEventHandler::instance()->SetSentInfo(&sentInfo); curStatus = MSG_NETWORK_SENDING; // Send SMS int tapiRet = TAPI_API_SUCCESS; tapiRet = tel_send_sms(pTapiHandle, &pkgInfo, bMoreMsg, TapiEventSentStatus, NULL); if (tapiRet == TAPI_API_SUCCESS) { MSG_DEBUG("######## TelTapiSmsSend Success !!! req Id : [%d] return : [%d] #######", reqId, tapiRet); } else { SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL); THROW(MsgException::SMS_PLG_ERROR, "######## TelTapiSmsSend Fail !!! req Id : [%d] return : [%d] #######", reqId, tapiRet); } msg_network_status_t retStatus = getNetStatus(); if (retStatus == MSG_NETWORK_SEND_SUCCESS) { MSG_DEBUG("######## Msg Sent was Successful !!! req Id : [%d] return : [%d] #######", reqId, retStatus); } else { SmsPluginEventHandler::instance()->handleSentStatus(MSG_NETWORK_SEND_FAIL); THROW(MsgException::SMS_PLG_ERROR, "######## Msg Sent was Failed !!! req Id : [%d] return : [%d] #######", reqId, retStatus); } if (tpdu.data.submit.userData.headerCnt > 0) tpdu.data.submit.userData.headerCnt--; } } MSG_END(); }
void SmsPluginTransport::sendDeliverReport(msg_error_t err) { MSG_BEGIN(); SMS_TPDU_S tpdu; tpdu.tpduType = SMS_TPDU_DELIVER_REP; TelSmsResponse_t response; int tapiRet = TAPI_API_SUCCESS, reqId = 0; if (err == MSG_SUCCESS) { tpdu.data.deliverRep.reportType = SMS_REPORT_POSITIVE; response = TAPI_NETTEXT_SENDSMS_SUCCESS; tapiRet = tel_set_sms_memory_status(pTapiHandle, TAPI_NETTEXT_PDA_MEMORY_STATUS_AVAILABLE, NULL, NULL); if (tapiRet == TAPI_API_SUCCESS) { MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! req Id : [%d] #######", reqId); } else { MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! req Id : [%d] return : [%d] #######", reqId, tapiRet); } } else if (err == MSG_ERR_SIM_STORAGE_FULL) { tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE; tpdu.data.deliverRep.failCause = SMS_FC_MSG_CAPA_EXCEEDED; response = TAPI_NETTEXT_SIM_FULL; tapiRet = tel_set_sms_memory_status(pTapiHandle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, NULL, NULL); if (tapiRet == TAPI_API_SUCCESS) { MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! req Id : [%d] #######", reqId); } else { MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! req Id : [%d] return : [%d] #######", reqId, tapiRet); } } else if (err == MSG_ERR_MESSAGE_COUNT_FULL) { tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE; tpdu.data.deliverRep.failCause = SMS_FC_MSG_CAPA_EXCEEDED; response = TAPI_NETTEXT_ME_FULL; tapiRet = tel_set_sms_memory_status(pTapiHandle, TAPI_NETTEXT_PDA_MEMORY_STATUS_FULL, NULL, NULL); if (tapiRet == TAPI_API_SUCCESS) { MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! req Id : [%d] #######", reqId); } else { MSG_DEBUG("######## tel_set_sms_memory_status() Success !!! req Id : [%d] return : [%d] #######", reqId, tapiRet); } } else { tpdu.data.deliverRep.reportType = SMS_REPORT_NEGATIVE; tpdu.data.deliverRep.failCause = SMS_FC_UNSPEC_ERROR; //response = TAPI_NETTEXT_PROTOCOL_ERROR; // For gcf test [34.2.5.3 class2 message] response = TAPI_NETTEXT_SIM_FULL; } MSG_DEBUG("err : [%d], response : [%02x]", err, response); tpdu.data.deliverRep.bHeaderInd = false; tpdu.data.deliverRep.paramInd = 0x00; // Encode SMS-DELIVER-REPORT TPDU int bufLen = 0; char buf[MAX_TPDU_DATA_LEN]; memset(buf, 0x00, sizeof(buf)); bufLen = SmsPluginTpduCodec::encodeTpdu(&tpdu, buf); // Make Telephony Structure TelSmsDatapackageInfo_t pkgInfo; // Set TPDU data memset((void*)pkgInfo.szData, 0x00, sizeof(pkgInfo.szData)); memcpy((void*)pkgInfo.szData, buf, bufLen); pkgInfo.szData[bufLen] = 0; pkgInfo.MsgLength = bufLen; // Set SMSC Address SMS_ADDRESS_S smsc; // Set SMSC Options setSmscOptions(&smsc); // Encode SMSC Address unsigned char smscAddr[MAX_SMSC_LEN]; memset(smscAddr, 0x00, sizeof(smscAddr)); int smscLen = SmsPluginParamCodec::encodeSMSC(&smsc, smscAddr); if (smscLen <= 0) return; // Set SMSC data memset(pkgInfo.Sca, 0x00, sizeof(pkgInfo.Sca)); memcpy((void*)pkgInfo.Sca, smscAddr, smscLen); pkgInfo.Sca[smscLen] = '\0'; // Send Deliver Report tapiRet = tel_send_sms_deliver_report(pTapiHandle, &pkgInfo, response, TapiEventDeliveryReportCNF, NULL); if (tapiRet == TAPI_API_SUCCESS) { MSG_DEBUG("######## tel_send_sms_deliver_report() Success !!! req Id : [%d] #######", reqId); } else { MSG_DEBUG("######## tel_send_sms_deliver_report() Fail !!! req Id : [%d] return : [%d] #######", reqId, tapiRet); } MSG_END(); }
void enterTowerLayerCopy(char *buffer) { char *hero_id,*towerId,*layerId,*perNikName,failMsg[LONG_MID_VALUE_LENGTH + 1] = {'\0'}; map<string,CpyLimit*>::iterator cpyLimt_it; map<string,map<string,string> >::iterator tower_it; map<string,string>::iterator layer_it; vector<string> heroId; TowerLayerRecord *towerLayerRecord; MSG_BEGIN(buffer, g_msg_len); /*解析id*/ MSG_CHAR(hero_id); #if 0 /*解析黑木崖塔id*/ MSG_CHAR(towerId); cout<<"towerId:"<<towerId<<endl; #endif towerId = pg_hero->memHero->nowTowerId; /*解析黑木崖层id*/ MSG_CHAR(layerId); cout<<"layerId:"<<layerId<<endl; heroId.push_back(hero_id); Failure_Reason* failure_reason = (Failure_Reason*)malloc(sizeof(Failure_Reason)); if(!initFailReson(failure_reason)) { cout<<"enterTowerLayerCopy failure_reason is NULL:"<<endl; free(failure_reason); return; } failure_reason->size = 0; size_t sizeFail = failure_reason->size; perNikName = pg_hero->getNickName(); #if 1 tower_it = towerMapConf.find(towerId); if(tower_it == towerMapConf.end()) { failure_reason->member[sizeFail].failure_flag = TOWER_LAYER_COPY_TOWER_ERROR; strncpy(failure_reason->member[sizeFail].nickName, perNikName, strlen(perNikName)); failure_reason->size += 1; dealFailRson(failure_reason,failMsg,sizeof(failMsg)); sendFailMsg(heroId,failMsg); free(failure_reason); cout<<"enterTowerLayerCopy the towerId is error:"<<towerId<<endl; return; } #endif layer_it = tower_it->second.find(layerId); if(layer_it == tower_it->second.end()) { failure_reason->member[sizeFail].failure_flag = TOWER_LAYER_COPY_LAYER_ERROR; strncpy(failure_reason->member[sizeFail].nickName, perNikName, strlen(perNikName)); failure_reason->size += 1; dealFailRson(failure_reason,failMsg,sizeof(failMsg)); sendFailMsg(heroId,failMsg); free(failure_reason); cout<<"enterTowerLayerCopy the layerId is error:"<<layerId<<endl; return; } towerLayerRecord = pg_hero->getTowerLayerRecord(); if(towerLayerRecord == NULL) { cout<<"enterTowerLayerCopy the towerLayerRecord is NULL:"<<pg_hero->getIdentity()<<endl; return; } #if 1 /*复查塔*/ if(!towerLayerRecord->isRightTower(towerId)) { failure_reason->member[sizeFail].failure_flag = TOWER_LAYER_COPY_TOWER_CLOSED; strncpy(failure_reason->member[sizeFail].nickName, perNikName, strlen(perNikName)); failure_reason->size += 1; dealFailRson(failure_reason,failMsg,sizeof(failMsg)); sendFailMsg(heroId,failMsg); free(failure_reason); cout<<"enterTowerLayerCopy the towerId is closed :"<<towerId<<endl; return; } #endif /*复查层*/ if(!towerLayerRecord->isRightLayer(layerId)) { failure_reason->member[sizeFail].failure_flag = TOWER_LAYER_COPY_LAYER_ERROR; strncpy(failure_reason->member[sizeFail].nickName, perNikName, strlen(perNikName)); failure_reason->size += 1; dealFailRson(failure_reason,failMsg,sizeof(failMsg)); sendFailMsg(heroId,failMsg); free(failure_reason); cout<<"enterTowerLayerCopy the layerId is closed :"<<layerId<<endl; return; } cpyLimt_it = cpyId_to_cpyLimit.find(layer_it->second); if(cpyLimt_it == cpyId_to_cpyLimit.end()) { failure_reason->member[sizeFail].failure_flag = TOWER_LAYER_COPY_COPY_ERROR; strncpy(failure_reason->member[sizeFail].nickName, perNikName, strlen(perNikName)); failure_reason->size += 1; dealFailRson(failure_reason,failMsg,sizeof(failMsg)); sendFailMsg(heroId,failMsg); free(failure_reason); cout<<"enterTowerLayerCopy the copyLimit is not find error:"<<layer_it->second<<endl; return; } /*资格审查*/ if(!cpyLimt_it->second->qualifyExamTowerLayerCopy(heroId,failure_reason)) { dealFailRson(failure_reason,failMsg,sizeof(failMsg)); sendFailMsg(heroId,failMsg); free(failure_reason); return; } cpyLimt_it->second->assignRom(heroId); free(failure_reason); pg_hero->setChoiseLayerId(layerId); char towerNameMsg[100] = {'\0'}; sprintf(towerNameMsg,"6,15,%s",cpyLimt_it->second->getName()); send_msg(pg_hero->getFd(),towerNameMsg); pg_hero->updataSingleTarget(0,1); //武林目标 }
void attactWagonComm(char *buff) { #if 0 char *wagonId; //马车Id char *skillId; //使用技能的Id int index = 0; //攻击者类型 MSG_BEGIN(buff, g_msg_len); MSG_INT(index); MSG_CHAR(wagonId); MSG_CHAR_END(skillId); //由fd查hero实例 Hero *hero = pg_hero; map<string,Wagon*>::iterator it_wagon; //cout<<"BisonTest:wagonInstMap size is "<<wagonInstMap.size()<<endl; it_wagon = wagonInstMap.find(wagonId); if (it_wagon == wagonInstMap.end()) { //没有这个马车 cout<<"BisonTest: Attack failed because of no the wagon of this id "<<wagonId<<endl; return; } Wagon *wagon = it_wagon->second; Map_Inform *wagonMap = hero->getMap(); if (wagonMap == NULL) { cout<<"This Map no Id ????????????????????"<<endl; return; } char *wagonMapId = wagonMap->getIdentity(); if (strcmp(wagonMapId, "map_001") == 0) { cout<<"You can't attack wagon In This Map"<<endl; return; } char* owerId; Hero *owner = wagon->getOwner(); if (owner == NULL) { cout<<"This wagon has no owner, but you can attack it"<<endl; goto LG; //没有主人的马车也能被打 // return; } //马车主人不能打自己的马车 owerId = owner->getIdentity(); if (!strcmp(owerId, hero->getIdentity())) { return; } LG: ; //全用像素点 Point wagonLocation = wagon->getPt(); int range; //攻击者的攻击范围 //bool isLive; //马车是否还活着 int distance = 0; //攻击者离马车距离 Skill *skill; //int skillNeedMagic = 0; //技能的魔法消耗 int attackLife = 100; //攻击者当前血量……置为宠物的属性值 int attackMagic = 100; //攻击者魔法……置为宠物的属性值 //int attackHurt = wagon->getHurt(); //马车每次被攻击掉血固定 //index = 0 为人攻击马车 if (index == 0) { map<string,Skill*> attack_skill_list; //玩家角色的技能列表 map<string,Skill*>::iterator skill_iter; attack_skill_list = hero->getSkill_list(); skill_iter = attack_skill_list.find(skillId); if(skill_iter == attack_skill_list.end()) { cout<<"BisonTest: hero does not has this skill to use when attack wagon"<<endl; return; } skill = skill_iter->second; //玩家所使用的技能 if (skill->gettype() != 1 || skill->geteffect() != 1) { //管你是群攻还是医疗,只要不是主动技能都别用来搞马车 cout<<"skill type can't attack wagon"<<endl; return; } if(!isFightStatusOfHero(hero, skill)) //判断玩家的真气,和技能的时间是否符合条件 { cout<<"BisonTest: magical or time is not ok to use this skill"<<endl; return; } cout<<"BisonTest: Hero attacks the wagon "<<wagonId<<endl; //判断距离是否够 Point heroLocation = hero->getLocation(); int deltaX = wagonLocation._x - heroLocation._x; int deltaY = wagonLocation._y - heroLocation._y; int distance = sqrt(deltaX * deltaX + deltaY * deltaY); range = hero->getAtk_range(); cout<<"BisonTest: distance is "<<distance<<" hero attack range is "<<range<<endl; if (distance > range) { cout<<"BisonTest: The wagon is out attack range"<<endl; return; } else { //攻击者者扣蓝 //hero->setMagicVal(hero->getMagicVal() - skillNeedMagic); PropertyOfAttackerChange(hero, skill); //玩家的当前血蓝 attackLife = hero->getLifeVal(); //难道还有攻击者自身会掉血的情况?不懂,随着他们用 attackMagic = hero->getMagicVal(); } } else if (index == 1) { //index = 1,为宠物打马车 Pet *pet = hero->getPetBox()->getActivePet(); if (pet == NULL) { cout<<"BisonTest: hero have no active Pet "<<endl; return; } else { //宠物位置 Point petLocation = pet->getLogicNow(); petLocation = LogicalExchangeMap(petLocation); int deltaX = wagonLocation._x - petLocation._x; int deltaY = wagonLocation._y - petLocation._y; int distance = sqrt(deltaX * deltaX + deltaY * deltaY); range = pet->getAttackRange(); cout<<"BisonTest: distance is "<<distance<<" pet attack range is "<<range<<endl; if (distance > range) { cout<<"BisonTest: The wagon is out attack range"<<endl; return; } } } else { return; } attackWagon(hero->getIdentity(), attackLife, attackMagic, skillId, wagonId); #endif }