2 * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
4 * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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 "MsgCppTypes.h"
22 #include "MsgException.h"
23 #include "MsgGconfWrapper.h"
24 #include "MsgNotificationWrapper.h"
25 #include "MsgSoundPlayer.h"
26 #include "MsgContact.h"
27 #include "MsgUtilStorage.h"
28 #include "MsgTextConvert.h"
29 #include "MsgDevicedWrapper.h"
31 #include "SmsPluginParamCodec.h"
32 #include "SmsPluginCallback.h"
33 #include "SmsPluginEventHandler.h"
34 #include "SmsPluginSimMsg.h"
35 #include "SmsPluginMain.h"
36 #include "SmsPluginSetting.h"
37 #include "SmsPluginDSHandler.h"
40 #include <tapi_common.h>
42 #include <TapiUtility.h>
43 #include <ITapiNetText.h>
45 #include <ITapiModem.h>
48 /*==================================================================================================
50 ==================================================================================================*/
53 /*==================================================================================================
54 IMPLEMENTATION OF SmsPluginSetting - Member Functions
55 ==================================================================================================*/
56 SmsPluginSetting* SmsPluginSetting::pInstance = NULL;
59 SmsPluginSetting::SmsPluginSetting()
61 /* Initialize member variables */
62 for (int i = 0; i <= MAX_TELEPHONY_HANDLE_CNT; i++) {
63 memset(&smscData[i], 0x00, sizeof(MSG_SMSC_DATA_S));
64 simStatus[i] = MSG_SIM_STATUS_NOT_FOUND;
67 simMailboxList.clear();
70 memset(&meImei, 0x00, sizeof(meImei));
77 for (int i = 0; i < MAX_TELEPHONY_HANDLE_CNT; i++)
78 bMbdnEnable[i] = false;
82 SmsPluginSetting::~SmsPluginSetting()
84 smscList.erase(smscList.begin(), smscList.end());
85 simMailboxList.erase(simMailboxList.begin(), simMailboxList.end());
86 simMwiInfo.erase(simMwiInfo.begin(), simMwiInfo.end());
87 cbOpt.erase(cbOpt.begin(), cbOpt.end());
91 SmsPluginSetting* SmsPluginSetting::instance()
94 pInstance = new SmsPluginSetting();
100 void* SmsPluginSetting::initSimInfo(void *data)
103 MutexLocker lock(mm);
105 instance()->processInitSimInfo(data);
110 void* SmsPluginSetting::processInitSimInfo(void *data)
114 /* Handle sim info initialization separately */
115 TapiHandle *handle = (TapiHandle *)data;
116 instance()->updateSimStatus(handle);
123 void SmsPluginSetting::updateSimStatus(TapiHandle *handle)
128 MSG_DEBUG("handle is NULL.");
133 int tapiRet = TAPI_API_SUCCESS;
135 char keyName[MAX_VCONFKEY_NAME_LEN];
136 memset(keyName, 0x00, sizeof(keyName));
138 int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
141 TelSimImsiInfo_t imsiInfo;
142 memset(&imsiInfo, 0x00, sizeof(TelSimImsiInfo_t));
144 tapiRet = tel_get_sim_imsi(handle, &imsiInfo);
145 if (tapiRet != TAPI_API_SUCCESS) {
146 MSG_SEC_DEBUG("tel_get_sim_imsi() Error![%d]", tapiRet);
149 /* Save Subcriber ID */
150 char *subscriberId = NULL;
151 memset(keyName, 0x00, sizeof(keyName));
153 if (SmsPluginDSHandler::instance()->getSubscriberId(simIndex, &subscriberId) != MSG_SUCCESS) {
154 MSG_DEBUG("getSubscriberId() is failed");
156 snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_SUBS_ID, simIndex);
157 if (MsgSettingSetString(keyName, subscriberId) != MSG_SUCCESS)
158 MSG_DEBUG("Fail MsgSettingSetString");
161 g_free(subscriberId); subscriberId = NULL;
163 /* Check device status */
164 tapiRet = tel_check_sms_device_status(handle, &status);
166 if (tapiRet != TAPI_API_SUCCESS) {
167 MSG_DEBUG("tel_check_sms_device_status() Error! [%d], Status [%d]", tapiRet, status);
171 if (status == TAPI_NETTEXT_READY_STATUS_3GPP) {
172 MSG_DEBUG("Device Is Ready");
174 MSG_DEBUG("Device Is Not Ready.. Waiting For Ready Callback");
176 if (SmsPluginEventHandler::instance()->getDeviceStatus(handle) == true) {
177 MSG_DEBUG("Device Is Ready");
179 MSG_DEBUG("Device Is Not Ready.");
184 /* init config data. */
185 initConfigData(handle);
188 /* init sim messages. */
189 SmsPluginSimMsg::instance()->initSimMessage(handle);
190 } catch (MsgException& e) {
191 MSG_FATAL("%s", e.what());
202 void SmsPluginSetting::initConfigData(TapiHandle *handle)
206 char keyName[MAX_VCONFKEY_NAME_LEN];
208 int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
209 /*==================== SMSC setting ====================*/
210 /* Init SMS Parameter */
213 bool bSelectedFound = false;
214 bool bAPReceive = false;
216 paramCnt = getParamCount(handle);
218 MSG_INFO("Parameter Count [%d]", paramCnt);
220 MSG_SMSC_DATA_S tmpSmscData = {};
221 MSG_SMSC_LIST_S tmpSmscList = {0, };
223 for (int index = 0; index < paramCnt; index++) {
224 memset(&tmpSmscData, 0x00, sizeof(MSG_SMSC_DATA_S));
225 if (getParam(handle, index, &tmpSmscData) == false) {
230 memcpy(&(tmpSmscList.smscData[index]), &tmpSmscData, sizeof(MSG_SMSC_DATA_S));
232 MSG_DEBUG("pid[%d]", tmpSmscList.smscData[index].pid);
233 MSG_DEBUG("val_period[%d]", tmpSmscList.smscData[index].valPeriod);
234 MSG_SEC_DEBUG("name[%s]", tmpSmscList.smscData[index].name);
236 MSG_DEBUG("ton[%d]", tmpSmscList.smscData[index].smscAddr.ton);
237 MSG_DEBUG("npi[%d]", tmpSmscList.smscData[index].smscAddr.npi);
238 MSG_SEC_DEBUG("address[%s]", tmpSmscList.smscData[index].smscAddr.address);
240 /* First smsc is selected index */
241 if (!bSelectedFound) {
242 tmpSmscList.selected = selectedParam;
243 bSelectedFound = !bSelectedFound;
247 tmpSmscList.totalCnt = (paramCnt - failCnt);
248 tmpSmscList.simIndex = sim_idx;
251 MSG_DEBUG("######## Add SMSC ist #######");
252 addSMSCList(&tmpSmscList);
255 /*==================== CB configuration ====================*/
256 if (simStatus[sim_idx] != MSG_SIM_STATUS_NOT_FOUND) {
257 MSG_DEBUG("simStatus == [%d]", simStatus[sim_idx]);
259 MSG_CBMSG_OPT_S cbMsgOpt = {0, };
260 cbMsgOpt.simIndex = sim_idx;
262 if (getCbConfig(&cbMsgOpt) == true) {
263 cbMsgOpt.simIndex = sim_idx;
265 memset(keyName, 0x00, sizeof(keyName));
266 snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, sim_idx);
267 if (MsgSettingGetBool(keyName, &bAPReceive) != MSG_SUCCESS)
268 MSG_INFO("MsgSettingGetBool() is failed");
270 if (cbMsgOpt.bReceive == false && bAPReceive == false) {
271 MSG_DEBUG("CB is off in CP and in AP. No need to send CB request to CP. ");
273 MSG_DEBUG("######## Add CB Option Success !!! #######");
274 MSG_SETTING_S cbSetting;
275 getCbOpt(&cbSetting, sim_idx);
276 setCbConfig(&(cbSetting.option.cbMsgOpt));
279 MSG_WARN("######## getCbConfig Fail !!! #######");
282 /*==================== Default Voice mail Setting ====================*/
283 if (simStatus[sim_idx] == MSG_SIM_STATUS_CHANGED) {
284 char keyName[MAX_VCONFKEY_NAME_LEN];
286 MSG_INFO("=================SIM CHANGED===================");
287 /* reset voicemail number */
288 memset(keyName, 0x00, sizeof(keyName));
289 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
290 if (MsgSettingSetString(keyName, "") != MSG_SUCCESS)
291 MSG_DEBUG("MsgSettingSetInt is failed!!");
293 memset(keyName, 0x00, sizeof(keyName));
294 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, sim_idx);
295 if (MsgSettingSetInt(keyName, 0) != MSG_SUCCESS)
296 MSG_DEBUG("MsgSettingSetInt is failed!!");
298 memset(keyName, 0x00, sizeof(keyName));
299 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, sim_idx);
300 if (MsgSettingSetString(keyName, VOICEMAIL_DEFAULT_ALPHA_ID) != MSG_SUCCESS)
301 MSG_DEBUG("MsgSettingSetString is failed!!");
303 MsgDeleteNoti(MSG_NOTI_TYPE_VOICE_1, sim_idx);
304 MsgDeleteNoti(MSG_NOTI_TYPE_VOICE_2, sim_idx);
307 /*==================== Voice mail information update ====================*/
308 if (getVoiceMailInfo(handle) == true) {
309 MSG_DEBUG("######## getVoiceMailInfo Success !!! #######");
310 memset(keyName, 0x00, sizeof(keyName));
311 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx);
313 char *voiceNumber = NULL;
314 if (MsgSettingGetString(keyName, &voiceNumber) != MSG_SUCCESS) {
315 MSG_INFO("MsgSettingGetString() is failed");
318 if (!voiceNumber || (voiceNumber && voiceNumber[0] == '\0')) {
319 MSG_WARN("Voice Number is Empty!!");
327 MSG_WARN("######## getVoiceMailInfo Fail !!! #######");
330 /*==================== Voice mail count update ====================*/
331 if (getMwiInfo(handle) == true) {
332 MSG_DEBUG("######## getMwiInfo Success !!! #######");
334 MSG_WARN("######## getMwiInfo Fail !!! #######");
336 /* Get MWI from vconf and insert notification */
338 char keyName[MAX_VCONFKEY_NAME_LEN];
339 memset(keyName, 0x00, sizeof(keyName));
340 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, sim_idx);
341 if (MsgSettingGetInt(keyName, &mwiCnt) != MSG_SUCCESS) {
342 MSG_INFO("MsgSettingGetInt() is failed");
345 deliverVoiceMsgNoti(sim_idx, mwiCnt);
348 /*==================== MSISDN update ====================*/
349 if (getMsisdnInfo(handle) == true) {
350 MSG_DEBUG("######## getMsisdnInfo Success !!! #######");
352 MSG_WARN("######## getMsisdnInfo Fail !!! #######");
355 /*==================== SST(SIM Service Table) update ====================*/
356 if (getSimServiceTable(handle) == true) {
357 MSG_DEBUG("######## getSimServiceTable Success !!! #######");
359 MSG_WARN("######## getSimServiceTable Fail !!! #######");
367 void SmsPluginSetting::SimRefreshCb(TapiHandle *handle)
371 if (pthread_create(&thd, NULL, &init_config_data, handle) < 0) {
372 MSG_DEBUG("pthread_create() error");
379 void* SmsPluginSetting::init_config_data(void *data)
381 TapiHandle *handle = (TapiHandle *)data;
382 instance()->initConfigData(handle);
387 void SmsPluginSetting::setConfigData(const MSG_SETTING_S *pSetting)
389 MSG_DEBUG("Setting Type : [%d]", pSetting->type);
391 switch (pSetting->type) {
393 case MSG_SMS_SENDOPT :
394 setNetworkMode(&pSetting->option.smsSendOpt);
398 setParamList(&pSetting->option.smscList);
399 addSMSCList((MSG_SMSC_LIST_S *)(&pSetting->option.smscList));
402 if (setCbConfig(&pSetting->option.cbMsgOpt) == false) {
403 THROW(MsgException::SMS_PLG_ERROR, "Failed to set config.");
406 case MSG_VOICEMAIL_OPT:
407 setVoiceMailInfo(&pSetting->option.voiceMailOpt);
410 THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
416 void SmsPluginSetting::getConfigData(MSG_SETTING_S *pSetting)
418 MSG_DEBUG("Setting Type : [%d]", pSetting->type);
420 switch (pSetting->type) {
422 getSmscListInfo(pSetting->option.smscList.simIndex, &(pSetting->option.smscList));
426 if (getCbConfig(&pSetting->option.cbMsgOpt) == false) {
427 THROW(MsgException::SMS_PLG_ERROR, "Get CB config option failed.");
432 THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
438 void SmsPluginSetting::addSMSCList(MSG_SMSC_LIST_S *pSmscList)
444 MSG_DEBUG("SIM index[%d]", pSmscList->simIndex);
445 MSG_DEBUG("total_count[%d]", pSmscList->totalCnt);
446 MSG_DEBUG("selected index[%d]", pSmscList->selected);
448 for (int i = 0; i < pSmscList->totalCnt; i++) {
449 MSG_DEBUG("pid[%d]", pSmscList->smscData[i].pid);
450 MSG_DEBUG("val_period[%d]", pSmscList->smscData[i].valPeriod);
451 MSG_SEC_DEBUG("name[%s]", pSmscList->smscData[i].name);
453 MSG_DEBUG("ton[%d]", pSmscList->smscData[i].smscAddr.ton);
454 MSG_DEBUG("npi[%d]", pSmscList->smscData[i].smscAddr.npi);
455 MSG_SEC_DEBUG("address[%s]", pSmscList->smscData[i].smscAddr.address);
458 sim_index = pSmscList->simIndex;
460 smscListMap::iterator it = smscList.find(pSmscList->simIndex);
461 if (it == smscList.end()) {
462 pair<int, MSG_SMSC_LIST_S> newList(sim_index, *pSmscList);
463 smscList.insert(newList);
465 /* update the list. */
466 MSG_SMSC_LIST_S &pTmpSmscList = it->second;
467 pTmpSmscList.simIndex = pSmscList->simIndex;
468 pTmpSmscList.totalCnt = pSmscList->totalCnt;
469 pTmpSmscList.selected = pSmscList->selected;
471 for (int i = 0; i < pSmscList->totalCnt; i++) {
472 pTmpSmscList.smscData[i].pid = pSmscList->smscData[i].pid;
473 pTmpSmscList.smscData[i].valPeriod = pSmscList->smscData[i].valPeriod;
474 memset(pTmpSmscList.smscData[i].name, 0x00, SMSC_NAME_MAX+1);
475 memcpy(pTmpSmscList.smscData[i].name, pSmscList->smscData[i].name, SMSC_NAME_MAX);
477 memset(pTmpSmscList.smscData[i].smscAddr.address, 0x00, SMSC_ADDR_MAX+1);
478 memcpy(pTmpSmscList.smscData[i].smscAddr.address, pSmscList->smscData[i].smscAddr.address, SMSC_ADDR_MAX);
480 if (pTmpSmscList.smscData[i].smscAddr.address[0] == '+')
481 pTmpSmscList.smscData[i].smscAddr.ton = MSG_TON_INTERNATIONAL;
483 pTmpSmscList.smscData[i].smscAddr.ton = MSG_TON_NATIONAL;
485 pTmpSmscList.smscData[i].smscAddr.npi = MSG_NPI_ISDN; /* app cannot set this value */
493 void SmsPluginSetting::getSmscListInfo(int simIndex, MSG_SMSC_LIST_S *pSmscList)
495 if (pSmscList == NULL) {
496 MSG_DEBUG("pSmscList is NULL!");
501 TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
502 simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
505 memset(pSmscList, 0x00, sizeof(MSG_SMSC_LIST_S));
507 if (simIndex != -1) {
508 smscListMap::iterator it = smscList.find(simIndex);
509 if (it != smscList.end()) {
510 MSG_SMSC_LIST_S &pTmpSmscList = it->second;
511 memcpy(pSmscList, &pTmpSmscList, sizeof(MSG_SMSC_LIST_S));
512 MSG_SEC_DEBUG("SMSC number for sim index [%d] is [%s]", pSmscList->simIndex, pSmscList->smscData[pSmscList->selected].smscAddr.address);
520 msg_error_t SmsPluginSetting::addCbOpt(MSG_CBMSG_OPT_S *pCbOpt)
522 msg_error_t err = MSG_SUCCESS;
523 char keyName[MAX_VCONFKEY_NAME_LEN];
525 MSG_DEBUG("Receive [%d], Max SIM Count [%d]", pCbOpt->bReceive, pCbOpt->maxSimCnt);
527 MSG_DEBUG("Channel Count [%d]", pCbOpt->channelData.channelCnt);
529 for (int i = 0; i < pCbOpt->channelData.channelCnt; i++) {
530 MSG_DEBUG("Channel FROM [%d], Channel TO [%d]", pCbOpt->channelData.channelInfo[i].from, pCbOpt->channelData.channelInfo[i].to);
534 /* Set Setting Data into Vconf */
535 memset(keyName, 0x00, sizeof(keyName));
536 snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, pCbOpt->simIndex);
537 if (MsgSettingSetBool(keyName, pCbOpt->bReceive) != MSG_SUCCESS) {
538 MSG_DEBUG("Error to set config data [%s]", keyName);
539 return MSG_ERR_SET_SETTING;
543 memset(keyName, 0x00, sizeof(keyName));
544 snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, pCbOpt->simIndex);
545 if (MsgSettingSetInt(keyName, pCbOpt->maxSimCnt) != MSG_SUCCESS) {
546 MSG_DEBUG("Error to set config data [%s]", keyName);
547 return MSG_ERR_SET_SETTING;
551 MsgDbHandler *dbHandle = getDbHandle();
552 err = MsgStoAddCBChannelInfo(dbHandle, &pCbOpt->channelData);
553 if (err != MSG_SUCCESS) {
554 MSG_DEBUG("MsgStoGetCBChannelInfo is failed [%d]", err);
555 return MSG_ERR_SET_SETTING;
563 void SmsPluginSetting::getCbOpt(MSG_SETTING_S *pSetting, int simIndex)
565 char keyName[MAX_VCONFKEY_NAME_LEN];
567 msg_error_t err = MSG_SUCCESS;
568 MsgDbHandler *dbHandle = getDbHandle();
570 memset(&(pSetting->option.cbMsgOpt), 0x00, sizeof(MSG_CBMSG_OPT_S));
572 pSetting->type = MSG_CBMSG_OPT;
573 pSetting->option.cbMsgOpt.simIndex = simIndex;
575 memset(keyName, 0x00, sizeof(keyName));
576 snprintf(keyName, sizeof(keyName), "%s/%d", CB_RECEIVE, simIndex);
577 if (MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bReceive) != MSG_SUCCESS)
578 MSG_INFO("MsgSettingGetBool() is failed");
580 memset(keyName, 0x00, sizeof(keyName));
581 snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex);
583 if (MsgSettingGetInt(keyName, &maxSimCnt) != MSG_SUCCESS) {
584 MSG_INFO("MsgSettingGetInt() is failed");
586 pSetting->option.cbMsgOpt.maxSimCnt = maxSimCnt;
588 err = MsgStoGetCBChannelInfo(dbHandle, &pSetting->option.cbMsgOpt.channelData, simIndex);
589 if (err != MSG_SUCCESS)
590 MSG_ERR("MsgStoGetCBChannelInfo : err=[%d]", err);
592 for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) {
593 memset(keyName, 0x00, sizeof(keyName));
594 snprintf(keyName, sizeof(keyName), "%s/%d", CB_LANGUAGE, i);
596 if (MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]) != MSG_SUCCESS)
597 MSG_INFO("MsgSettingGetBool() is failed");
602 void SmsPluginSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
606 MutexLocker lock(mx);
608 TelSmsParams_t smsParam = {0};
610 int ret = TAPI_API_SUCCESS;
612 int index = pSMSCList->index;
613 MSG_DEBUG("SMSC Index to be set in SIM = %d", index);
615 /*Setting the SMSP Record index value*/
616 smsParam.RecordIndex = (unsigned char)index;
618 /*Setting the SMSP Record Length value = 28 + alphaId_len*/
619 smsParam.RecordLen = 28 + strlen(pSMSCList->smscData[index].name);
621 /*Setting the SMSP Alpha ID value*/
622 smsParam.AlphaIdLen = strlen(pSMSCList->smscData[index].name);
623 MSG_DEBUG("AlphaIdLen = %ld", smsParam.AlphaIdLen);
625 if (smsParam.AlphaIdLen > 0 && smsParam.AlphaIdLen <= SMSC_NAME_MAX) {
626 memcpy(smsParam.szAlphaId, pSMSCList->smscData[index].name, smsParam.AlphaIdLen);
627 smsParam.szAlphaId[smsParam.AlphaIdLen] = '\0';
628 MSG_DEBUG("szAlphaId = %s", smsParam.szAlphaId);
631 smsParam.ParamIndicator = 0x00;
633 if (strlen(pSMSCList->smscData[index].smscAddr.address) > 0) {
634 smsParam.ParamIndicator |= 0x02 ; /* enable 2nd Bit */
635 MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
637 if (pSMSCList->smscData[index].smscAddr.address[0] == '+')
638 smsParam.TpSvcCntrAddr.Ton = TAPI_SIM_TON_INTERNATIONAL;
640 smsParam.TpSvcCntrAddr.Ton = TAPI_SIM_TON_NATIONAL;
642 smsParam.TpSvcCntrAddr.Npi = TAPI_SIM_NPI_ISDN_TEL; /* app cannot set this value */
644 MSG_DEBUG("SMSC TON = [%d] NPI = [%d]", smsParam.TpSvcCntrAddr.Ton, smsParam.TpSvcCntrAddr.Npi);
646 MSG_SEC_DEBUG("address = %s", pSMSCList->smscData[index].smscAddr.address);
648 smsParam.TpSvcCntrAddr.DialNumLen = SmsPluginParamCodec::encodeSMSC(pSMSCList->smscData[index].smscAddr.address, smsParam.TpSvcCntrAddr.szDiallingNum);
650 MSG_DEBUG("SMSC Addr is not present");
653 /*Setting the PID value*/
654 smsParam.ParamIndicator |= 0x04 ; /* enable 3rd Bit */
655 MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
657 smsParam.TpProtocolId = (unsigned short)convertPid(pSMSCList->smscData[index].pid);
659 /*Setting the ValidityPeriod value*/
660 smsParam.ParamIndicator |= 0x10 ; /* enable 5th Bit */
661 MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
663 smsParam.TpValidityPeriod = (unsigned short)pSMSCList->smscData[index].valPeriod;
665 smsParam.ParamIndicator = ~(smsParam.ParamIndicator);
666 MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
668 /* Get TAPI handle */
669 TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pSMSCList->simIndex);
671 ret = tel_set_sms_parameters(handle, (const TelSmsParams_t*)&smsParam, TapiEventSetConfigData, NULL);
673 if (ret != TAPI_API_SUCCESS)
674 THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_parameters() Error. [%d]", ret);
676 if (!getResultFromSim())
677 THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_parameters() Result Error.");
683 void SmsPluginSetting::getParamList(MSG_SMSC_LIST_S *pSMSCList)
689 MSG_SEC_DEBUG("SIM index [%d]", pSMSCList->simIndex);
690 TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(pSMSCList->simIndex);
691 paramCnt = getParamCount(handle);
693 MSG_DEBUG("Parameter Count [%d]", paramCnt);
695 int ret = TAPI_API_SUCCESS;
697 MSG_SMSC_DATA_S tmpSmscData = {};
699 for (int index = 0; index < paramCnt; index++) {
700 ret = tel_get_sms_parameters(handle, index, TapiEventGetParam, NULL);
702 if (ret == TAPI_API_SUCCESS) {
703 MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
705 THROW(MsgException::SMS_PLG_ERROR, "######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
708 if (getParamEvent(handle, &tmpSmscData) == true) {
709 MSG_DEBUG("######## Get Parameter was Successful !!! #######");
711 memcpy(&(pSMSCList->smscData[index]), &tmpSmscData, sizeof(MSG_SMSC_DATA_S));
713 MSG_DEBUG("pid[%d]", pSMSCList->smscData[index].pid);
714 MSG_DEBUG("val_period[%d]", pSMSCList->smscData[index].valPeriod);
715 MSG_SEC_DEBUG("name[%s]", pSMSCList->smscData[index].name);
717 MSG_DEBUG("ton[%d]", pSMSCList->smscData[index].smscAddr.ton);
718 MSG_DEBUG("npi[%d]", pSMSCList->smscData[index].smscAddr.npi);
719 MSG_SEC_DEBUG("address[%s]", pSMSCList->smscData[index].smscAddr.address);
721 MSG_DEBUG("######## Get Parameter was Failed !!! #######");
725 pSMSCList->totalCnt = paramCnt;
726 pSMSCList->selected = selectedParam;
728 MSG_DEBUG("total_count[%d]", pSMSCList->totalCnt);
734 int SmsPluginSetting::getParamCount(TapiHandle *handle)
736 int ret = TAPI_API_SUCCESS;
738 ret = tel_get_sms_parameter_count(handle, TapiEventGetParamCnt, NULL);
740 if (ret == TAPI_API_SUCCESS) {
741 MSG_DEBUG("######## tel_get_sms_parameter_count() Success !!! #######");
743 THROW(MsgException::SMS_PLG_ERROR, "tel_get_sms_parameter_count() Error. [%d]", ret);
746 return getParamCntEvent();
750 bool SmsPluginSetting::getParam(TapiHandle *handle, int Index, MSG_SMSC_DATA_S *pSmscData)
752 int ret = TAPI_API_SUCCESS;
754 ret = tel_get_sms_parameters(handle, Index, TapiEventGetParam, NULL);
756 if (ret == TAPI_API_SUCCESS) {
757 MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
759 MSG_ERR("######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
763 if (getParamEvent(handle, pSmscData) == true) {
764 MSG_DEBUG("######## Get Parameter was Successful !!! #######");
766 MSG_ERR("######## Get Parameter was Failed !!! #######");
774 void SmsPluginSetting::setSmscInfo(const MSG_SMSC_LIST_S *pSmscList)
778 MutexLocker lock(mx);
780 int ret = TAPI_API_SUCCESS;
782 TapiHandle *handle = NULL;
784 handle = SmsPluginDSHandler::instance()->getTelHandle(pSmscList->simIndex);
786 int select_id = pSmscList->selected;
787 const MSG_SMSC_DATA_S *pSmscData = (const MSG_SMSC_DATA_S *)&(pSmscList->smscData[select_id]);
789 MSG_DEBUG("Select SMSC id = [%d]", select_id);
791 TelSmsAddressInfo_t sca;
792 memset(&sca, 0x00, sizeof(TelSmsAddressInfo_t));
794 if (strlen(pSmscData->smscAddr.address) > 0) {
795 if (pSmscData->smscAddr.address[0] == '+')
796 sca.Ton = TAPI_SIM_TON_INTERNATIONAL;
798 sca.Ton = TAPI_SIM_TON_NATIONAL;
800 sca.Npi = TAPI_SIM_NPI_ISDN_TEL; /* app cannot set this value */
802 MSG_SEC_DEBUG("SMSC TON = [%d], NPI = [%d], Address = [%s]", sca.Ton, sca.Npi, pSmscData->smscAddr.address);
804 sca.DialNumLen = SmsPluginParamCodec::encodeSMSC(pSmscData->smscAddr.address, sca.szDiallingNum);
806 MSG_DEBUG("SMSC Addr is not present");
809 ret = tel_set_sms_sca(handle, (const TelSmsAddressInfo_t *)&sca, 0, TapiEventSetSmscInfo, NULL);
811 if (ret != TAPI_API_SUCCESS)
812 THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_sca() Error. [%d]", ret);
814 if (!getResultFromSim())
815 THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_sca() Result Error.");
821 bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
823 TapiHandle *handle = NULL;
824 int simCnt = SmsPluginDSHandler::instance()->getTelHandleCount();
826 TelSmsCbConfig_t cbConfig = {};
829 int ret = TAPI_API_SUCCESS;
831 if (pCbOpt->bReceive == true)
832 cbEnabled = 2;/* Need to get a Enumeration from TAPI, currently it is not available */
834 MSG_DEBUG("simIndex:%d, cbEnabled:%d", pCbOpt->simIndex, cbEnabled);
836 if (pCbOpt->simIndex == 0) {
837 char keyName[MAX_VCONFKEY_NAME_LEN];
838 memset(keyName, 0x00, sizeof(keyName));
839 MSG_SIM_STATUS_T simStatus = MSG_SIM_STATUS_NOT_FOUND;
841 for (int i = 1; i <= simCnt; i++) {
842 MutexLocker lock(mx);
844 memset(keyName, 0x00, sizeof(keyName));
845 snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, i);
847 if (MsgSettingGetInt(keyName, &tmpVal) != MSG_SUCCESS) {
848 MSG_INFO("MsgSettingGetInt() is failed");
850 simStatus = (MSG_SIM_STATUS_T)tmpVal;
852 if (simStatus == MSG_SIM_STATUS_NOT_FOUND) {
853 MSG_DEBUG("SIM %d is not present..", i);
857 handle = SmsPluginDSHandler::instance()->getTelHandle(i);
858 memset(&cbConfig, 0x00, sizeof(TelSmsCbConfig_t));
859 cbConfig.CBEnabled = cbEnabled;
860 cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
862 /*MSG_SETTING_S cbSetting;
863 getCbOpt(&cbSetting, i);
865 cbConfig.CBEnabled = (int)pCbOpt->bReceive;
866 cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
867 cbConfig.MsgIdMaxCount = cbSetting.option.cbMsgOpt.maxSimCnt;
868 cbConfig.MsgIdRangeCount = cbSetting.option.cbMsgOpt.channelData.channelCnt;
870 for (int i = 0; i < cbConfig.MsgIdRangeCount; i++) {
871 cbConfig.MsgIDs[i].Net3gpp.Selected = (unsigned short)cbSetting.option.cbMsgOpt.channelData.channelInfo[i].bActivate;
872 cbConfig.MsgIDs[i].Net3gpp.FromMsgId = (unsigned short)cbSetting.option.cbMsgOpt.channelData.channelInfo[i].from;
873 cbConfig.MsgIDs[i].Net3gpp.ToMsgId = (unsigned short)cbSetting.option.cbMsgOpt.channelData.channelInfo[i].to;
876 ret = tel_set_sms_cb_config(handle, &cbConfig, TapiEventSetConfigData, NULL);
878 if (ret == TAPI_API_SUCCESS) {
879 MSG_DEBUG("######## tel_set_sms_cb_config() Success !!! #######");
881 MSG_ERR("######## tel_set_sms_cb_config() Fail !!! return : %d #######", ret);
885 if (getResultFromSim() == true) {
886 MSG_DEBUG("######## Set Cb Config was Successful !!! #######");
888 MSG_ERR("######## Set Cb Config was Failed !!! #######");
892 msg_error_t err = MSG_SUCCESS;
893 MsgDbHandler *dbHandle = getDbHandle();
894 err = MsgStoAddCBChannelInfo(dbHandle, const_cast<MSG_CB_CHANNEL_S*>(&pCbOpt->channelData), i);
895 if (err != MSG_SUCCESS) {
896 MSG_DEBUG("MsgStoAddCBChannelInfo is failed [%d]", err);
901 MSG_DEBUG("SIM Index = [0], Set CB Receive is done");
904 MutexLocker lock(mx);
906 handle = SmsPluginDSHandler::instance()->getTelHandle(pCbOpt->simIndex);
908 memset(&cbConfig, 0x00, sizeof(TelSmsCbConfig_t));
909 cbConfig.CBEnabled = cbEnabled;
910 cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
911 /* cbConfig.CBEnabled = (int)pCbOpt->bReceive;
912 cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
913 cbConfig.MsgIdMaxCount = pCbOpt->maxSimCnt;
914 cbConfig.MsgIdRangeCount = pCbOpt->channelData.channelCnt;
916 for (int i = 0; i < cbConfig.MsgIdRangeCount; i++) {
917 cbConfig.MsgIDs[i].Net3gpp.Selected = (unsigned short)pCbOpt->channelData.channelInfo[i].bActivate;
918 cbConfig.MsgIDs[i].Net3gpp.FromMsgId = (unsigned short)pCbOpt->channelData.channelInfo[i].from;
919 cbConfig.MsgIDs[i].Net3gpp.ToMsgId = (unsigned short)pCbOpt->channelData.channelInfo[i].to;
921 MSG_DEBUG("FROM: %d, TO: %d", cbConfig.MsgIDs[i].Net3gpp.FromMsgId, cbConfig.MsgIDs[i].Net3gpp.ToMsgId);
923 MSG_DEBUG("CBEnabled: %d, range_count: %d", cbConfig.CBEnabled, cbConfig.MsgIdRangeCount);*/
925 ret = tel_set_sms_cb_config(handle, &cbConfig, TapiEventSetConfigData, NULL);
927 if (ret == TAPI_API_SUCCESS) {
928 MSG_DEBUG("######## tel_set_sms_cb_config() Success !!! #######");
930 MSG_ERR("######## tel_set_sms_cb_config() Fail !!! return : %d #######", ret);
934 if (getResultFromSim() == true) {
935 MSG_DEBUG("######## Set Cb Config was Successful !!! #######");
937 MSG_ERR("######## Set Cb Config was Failed !!! #######");
946 bool SmsPluginSetting::getCbConfig(MSG_CBMSG_OPT_S *pCbOpt)
948 int ret = TAPI_API_SUCCESS;
950 TapiHandle *handle = NULL;
952 if (pCbOpt->simIndex == 0) {
953 MSG_DEBUG("SIM Index for getCBConfig = 0, CANNOT get cbconfig from SIM 0");
957 handle = SmsPluginDSHandler::instance()->getTelHandle(pCbOpt->simIndex);
959 ret = tel_get_sms_cb_config(handle, TapiEventGetCBConfig, NULL);
961 if (ret == TAPI_API_SUCCESS) {
962 MSG_DEBUG("######## tel_get_sms_cb_config() Success !!! #######");
964 MSG_ERR("######## tel_get_sms_cb_config() Fail !!! return : %d #######", ret);
968 if (getCbConfigEvent(pCbOpt) == true) {
969 MSG_DEBUG("######## Get Cb Config was Successful !!! #######");
971 MSG_ERR("######## Get Cb Config was Failed !!! #######");
979 void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
982 MutexLocker lock(mx);
984 int ret = TAPI_API_SUCCESS;
985 bool *bShowError = NULL; /* When invalid voicemail data exists on SIM, update error should not be handled. */
987 int simIndex = pVoiceOpt->simIndex;
989 if (bMbdnEnable[simIndex] == false) {
990 MSG_DEBUG("MBDN service is disable.");
994 TelSimMailBoxNumber_t mailboxInfo = {0, };
995 bool bExistVoicetype = false;
998 smsSimMailboxListMap::iterator it = simMailboxList.find(simIndex);
999 if (it == simMailboxList.end()) {
1003 SMS_SIM_MAILBOX_LIST_S &pTmpSimMailboxList = it->second;
1004 if (pTmpSimMailboxList.count < 0) { /* Not available */
1008 bShowError = (bool*)calloc(1, sizeof(bool));
1012 if (pTmpSimMailboxList.count == 0) {
1013 char num[MAX_PHONE_NUMBER_LEN + 1] = {0, };
1015 mailboxInfo.mb_type = TAPI_SIM_MAILBOX_VOICE;
1016 mailboxInfo.rec_index = 1;
1017 mailboxInfo.ton = TAPI_SIM_TON_UNKNOWN;
1019 snprintf(num, sizeof(num), "%s", pVoiceOpt->mailNumber);
1020 MSG_DEBUG("Mailbox number config [%s]", num);
1022 if (num[0] == '+') {
1023 snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", &(num[1]));
1024 mailboxInfo.ton = TAPI_SIM_TON_INTERNATIONAL;
1026 snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", num);
1029 MSG_SEC_DEBUG("Mailbox number to save sim [%s]", mailboxInfo.num);
1031 *bShowError = false;
1034 for (i = 0; i < pTmpSimMailboxList.count; i++) {
1035 if (pTmpSimMailboxList.list[i].mb_type == TAPI_SIM_MAILBOX_VOICE) {
1036 bExistVoicetype = true;
1041 if (bExistVoicetype == false) {
1042 *bShowError = false;
1043 /* There is no mailbox information for voicemail type on SIM. */
1044 for (i = 0; i < pTmpSimMailboxList.count; i++) {
1045 if (pTmpSimMailboxList.list[i].mb_type < TAPI_SIM_MAILBOX_VOICE || pTmpSimMailboxList.list[i].mb_type > TAPI_SIM_MAILBOX_OTHER) {
1046 pTmpSimMailboxList.list[i].mb_type = TAPI_SIM_MAILBOX_VOICE;
1052 /* if strlen of voicemail number retrieved from SIM is zero, error is not shown */
1053 if (pTmpSimMailboxList.list[i].num_len == 0) {
1054 MSG_DEBUG("In SIM voicemail does not exist");
1055 *bShowError = false;
1056 } else if (pTmpSimMailboxList.list[i].num_len > 0) {
1057 MSG_DEBUG("In SIM voicemail exist");
1061 MSG_INFO("bShowError = %d", *bShowError);
1063 memset(&pTmpSimMailboxList.list[i].num, 0x00, sizeof(pTmpSimMailboxList.list[i].num));
1064 snprintf(pTmpSimMailboxList.list[i].num, sizeof(pTmpSimMailboxList.list[i].num), "%s", pVoiceOpt->mailNumber);
1065 MSG_DEBUG("Mailbox number config [%s]", pTmpSimMailboxList.list[i].num);
1067 mailboxInfo.b_cphs = pTmpSimMailboxList.list[i].b_cphs;
1068 mailboxInfo.alpha_id_max_len = pTmpSimMailboxList.list[i].alpha_id_max_len;
1069 mailboxInfo.mb_type = (TelSimMailboxType_t)pTmpSimMailboxList.list[i].mb_type;
1070 mailboxInfo.profile_num = pTmpSimMailboxList.list[i].profile_num;
1071 mailboxInfo.rec_index = (pTmpSimMailboxList.list[i].rec_index == 0) ? 1 : pTmpSimMailboxList.list[i].rec_index;
1072 mailboxInfo.ton = (TelSimTypeOfNum_t)pTmpSimMailboxList.list[i].ton;
1073 mailboxInfo.npi = (TelSimNumberingPlanIdentity_t)pTmpSimMailboxList.list[i].npi;
1074 snprintf(mailboxInfo.alpha_id, sizeof(mailboxInfo.alpha_id), "%s", pTmpSimMailboxList.list[i].alpha_id);
1076 if (pTmpSimMailboxList.list[i].num[0] == '+') {
1077 snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", &(pTmpSimMailboxList.list[i].num[1]));
1078 mailboxInfo.ton = TAPI_SIM_TON_INTERNATIONAL;
1080 snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", pTmpSimMailboxList.list[i].num);
1082 MSG_DEBUG("Mailbox number to save sim [%s]", mailboxInfo.num);
1084 mailboxInfo.cc_id = pTmpSimMailboxList.list[i].cc_id;
1085 mailboxInfo.ext1_id = pTmpSimMailboxList.list[i].ext1_id;
1088 TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
1090 ret = tel_set_sim_mailbox_info(handle, &mailboxInfo, TapiEventSetMailboxInfo, (void*)bShowError);
1092 if (ret == TAPI_API_SUCCESS) {
1093 MSG_DEBUG("######## tel_set_sim_mailbox_info() Success !!! #######");
1095 MSG_ERR("######## tel_set_sim_mailbox_info() Fail !!! return : %d #######", ret);
1098 if (getResultFromSim() == true) {
1099 MSG_DEBUG("######## Set mailbox info Success !!! #######");
1103 THROW(MsgException::SMS_PLG_ERROR, "######## Set mailbox info Failed !!!#######");
1104 MSG_ERR("######## Set mailbox info Failed !!! #######");
1115 bool SmsPluginSetting::getVoiceMailInfo(TapiHandle *handle)
1117 MutexLocker lock(mx);
1119 int ret = TAPI_API_SUCCESS;
1121 ret = tel_get_sim_mailbox_info(handle, TapiEventGetMailboxInfo, NULL);
1123 if (ret == TAPI_API_SUCCESS) {
1124 MSG_DEBUG("######## tel_get_sim_mailbox_info() Success !!! #######");
1126 MSG_ERR("######## tel_get_sim_mailbox_info() Fail !!! return : %d #######", ret);
1130 if (getMailboxInfoEvent() == true) {
1131 MSG_DEBUG("######## Get mailbox info was Successful !!! #######");
1133 MSG_ERR("######## Get mailbox info was Failed !!! #######");
1141 void SmsPluginSetting::getMeImei(char *pImei)
1143 int ret = TAPI_API_SUCCESS;
1145 TapiHandle *handle = NULL;
1146 handle = SmsPluginDSHandler::instance()->getTelHandle(1);
1148 if (handle == NULL) {
1149 MSG_DEBUG("Tapi Handle is NULL!");
1153 ret = tel_get_misc_me_imei(handle, TapiEventGetMeImei, NULL);
1155 if (ret == TAPI_API_SUCCESS) {
1156 MSG_SEC_DEBUG("######## tel_get_misc_me_imei() Success !!! #######");
1158 if (getResultImei(pImei) == true) {
1159 MSG_SEC_DEBUG("######## Get ME IMEI was Successful !!! #######");
1161 MSG_SEC_DEBUG("######## Get ME IMEI was Failed !!! #######");
1164 MSG_SEC_DEBUG("######## tel_get_misc_me_imei() Fail !!! return : %d #######", ret);
1169 void SmsPluginSetting::setMwiInfo(int simIndex, MSG_SUB_TYPE_T type, int count)
1171 MSG_DEBUG("SET MWI INFO, type=[%d]", type);
1172 MSG_DEBUG("SET MWI INFO, count=[%d]", count);
1174 char keyName[MAX_VCONFKEY_NAME_LEN];
1176 memset(keyName, 0x00, sizeof(keyName));
1177 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, simIndex);
1179 if (MsgSettingSetInt(keyName, count) != MSG_SUCCESS)
1180 MSG_DEBUG("MsgSettingSetInt is failed!!");
1183 if (type == MSG_MWI_VOICE_SMS)
1184 MsgDeleteNoti(MSG_NOTI_TYPE_VOICE_1, simIndex);
1185 else if (type == MSG_MWI_VOICE2_SMS)
1186 MsgDeleteNoti(MSG_NOTI_TYPE_VOICE_2, simIndex);
1189 if (bMbdnEnable[simIndex] == false) {
1190 MSG_DEBUG("MBDN service is disable.");
1194 int ret = TAPI_API_SUCCESS;
1195 TelSimMessageWaitingReq_t mwReq = {0, };
1197 simMwiInfoMap::iterator iter = simMwiInfo.find(simIndex);
1198 if(iter == simMwiInfo.end()) {
1199 MSG_DEBUG("IT is not present");
1203 MSG_DEBUG("IT is present");
1205 SMS_SIM_MWI_INFO_S &pTmpsimMwiInfo = iter->second;
1207 MSG_DEBUG("SET MWI INFO, CPHS? [%s]", pTmpsimMwiInfo.b_cphs?"Yes":"No");
1209 if (pTmpsimMwiInfo.b_cphs) {
1210 MSG_DEBUG("b_cphs is set");
1211 if (type == MSG_MWI_VOICE_SMS)
1212 pTmpsimMwiInfo.cphs_mwi.b_voice1 = (count > 0 ? 1:0);
1213 else if (type == MSG_MWI_VOICE2_SMS)
1214 pTmpsimMwiInfo.cphs_mwi.b_voice2 = (count > 0 ? 1:0);
1215 else if (type == MSG_MWI_FAX_SMS)
1216 pTmpsimMwiInfo.cphs_mwi.b_fax = (count > 0 ? 1:0);
1218 MSG_DEBUG("There is no type [%d] in CPHS.", type);
1222 mwReq.mw_data_u.cphs_mw.b_voice1 = pTmpsimMwiInfo.cphs_mwi.b_voice1;
1223 mwReq.mw_data_u.cphs_mw.b_voice2 = pTmpsimMwiInfo.cphs_mwi.b_voice2;
1224 mwReq.mw_data_u.cphs_mw.b_fax = pTmpsimMwiInfo.cphs_mwi.b_fax;
1225 mwReq.mw_data_u.cphs_mw.b_data = pTmpsimMwiInfo.cphs_mwi.b_data;
1227 MSG_DEBUG("MWI voice 1 = [%d]", mwReq.mw_data_u.cphs_mw.b_voice1);
1228 MSG_DEBUG("MWI voice 2 = [%d]", mwReq.mw_data_u.cphs_mw.b_voice2);
1229 MSG_DEBUG("MWI fax = [%d]", mwReq.mw_data_u.cphs_mw.b_fax);
1230 MSG_DEBUG("MWI data = [%d]", mwReq.mw_data_u.cphs_mw.b_data);
1233 MSG_DEBUG("b_cphs is not set");
1235 if (type == MSG_MWI_VOICE_SMS)
1236 pTmpsimMwiInfo.mwi_list.mw_info[0].voice_count = count;
1237 else if (type == MSG_MWI_FAX_SMS)
1238 pTmpsimMwiInfo.mwi_list.mw_info[0].fax_count = count;
1239 else if (type == MSG_MWI_EMAIL_SMS)
1240 pTmpsimMwiInfo.mwi_list.mw_info[0].email_count = count;
1241 else /* MSG_MWI_OTHER_SMS */
1242 pTmpsimMwiInfo.mwi_list.mw_info[0].other_count = count;
1244 mwReq.mw_data_u.mw.rec_index = pTmpsimMwiInfo.mwi_list.mw_info[0].rec_index;
1247 mwReq.mw_data_u.mw.indicator_status = 0x00;
1249 mwReq.mw_data_u.mw.indicator_status = 0x01;
1251 mwReq.mw_data_u.mw.voice_count = pTmpsimMwiInfo.mwi_list.mw_info[0].voice_count;
1252 mwReq.mw_data_u.mw.fax_count = pTmpsimMwiInfo.mwi_list.mw_info[0].fax_count;
1253 mwReq.mw_data_u.mw.email_count = pTmpsimMwiInfo.mwi_list.mw_info[0].email_count;
1254 mwReq.mw_data_u.mw.other_count = pTmpsimMwiInfo.mwi_list.mw_info[0].other_count;
1255 mwReq.mw_data_u.mw.video_count = pTmpsimMwiInfo.mwi_list.mw_info[0].video_count;
1257 MSG_DEBUG("MWI record index = [%d]", mwReq.mw_data_u.mw.rec_index);
1258 MSG_DEBUG("MWI ind status = [%d]", mwReq.mw_data_u.mw.indicator_status);
1259 MSG_DEBUG("MWI voice = [%d]", mwReq.mw_data_u.mw.voice_count);
1260 MSG_DEBUG("MWI fax = [%d]", mwReq.mw_data_u.mw.fax_count);
1261 MSG_DEBUG("MWI email = [%d]", mwReq.mw_data_u.mw.email_count);
1262 MSG_DEBUG("MWI other = [%d]", mwReq.mw_data_u.mw.other_count);
1263 MSG_DEBUG("MWI video = [%d]", mwReq.mw_data_u.mw.video_count);
1266 mwReq.b_cphs = pTmpsimMwiInfo.b_cphs;
1268 TapiHandle *handle = SmsPluginDSHandler::instance()->getTelHandle(simIndex);
1270 ret = tel_set_sim_messagewaiting_info(handle, &mwReq, TapiEventSetMwiInfo, NULL);
1272 if (ret == TAPI_API_SUCCESS) {
1273 MSG_DEBUG("######## tel_set_sim_messagewaiting_info() Success !!! #######");
1275 MSG_DEBUG("######## tel_set_sim_messagewaiting_info() Fail !!! return : %d #######", ret);
1282 bool SmsPluginSetting::getMwiInfo(TapiHandle *handle)
1284 MutexLocker lock(mx);
1286 int ret = TAPI_API_SUCCESS;
1288 ret = tel_get_sim_messagewaiting_info(handle, TapiEventGetMwiInfo, NULL);
1290 if (ret == TAPI_API_SUCCESS) {
1291 MSG_DEBUG("######## tel_get_sim_messagewaiting_info() Success !!! #######");
1293 MSG_DEBUG("######## tel_get_sim_messagewaiting_info() Fail !!! return : %d #######", ret);
1297 if (getResultFromSim() == true) {
1298 MSG_DEBUG("######## Get Mainbox info was Successful !!! #######");
1300 MSG_DEBUG("######## Get Mainbox info was Failed !!! #######");
1308 bool SmsPluginSetting::getMsisdnInfo(TapiHandle *handle)
1310 MutexLocker lock(mx);
1312 int ret = TAPI_API_SUCCESS;
1314 ret = tel_get_sim_msisdn(handle, TapiEventGetMsisdnInfo, NULL);
1316 if (ret == TAPI_API_SUCCESS) {
1317 MSG_DEBUG("######## tel_get_sim_msisdn() Success !!! #######");
1319 MSG_DEBUG("######## tel_get_sim_msisdn() Fail !!! return : %d #######", ret);
1323 if (getResultFromSim() == true) {
1324 MSG_DEBUG("######## Get Sim msisdn was Successful !!! #######");
1326 MSG_DEBUG("######## Get Sim msisdn was Failed !!! #######");
1334 bool SmsPluginSetting::getSimServiceTable(TapiHandle *handle)
1336 MutexLocker lock(mx);
1338 int ret = TAPI_API_SUCCESS;
1340 ret = tel_get_sim_service_table(handle, TapiEventGetSimServiceTable, NULL);
1342 if (ret == TAPI_API_SUCCESS) {
1343 MSG_DEBUG("######## tel_get_sim_service_table() Success !!! #######");
1345 MSG_DEBUG("######## tel_get_sim_service_table() Fail !!! return : %d #######", ret);
1349 if (getResultFromSim() == true) {
1350 MSG_DEBUG("######## Get SST info was Successful !!! #######");
1352 MSG_DEBUG("######## Get SST info was Failed !!! #######");
1360 void SmsPluginSetting::setParamCntEvent(int ParamCnt)
1364 paramCnt = ParamCnt;
1372 int SmsPluginSetting::getParamCntEvent()
1378 ret = cv.timedwait(mx.pMutex(), MAX_TAPI_SIM_API_TIMEOUT);
1382 if (ret == ETIMEDOUT) {
1383 MSG_ERR("WARNING: TAPI callback TIME-OUT");
1391 void SmsPluginSetting::setParamEvent(struct tapi_handle *handle, const MSG_SMSC_DATA_S *pSmscData, int RecordIdx, bool bSuccess)
1395 bTapiResult = bSuccess;
1397 int sim_idx = SmsPluginDSHandler::instance()->getSimIndex(handle);
1399 memset(&smscData[sim_idx], 0x00, sizeof(MSG_SMSC_DATA_S));
1401 if (bTapiResult == true) {
1402 MSG_DEBUG("Success to get parameter data");
1404 selectedParam = RecordIdx;
1406 memcpy(&smscData[sim_idx], pSmscData, sizeof(MSG_SMSC_DATA_S));
1415 bool SmsPluginSetting::getParamEvent(TapiHandle *handle, MSG_SMSC_DATA_S *pSmscData)
1421 bTapiResult = false;
1422 ret = cv.timedwait(mx.pMutex(), MAX_TAPI_SIM_API_TIMEOUT);
1426 if (ret == ETIMEDOUT) {
1427 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
1431 memset(pSmscData, 0x00, sizeof(MSG_SMSC_DATA_S));
1433 if (bTapiResult == true) {
1434 int index = SmsPluginDSHandler::instance()->getSimIndex(handle);
1435 memcpy(pSmscData, &smscData[index], sizeof(MSG_SMSC_DATA_S));
1442 void SmsPluginSetting::setCbConfigEvent(TapiHandle *handle, const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess)
1448 char keyName[MAX_VCONFKEY_NAME_LEN];
1450 bTapiResult = bSuccess;
1452 int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
1454 if (bTapiResult == true) {
1455 MSG_DEBUG("Success to get cb config data");
1457 pair <int, MSG_CBMSG_OPT_S> newCbOpt(simIndex, *pCbOpt);
1458 cbOptMap::iterator it = cbOpt.find(simIndex);
1460 if (it == cbOpt.end()) {
1461 MSG_DEBUG("IT is not present");
1463 MSG_DEBUG("IT present");
1466 cbOpt.insert(newCbOpt);
1468 memset(keyName, 0x00, sizeof(keyName));
1469 snprintf(keyName, sizeof(keyName), "%s/%d", CB_MAX_SIM_COUNT, simIndex);
1470 if (MsgSettingSetInt(keyName, pCbOpt->maxSimCnt) != MSG_SUCCESS) {
1471 MSG_DEBUG("Error to set config data [%s]", keyName);
1474 MSG_DEBUG("Failed to get cb config data");
1476 cbOptMap::iterator it = cbOpt.find(simIndex);
1478 if (it == cbOpt.end()) {
1479 MSG_DEBUG("IT not present");
1480 MSG_CBMSG_OPT_S pTmpCbOpt;
1482 memset(&pTmpCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
1483 pair <int, MSG_CBMSG_OPT_S> newCbOpt(simIndex, pTmpCbOpt);
1485 cbOpt.insert(newCbOpt);
1496 bool SmsPluginSetting::getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt)
1504 bTapiResult = false;
1505 ret = cv.timedwait(mx.pMutex(), MAX_TAPI_SIM_API_TIMEOUT);
1509 if (ret == ETIMEDOUT) {
1510 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
1514 int simIndex = pCbOpt->simIndex;
1516 memset(pCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
1518 if (bTapiResult == true) {
1519 cbOptMap::iterator it = cbOpt.find(simIndex);
1521 if (it == cbOpt.end()) {
1522 MSG_DEBUG("IT is not present");
1526 MSG_DEBUG("IT is present");
1528 MSG_CBMSG_OPT_S &pTmpCbOpt = it->second;
1529 memcpy(pCbOpt, &pTmpCbOpt, sizeof(MSG_CBMSG_OPT_S));
1537 void SmsPluginSetting::setMailboxInfoEvent(TapiHandle *handle, SMS_SIM_MAILBOX_LIST_S *pMailboxList, bool bSuccess, bool bMbdn)
1541 MSG_DEBUG("bSuccess = %d, bMbdn = %d", bSuccess, bMbdn);
1544 bTapiResult = bSuccess;
1546 int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
1548 bMbdnEnable[simIndex] = bMbdn;
1550 /* print incoming mailbox list */
1552 MSG_DEBUG("Input list is count = %d ", pMailboxList->count);
1554 for (int i = 0; i < pMailboxList->count; i++) {
1555 MSG_DEBUG("List index = %d", i);
1556 MSG_DEBUG("ton = %d, num = %s, alpha_id = %s", pMailboxList->list[i].ton, pMailboxList->list[i].num, pMailboxList->list[i].alpha_id);
1559 MSG_INFO("pMailboxList is NULL");
1562 if (bTapiResult == true) {
1564 bool bExistMailboxType = false;
1565 char keyName[MAX_VCONFKEY_NAME_LEN];
1567 if (pMailboxList && pMailboxList->count > 0) {
1568 pair <int, SMS_SIM_MAILBOX_LIST_S> newList(simIndex, *pMailboxList);
1570 smsSimMailboxListMap::iterator it = simMailboxList.find(simIndex);
1571 if (it == simMailboxList.end()) {
1572 MSG_DEBUG("IT not present !!!");
1573 simMailboxList.insert(newList);
1575 MSG_DEBUG("IT present !!!");
1576 simMailboxList.erase(it);
1577 simMailboxList.insert(newList);
1580 /* Temp :: Save voicemail number with VOICE1 line number */
1581 for (i = 0; i < pMailboxList->count ; i++) {
1582 MSG_SEC_DEBUG("Mailbox list[%d] type=[%d]", i, pMailboxList->list[i].mb_type);
1584 if (pMailboxList->list[i].mb_type == TAPI_SIM_MAILBOX_VOICE) {
1585 bExistMailboxType = true;
1590 if (bExistMailboxType == false) {
1591 MSG_DEBUG("There is no voice mailbox type.");
1592 for (i = 0; i < simMailboxList[simIndex].count; i++) {
1593 if (pMailboxList->list[i].mb_type < TAPI_SIM_MAILBOX_VOICE || pMailboxList->list[i].mb_type > TAPI_SIM_MAILBOX_OTHER) {
1594 pMailboxList->list[i].mb_type = TAPI_SIM_MAILBOX_VOICE;
1600 smsSimMailboxListMap::iterator iter = simMailboxList.find(simIndex);
1602 SMS_SIM_MAILBOX_LIST_S &pTmpMailboxList = iter->second;
1604 char mailNumber[MAX_PHONE_NUMBER_LEN+1];
1605 memset(mailNumber, 0x00 , sizeof(mailNumber));
1607 MSG_SEC_DEBUG("Mailbox list[%d] ton=[%d], address=[%s], alpha_id=[%s]", \
1608 i, pTmpMailboxList.list[i].ton, pTmpMailboxList.list[i].num, \
1609 pTmpMailboxList.list[i].alpha_id);
1611 if (pTmpMailboxList.list[i].ton == MSG_TON_INTERNATIONAL && pTmpMailboxList.list[i].num[0] != '+') {
1612 snprintf(mailNumber, sizeof(mailNumber), "+%s", pTmpMailboxList.list[i].num);
1613 MSG_WARN("MSG_TON_INTERNATIONAL [%s]", mailNumber);
1615 snprintf(mailNumber, sizeof(mailNumber), "%s", pTmpMailboxList.list[i].num);
1616 MSG_DEBUG("[%s]", mailNumber);
1619 if (mailNumber[0] != '\0') {
1620 memset(keyName, 0x00, sizeof(keyName));
1621 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, simIndex);
1622 if (MsgSettingSetString(keyName, mailNumber) != MSG_SUCCESS)
1623 MSG_DEBUG("MsgSettingSetString is failed!!");
1626 if (pTmpMailboxList.list[i].alpha_id[0] != '\0') {
1627 char unpackAlphaId[MAX_SIM_XDN_ALPHA_ID_LEN+8];
1629 MSG_LANG_INFO_S langInfo = {0, };
1631 memset(unpackAlphaId, 0x00, sizeof(unpackAlphaId));
1633 langInfo.bSingleShift = false;
1634 langInfo.bLockingShift = false;
1636 tmpLen = strlen(pTmpMailboxList.list[i].alpha_id);
1638 MsgTextConvert *textCvt = MsgTextConvert::instance();
1639 textCvt->convertGSM7bitToUTF8((unsigned char*)unpackAlphaId, sizeof(unpackAlphaId), (unsigned char*)pTmpMailboxList.list[i].alpha_id, tmpLen, &langInfo);
1641 MSG_DEBUG("UTF8 ALPHA_ID = [%s]", unpackAlphaId);
1643 memset(keyName, 0x00, sizeof(keyName));
1644 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, simIndex);
1645 if (MsgSettingSetString(keyName, unpackAlphaId) != MSG_SUCCESS)
1646 MSG_DEBUG("MsgSettingSetString is failed!!");
1650 /* insert empty list with sim index */
1651 SMS_SIM_MAILBOX_LIST_S pDummySimMailboxList;
1653 memset(&pDummySimMailboxList, 0x00, sizeof(SMS_SIM_MAILBOX_LIST_S));
1654 pair <int, SMS_SIM_MAILBOX_LIST_S> newTmpList(simIndex, pDummySimMailboxList);
1655 simMailboxList.insert(newTmpList);
1664 bool SmsPluginSetting::getMailboxInfoEvent()
1670 bTapiResult = false;
1671 ret = cv.timedwait(mx.pMutex(), MAX_TAPI_SIM_API_TIMEOUT);
1675 if (ret == ETIMEDOUT) {
1676 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
1683 void SmsPluginSetting::setMwiInfoEvent(struct tapi_handle *handle, SMS_SIM_MWI_INFO_S *pMwiInfo, bool bSuccess)
1689 bTapiResult = bSuccess;
1691 int index = SmsPluginDSHandler::instance()->getSimIndex(handle);
1693 if (bTapiResult == true) {
1695 char keyName[MAX_VCONFKEY_NAME_LEN];
1697 pair <int, SMS_SIM_MWI_INFO_S> newList(index, *pMwiInfo);
1698 simMwiInfoMap::iterator it = simMwiInfo.find(index);
1700 if (it == simMwiInfo.end()) {
1701 MSG_DEBUG("IT not present");
1703 MSG_DEBUG("IT present");
1704 simMwiInfo.erase(it);
1706 simMwiInfo.insert(newList);
1708 simMwiInfoMap::iterator iter = simMwiInfo.find(index);
1710 SMS_SIM_MWI_INFO_S &pTmpsimMwiInfoList = iter->second;
1712 /* Save MW count with VOICE line1 number */
1713 if (pTmpsimMwiInfoList.b_cphs == true) {
1714 mwiCnt = pTmpsimMwiInfoList.cphs_mwi.b_voice1;
1716 mwiCnt = pTmpsimMwiInfoList.mwi_list.mw_info[0].voice_count;
1718 /* TODO :: Add operation for voice mail of line 2 */
1720 memset(keyName, 0x00, sizeof(keyName));
1721 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, index);
1722 if (MsgSettingSetInt(keyName, mwiCnt) != MSG_SUCCESS)
1723 MSG_DEBUG("MsgSettingSetInt is failed!!");
1725 MSG_DEBUG("MWI count = [%d]", mwiCnt);
1728 deliverVoiceMsgNoti(index, mwiCnt);
1731 SMS_SIM_MWI_INFO_S pTmpsimMwiInfo;
1733 memset(&pTmpsimMwiInfo, 0x00, sizeof(SMS_SIM_MWI_INFO_S));
1735 pair <int, SMS_SIM_MWI_INFO_S> newList(index, pTmpsimMwiInfo);
1736 simMwiInfoMap::iterator it = simMwiInfo.find(index);
1738 if (it == simMwiInfo.end()) {
1739 MSG_DEBUG("IT not present");
1741 MSG_DEBUG("IT present");
1742 simMwiInfo.erase(it);
1744 simMwiInfo.insert(newList);
1755 void SmsPluginSetting::setResultImei(bool bResult, char *pImei)
1759 bTapiResult = bResult;
1761 memset(&meImei, 0x00, sizeof(meImei));
1763 if (bTapiResult == true && pImei) {
1764 snprintf(meImei, sizeof(meImei), "%s", pImei);
1773 bool SmsPluginSetting::getResultImei(char *pImei)
1779 ret = cv.timedwait(mx.pMutex(), MAX_TAPI_SIM_API_TIMEOUT);
1783 if (ret == ETIMEDOUT) {
1784 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
1788 if (bTapiResult == true && pImei) {
1789 snprintf(pImei, sizeof(meImei), "%s", meImei);
1796 void SmsPluginSetting::setResultFromSim(bool bResult)
1800 bTapiResult = bResult;
1808 bool SmsPluginSetting::getResultFromSim()
1812 MSG_DEBUG("getResultFromSim() is called .");
1814 ret = cv.timedwait(mx.pMutex(), MAX_TAPI_SIM_API_TIMEOUT);
1816 if (ret == ETIMEDOUT) {
1817 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
1825 SMS_PID_T SmsPluginSetting::convertPid(MSG_SMS_PID_T pid)
1831 retPid = SMS_PID_NORMAL;
1833 case MSG_PID_VOICE :
1834 retPid = SMS_PID_VOICE;
1837 retPid = SMS_PID_TELEX;
1840 retPid = SMS_PID_x400;
1842 case MSG_PID_ERMES :
1843 retPid = SMS_PID_ERMES;
1845 case MSG_PID_EMAIL :
1846 retPid = SMS_PID_EMAIL;
1849 retPid = SMS_PID_NORMAL;
1857 void SmsPluginSetting::deliverVoiceMsgNoti(int simIndex, int mwiCnt)
1861 MSG_MESSAGE_INFO_S msgInfo = {0, };
1863 msgInfo.addressList = NULL;
1864 unique_ptr<MSG_ADDRESS_INFO_S*, void(*)(MSG_ADDRESS_INFO_S**)> addressListBuf(&msgInfo.addressList, unique_ptr_deleter);
1866 msgInfo.addressList = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)];
1867 memset(msgInfo.addressList, 0x00, sizeof(MSG_ADDRESS_INFO_S));
1869 msgInfo.nAddressCnt = 1;
1871 msgInfo.displayTime = time(NULL);
1873 char keyName[MAX_VCONFKEY_NAME_LEN];
1874 char *voiceNum = NULL;
1875 memset(keyName, 0x00, sizeof(keyName));
1876 snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, simIndex);
1877 if (MsgSettingGetString(keyName, &voiceNum) != MSG_SUCCESS) {
1878 MSG_INFO("MsgSettingGetString() is failed");
1882 snprintf(msgInfo.addressList[0].addressVal, sizeof(msgInfo.addressList[0].addressVal), "%s", voiceNum);
1886 memset(msgInfo.addressList[0].displayName, 0x00, sizeof(msgInfo.addressList[0].displayName));
1887 msgInfo.msgType.mainType = MSG_SMS_TYPE;
1888 msgInfo.msgType.subType = MSG_MWI_VOICE_SMS;
1889 msgInfo.sim_idx = simIndex;
1892 if (simMwiInfo.b_cphs == false) {
1893 snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new voice message", mwiCnt);
1895 snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "New voice message");
1898 snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d", mwiCnt);
1902 if (SmsPluginEventHandler::instance()->callbackMsgIncoming(&msgInfo) != MSG_SUCCESS)
1903 MSG_DEBUG("callbackIncoming is failed.");
1905 MsgInsertNotification(&msgInfo);
1906 if (MsgCheckNotificationSettingEnable())
1914 void SmsPluginSetting::setSimChangeStatus(TapiHandle *handle, bool bInitializing)
1918 int tapiRet = TAPI_API_SUCCESS;
1919 TelSimCardStatus_t status = TAPI_SIM_STATUS_CARD_ERROR;
1921 int cardChanged = 0;
1922 int simIndex = SmsPluginDSHandler::instance()->getSimIndex(handle);
1925 char keyName[MAX_VCONFKEY_NAME_LEN] = {0, };
1927 tapiRet = tel_get_sim_init_info(handle, &status, &cardChanged);
1928 MSG_INFO("Tapi Ret=[%d], SIM index [%d], SIM status [%d], CardChanged [%d]", tapiRet, simIndex, status, cardChanged);
1930 if (status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
1931 if (simStatus[simIndex] == MSG_SIM_STATUS_NOT_FOUND) {
1932 if (cardChanged == 1) {
1933 snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, simIndex);
1934 MsgSettingSetInt(keyName, MSG_SIM_STATUS_CHANGED);
1935 simStatus[simIndex] = MSG_SIM_STATUS_CHANGED;
1937 snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, simIndex);
1938 MsgSettingSetInt(keyName, MSG_SIM_STATUS_NORMAL);
1939 simStatus[simIndex] = MSG_SIM_STATUS_NORMAL;
1942 /* Modified to call initSimInfo for SIM separately */
1943 MSG_DEBUG("calling initSimInfo");
1944 if (pthread_create(&thd, NULL, &initSimInfo, handle) < 0) {
1945 MSG_DEBUG("pthread_create() error");
1947 pthread_detach(thd);
1950 MSG_DEBUG("SIM init was already done!");
1953 MSG_DEBUG("It doesn't initialize yet!!");
1954 snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_CHANGED, simIndex);
1955 MSG_DEBUG("Set MSG_SIM_CHANGED to MSG_SIM_STATUS_NOT_FOUND");
1956 if (MsgSettingSetInt(keyName, MSG_SIM_STATUS_NOT_FOUND) != MSG_SUCCESS)
1957 MSG_DEBUG("Fail to set MSG_SIM_CHANGED to MSG_SIM_STATUS_NOT_FOUND");
1959 simStatus[simIndex] = MSG_SIM_STATUS_NOT_FOUND;