2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (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://www.tizenopensource.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.originAddress.address : %s", tpdu.data.deliver.originAddress.address);
118 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,
119 tpdu.data.deliver.timeStamp.time.absolute.hour, tpdu.data.deliver.timeStamp.time.absolute.minute, tpdu.data.deliver.timeStamp.time.absolute.second);
120 MSG_DEBUG("tpdu.data.deliver.userData.headerCnt : %d", tpdu.data.deliver.userData.headerCnt);
121 MSG_DEBUG("tpdu.data.deliver.userData.length : %d", tpdu.data.deliver.userData.length);
122 MSG_DEBUG("tpdu.data.deliver.userData.data : %s", tpdu.data.deliver.userData.data);
123 MSG_DEBUG("#####################################################");
125 else if (tpdu.tpduType == SMS_TPDU_STATUS_REP)
127 MSG_DEBUG("############# SMS_TPDU_STATUS_REP Incoming decoded tpdu values ####################");
128 MSG_DEBUG("tpdu.data.statusRep.msgRef : %d", tpdu.data.statusRep.msgRef);
129 MSG_DEBUG("tpdu.data.statusRep.bMoreMsg : %d", tpdu.data.statusRep.bMoreMsg);
130 MSG_DEBUG("tpdu.data.statusRep.bStatusReport : %d", tpdu.data.statusRep.bStatusReport);
131 MSG_DEBUG("tpdu.data.statusRep.statusRep : %d", tpdu.data.statusRep.bHeaderInd);
132 MSG_DEBUG("tpdu.data.statusRep.status : %02x", tpdu.data.statusRep.status);
133 MSG_DEBUG("tpdu.data.statusRep.pid : %d", tpdu.data.statusRep.pid);
134 MSG_DEBUG("tpdu.data.statusRep.dcs.bCompressed : %d", tpdu.data.statusRep.dcs.bCompressed);
135 MSG_DEBUG("tpdu.data.statusRep.dcs.msgClass : %d", tpdu.data.statusRep.dcs.msgClass);
136 MSG_DEBUG("tpdu.data.statusRep.dcs.codingScheme : %d", tpdu.data.statusRep.dcs.codingScheme);
137 MSG_DEBUG("tpdu.data.statusRep.dcs.codingGroup : %d", tpdu.data.statusRep.dcs.codingGroup);
138 MSG_DEBUG("tpdu.data.statusRep.recipAddress.address : %s", tpdu.data.statusRep.recipAddress.address);
139 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,
140 tpdu.data.statusRep.timeStamp.time.absolute.hour, tpdu.data.statusRep.timeStamp.time.absolute.minute, tpdu.data.statusRep.timeStamp.time.absolute.second);
141 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,
142 tpdu.data.statusRep.dischargeTime.time.absolute.hour, tpdu.data.statusRep.dischargeTime.time.absolute.minute, tpdu.data.statusRep.dischargeTime.time.absolute.second);
143 MSG_DEBUG("tpdu.data.statusRep.userData.headerCnt : %d", tpdu.data.statusRep.userData.headerCnt);
144 MSG_DEBUG("tpdu.data.statusRep.userData.length : %d", tpdu.data.statusRep.userData.length);
145 MSG_DEBUG("tpdu.data.statusRep.userData.data : %s", tpdu.data.statusRep.userData.data);
146 MSG_DEBUG("#####################################################");
151 if (tpdu.tpduType == SMS_TPDU_DELIVER)
153 if (tpdu.data.deliver.dcs.msgClass == SMS_MSG_CLASS_2) {
154 // For GCF test, 34.2.5.3
155 SmsPluginSimMsg::instance()->setSmsData((const char*)pDataPackage->Sca, (const char *)pDataPackage->szData, pDataPackage->MsgLength);
158 if (tpdu.data.deliver.dcs.codingGroup == SMS_GROUP_DISCARD) {
159 if (tpdu.data.deliver.dcs.bIndActive == false) {
160 SmsPluginSetting::instance()->setMwiInfo(tpdu.data.deliver.dcs.indType + MSG_MWI_VOICE_SMS, 0);
162 SmsPluginTransport::instance()->sendDeliverReport(MSG_SUCCESS);
164 if (SmsPluginConcatHandler::instance()->IsConcatMsg(&(tpdu.data.deliver.userData)) == true ||
165 SmsPluginWapPushHandler::instance()->IsWapPushMsg(&(tpdu.data.deliver.userData)) == true)
167 SmsPluginConcatHandler::instance()->handleConcatMsg(&tpdu); // Call Concat Msg Handler
171 SmsPluginEventHandler::instance()->handleMsgIncoming(&tpdu); // Call Event Handler
175 else if (tpdu.tpduType == SMS_TPDU_STATUS_REP)
177 SmsPluginEventHandler::instance()->handleMsgIncoming(&tpdu); // Call Event Handler
180 catch (MsgException& e)
182 MSG_FATAL("%s", e.what());
189 void TapiEventCbMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
191 MSG_DEBUG("TapiEventCbMsgIncoming is called. noti_id [%s]", noti_id);
194 MSG_DEBUG("Error. evt->pData is NULL.");
198 TelSmsCbMsg_t *pCbMsg = (TelSmsCbMsg_t*)data;
202 SmsPluginCbMsgHandler::instance()->handleCbMsg(pCbMsg);
204 catch (MsgException& e)
206 MSG_FATAL("%s", e.what());
213 void TapiEventEtwsMsgIncoming(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
215 MSG_DEBUG("TapiEventEtwsMsgIncoming is called. noti_id [%s]", noti_id);
218 MSG_DEBUG("Error. evt->pData is NULL.");
222 TelSmsEtwsMsg_t *pEtwsMsg = (TelSmsEtwsMsg_t*)data;
226 SmsPluginCbMsgHandler::instance()->handleEtwsMsg(pEtwsMsg);
228 catch (MsgException& e)
230 MSG_FATAL("%s", e.what());
236 void TapiEventDeliveryReportCNF(TapiHandle *handle, int result, void *data, void *user_data)
238 MSG_DEBUG("TapiEventDeliveryReportCNF is called. : result = [%d]", result);
244 void TapiEventGetSimMsgCnt(TapiHandle *handle, int result, void *data, void *user_data)
246 MSG_DEBUG("TapiEventGetSimMsgCnt is called.");
248 if (result != TAPI_API_SUCCESS || data == NULL)
250 MSG_DEBUG("Error. data is NULL.");
251 MSG_SIM_COUNT_S simCnt;
252 memset(&simCnt, 0x00, sizeof(MSG_SIM_COUNT_S));
253 SmsPluginSimMsg::instance()->setSimMsgCntEvent(&simCnt);
257 SmsPluginSimMsg::instance()->setSimMsgCntEvent((MSG_SIM_COUNT_S *)data);
262 void TapiEventGetSimMsg(TapiHandle *handle, int result, void *data, void *user_data)
264 MSG_DEBUG("TapiEventGetSimMsg is called.");
266 if (result != TAPI_API_SUCCESS || data == NULL)
268 MSG_DEBUG("Error!! pEvent->Status [%d]", result);
270 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
275 TelSmsData_t* pSmsTpdu = (TelSmsData_t*)data;
277 // Reading TelSmsData_t
278 MSG_DEBUG ("sim index %d", pSmsTpdu->SimIndex);
279 MSG_DEBUG ("status %d", pSmsTpdu->MsgStatus);
281 // Reading TelSmsDatapackageInfo_t
282 if (pSmsTpdu->SmsData.MsgLength > MAX_TPDU_DATA_LEN)
284 MSG_DEBUG ("WARNING: tpdu_len > MAX_SMS_TPDU_SIZE [%d] bytes. setting to 0.", pSmsTpdu->SmsData.MsgLength);
286 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
294 SmsPluginTpduCodec::decodeTpdu(pSmsTpdu->SmsData.szData, pSmsTpdu->SmsData.MsgLength, &tpdu);
296 MSG_DEBUG("Sim Message Type [%d]", tpdu.tpduType);
301 if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_READ)
303 else if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_UNREAD)
306 if (tpdu.tpduType == SMS_TPDU_DELIVER)
308 if (tpdu.data.deliver.dcs.codingScheme == SMS_CHARSET_8BIT && tpdu.data.deliver.pid == 0x11) {
309 MSG_DEBUG("Unsupported message!!");
310 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
314 MSG_DEBUG("headerCnt [%d]", tpdu.data.deliver.userData.headerCnt);
315 for (int i = 0; i < tpdu.data.deliver.userData.headerCnt; i++)
317 // Handler Concatenated Message
318 if (tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
319 tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT)
321 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
326 else if (tpdu.tpduType == SMS_TPDU_SUBMIT)
328 if (tpdu.data.submit.dcs.codingScheme == SMS_CHARSET_8BIT && tpdu.data.submit.pid == 0x11) {
329 MSG_DEBUG("Unsupported message!!");
330 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
334 MSG_DEBUG("headerCnt [%d]", tpdu.data.submit.userData.headerCnt);
336 for (int i = 0; i < tpdu.data.submit.userData.headerCnt; i++)
338 // Handler Concatenated Message
339 if (tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
340 tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT)
342 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
348 // Make MSG_MESSAGE_INFO_S
349 MSG_MESSAGE_INFO_S msgInfo;
350 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
352 SmsPluginEventHandler::instance()->convertTpduToMsginfo(&tpdu, &msgInfo);
354 // set Sim Message ID
355 msgInfo.msgId = pSmsTpdu->SimIndex;
358 msgInfo.bRead = bRead;
361 msgInfo.storageId = MSG_STORAGE_SIM;
363 /// Print MSG_MESSAGE_INFO_S
364 MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
365 MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
366 MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
367 MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
368 MSG_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
369 MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
370 MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
371 MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
372 MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
373 MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
374 MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
375 MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
376 MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
377 MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
378 MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
379 if (msgInfo.bTextSms == true)
380 MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
382 MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
383 MSG_DEBUG("###############################################################");
385 SmsPluginSimMsg::instance()->setSimMsgEvent(&msgInfo, true); // Call Event Handler
390 void TapiEventSaveSimMsg(TapiHandle *handle, int result, void *data, void *user_data)
392 MSG_DEBUG("TapiEventSaveSimMsg is called. result [%d]", result);
397 simId = *((int*)data);
399 MSG_DEBUG("Data(SIM Msg ID) is NULL");
401 SmsPluginSimMsg::instance()->setSaveSimMsgEvent(simId, result);
405 void TapiEventSaveClass2Msg(TapiHandle *handle, int result, void *data, void *user_data)
407 MSG_DEBUG("TapiEventSaveSimMsg is called. result [%d]", result);
412 simId = *((int*)data);
414 MSG_DEBUG("Data(SIM Msg ID) is NULL");
416 SmsPluginSimMsg::instance()->setSaveClass2MsgEvent(simId, result);
420 void TapiEventDeleteSimMsg(TapiHandle *handle, int result, void *data, void *user_data)
422 MSG_DEBUG("TapiEventDeleteSimMsg is called. result [%d]", result);
424 MSG_DEBUG("status : [%d]", (TelSmsCause_t)result);
426 if (result != TAPI_API_SUCCESS || data == NULL)
428 MSG_DEBUG("Error. data is NULL.");
429 SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)0, false);
433 int sim_id = *((int*)data);
435 SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)sim_id, true);
440 void TapiEventSetConfigData(TapiHandle *handle, int result, void *data, void *user_data)
442 MSG_DEBUG("TapiEventSetConfigData is called.");
446 MSG_DEBUG("Error. data is NULL.");
450 TelSmsSetResponse* responseType = (TelSmsSetResponse*)data;
452 MSG_DEBUG("responseType : [%d]", *responseType);
454 switch (*responseType)
456 case TAPI_NETTEXT_SETPREFERREDBEARER_RSP :
457 MSG_DEBUG("TAPI_NETTEXT_SETPREFERREDBEARER_RSP is called");
460 case TAPI_NETTEXT_SETPARAMETERS_RSP :
461 MSG_DEBUG("TAPI_NETTEXT_SETPARAMETERS_RSP is called");
464 case TAPI_NETTEXT_CBSETCONFIG_RSP :
465 MSG_DEBUG("TAPI_NETTEXT_CBSETCONFIG_RSP is called");
468 case TAPI_NETTEXT_SETMEMORYSTATUS_RSP :
469 MSG_DEBUG("TAPI_NETTEXT_SETMEMORYSTATUS_RSP is called");
472 case TAPI_NETTEXT_SETMESSAGESTATUS_RSP :
473 MSG_DEBUG("TAPI_NETTEXT_SETMESSAGESTATUS_RSP is called");
477 MSG_DEBUG("Unknown Response is called [%d]", *responseType);
483 MSG_DEBUG("status : [%d]", (TelSmsCause_t)result);
485 if ((TelSmsCause_t)result != TAPI_NETTEXT_SUCCESS) bRet = false;
487 if (*responseType == TAPI_NETTEXT_SETMESSAGESTATUS_RSP)
488 SmsPluginSimMsg::instance()->setSimEvent(0, bRet);
490 SmsPluginSetting::instance()->setResultFromSim(bRet);
495 void TapiEventGetParamCnt(TapiHandle *handle, int result, void *data, void *user_data)
497 MSG_DEBUG("TapiEventGetParamCnt is called.");
499 if (result != TAPI_API_SUCCESS || data == NULL)
501 MSG_DEBUG("Error. evt->pData is NULL.");
502 SmsPluginSetting::instance()->setParamCntEvent(0);
507 paramCnt = *((int*)data);
509 SmsPluginSetting::instance()->setParamCntEvent(paramCnt);
514 void TapiEventGetParam(TapiHandle *handle, int result, void *data, void *user_data)
516 MSG_DEBUG("TapiEventGetConfigData is called.");
518 if (result != TAPI_API_SUCCESS || data == NULL)
520 MSG_DEBUG("Error. data is NULL.");
521 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
525 TelSmsParams_t* smsParam = (TelSmsParams_t*)data;
529 MSG_SMSC_DATA_S smscData = {0, };
531 /*Check Alpha ID value*/
532 alphaIdLen = smsParam->AlphaIdLen;
533 MSG_DEBUG("alphaId_len[%d]", alphaIdLen);
535 if (alphaIdLen < 0 || alphaIdLen > SMSC_NAME_MAX)
537 MSG_DEBUG("Wrong Alpha ID Length[%d]", alphaIdLen);
539 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
545 /*Check Address value*/
546 addrLen = smsParam->TpSvcCntrAddr.DialNumLen;
548 if(addrLen > SMSC_ADDR_MAX)
550 MSG_DEBUG("addrLen is too long: %d", addrLen);
551 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
556 MSG_DEBUG("addrLen is too short: %d", addrLen);
557 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
561 MSG_DEBUG("addrLen : %d", addrLen);
564 /*SMSP Parameter Indicator value*/
565 MSG_DEBUG("ParamIndicator[%02x]", smsParam->ParamIndicator);
568 if(0x00 == (0x02 & smsParam->ParamIndicator))
570 MSG_DEBUG("record index[%d]", (int)smsParam->RecordIndex);
572 MSG_DEBUG("TON : %d", smsParam->TpSvcCntrAddr.Ton);
573 MSG_DEBUG("NPI : %d", smsParam->TpSvcCntrAddr.Npi);
575 smscData.smscAddr.ton = smsParam->TpSvcCntrAddr.Ton;
576 smscData.smscAddr.npi = smsParam->TpSvcCntrAddr.Npi;
578 SmsPluginParamCodec paramCodec;
580 memset(smscData.smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
581 paramCodec.decodeSMSC(smsParam->TpSvcCntrAddr.szDiallingNum, addrLen, smscData.smscAddr.ton, smscData.smscAddr.address);
583 MSG_DEBUG("SMSC Address : [%s]", smscData.smscAddr.address);
585 memset(smscData.name, 0x00, SMSC_NAME_MAX+1);
586 memcpy(smscData.name, smsParam->szAlphaId, alphaIdLen);
587 smscData.name[alphaIdLen] = '\0';
589 MSG_DEBUG("SMSC Name : [%s]", smscData.name);
593 MSG_DEBUG("SMSC Address is not present");
595 // smscData.smscAddr.ton = MSG_TON_UNKNOWN;
596 // smscData.smscAddr.npi = MSG_NPI_UNKNOWN;
598 // memset(smscData.smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
599 // memset(smscData.name, 0x00, SMSC_NAME_MAX+1);
601 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
606 /*Get the PID value*/
607 if (0x00 == (0x04 & smsParam->ParamIndicator))
609 SMS_PID_T pid = (SMS_PID_T)smsParam->TpProtocolId;
611 MSG_DEBUG("smsParam->TpProtocolId : %d", smsParam->TpProtocolId);
616 smscData.pid = MSG_PID_TEXT;
619 smscData.pid = MSG_PID_VOICE;
622 smscData.pid = MSG_PID_FAX;
625 smscData.pid = MSG_PID_X400;
628 smscData.pid = MSG_PID_ERMES;
631 smscData.pid = MSG_PID_EMAIL;
634 smscData.pid = MSG_PID_TEXT;
638 MSG_DEBUG("smscData.pid : %d", smscData.pid);
642 MSG_DEBUG("PID is not present");
643 smscData.pid = MSG_PID_TEXT;
644 MSG_DEBUG("MSG_PID_TEXT is inserted to PID");
648 /*Get the DCS value*/
649 if (0x00 == (0x08 & smsParam->ParamIndicator))
651 smscList.smscData[index].dcs = smsParam->TpDataCodingScheme;
652 MSG_DEBUG("dcs : %d", smscList.smscData[index].dcs);
656 smscList.smscData[index].dcs = MSG_ENCODE_GSM7BIT;
657 MSG_DEBUG("DCS is not present");
661 /*Get the ValidityPeriod value*/
662 if (0x00 == (0x10 & smsParam->ParamIndicator))
664 smscData.valPeriod = smsParam->TpValidityPeriod;
665 MSG_DEBUG("valPeriod : %d", smscData.valPeriod);
669 smscData.valPeriod = 0;
670 MSG_DEBUG("Validity Period is not present");
673 SmsPluginSetting::instance()->setParamEvent(&smscData, (int)smsParam->RecordIndex, true);
678 void TapiEventGetCBConfig(TapiHandle *handle, int result, void *data, void *user_data)
680 MSG_DEBUG("TapiEventGetCBConfig is called.");
682 MSG_CBMSG_OPT_S cbOpt = {0};
684 if (result != TAPI_API_SUCCESS || data == NULL)
686 MSG_DEBUG("Error. data is NULL.");
688 SmsPluginSetting::instance()->setCbConfigEvent(NULL, false);
693 TelSmsCbConfig_t* pCBConfig = (TelSmsCbConfig_t*)data;
695 cbOpt.bReceive = (bool)pCBConfig->CBEnabled;
697 cbOpt.maxSimCnt = pCBConfig->MsgIdMaxCount;
699 MSG_DEBUG("Receive [%d], Max SIM Count [%d]", cbOpt.bReceive, cbOpt.maxSimCnt);
701 cbOpt.channelData.channelCnt = pCBConfig->MsgIdRangeCount;
703 if (cbOpt.channelData.channelCnt > CB_CHANNEL_MAX)
705 MSG_DEBUG("Channel Count [%d] from TAPI is over MAX", cbOpt.channelData.channelCnt);
706 cbOpt.channelData.channelCnt = CB_CHANNEL_MAX;
709 if (MsgSettingSetInt(CB_CHANNEL_COUNT, cbOpt.channelData.channelCnt) != MSG_SUCCESS) {
710 MSG_DEBUG("Error to set config data [%s]", CB_CHANNEL_COUNT);
713 MSG_DEBUG("Channel Count [%d]", cbOpt.channelData.channelCnt);
715 for (int i = 0; i < cbOpt.channelData.channelCnt; i++)
717 cbOpt.channelData.channelInfo[i].bActivate = pCBConfig->MsgIDs[i].Net3gpp.Selected;
718 cbOpt.channelData.channelInfo[i].from = pCBConfig->MsgIDs[i].Net3gpp.FromMsgId;
719 cbOpt.channelData.channelInfo[i].to = pCBConfig->MsgIDs[i].Net3gpp.ToMsgId;
720 memset(cbOpt.channelData.channelInfo[i].name, 0x00, CB_CHANNEL_NAME_MAX+1);
722 MSG_DEBUG("Channel FROM [%d], Channel TO [%d] ", cbOpt.channelData.channelInfo[i].from, cbOpt.channelData.channelInfo[i].to);
725 SmsPluginSetting::instance()->setCbConfigEvent(&cbOpt, true);
728 void TapiEventSetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data)
730 MSG_DEBUG("TapiEventSetMailboxInfo is called. result = [%d]", result);
734 if (result != TAPI_SIM_ACCESS_SUCCESS)
737 SmsPluginSetting::instance()->setResultFromSim(bRet);
740 void TapiEventGetMailboxInfo(TapiHandle *handle, int result, void *data, void *user_data)
742 MSG_DEBUG("TapiEventGetMailboxInfo is called.");
744 if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL)
746 MSG_DEBUG("Error. data is NULL.");
747 SmsPluginSetting::instance()->setMailboxInfoEvent(NULL, false);
752 TelSimMailboxList_t *list = (TelSimMailboxList_t *)data;
753 SMS_SIM_MAILBOX_LIST_S mbList = {0,};
755 if (list->count <= 0) {
756 SmsPluginSetting::instance()->setMailboxInfoEvent(NULL, true);
760 mbList.count = list->count;
762 for (int i = 0; i < mbList.count; i++) {
763 mbList.list[i].b_cphs = list->list[i].b_cphs;
764 mbList.list[i].alpha_id_max_len = list->list[i].alpha_id_max_len;
765 mbList.list[i].mb_type = list->list[i].mb_type;
766 mbList.list[i].profile_num = list->list[i].profile_num;
767 mbList.list[i].rec_index = list->list[i].rec_index;
768 mbList.list[i].ton = list->list[i].ton;
769 mbList.list[i].npi = list->list[i].npi;
770 snprintf(mbList.list[i].alpha_id, sizeof(mbList.list[i].alpha_id), "%s", list->list[i].alpha_id);
771 snprintf(mbList.list[i].num, sizeof(mbList.list[i].num), "%s", list->list[i].num);
772 mbList.list[i].cc_id = list->list[i].cc_id;
773 mbList.list[i].ext1_id = list->list[i].ext1_id;
776 SmsPluginSetting::instance()->setMailboxInfoEvent(&mbList, true);
779 void TapiEventSetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data)
781 MSG_DEBUG("TapiEventSetMwiInfo is called. result = [%d]", result);
785 if (result != TAPI_SIM_ACCESS_SUCCESS)
788 SmsPluginSetting::instance()->setResultFromSim(bRet);
791 void TapiEventGetMwiInfo(TapiHandle *handle, int result, void *data, void *user_data)
793 MSG_DEBUG("TapiEventGetMwiInfo is called.");
795 if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL)
797 MSG_DEBUG("Error. data is NULL.");
798 SmsPluginSetting::instance()->setMwiInfoEvent(NULL, false);
803 TelSimMessageWaitingResp_t *MwiInfo = (TelSimMessageWaitingResp_t *)data;
804 SMS_SIM_MWI_INFO_S simMwiInfo = {0,};
806 memcpy(&simMwiInfo, MwiInfo, sizeof(SMS_SIM_MWI_INFO_S));
808 SmsPluginSetting::instance()->setMwiInfoEvent(&simMwiInfo, true);
811 void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *user_data)
813 MSG_DEBUG("TapiEventGetMsisdnInfo is called.");
815 if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL)
817 MSG_DEBUG("Error. data is NULL.");
821 TelSimMsisdnList_t *list = (TelSimMsisdnList_t *)data;
823 for (int i = 0; i < list->count; i++) {
824 if (list->list[i].num[0] != '\0') {
825 if (MsgSettingSetString(MSG_SIM_MSISDN, list->list[i].num) == MSG_SUCCESS)
826 MSG_DEBUG("Get MSISDN from SIM : [%s]", list->list[i].num);
828 MSG_DEBUG("Getting MSISDN is failed!");
835 void TapiEventSatSmsRefresh(TapiHandle *handle, int result, void *data, void *user_data)
837 MSG_DEBUG("TapiEventSatSmsRefresh is called.");
839 if (result != TAPI_API_SUCCESS || data == NULL)
841 MSG_DEBUG("Error. data is NULL.");
847 SmsPluginSatHandler::instance()->refreshSms(data);
849 catch (MsgException& e)
851 MSG_FATAL("%s", e.what());
858 void TapiEventSatSendSms(TapiHandle *handle, const char *noti_id, void *data, void *user_data)
860 MSG_DEBUG("TapiEventSatSendSms is called.");
864 MSG_DEBUG("Error. data is NULL.");
870 SmsPluginSatHandler::instance()->sendSms(data);
872 catch (MsgException& e)
874 MSG_FATAL("%s", e.what());
881 void TapiEventSatMoSmsCtrl(TapiHandle *handle, int result, void *data, void *user_data)
883 MSG_DEBUG("TapiEventSatMoSmsCtrl is called.");
885 if (result != TAPI_API_SUCCESS || data == NULL)
887 MSG_DEBUG("Error. data is NULL.");
893 SmsPluginSatHandler::instance()->ctrlSms(data);
895 catch (MsgException& e)
897 MSG_FATAL("%s", e.what());
903 void TapiEventMemoryStatus(TapiHandle *handle, int result, void *data, void *user_data)
905 MSG_DEBUG("Tapi result is [%d]", result);
908 void TapiEventSetMsgStatus(TapiHandle *handle, int result, void *data, void *user_data)
910 MSG_DEBUG("TapiEventSetMsgStatus is called. result [%d]", result);
912 if (result != TAPI_API_SUCCESS || data == NULL)
914 MSG_DEBUG("Error. data is NULL.");
915 SmsPluginSimMsg::instance()->setSimEvent((msg_sim_id_t)0, false);
919 msg_sim_id_t sim_id = *((msg_sim_id_t *)user_data);
921 SmsPluginSimMsg::instance()->setSimEvent(sim_id, true);
924 /*==================================================================================================
925 IMPLEMENTATION OF SmsPluginCallback - Member Functions
926 ==================================================================================================*/
927 SmsPluginCallback* SmsPluginCallback::pInstance = NULL;
930 SmsPluginCallback::SmsPluginCallback()
937 SmsPluginCallback::~SmsPluginCallback()
939 if (pInstance != NULL)
947 SmsPluginCallback* SmsPluginCallback::instance()
950 pInstance = new SmsPluginCallback();
956 void SmsPluginCallback::registerEvent()
958 tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_DEVICE_READY, TapiEventDeviceReady, NULL);
959 tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_INCOM_MSG, TapiEventMsgIncoming, NULL);
960 tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_CB_INCOM_MSG, TapiEventCbMsgIncoming, NULL);
961 tel_register_noti_event(pTapiHandle, TAPI_NOTI_SMS_ETWS_INCOM_MSG, TapiEventEtwsMsgIncoming, NULL);
962 // tel_register_noti_event(pTapiHandle, TAPI_NOTI_SAT_REFRESH, TapiEventSatSmsRefresh, NULL);
963 tel_register_noti_event(pTapiHandle, TAPI_NOTI_SAT_SEND_SMS, TapiEventSatSendSms, NULL);
964 // tel_register_noti_event(pTapiHandle, TAPI_NOTI_SAT_MO_SMS_CTRL, TapiEventSatMoSmsCtrl, NULL);
968 void SmsPluginCallback::deRegisterEvent()