3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
35 #include "MsgException.h"
36 #include "SmsPluginEventHandler.h"
37 #include "SmsPluginCbMsgHandler.h"
38 #include "SmsPluginConcatHandler.h"
39 #include "SmsPluginWapPushHandler.h"
40 #include "SmsPluginSatHandler.h"
41 #include "SmsPluginParamCodec.h"
42 #include "SmsPluginTpduCodec.h"
43 #include "SmsPluginSimMsg.h"
44 #include "SmsPluginSetting.h"
45 #include "SmsPluginCallback.h"
49 #include <ITapiProductivity.h>
53 /*==================================================================================================
54 FUNCTION IMPLEMENTATION
55 ==================================================================================================*/
56 int TapiEventDeviceReady(const TelTapiEvent_t *pEvent, void*)
58 MSG_DEBUG("TapiEventDeviceReady is called. : request id = [%d] status = [%d]", pEvent->RequestId, pEvent->Status);
63 SmsPluginEventHandler::instance()->setDeviceStatus();
65 catch (MsgException& e)
67 MSG_FATAL("%s", e.what());
75 int TapiEventSentStatus(const TelTapiEvent_t *pEvent, void*)
77 MSG_DEBUG("TapiEventSentStatus is called. : request id = [%d] status = [%d]", pEvent->RequestId, pEvent->Status);
79 MSG_NETWORK_STATUS_T netStatus;
81 // Convert TAPI status -> Messaging status
82 if ((TelSmsResponse_t)pEvent->Status == TAPI_NETTEXT_SENDSMS_SUCCESS)
83 netStatus = MSG_NETWORK_SEND_SUCCESS;
85 netStatus = MSG_NETWORK_SEND_FAIL;
90 SmsPluginEventHandler::instance()->handleSentStatus(pEvent->RequestId, netStatus);
93 SmsPluginSatHandler::instance()->ctrlSms(netStatus);
95 catch (MsgException& e)
97 MSG_FATAL("%s", e.what());
105 int TapiEventMsgIncoming(const TelTapiEvent_t *pEvent, void*)
107 MSG_DEBUG("TapiEventMsgIncoming is called. Red Id [%d]", pEvent->RequestId);
109 if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
111 MSG_DEBUG("Error. evt->pData is NULL.");
115 TelSmsDatapackageInfo_t* pDataPackage = (TelSmsDatapackageInfo_t*)pEvent->pData;
119 // Decode Incoming Message
120 SmsPluginTpduCodec::decodeTpdu(pDataPackage->szData, pDataPackage->MsgLength, &tpdu);
123 if (tpdu.tpduType == SMS_TPDU_DELIVER)
125 MSG_DEBUG("############# SMS_TPDU_DELIVER Incoming decoded tpdu values ####################");
126 MSG_DEBUG("tpdu.data.deliver.bMoreMsg : %d", tpdu.data.deliver.bMoreMsg);
127 MSG_DEBUG("tpdu.data.deliver.bStatusReport : %d", tpdu.data.deliver.bStatusReport);
128 MSG_DEBUG("tpdu.data.deliver.bHeaderInd : %d", tpdu.data.deliver.bHeaderInd);
129 MSG_DEBUG("tpdu.data.deliver.bReplyPath : %d", tpdu.data.deliver.bReplyPath);
130 MSG_DEBUG("tpdu.data.deliver.pid : %d", tpdu.data.deliver.pid);
131 MSG_DEBUG("tpdu.data.deliver.dcs.bCompressed : %d", tpdu.data.deliver.dcs.bCompressed);
132 MSG_DEBUG("tpdu.data.deliver.dcs.msgClass : %d", tpdu.data.deliver.dcs.msgClass);
133 MSG_DEBUG("tpdu.data.deliver.dcs.codingScheme : %d", tpdu.data.deliver.dcs.codingScheme);
134 MSG_DEBUG("tpdu.data.deliver.dcs.codingGroup : %d", tpdu.data.deliver.dcs.codingGroup);
135 MSG_DEBUG("tpdu.data.deliver.originAddress.address : %s", tpdu.data.deliver.originAddress.address);
136 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,
137 tpdu.data.deliver.timeStamp.time.absolute.hour, tpdu.data.deliver.timeStamp.time.absolute.minute, tpdu.data.deliver.timeStamp.time.absolute.second);
138 MSG_DEBUG("tpdu.data.deliver.userData.headerCnt : %d", tpdu.data.deliver.userData.headerCnt);
139 MSG_DEBUG("tpdu.data.deliver.userData.length : %d", tpdu.data.deliver.userData.length);
140 MSG_DEBUG("tpdu.data.deliver.userData.data : %s", tpdu.data.deliver.userData.data);
141 MSG_DEBUG("#####################################################");
143 else if (tpdu.tpduType == SMS_TPDU_STATUS_REP)
145 MSG_DEBUG("############# SMS_TPDU_STATUS_REP Incoming decoded tpdu values ####################");
146 MSG_DEBUG("tpdu.data.statusRep.msgRef : %d", tpdu.data.statusRep.msgRef);
147 MSG_DEBUG("tpdu.data.statusRep.bMoreMsg : %d", tpdu.data.statusRep.bMoreMsg);
148 MSG_DEBUG("tpdu.data.statusRep.bStatusReport : %d", tpdu.data.statusRep.bStatusReport);
149 MSG_DEBUG("tpdu.data.statusRep.statusRep : %d", tpdu.data.statusRep.bHeaderInd);
150 MSG_DEBUG("tpdu.data.statusRep.status : %02x", tpdu.data.statusRep.status);
151 MSG_DEBUG("tpdu.data.statusRep.pid : %d", tpdu.data.statusRep.pid);
152 MSG_DEBUG("tpdu.data.statusRep.dcs.bCompressed : %d", tpdu.data.statusRep.dcs.bCompressed);
153 MSG_DEBUG("tpdu.data.statusRep.dcs.msgClass : %d", tpdu.data.statusRep.dcs.msgClass);
154 MSG_DEBUG("tpdu.data.statusRep.dcs.codingScheme : %d", tpdu.data.statusRep.dcs.codingScheme);
155 MSG_DEBUG("tpdu.data.statusRep.dcs.codingGroup : %d", tpdu.data.statusRep.dcs.codingGroup);
156 MSG_DEBUG("tpdu.data.statusRep.recipAddress.address : %s", tpdu.data.statusRep.recipAddress.address);
157 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,
158 tpdu.data.statusRep.timeStamp.time.absolute.hour, tpdu.data.statusRep.timeStamp.time.absolute.minute, tpdu.data.statusRep.timeStamp.time.absolute.second);
159 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,
160 tpdu.data.statusRep.dischargeTime.time.absolute.hour, tpdu.data.statusRep.dischargeTime.time.absolute.minute, tpdu.data.statusRep.dischargeTime.time.absolute.second);
161 MSG_DEBUG("tpdu.data.statusRep.userData.headerCnt : %d", tpdu.data.statusRep.userData.headerCnt);
162 MSG_DEBUG("tpdu.data.statusRep.userData.length : %d", tpdu.data.statusRep.userData.length);
163 MSG_DEBUG("tpdu.data.statusRep.userData.data : %s", tpdu.data.statusRep.userData.data);
164 MSG_DEBUG("#####################################################");
169 if (tpdu.tpduType == SMS_TPDU_DELIVER)
171 if (SmsPluginConcatHandler::instance()->IsConcatMsg(&(tpdu.data.deliver.userData)) == true ||
172 SmsPluginWapPushHandler::instance()->IsWapPushMsg(&(tpdu.data.deliver.userData)) == true)
174 SmsPluginConcatHandler::instance()->handleConcatMsg(&tpdu); // Call Concat Msg Handler
178 SmsPluginEventHandler::instance()->handleMsgIncoming(&tpdu); // Call Event Handler
181 else if (tpdu.tpduType == SMS_TPDU_STATUS_REP)
183 SmsPluginEventHandler::instance()->handleMsgIncoming(&tpdu); // Call Event Handler
186 catch (MsgException& e)
188 MSG_FATAL("%s", e.what());
189 return e.errorCode();
196 int TapiEventCbMsgIncoming(const TelTapiEvent_t *pEvent, void*)
198 MSG_DEBUG("TapiEventCbMsgIncoming is called.");
200 if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
202 MSG_DEBUG("Error. evt->pData is NULL.");
206 TelSmsCbMsg_t *pCbMsg = (TelSmsCbMsg_t*)pEvent->pData;
210 SmsPluginCbMsgHandler::instance()->handleCbMsg(pCbMsg);
212 catch (MsgException& e)
214 MSG_FATAL("%s", e.what());
222 int TapiEventDeliveryReportCNF(const TelTapiEvent_t *pEvent, void*)
224 MSG_DEBUG("TapiEventDeliveryReportCNF is called. : request id = [%d] status = [%d]", pEvent->RequestId, pEvent->Status);
230 int TapiEventGetSimMsgCnt(const TelTapiEvent_t *pEvent, void*)
232 MSG_DEBUG("TapiEventGetSimMsgCnt is called.");
234 if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
236 MSG_DEBUG("Error. evt->pData is NULL.");
237 MSG_SIM_COUNT_S simCnt;
238 memset(&simCnt, 0x00, sizeof(MSG_SIM_COUNT_S));
239 SmsPluginSimMsg::instance()->setSimMsgCntEvent(&simCnt);
243 SmsPluginSimMsg::instance()->setSimMsgCntEvent((MSG_SIM_COUNT_S *)pEvent->pData);
249 int TapiEventGetSimMsg(const TelTapiEvent_t *pEvent, void*)
251 MSG_DEBUG("TapiEventGetSimMsg is called.");
253 if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
255 MSG_DEBUG("Error!! pEvent->Status [%d]", pEvent->Status);
257 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
262 TelSmsData_t* pSmsTpdu = (TelSmsData_t*)pEvent->pData;
264 // Reading TelSmsData_t
265 MSG_DEBUG ("sim index %d", pSmsTpdu->SimIndex);
266 MSG_DEBUG ("status %d", pSmsTpdu->MsgStatus);
268 // Reading TelSmsDatapackageInfo_t
269 if (pSmsTpdu->SmsData.MsgLength > MAX_TPDU_DATA_LEN)
271 MSG_DEBUG ("WARNING: tpdu_len > MAX_SMS_TPDU_SIZE [%d] bytes. setting to 0.", pSmsTpdu->SmsData.MsgLength);
273 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
281 SmsPluginTpduCodec::decodeTpdu(pSmsTpdu->SmsData.szData, pSmsTpdu->SmsData.MsgLength, &tpdu);
283 MSG_DEBUG("Sim Message Type [%d]", tpdu.tpduType);
288 if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_READ)
290 else if (pSmsTpdu->MsgStatus == TAPI_NETTEXT_STATUS_UNREAD)
293 if (tpdu.tpduType == SMS_TPDU_DELIVER)
295 MSG_DEBUG("headerCnt [%d]", tpdu.data.deliver.userData.headerCnt);
297 for (int i = 0; i < tpdu.data.deliver.userData.headerCnt; i++)
299 // Handler Concatenated Message
300 if (tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
301 tpdu.data.deliver.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT)
303 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
308 else if (tpdu.tpduType == SMS_TPDU_SUBMIT)
310 MSG_DEBUG("headerCnt [%d]", tpdu.data.submit.userData.headerCnt);
312 for (int i = 0; i < tpdu.data.submit.userData.headerCnt; i++)
314 // Handler Concatenated Message
315 if (tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_8BIT ||
316 tpdu.data.submit.userData.header[i].udhType == SMS_UDH_CONCAT_16BIT)
318 SmsPluginSimMsg::instance()->setSimMsgEvent(NULL, false);
324 // Make MSG_MESSAGE_INFO_S
325 MSG_MESSAGE_INFO_S msgInfo;
326 memset(&msgInfo, 0x00, sizeof(MSG_MESSAGE_INFO_S));
328 SmsPluginEventHandler::instance()->convertTpduToMsginfo(&tpdu, &msgInfo);
330 // set Sim Message ID
331 msgInfo.msgId = pSmsTpdu->SimIndex;
334 msgInfo.bRead = bRead;
337 msgInfo.storageId = MSG_STORAGE_SIM;
339 /// Print MSG_MESSAGE_INFO_S
340 MSG_DEBUG("############# Convert tpdu values to Message Info values ####################");
341 MSG_DEBUG("msgInfo.msgId : %d", msgInfo.msgId);
342 MSG_DEBUG("msgInfo.nAddressCnt : %d", msgInfo.nAddressCnt);
343 MSG_DEBUG("msgInfo.addressList[0].addressType : %d", msgInfo.addressList[0].addressType);
344 MSG_DEBUG("msgInfo.addressList[0].addressVal : %s", msgInfo.addressList[0].addressVal);
345 MSG_DEBUG("msgInfo.priority : %d", msgInfo.priority);
346 MSG_DEBUG("msgInfo.bProtected : %d", msgInfo.bProtected);
347 MSG_DEBUG("msgInfo.bRead : %d", msgInfo.bRead);
348 MSG_DEBUG("msgInfo.bTextSms : %d", msgInfo.bTextSms);
349 MSG_DEBUG("msgInfo.direction : %d", msgInfo.direction);
350 MSG_DEBUG("msgInfo.msgType.mainType : %d", msgInfo.msgType.mainType);
351 MSG_DEBUG("msgInfo.msgType.subType : %d", msgInfo.msgType.subType);
352 MSG_DEBUG("msgInfo.msgType.classType : %d", msgInfo.msgType.classType);
353 MSG_DEBUG("msgInfo.displayTime : %s", ctime(&msgInfo.displayTime));
354 MSG_DEBUG("msgInfo.dataSize : %d", msgInfo.dataSize);
355 if (msgInfo.bTextSms == true)
356 MSG_DEBUG("msgInfo.msgText : %s", msgInfo.msgText);
358 MSG_DEBUG("msgInfo.msgData : %s", msgInfo.msgData);
359 MSG_DEBUG("###############################################################");
361 SmsPluginSimMsg::instance()->setSimMsgEvent(&msgInfo, true); // Call Event Handler
367 int TapiEventSaveSimMsg(const TelTapiEvent_t *pEvent, void*)
369 MSG_DEBUG("TapiEventSaveSimMsg is called. Red Id [%d]", pEvent->RequestId);
371 if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
373 MSG_DEBUG("Error. evt->pData is NULL.");
374 SmsPluginSimMsg::instance()->setSimEvent((MSG_SIM_ID_T)0, false);
378 int simId = *((int*)pEvent->pData);
380 MSG_DEBUG("sim ID : [%d], status : [%d]", simId, (TelSmsCause_t)pEvent->Status);
382 SmsPluginSimMsg::instance()->setSimEvent((MSG_SIM_ID_T)simId, true);
388 int TapiEventDeleteSimMsg(const TelTapiEvent_t *pEvent, void*)
390 MSG_DEBUG("TapiEventDeleteSimMsg is called. Red Id [%d]", pEvent->RequestId);
391 MSG_DEBUG("status : [%d]", (TelSmsCause_t)pEvent->Status);
393 if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
395 MSG_DEBUG("Error. evt->pData is NULL.");
396 SmsPluginSimMsg::instance()->setSimEvent((MSG_SIM_ID_T)0, false);
400 int sim_id = *((int*)pEvent->pData);
402 SmsPluginSimMsg::instance()->setSimEvent((MSG_SIM_ID_T)sim_id, true);
408 int TapiEventSetConfigData(const TelTapiEvent_t *pEvent, void*)
410 MSG_DEBUG("TapiEventSetConfigData is called.");
412 if (pEvent->pData == NULL)
414 MSG_DEBUG("Error. evt->pData is NULL.");
418 TelSmsSetResponse* responseType = (TelSmsSetResponse*)pEvent->pData;
420 MSG_DEBUG("responseType : [%d]", *responseType);
422 switch (*responseType)
424 case TAPI_NETTEXT_SETPREFERREDBEARER_RSP :
425 MSG_DEBUG("TAPI_NETTEXT_SETPREFERREDBEARER_RSP is called");
428 case TAPI_NETTEXT_SETPARAMETERS_RSP :
429 MSG_DEBUG("TAPI_NETTEXT_SETPARAMETERS_RSP is called");
432 case TAPI_NETTEXT_CBSETCONFIG_RSP :
433 MSG_DEBUG("TAPI_NETTEXT_CBSETCONFIG_RSP is called");
436 case TAPI_NETTEXT_SETMEMORYSTATUS_RSP :
437 MSG_DEBUG("TAPI_NETTEXT_SETMEMORYSTATUS_RSP is called");
440 case TAPI_NETTEXT_SETMESSAGESTATUS_RSP :
441 MSG_DEBUG("TAPI_NETTEXT_SETMESSAGESTATUS_RSP is called");
445 MSG_DEBUG("Unknown Response is called [%d]", *responseType);
451 MSG_DEBUG("status : [%d]", (TelSmsCause_t)pEvent->Status);
453 if ((TelSmsCause_t)pEvent->Status != TAPI_NETTEXT_SUCCESS) bRet = false;
455 if (*responseType == TAPI_NETTEXT_SETMESSAGESTATUS_RSP)
456 SmsPluginSimMsg::instance()->setSimEvent(0, bRet);
458 SmsPluginSetting::instance()->setResultFromSim(bRet);
464 int TapiEventGetParamCnt(const TelTapiEvent_t *pEvent, void*)
466 MSG_DEBUG("TapiEventGetParamCnt is called.");
468 if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
470 MSG_DEBUG("Error. evt->pData is NULL.");
471 SmsPluginSetting::instance()->setParamCntEvent(0);
476 paramCnt = *((int*)pEvent->pData);
478 SmsPluginSetting::instance()->setParamCntEvent(paramCnt);
484 int TapiEventGetParam(const TelTapiEvent_t *pEvent, void*)
486 MSG_DEBUG("TapiEventGetConfigData is called.");
488 if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
490 MSG_DEBUG("Error. evt->pData is NULL.");
491 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
495 TelSmsParams_t* smsParam = (TelSmsParams_t*)pEvent->pData;
499 MSG_SMSC_DATA_S smscData = {};
501 /*Check Alpha ID value*/
502 alphaIdLen = smsParam->AlphaIdLen;
503 MSG_DEBUG("alphaId_len[%d]", alphaIdLen);
505 if (alphaIdLen < 0 || alphaIdLen > SMSC_NAME_MAX)
507 MSG_DEBUG("Wrong Alpha ID Length[%d]", alphaIdLen);
509 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
515 /*Check Address value*/
516 addrLen = smsParam->TpSvcCntrAddr.DialNumLen;
518 if(addrLen > SMSC_ADDR_MAX)
520 MSG_DEBUG("addrLen is too long: %d", addrLen);
521 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
526 MSG_DEBUG("addrLen is too short: %d", addrLen);
527 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
531 MSG_DEBUG("addrLen : %d", addrLen);
534 /*SMSP Parameter Indicator value*/
535 MSG_DEBUG("ParamIndicator[%02x]", smsParam->ParamIndicator);
538 if(0x00 == (0x02 & smsParam->ParamIndicator))
540 MSG_DEBUG("record index[%d]", (int)smsParam->RecordIndex);
542 MSG_DEBUG("TON : %d", smsParam->TpSvcCntrAddr.Ton);
543 MSG_DEBUG("NPI : %d", smsParam->TpSvcCntrAddr.Npi);
545 smscData.smscAddr.ton = smsParam->TpSvcCntrAddr.Ton;
546 smscData.smscAddr.npi = smsParam->TpSvcCntrAddr.Npi;
548 SmsPluginParamCodec paramCodec;
550 memset(smscData.smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
551 paramCodec.decodeSMSC(smsParam->TpSvcCntrAddr.szDiallingNum, addrLen, smscData.smscAddr.ton, smscData.smscAddr.address);
553 MSG_DEBUG("SMSC Address : [%s]", smscData.smscAddr.address);
555 memset(smscData.name, 0x00, SMSC_NAME_MAX+1);
556 memcpy(smscData.name, smsParam->szAlphaId, alphaIdLen);
557 smscData.name[alphaIdLen] = '\0';
559 MSG_DEBUG("SMSC Name : [%s]", smscData.name);
563 MSG_DEBUG("SMSC Address is not present");
565 SmsPluginSetting::instance()->setParamEvent(NULL, -1, false);
570 /*Get the PID value*/
571 if (0x00 == (0x04 & smsParam->ParamIndicator))
573 SMS_PID_T pid = (SMS_PID_T)smsParam->TpProtocolId;
575 MSG_DEBUG("smsParam->TpProtocolId : %d", smsParam->TpProtocolId);
580 smscData.pid = MSG_PID_TEXT;
583 smscData.pid = MSG_PID_VOICE;
586 smscData.pid = MSG_PID_FAX;
589 smscData.pid = MSG_PID_X400;
592 smscData.pid = MSG_PID_ERMES;
595 smscData.pid = MSG_PID_EMAIL;
598 smscData.pid = MSG_PID_TEXT;
602 MSG_DEBUG("smscData.pid : %d", smscData.pid);
606 MSG_DEBUG("PID is not present");
607 smscData.pid = MSG_PID_TEXT;
608 MSG_DEBUG("MSG_PID_TEXT is inserted to PID");
611 /*Get the ValidityPeriod value*/
612 if (0x00 == (0x10 & smsParam->ParamIndicator))
614 smscData.valPeriod = smsParam->TpValidityPeriod;
615 MSG_DEBUG("valPeriod : %d", smscData.valPeriod);
619 smscData.valPeriod = 0;
620 MSG_DEBUG("Validity Period is not present");
623 SmsPluginSetting::instance()->setParamEvent(&smscData, (int)smsParam->RecordIndex, true);
629 int TapiEventGetCBConfig(const TelTapiEvent_t *pEvent, void*)
631 MSG_DEBUG("TapiEventGetCBConfig is called.");
633 MSG_CBMSG_OPT_S cbOpt = {0};
635 if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
637 MSG_DEBUG("Error. evt->pData is NULL.");
639 SmsPluginSetting::instance()->setCbConfigEvent(NULL, false);
644 TelSmsCbConfig_t* pCBConfig = (TelSmsCbConfig_t*)pEvent->pData;
646 cbOpt.bReceive = (bool)pCBConfig->bCBEnabled;
648 if (pCBConfig->SelectedId == 0x01)
649 cbOpt.bAllChannel = true;
650 else if (pCBConfig->SelectedId == 0x02)
651 cbOpt.bAllChannel = false;
653 cbOpt.maxSimCnt = pCBConfig->MsgIdMaxCount;
655 MSG_DEBUG("Receive [%d], All Channel [%d], Max SIM Count [%d]", cbOpt.bReceive, cbOpt.bAllChannel, cbOpt.maxSimCnt);
657 cbOpt.channelData.channelCnt = pCBConfig->MsgIdCount;
659 if (cbOpt.channelData.channelCnt > CB_CHANNEL_MAX)
661 MSG_DEBUG("Channel Count [%d] from TAPI is over MAX", cbOpt.channelData.channelCnt);
662 cbOpt.channelData.channelCnt = CB_CHANNEL_MAX;
665 MSG_DEBUG("Channel Count [%d]", cbOpt.channelData.channelCnt);
667 for (int i = 0; i < cbOpt.channelData.channelCnt; i++)
669 cbOpt.channelData.channelInfo[i].bActivate = cbOpt.bReceive;
670 cbOpt.channelData.channelInfo[i].id = pCBConfig->MsgIDs[i];
671 memset(cbOpt.channelData.channelInfo[i].name, 0x00, CB_CHANNEL_NAME_MAX+1);
673 MSG_DEBUG("Channel ID [%d]", cbOpt.channelData.channelInfo[i].id);
676 SmsPluginSetting::instance()->setCbConfigEvent(&cbOpt, true);
682 int TapiEventSatSmsRefresh(const TelTapiEvent_t *pEvent, void*)
684 MSG_DEBUG("TapiEventSatSmsRefresh is called.");
686 if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
688 MSG_DEBUG("Error. evt->pData is NULL.");
694 SmsPluginSatHandler::instance()->refreshSms(pEvent->pData);
696 catch (MsgException& e)
698 MSG_FATAL("%s", e.what());
699 return e.errorCode();
706 int TapiEventSatSendSms(const TelTapiEvent_t *pEvent, void*)
708 MSG_DEBUG("TapiEventSatSendSms is called.");
710 if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
712 MSG_DEBUG("Error. evt->pData is NULL.");
718 SmsPluginSatHandler::instance()->sendSms(pEvent->pData);
720 catch (MsgException& e)
722 MSG_FATAL("%s", e.what());
723 return e.errorCode();
730 int TapiEventSatMoSmsCtrl(const TelTapiEvent_t *pEvent, void*)
732 MSG_DEBUG("TapiEventSatMoSmsCtrl is called.");
734 if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
736 MSG_DEBUG("Error. evt->pData is NULL.");
742 SmsPluginSatHandler::instance()->ctrlSms(pEvent->pData);
744 catch (MsgException& e)
746 MSG_FATAL("%s", e.what());
747 return e.errorCode();
755 int TapiEventFactoryDftSms(const TelTapiEvent_t *pEvent, void*)
757 MSG_DEBUG("TapiEventFactoryDftSms is called.");
759 if (pEvent->Status != TAPI_API_SUCCESS || pEvent->pData == NULL)
761 MSG_DEBUG("Error. evt->pData is NULL.");
765 TelFactoryDftSmsInfo_t* pSmsInfo = (TelFactoryDftSmsInfo_t *)pEvent->pData;
767 MSG_FOLDER_ID_T folderId = MSG_INBOX_ID;
769 if (pSmsInfo->option == TAPI_FACTORY_DFT_SMS_INBOX)
771 folderId = MSG_INBOX_ID;
773 else if (pSmsInfo->option == TAPI_FACTORY_DFT_SMS_DRAFTS)
775 folderId = MSG_DRAFT_ID;
777 else if (pSmsInfo->option == TAPI_FACTORY_DFT_SMS_OUTBOX)
779 folderId = MSG_OUTBOX_ID;
781 else if (pSmsInfo->option == TAPI_FACTORY_DFT_SMS_SENTBOX)
783 folderId = MSG_SENTBOX_ID;
788 SmsPluginEventHandler::instance()->handleDftSms(folderId, pSmsInfo->number, pSmsInfo->data); // Call Event Handler
790 catch (MsgException& e)
792 MSG_FATAL("%s", e.what());
793 return e.errorCode();
800 /*==================================================================================================
801 IMPLEMENTATION OF SmsPluginCallback - Member Functions
802 ==================================================================================================*/
803 SmsPluginCallback* SmsPluginCallback::pInstance = NULL;
806 SmsPluginCallback::SmsPluginCallback()
813 SmsPluginCallback::~SmsPluginCallback()
815 if (pInstance != NULL)
823 SmsPluginCallback* SmsPluginCallback::instance()
826 pInstance = new SmsPluginCallback();
832 void SmsPluginCallback::registerEvent()
834 unsigned int tempId = 0;
836 tel_register_event(TAPI_EVENT_NETTEXT_DEVICE_READY_IND, &tempId, (TelAppCallback)&TapiEventDeviceReady, NULL);
838 tel_register_event(TAPI_EVENT_NETTEXT_SENTSTATUS_CNF, &tempId, (TelAppCallback)&TapiEventSentStatus, NULL);
839 tel_register_event(TAPI_EVENT_NETTEXT_INCOM_IND, &tempId, (TelAppCallback)&TapiEventMsgIncoming, NULL);
840 tel_register_event(TAPI_EVENT_NETTEXT_CB_INCOM_IND, &tempId, (TelAppCallback)&TapiEventCbMsgIncoming, NULL);
841 tel_register_event(TAPI_EVENT_NETTEXT_DELIVERY_REPORT_CNF, &tempId, (TelAppCallback)&TapiEventDeliveryReportCNF, NULL);
843 tel_register_event(TAPI_EVENT_NETTEXT_SAVE_STATUS_CNF, &tempId, (TelAppCallback)&TapiEventSaveSimMsg, NULL);
844 tel_register_event(TAPI_EVENT_NETTEXT_DELETE_STATUS_CNF, &tempId, (TelAppCallback)&TapiEventDeleteSimMsg, NULL);
845 tel_register_event(TAPI_EVENT_NETTEXT_GET_COUNT_CNF, &tempId, (TelAppCallback)&TapiEventGetSimMsgCnt, NULL);
846 tel_register_event(TAPI_EVENT_NETTEXT_READ_SMS_CNF, &tempId, (TelAppCallback)&TapiEventGetSimMsg, NULL);
848 tel_register_event(TAPI_EVENT_NETTEXT_SET_REQUEST_CNF, &tempId, (TelAppCallback)&TapiEventSetConfigData, NULL);
849 tel_register_event(TAPI_EVENT_NETTEXT_PARAM_COUNT_IND, &tempId, (TelAppCallback)&TapiEventGetParamCnt, NULL);
850 tel_register_event(TAPI_EVENT_NETTEXT_GET_PARAM_CNF, &tempId, (TelAppCallback)&TapiEventGetParam, NULL);
851 tel_register_event(TAPI_EVENT_NETTEXT_GET_CB_CONFIG_CNF, &tempId, (TelAppCallback)&TapiEventGetCBConfig, NULL);
853 tel_register_event(TAPI_EVENT_SAT_SMS_REFRESH_IND, &tempId, (TelAppCallback)&TapiEventSatSmsRefresh, NULL);
854 tel_register_event(TAPI_EVENT_SAT_SEND_SMS_IND, &tempId, (TelAppCallback)&TapiEventSatSendSms, NULL);
855 tel_register_event(TAPI_EVENT_SAT_MO_SMS_CONTROL_IND, &tempId, (TelAppCallback)&TapiEventSatMoSmsCtrl, NULL);
857 tel_register_event(TAPI_EVENT_FACTORY_DFT_SMS, &tempId, (TelAppCallback)&TapiEventFactoryDftSms, NULL);
859 int tapiRet = TAPI_API_SUCCESS;
861 // Register app name to telephony server
862 tapiRet = tel_register_app_name((char*)"org.tizen.msgfw");
864 if (tapiRet != TAPI_API_SUCCESS)
866 THROW(MsgException::SMS_PLG_ERROR, "Failed to register applicatoin name on Telephony Server [%d]", tapiRet);
871 void SmsPluginCallback::deRegisterEvent()