2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include "MsgException.h"
22 #include "SmsPluginEventHandler.h"
23 #include "SmsPluginCbMsgHandler.h"
24 #include "SmsPluginConcatHandler.h"
25 #include "SmsPluginWapPushHandler.h"
26 #include "SmsPluginSatHandler.h"
27 #include "SmsPluginParamCodec.h"
28 #include "SmsPluginTpduCodec.h"
29 #include "SmsPluginTransport.h"
30 #include "SmsPluginSimMsg.h"
31 #include "SmsPluginSetting.h"
32 #include "MsgGconfWrapper.h"
33 #include "SmsPluginCallback.h"
35 extern struct tapi_handle *pTapiHandle;
37 /*==================================================================================================
38 FUNCTION IMPLEMENTATION
39 ==================================================================================================*/
40 void TapiEventDeviceReady(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
42 MSG_DEBUG("TapiEventDeviceReady is called. : noti_id = [%d]", noti_id);
47 SmsPluginEventHandler::instance()->setDeviceStatus();
49 catch (MsgException& e)
51 MSG_FATAL("%s", e.what());
58 void TapiEventSentStatus(TapiHandle *handle, int result, void *data, void *user_data)
60 MSG_DEBUG("TapiEventSentStatus is called. : result = [%d]", result);
62 msg_network_status_t netStatus;
64 // Convert TAPI status -> Messaging status
65 if ((TelSmsResponse_t)result == TAPI_NETTEXT_SENDSMS_SUCCESS)
66 netStatus = MSG_NETWORK_SEND_SUCCESS;
68 netStatus = MSG_NETWORK_SEND_FAIL;
73 SmsPluginEventHandler::instance()->handleSentStatus(netStatus);
76 SmsPluginSatHandler::instance()->ctrlSms(netStatus);
78 catch (MsgException& e)
80 MSG_FATAL("%s", e.what());
87 void TapiEventMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
89 MSG_DEBUG("TapiEventMsgIncoming is called. noti_id [%s]", noti_id);
92 MSG_DEBUG("Error. evt->pData is NULL.");
96 TelSmsDatapackageInfo_t* pDataPackage = (TelSmsDatapackageInfo_t*)data;
99 memset(&tpdu, 0x00, sizeof(SMS_TPDU_S));
101 // Decode Incoming Message
102 SmsPluginTpduCodec::decodeTpdu(pDataPackage->szData, pDataPackage->MsgLength, &tpdu);
105 if (tpdu.tpduType == SMS_TPDU_DELIVER)
107 MSG_DEBUG("############# SMS_TPDU_DELIVER Incoming decoded tpdu values ####################");
108 MSG_DEBUG("tpdu.data.deliver.bMoreMsg : %d", tpdu.data.deliver.bMoreMsg);
109 MSG_DEBUG("tpdu.data.deliver.bStatusReport : %d", tpdu.data.deliver.bStatusReport);
110 MSG_DEBUG("tpdu.data.deliver.bHeaderInd : %d", tpdu.data.deliver.bHeaderInd);
111 MSG_DEBUG("tpdu.data.deliver.bReplyPath : %d", tpdu.data.deliver.bReplyPath);
112 MSG_DEBUG("tpdu.data.deliver.pid : %d", tpdu.data.deliver.pid);
113 MSG_DEBUG("tpdu.data.deliver.dcs.bCompressed : %d", tpdu.data.deliver.dcs.bCompressed);
114 MSG_DEBUG("tpdu.data.deliver.dcs.msgClass : %d", tpdu.data.deliver.dcs.msgClass);
115 MSG_DEBUG("tpdu.data.deliver.dcs.codingScheme : %d", tpdu.data.deliver.dcs.codingScheme);
116 MSG_DEBUG("tpdu.data.deliver.dcs.codingGroup : %d", tpdu.data.deliver.dcs.codingGroup);
117 MSG_DEBUG("tpdu.data.deliver.dcs.bIndActive : %d", tpdu.data.deliver.dcs.bIndActive);
118 MSG_DEBUG("tpdu.data.deliver.originAddress.address : %s", tpdu.data.deliver.originAddress.address);
119 MSG_DEBUG("tpdu.data.deliver.timeStamp.time : %d/%d/%d %d:%d:%d ", tpdu.data.deliver.timeStamp.time.absolute.year, tpdu.data.deliver.timeStamp.time.absolute.month, tpdu.data.deliver.timeStamp.time.absolute.day,
120 tpdu.data.deliver.timeStamp.time.absolute.hour, tpdu.data.deliver.timeStamp.time.absolute.minute, tpdu.data.deliver.timeStamp.time.absolute.second);
121 MSG_DEBUG("tpdu.data.deliver.userData.headerCnt : %d", tpdu.data.deliver.userData.headerCnt);
122 MSG_DEBUG("tpdu.data.deliver.userData.length : %d", tpdu.data.deliver.userData.length);
123 MSG_DEBUG("tpdu.data.deliver.userData.data : %s", tpdu.data.deliver.userData.data);
124 MSG_DEBUG("#####################################################");
126 else if (tpdu.tpduType == SMS_TPDU_STATUS_REP)
128 MSG_DEBUG("############# SMS_TPDU_STATUS_REP Incoming decoded tpdu values ####################");
129 MSG_DEBUG("tpdu.data.statusRep.msgRef : %d", tpdu.data.statusRep.msgRef);
130 MSG_DEBUG("tpdu.data.statusRep.bMoreMsg : %d", tpdu.data.statusRep.bMoreMsg);
131 MSG_DEBUG("tpdu.data.statusRep.bStatusReport : %d", tpdu.data.statusRep.bStatusReport);
132 MSG_DEBUG("tpdu.data.statusRep.statusRep : %d", tpdu.data.statusRep.bHeaderInd);
133 MSG_DEBUG("tpdu.data.statusRep.status : %02x", tpdu.data.statusRep.status);
134 MSG_DEBUG("tpdu.data.statusRep.pid : %d", tpdu.data.statusRep.pid);
135 MSG_DEBUG("tpdu.data.statusRep.dcs.bCompressed : %d", tpdu.data.statusRep.dcs.bCompressed);
136 MSG_DEBUG("tpdu.data.statusRep.dcs.msgClass : %d", tpdu.data.statusRep.dcs.msgClass);
137 MSG_DEBUG("tpdu.data.statusRep.dcs.codingScheme : %d", tpdu.data.statusRep.dcs.codingScheme);
138 MSG_DEBUG("tpdu.data.statusRep.dcs.codingGroup : %d", tpdu.data.statusRep.dcs.codingGroup);
139 MSG_DEBUG("tpdu.data.statusRep.recipAddress.address : %s", tpdu.data.statusRep.recipAddress.address);
140 MSG_DEBUG("tpdu.data.statusRep.timeStamp.time : %d/%d/%d %d:%d:%d ", tpdu.data.statusRep.timeStamp.time.absolute.year, tpdu.data.statusRep.timeStamp.time.absolute.month, tpdu.data.statusRep.timeStamp.time.absolute.day,
141 tpdu.data.statusRep.timeStamp.time.absolute.hour, tpdu.data.statusRep.timeStamp.time.absolute.minute, tpdu.data.statusRep.timeStamp.time.absolute.second);
142 MSG_DEBUG("tpdu.data.statusRep.dischargeTime.time : %d/%d/%d %d:%d:%d ", tpdu.data.statusRep.dischargeTime.time.absolute.year, tpdu.data.statusRep.dischargeTime.time.absolute.month, tpdu.data.statusRep.dischargeTime.time.absolute.day,
143 tpdu.data.statusRep.dischargeTime.time.absolute.hour, tpdu.data.statusRep.dischargeTime.time.absolute.minute, tpdu.data.statusRep.dischargeTime.time.absolute.second);
144 MSG_DEBUG("tpdu.data.statusRep.userData.headerCnt : %d", tpdu.data.statusRep.userData.headerCnt);
145 MSG_DEBUG("tpdu.data.statusRep.userData.length : %d", tpdu.data.statusRep.userData.length);
146 MSG_DEBUG("tpdu.data.statusRep.userData.data : %s", tpdu.data.statusRep.userData.data);
147 MSG_DEBUG("#####################################################");
152 if (tpdu.tpduType == SMS_TPDU_DELIVER)
154 if (tpdu.data.deliver.dcs.msgClass == SMS_MSG_CLASS_2) {
155 // For GCF test, 34.2.5.3
156 SmsPluginSimMsg::instance()->setSmsData((const char*)pDataPackage->Sca, (const char *)pDataPackage->szData, pDataPackage->MsgLength);
159 if (SmsPluginConcatHandler::instance()->IsConcatMsg(&(tpdu.data.deliver.userData)) == true ||
160 SmsPluginWapPushHandler::instance()->IsWapPushMsg(&(tpdu.data.deliver.userData)) == true)
162 SmsPluginConcatHandler::instance()->handleConcatMsg(&tpdu); // Call Concat Msg Handler
166 SmsPluginEventHandler::instance()->handleMsgIncoming(&tpdu); // Call Event Handler
169 else if (tpdu.tpduType == SMS_TPDU_STATUS_REP)
171 SmsPluginEventHandler::instance()->handleMsgIncoming(&tpdu); // Call Event Handler
174 catch (MsgException& e)
176 MSG_FATAL("%s", e.what());
183 void TapiEventCbMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
185 MSG_DEBUG("TapiEventCbMsgIncoming is called. noti_id [%s]", noti_id);
188 MSG_DEBUG("Error. evt->pData is NULL.");
192 TelSmsCbMsg_t *pCbMsg = (TelSmsCbMsg_t*)data;
196 SmsPluginCbMsgHandler::instance()->handleCbMsg(pCbMsg);
198 catch (MsgException& e)
200 MSG_FATAL("%s", e.what());
207 void TapiEventEtwsMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
209 MSG_DEBUG("TapiEventEtwsMsgIncoming is called. noti_id [%s]", noti_id);
212 MSG_DEBUG("Error. evt->pData is NULL.");
216 TelSmsEtwsMsg_t *pEtwsMsg = (TelSmsEtwsMsg_t*)data;
220 SmsPluginCbMsgHandler::instance()->handleEtwsMsg(pEtwsMsg);
222 catch (MsgException& e)
224 MSG_FATAL("%s", e.what());
230 void TapiEventDeliveryReportCNF(TapiHandle *handle, int result, void *data, void *user_data)
232 MSG_DEBUG("TapiEventDeliveryReportCNF is called. : result = [%d]", result);
238 void TapiEventGetSimMsgCnt(TapiHandle *handle, int result, void *data, void *user_data)
240 MSG_DEBUG("TapiEventGetSimMsgCnt is called.");
242 if (result != TAPI_API_SUCCESS || data == NULL)
244 MSG_DEBUG("Error. data is NULL.");
245 MSG_SIM_COUNT_S simCnt;
246 memset(&simCnt, 0x00, sizeof(MSG_SIM_COUNT_S));
247 SmsPluginSimMsg::instance()->setSimMsgCntEvent(&simCnt);
251 SmsPluginSimMsg::instance()->setSimMsgCntEvent((MSG_SIM_COUNT_S *)data);
256 void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_data)
258 MSG_DEBUG("TapiEventGetSimMsg is called.");
260 if (result != TAPI_API_SUCCESS || data == NULL)
262 MSG_DEBUG("Error!! pEvent->Status [%d]", result);
264 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
269 TelSmsData_t* pSmsTpdu = (TelSmsData_t*)data;
271 // Reading TelSmsData_t
272 MSG_DEBUG ("sim index %d", pSmsTpdu->SimIndex);
273 MSG_DEBUG ("status %d", pSmsTpdu->MsgStatus);
275 // Reading TelSmsDatapackageInfo_t
276 if (pSmsTpdu->SmsData.MsgLength > MAX_TPDU_DATA_LEN)
278 MSG_DEBUG ("WARNING: tpdu_len > MAX_SMS_TPDU_SIZE [%d] bytes. setting to 0.", pSmsTpdu->SmsData.MsgLength);
280 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
288 SmsPluginTpduCodec::decodeTpdu(pSmsTpdu->SmsData.szData, pSmsTpdu->SmsData.MsgLength, &tpdu);
290 MSG_DEBUG("Sim Message Type [%d]", tpdu.tpduType);
295 if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_READ)
297 else if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_UNREAD)
300 if (tpdu.tpduType == SMS_TPDU_DELIVER)
302 if (tpdu.data.deliver.dcs.codingScheme == SMS_CHARSET_8BIT && tpdu.data.deliver.pid == 0x11) {
303 MSG_DEBUG("Unsupported message!!");
304 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
308 MSG_DEBUG("headerCnt [%d]", tpdu.data.deliver.userData.headerCnt);
309 for (int i = 0; i < tpdu.data.deliver.userData.headerCnt; i++)
311 // Handler Concatenated Message
312 if (tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
313 tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT)
315 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
320 else if (tpdu.tpduType == SMS_TPDU_SUBMIT)
322 if (tpdu.data.submit.dcs.codingScheme == SMS_CHARSET_8BIT && tpdu.data.submit.pid == 0x11) {
323 MSG_DEBUG("Unsupported message!!");
324 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
328 MSG_DEBUG("headerCnt [%d]", tpdu.data.submit.userData.headerCnt);
330 for (int i = 0; i < tpdu.data.submit.userData.headerCnt; i++)
332 // Handler Concatenated Message
333 if (tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
334 tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT)
336 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
342 // Make MSG_MESSAGE_INFO_S
343 MSG_MESSAGE_INFO_S msgInfo;
344 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
346 SmsPluginEventHandler::instance()->convertTpduToMsginfo(&tpdu, &msgInfo);
348 // set Sim Message ID
349 msgInfo.msgId = pSmsTpdu->SimIndex;
352 msgInfo.bRead = bRead;
355 msgInfo.storageId = MSG_STORAGE_SIM;
357 /// Print MSG_MESSAGE_INFO_S
358 MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
359 MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
360 MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
361 MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
362 MSG_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
363 MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
364 MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
365 MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
366 MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
367 MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
368 MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
369 MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
370 MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
371 MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
372 MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
373 if (msgInfo.bTextSms == true)
374 MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
376 MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
377 MSG_DEBUG("###############################################################");
379 SmsPluginSimMsg::instance()->setSimMsgEvent(&msgInfo, true); // Call Event Handler
384 void TapiEventSaveSimMsg(TapiHandle *handle, int result, void *data, void *user_data)
386 MSG_DEBUG("TapiEventSaveSimMsg is called. result [%d]", result);
391 simId = *((int*)data);
393 MSG_DEBUG("Data(SIM Msg ID) is NULL");
395 SmsPluginSimMsg::instance()->setSaveSimMsgEvent(simId, result);
399 void TapiEventSaveClass2Msg(TapiHandle *handle, int result, void *data, void *user_data)
401 MSG_DEBUG("TapiEventSaveSimMsg is called. result [%d]", result);
406 simId = *((int*)data);
408 MSG_DEBUG("Data(SIM Msg ID) is NULL");
410 SmsPluginSimMsg::instance()->setSaveClass2MsgEvent(simId, result);
414 void TapiEventDeleteSimMsg(TapiHandle *handle, int result, void *data, void *user_data)
416 MSG_DEBUG("TapiEventDeleteSimMsg is called. result [%d]", result);
418 MSG_DEBUG("status : [%d]", (TelSmsCause_t)result);
420 if (result != TAPI_API_SUCCESS || data == NULL)
422 MSG_DEBUG("Error. data is NULL.");
423 SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)0, false);
427 int sim_id = *((int*)data);
429 SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)sim_id, true);
434 void TapiEventSetConfigData(TapiHandle *handle, int result, void *data, void *user_data)
436 MSG_DEBUG("TapiEventSetConfigData is called.");
440 MSG_DEBUG("Error. data is NULL.");
444 TelSmsSetResponse* responseType = (TelSmsSetResponse*)data;
446 MSG_DEBUG("responseType : [%d]", *responseType);
448 switch (*responseType)
450 case TAPI_NETTEXT_SETPREFERREDBEARER_RSP :
451 MSG_DEBUG("TAPI_NETTEXT_SETPREFERREDBEARER_RSP is called");
454 case TAPI_NETTEXT_SETPARAMETERS_RSP :
455 MSG_DEBUG("TAPI_NETTEXT_SETPARAMETERS_RSP is called");
458 case TAPI_NETTEXT_CBSETCONFIG_RSP :
459 MSG_DEBUG("TAPI_NETTEXT_CBSETCONFIG_RSP is called");
462 case TAPI_NETTEXT_SETMEMORYSTATUS_RSP :
463 MSG_DEBUG("TAPI_NETTEXT_SETMEMORYSTATUS_RSP is called");
466 case TAPI_NETTEXT_SETMESSAGESTATUS_RSP :
467 MSG_DEBUG("TAPI_NETTEXT_SETMESSAGESTATUS_RSP is called");
471 MSG_DEBUG("Unknown Response is called [%d]", *responseType);
477 MSG_DEBUG("status : [%d]", (TelSmsCause_t)result);
479 if ((TelSmsCause_t)result != TAPI_NETTEXT_SUCCESS) bRet = false;
481 if (*responseType == TAPI_NETTEXT_SETMESSAGESTATUS_RSP)
482 SmsPluginSimMsg::instance()->setSimEvent(0, bRet);
484 SmsPluginSetting::instance()->setResultFromSim(bRet);
489 void TapiEventGetParamCnt(TapiHandle *handle, int result, void *data, void *user_data)
491 MSG_DEBUG("TapiEventGetParamCnt is called.");
493 if (result != TAPI_API_SUCCESS || data == NULL)
495 MSG_DEBUG("Error. evt->pData is NULL.");
496 SmsPluginSetting::instance()->setParamCntEvent(0);
501 paramCnt = *((int*)data);
503 SmsPluginSetting::instance()->setParamCntEvent(paramCnt);
508 void TapiEventGetParam(TapiHandle *handle, int result, void *data, void *user_data)
510 MSG_DEBUG("TapiEventGetConfigData is called.");
512 if (result != TAPI_API_SUCCESS || data == NULL)
514 MSG_DEBUG("Error. data is NULL.");
515 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
519 TelSmsParams_t* smsParam = (TelSmsParams_t*)data;
523 MSG_SMSC_DATA_S smscData = {0, };
525 /*Check Alpha ID value*/
526 alphaIdLen = smsParam->AlphaIdLen;
527 MSG_DEBUG("alphaId_len[%d]", alphaIdLen);
529 if (alphaIdLen < 0 || alphaIdLen > SMSC_NAME_MAX)
531 MSG_DEBUG("Wrong Alpha ID Length[%d]", alphaIdLen);
533 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
539 /*Check Address value*/
540 addrLen = smsParam->TpSvcCntrAddr.DialNumLen;
542 if(addrLen > SMSC_ADDR_MAX)
544 MSG_DEBUG("addrLen is too long: %d", addrLen);
545 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
550 MSG_DEBUG("addrLen is too short: %d", addrLen);
551 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
555 MSG_DEBUG("addrLen : %d", addrLen);
558 /*SMSP Parameter Indicator value*/
559 MSG_DEBUG("ParamIndicator[%02x]", smsParam->ParamIndicator);
562 if(0x00 == (0x02 & smsParam->ParamIndicator))
564 MSG_DEBUG("record index[%d]", (int)smsParam->RecordIndex);
566 MSG_DEBUG("TON : %d", smsParam->TpSvcCntrAddr.Ton);
567 MSG_DEBUG("NPI : %d", smsParam->TpSvcCntrAddr.Npi);
569 smscData.smscAddr.ton = smsParam->TpSvcCntrAddr.Ton;
570 smscData.smscAddr.npi = smsParam->TpSvcCntrAddr.Npi;
572 SmsPluginParamCodec paramCodec;
574 memset(smscData.smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
575 paramCodec.decodeSMSC(smsParam->TpSvcCntrAddr.szDiallingNum, addrLen, smscData.smscAddr.ton, smscData.smscAddr.address);
577 MSG_DEBUG("SMSC Address : [%s]", smscData.smscAddr.address);
579 memset(smscData.name, 0x00, SMSC_NAME_MAX+1);
580 memcpy(smscData.name, smsParam->szAlphaId, alphaIdLen);
581 smscData.name[alphaIdLen] = '\0';
583 MSG_DEBUG("SMSC Name : [%s]", smscData.name);
587 MSG_DEBUG("SMSC Address is not present");
589 // smscData.smscAddr.ton = MSG_TON_UNKNOWN;
590 // smscData.smscAddr.npi = MSG_NPI_UNKNOWN;
592 // memset(smscData.smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
593 // memset(smscData.name, 0x00, SMSC_NAME_MAX+1);
595 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
600 /*Get the PID value*/
601 if (0x00 == (0x04 & smsParam->ParamIndicator))
603 SMS_PID_T pid = (SMS_PID_T)smsParam->TpProtocolId;
605 MSG_DEBUG("smsParam->TpProtocolId : %d", smsParam->TpProtocolId);
610 smscData.pid = MSG_PID_TEXT;
613 smscData.pid = MSG_PID_VOICE;
616 smscData.pid = MSG_PID_FAX;
619 smscData.pid = MSG_PID_X400;
622 smscData.pid = MSG_PID_ERMES;
625 smscData.pid = MSG_PID_EMAIL;
628 smscData.pid = MSG_PID_TEXT;
632 MSG_DEBUG("smscData.pid : %d", smscData.pid);
636 MSG_DEBUG("PID is not present");
637 smscData.pid = MSG_PID_TEXT;
638 MSG_DEBUG("MSG_PID_TEXT is inserted to PID");
642 /*Get the DCS value*/
643 if (0x00 == (0x08 & smsParam->ParamIndicator))
645 smscList.smscData[index].dcs = smsParam->TpDataCodingScheme;
646 MSG_DEBUG("dcs : %d", smscList.smscData[index].dcs);
650 smscList.smscData[index].dcs = MSG_ENCODE_GSM7BIT;
651 MSG_DEBUG("DCS is not present");
655 /*Get the ValidityPeriod value*/
656 if (0x00 == (0x10 & smsParam->ParamIndicator))
658 smscData.valPeriod = smsParam->TpValidityPeriod;
659 MSG_DEBUG("valPeriod : %d", smscData.valPeriod);
663 smscData.valPeriod = 0;
664 MSG_DEBUG("Validity Period is not present");
667 SmsPluginSetting::instance()->setParamEvent(&smscData, (int)smsParam->RecordIndex, true);
672 void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user_data)
674 MSG_DEBUG("TapiEventGetCBConfig is called.");
676 MSG_CBMSG_OPT_S cbOpt = {0};
678 if (result != TAPI_API_SUCCESS || data == NULL)
680 MSG_DEBUG("Error. data is NULL.");
682 SmsPluginSetting::instance()->setCbConfigEvent(NULL, false);
687 TelSmsCbConfig_t* pCBConfig = (TelSmsCbConfig_t*)data;
689 cbOpt.bReceive = (bool)pCBConfig->CBEnabled;
691 cbOpt.maxSimCnt = pCBConfig->MsgIdMaxCount;
693 MSG_DEBUG("Receive [%d], Max SIM Count [%d]", cbOpt.bReceive, cbOpt.maxSimCnt);
695 cbOpt.channelData.channelCnt = pCBConfig->MsgIdRangeCount;
697 if (cbOpt.channelData.channelCnt > CB_CHANNEL_MAX)
699 MSG_DEBUG("Channel Count [%d] from TAPI is over MAX", cbOpt.channelData.channelCnt);
700 cbOpt.channelData.channelCnt = CB_CHANNEL_MAX;
703 if (MsgSettingSetInt(CB_CHANNEL_COUNT, cbOpt.channelData.channelCnt) != MSG_SUCCESS) {
704 MSG_DEBUG("Error to set config data [%s]", CB_CHANNEL_COUNT);
707 MSG_DEBUG("Channel Count [%d]", cbOpt.channelData.channelCnt);
709 for (int i = 0; i < cbOpt.channelData.channelCnt; i++)
711 cbOpt.channelData.channelInfo[i].bActivate = pCBConfig->MsgIDs[i].Net3gpp.Selected;
712 cbOpt.channelData.channelInfo[i].from = pCBConfig->MsgIDs[i].Net3gpp.FromMsgId;
713 cbOpt.channelData.channelInfo[i].to = pCBConfig->MsgIDs[i].Net3gpp.ToMsgId;
714 memset(cbOpt.channelData.channelInfo[i].name, 0x00, CB_CHANNEL_NAME_MAX+1);
716 MSG_DEBUG("Channel FROM [%d], Channel TO [%d] ", cbOpt.channelData.channelInfo[i].from, cbOpt.channelData.channelInfo[i].to);
719 SmsPluginSetting::instance()->setCbConfigEvent(&cbOpt, true);
722 void TapiEventSetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data)
724 MSG_DEBUG("TapiEventSetMailboxInfo is called. result = [%d]", result);
728 if (result != TAPI_SIM_ACCESS_SUCCESS)
731 SmsPluginSetting::instance()->setResultFromSim(bRet);
734 void TapiEventGetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data)
736 MSG_DEBUG("TapiEventGetMailboxInfo is called.");
738 if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL)
740 MSG_DEBUG("Error. data is NULL.");
741 SmsPluginSetting::instance()->setMailboxInfoEvent(NULL, false);
746 TelSimMailboxList_t *list = (TelSimMailboxList_t *)data;
747 SMS_SIM_MAILBOX_LIST_S mbList = {0,};
749 if (list->count <= 0) {
750 SmsPluginSetting::instance()->setMailboxInfoEvent(NULL, true);
754 mbList.count = list->count;
756 for (int i = 0; i < mbList.count; i++) {
757 mbList.list[i].b_cphs = list->list[i].b_cphs;
758 mbList.list[i].alpha_id_max_len = list->list[i].alpha_id_max_len;
759 mbList.list[i].mb_type = list->list[i].mb_type;
760 mbList.list[i].profile_num = list->list[i].profile_num;
761 mbList.list[i].rec_index = list->list[i].rec_index;
762 mbList.list[i].ton = list->list[i].ton;
763 mbList.list[i].npi = list->list[i].npi;
764 snprintf(mbList.list[i].alpha_id, sizeof(mbList.list[i].alpha_id), "%s", list->list[i].alpha_id);
765 snprintf(mbList.list[i].num, sizeof(mbList.list[i].num), "%s", list->list[i].num);
766 mbList.list[i].cc_id = list->list[i].cc_id;
767 mbList.list[i].ext1_id = list->list[i].ext1_id;
770 SmsPluginSetting::instance()->setMailboxInfoEvent(&mbList, true);
773 void TapiEventSetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data)
775 MSG_DEBUG("TapiEventSetMwiInfo is called. result = [%d]", result);
778 void TapiEventGetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data)
780 MSG_DEBUG("TapiEventGetMwiInfo is called.");
782 if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL)
784 MSG_DEBUG("Error. data is NULL.");
785 SmsPluginSetting::instance()->setMwiInfoEvent(NULL, false);
790 TelSimMessageWaitingResp_t *MwiInfo = (TelSimMessageWaitingResp_t *)data;
791 SMS_SIM_MWI_INFO_S simMwiInfo = {0,};
793 memcpy(&simMwiInfo, MwiInfo, sizeof(SMS_SIM_MWI_INFO_S));
795 SmsPluginSetting::instance()->setMwiInfoEvent(&simMwiInfo, true);
798 void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *user_data)
800 MSG_DEBUG("TapiEventGetMsisdnInfo is called.");
802 if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL)
804 MSG_DEBUG("Error. data is NULL.");
808 TelSimMsisdnList_t *list = (TelSimMsisdnList_t *)data;
810 for (int i = 0; i < list->count; i++) {
811 if (list->list[i].num[0] != '\0') {
812 if (MsgSettingSetString(MSG_SIM_MSISDN, list->list[i].num) == MSG_SUCCESS)
813 MSG_DEBUG("Get MSISDN from SIM : [%s]", list->list[i].num);
815 MSG_DEBUG("Getting MSISDN is failed!");
822 void TapiEventSatSmsRefresh(TapiHandle *handle, int result, void *data, void *user_data)
824 MSG_DEBUG("TapiEventSatSmsRefresh is called.");
826 if (result != TAPI_API_SUCCESS || data == NULL)
828 MSG_DEBUG("Error. data is NULL.");
834 SmsPluginSatHandler::instance()->refreshSms(data);
836 catch (MsgException& e)
838 MSG_FATAL("%s", e.what());
845 void TapiEventSatSendSms(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
847 MSG_DEBUG("TapiEventSatSendSms is called.");
851 MSG_DEBUG("Error. data is NULL.");
857 SmsPluginSatHandler::instance()->sendSms(data);
859 catch (MsgException& e)
861 MSG_FATAL("%s", e.what());
868 void TapiEventSatMoSmsCtrl(TapiHandle *handle, int result, void *data, void *user_data)
870 MSG_DEBUG("TapiEventSatMoSmsCtrl is called.");
872 if (result != TAPI_API_SUCCESS || data == NULL)
874 MSG_DEBUG("Error. data is NULL.");
880 SmsPluginSatHandler::instance()->ctrlSms(data);
882 catch (MsgException& e)
884 MSG_FATAL("%s", e.what());
890 void TapiEventMemoryStatus(TapiHandle *handle, int result, void *data, void *user_data)
892 MSG_DEBUG("Tapi result is [%d]", result);
895 void TapiEventSetMsgStatus(TapiHandle *handle, int result, void *data, void *user_data)
897 MSG_DEBUG("TapiEventSetMsgStatus is called. result [%d]", result);
899 if (result != TAPI_API_SUCCESS || data == NULL)
901 MSG_DEBUG("Error. data is NULL.");
902 SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)0, false);
906 msg_sim_id_t sim_id = *((msg_sim_id_t *)user_data);
908 SmsPluginSimMsg::instance()->setSimEvent(sim_id, true);
911 /*==================================================================================================
912 IMPLEMENTATION OF SmsPluginCallback - Member Functions
913 ==================================================================================================*/
914 SmsPluginCallback* SmsPluginCallback::pInstance = NULL;
917 SmsPluginCallback::SmsPluginCallback()
924 SmsPluginCallback::~SmsPluginCallback()
926 if (pInstance != NULL)
934 SmsPluginCallback* SmsPluginCallback::instance()
937 pInstance = new SmsPluginCallback();
943 void SmsPluginCallback::registerEvent()
945 tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_DEVICE_READY, TapiEventDeviceReady, NULL);
946 tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_INCOM_MSG, TapiEventMsgIncoming, NULL);
947 tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_CB_INCOM_MSG, TapiEventCbMsgIncoming, NULL);
948 tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_ETWS_INCOM_MSG, TapiEventEtwsMsgIncoming, NULL);
949 // tel_register_noti_event(pTapiHandle, TAPI_NOTI_SAT_REFRESH, TapiEventSatSmsRefresh, NULL);
950 tel_register_noti_event(pTapiHandle, TAPI_NOTI_SAT_SEND_SMS, TapiEventSatSendSms, NULL);
951 // tel_register_noti_event(pTapiHandle, TAPI_NOTI_SAT_MO_SMS_CTRL, TapiEventSatMoSmsCtrl, NULL);
955 void SmsPluginCallback::deRegisterEvent()