4 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
23 #include "MsgException.h"
24 #include "MsgGconfWrapper.h"
25 #include "MsgNotificationWrapper.h"
26 #include "MsgSoundPlayer.h"
28 #include "SmsPluginParamCodec.h"
29 #include "SmsPluginCallback.h"
30 #include "SmsPluginSetting.h"
35 #include <tapi_common.h>
37 #include <TapiUtility.h>
38 #include <ITapiNetText.h>
42 extern struct tapi_handle *pTapiHandle;
44 /*==================================================================================================
45 IMPLEMENTATION OF SmsPluginSetting - Member Functions
46 ==================================================================================================*/
47 SmsPluginSetting* SmsPluginSetting::pInstance = NULL;
50 SmsPluginSetting::SmsPluginSetting()
52 // Initialize member variables
53 memset(&smscData, 0x00, sizeof(MSG_SMSC_DATA_S));
54 memset(&cbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
55 memset(&simMailboxList, 0x00, sizeof(SMS_SIM_MAILBOX_LIST_S));
63 SmsPluginSetting::~SmsPluginSetting()
70 SmsPluginSetting* SmsPluginSetting::instance()
73 pInstance = new SmsPluginSetting();
79 void SmsPluginSetting::initConfigData(MSG_SIM_STATUS_T SimStatus)
83 msg_error_t err = MSG_SUCCESS;
89 paramCnt = getParamCount();
91 MSG_DEBUG("Parameter Count [%d]", paramCnt);
93 MSG_SMSC_DATA_S tmpSmscData = {};
94 MSG_SMSC_LIST_S tmpSmscList = {};
96 for (int index = 0; index < paramCnt; index++)
98 if (getParam(index, &tmpSmscData) == false) {
103 memcpy(&(tmpSmscList.smscData[index]), &tmpSmscData, sizeof(MSG_SMSC_DATA_S));
105 MSG_DEBUG("pid[%d]", tmpSmscList.smscData[index].pid);
106 MSG_DEBUG("val_period[%d]", tmpSmscList.smscData[index].valPeriod);
107 MSG_DEBUG("name[%s]", tmpSmscList.smscData[index].name);
109 MSG_DEBUG("ton[%d]", tmpSmscList.smscData[index].smscAddr.ton);
110 MSG_DEBUG("npi[%d]", tmpSmscList.smscData[index].smscAddr.npi);
111 MSG_DEBUG("address[%s]", tmpSmscList.smscData[index].smscAddr.address);
114 tmpSmscList.totalCnt = (paramCnt - failCnt);
115 // below is commented to be the first smsc is selected.
116 // tmpSmscList.selected = selectedParam;
119 err = addSMSCList(&tmpSmscList);
121 if (err == MSG_SUCCESS) {
122 MSG_DEBUG("######## Add SMSC List Success !!! #######");
124 MSG_DEBUG("######## Add SMSC List Fail !!! return : %d #######", err);
129 if (SimStatus == MSG_SIM_STATUS_CHANGED) {
130 MSG_DEBUG("simStatus == MSG_SIM_STATUS_CHANGED");
132 MSG_CBMSG_OPT_S cbMsgOpt = {};
134 if (getCbConfig(&cbMsgOpt) == true) {
135 err = addCbOpt(&cbMsgOpt);
137 if (err == MSG_SUCCESS) {
138 MSG_DEBUG("######## Add CB Option Success !!! #######");
140 MSG_DEBUG("######## Add CB Option Fail !!! return : %d #######", err);
143 } else if (SimStatus == MSG_SIM_STATUS_NORMAL) {
144 MSG_DEBUG("simStatus == MSG_SIM_STATUS_NORMAL");
146 // Set CB Data into SIM in case of same SIM
147 MSG_SETTING_S cbSetting;
148 cbSetting.type = MSG_CBMSG_OPT;
150 getCbOpt(&cbSetting);
152 setCbConfig(&(cbSetting.option.cbMsgOpt));
155 if (SimStatus != MSG_SIM_STATUS_NOT_FOUND)
157 MSG_VOICEMAIL_OPT_S tmpVoiceMail;
158 memset(&tmpVoiceMail, 0x00, sizeof(MSG_VOICEMAIL_OPT_S));
160 if (getVoiceMailInfo(&tmpVoiceMail) == true) {
161 MSG_DEBUG("######## getVoiceMailInfo Success !!! #######");
163 MSG_DEBUG("######## getVoiceMailInfo Fail !!! #######");
166 if (getMwiInfo() == true) {
167 MSG_DEBUG("######## getMwiInfo Success !!! #######");
169 MSG_DEBUG("######## getMwiInfo Fail !!! #######");
172 if (getMsisdnInfo() == true) {
173 MSG_DEBUG("######## getMsisdnInfo Success !!! #######");
175 MSG_DEBUG("######## getMsisdnInfo Fail !!! #######");
183 void SmsPluginSetting::setConfigData(const MSG_SETTING_S *pSetting)
185 MSG_DEBUG("Setting Type : [%d]", pSetting->type);
187 switch (pSetting->type)
190 case MSG_SMS_SENDOPT :
191 setNetworkMode(&pSetting->option.smsSendOpt);
195 setParamList(&pSetting->option.smscList);
198 setCbConfig(&pSetting->option.cbMsgOpt);
200 case MSG_VOICEMAIL_OPT:
201 setVoiceMailInfo(&pSetting->option.voiceMailOpt);
204 THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
210 void SmsPluginSetting::getConfigData(MSG_SETTING_S *pSetting)
212 MSG_DEBUG("Setting Type : [%d]", pSetting->type);
214 switch (pSetting->type)
217 getParamList(&pSetting->option.smscList);
221 getCbConfig(&pSetting->option.cbMsgOpt);
225 THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
231 msg_error_t SmsPluginSetting::addSMSCList(MSG_SMSC_LIST_S *pSmscList)
233 msg_error_t err = MSG_SUCCESS;
235 MSG_DEBUG("total_count[%d]", pSmscList->totalCnt);
236 MSG_DEBUG("selected index[%d]", pSmscList->selected);
238 for (int i = 0; i < pSmscList->totalCnt; i++)
240 MSG_DEBUG("pid[%d]", pSmscList->smscData[i].pid);
241 MSG_DEBUG("val_period[%d]", pSmscList->smscData[i].valPeriod);
242 MSG_DEBUG("name[%s]", pSmscList->smscData[i].name);
244 MSG_DEBUG("ton[%d]", pSmscList->smscData[i].smscAddr.ton);
245 MSG_DEBUG("npi[%d]", pSmscList->smscData[i].smscAddr.npi);
246 MSG_DEBUG("address[%s]", pSmscList->smscData[i].smscAddr.address);
251 if (MsgSettingSetInt(SMSC_TOTAL_COUNT, pSmscList->totalCnt) != MSG_SUCCESS) {
252 MSG_DEBUG("Error to set config data [%s]", SMSC_TOTAL_COUNT);
253 return MSG_ERR_SET_SETTING;
256 if (MsgSettingSetInt(SMSC_SELECTED, pSmscList->selected) != MSG_SUCCESS) {
257 MSG_DEBUG("Error to set config data [%s]", SMSC_SELECTED);
258 return MSG_ERR_SET_SETTING;
261 for (int i = 0; i < pSmscList->totalCnt; i++) {
262 memset(keyName, 0x00, sizeof(keyName));
263 sprintf(keyName, "%s/%d", SMSC_PID, i);
265 if ((err = MsgSettingSetInt(keyName, (int)pSmscList->smscData[i].pid)) != MSG_SUCCESS)
268 memset(keyName, 0x00, sizeof(keyName));
269 sprintf(keyName, "%s/%d", SMSC_VAL_PERIOD, i);
271 if ((err = MsgSettingSetInt(keyName, (int)pSmscList->smscData[i].valPeriod)) != MSG_SUCCESS)
274 memset(keyName, 0x00, sizeof(keyName));
275 sprintf(keyName, "%s/%d", SMSC_NAME, i);
277 if ((err = MsgSettingSetString(keyName, pSmscList->smscData[i].name)) != MSG_SUCCESS)
280 memset(keyName, 0x00, sizeof(keyName));
281 sprintf(keyName, "%s/%d", SMSC_TON, i);
283 if (pSmscList->smscData[i].smscAddr.address[0] == '+')
284 pSmscList->smscData[i].smscAddr.ton = MSG_TON_INTERNATIONAL;
286 pSmscList->smscData[i].smscAddr.ton = MSG_TON_NATIONAL;
288 if ((err = MsgSettingSetInt(keyName, (int)pSmscList->smscData[i].smscAddr.ton)) != MSG_SUCCESS)
291 memset(keyName, 0x00, sizeof(keyName));
292 sprintf(keyName, "%s/%d", SMSC_NPI, i);
294 pSmscList->smscData[i].smscAddr.npi = MSG_NPI_ISDN; // app cannot set this value
296 if ((err = MsgSettingSetInt(keyName, (int)pSmscList->smscData[i].smscAddr.npi)) != MSG_SUCCESS)
299 memset(keyName, 0x00, sizeof(keyName));
300 sprintf(keyName, "%s/%d", SMSC_ADDRESS, i);
302 if ((err = MsgSettingSetString(keyName, pSmscList->smscData[i].smscAddr.address)) != MSG_SUCCESS)
306 if (err != MSG_SUCCESS) {
307 MSG_DEBUG("Error to set config data [%s]", keyName);
314 msg_error_t SmsPluginSetting::addCbOpt(MSG_CBMSG_OPT_S *pCbOpt)
316 msg_error_t err = MSG_SUCCESS;
318 MSG_DEBUG("Receive [%d], Max SIM Count [%d]", pCbOpt->bReceive, pCbOpt->maxSimCnt);
320 MSG_DEBUG("Channel Count [%d]", pCbOpt->channelData.channelCnt);
322 for (int i = 0; i < pCbOpt->channelData.channelCnt; i++)
324 MSG_DEBUG("Channel FROM [%d], Channel TO [%d]", pCbOpt->channelData.channelInfo[i].from, pCbOpt->channelData.channelInfo[i].to);
327 // Set Setting Data into Vconf
328 if (MsgSettingSetBool(CB_RECEIVE, pCbOpt->bReceive) != MSG_SUCCESS) {
329 MSG_DEBUG("Error to set config data [%s]", CB_RECEIVE);
330 return MSG_ERR_SET_SETTING;
333 if (MsgSettingSetInt(CB_MAX_SIM_COUNT, pCbOpt->maxSimCnt) != MSG_SUCCESS) {
334 MSG_DEBUG("Error to set config data [%s]", CB_MAX_SIM_COUNT);
335 return MSG_ERR_SET_SETTING;
338 if (MsgSettingSetInt(CB_CHANNEL_COUNT, pCbOpt->channelData.channelCnt) != MSG_SUCCESS) {
339 MSG_DEBUG("Error to set config data [%s]", CB_CHANNEL_COUNT);
340 return MSG_ERR_SET_SETTING;
345 for (int i = 0; i < pCbOpt->channelData.channelCnt; i++) {
346 memset(keyName, 0x00, sizeof(keyName));
347 sprintf(keyName, "%s/%d", CB_CHANNEL_ACTIVATE, i);
349 if ((err = MsgSettingSetBool(keyName, pCbOpt->channelData.channelInfo[i].bActivate)) != MSG_SUCCESS)
352 memset(keyName, 0x00, sizeof(keyName));
353 sprintf(keyName, "%s/%d", CB_CHANNEL_ID_FROM, i);
355 if ((err = MsgSettingSetInt(keyName, pCbOpt->channelData.channelInfo[i].from)) != MSG_SUCCESS)
358 memset(keyName, 0x00, sizeof(keyName));
359 sprintf(keyName, "%s/%d", CB_CHANNEL_ID_TO, i);
361 if ((err = MsgSettingSetInt(keyName, pCbOpt->channelData.channelInfo[i].to)) != MSG_SUCCESS)
364 memset(keyName, 0x00, sizeof(keyName));
365 sprintf(keyName, "%s/%d", CB_CHANNEL_NAME, i);
367 if ((err = MsgSettingSetString(keyName, pCbOpt->channelData.channelInfo[i].name)) != MSG_SUCCESS)
375 void SmsPluginSetting::getCbOpt(MSG_SETTING_S *pSetting)
378 char *tmpValue = NULL;
380 memset(&(pSetting->option.cbMsgOpt), 0x00, sizeof(MSG_CBMSG_OPT_S));
382 MsgSettingGetBool(CB_RECEIVE, &pSetting->option.cbMsgOpt.bReceive);
384 pSetting->option.cbMsgOpt.maxSimCnt = MsgSettingGetInt(CB_MAX_SIM_COUNT);
386 pSetting->option.cbMsgOpt.channelData.channelCnt = MsgSettingGetInt(CB_CHANNEL_COUNT);
388 for (int i = 0; i < pSetting->option.cbMsgOpt.channelData.channelCnt; i++) {
389 memset(keyName, 0x00, sizeof(keyName));
390 sprintf(keyName, "%s/%d", CB_CHANNEL_ACTIVATE, i);
392 MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.channelData.channelInfo[i].bActivate);
394 memset(keyName, 0x00, sizeof(keyName));
395 sprintf(keyName, "%s/%d", CB_CHANNEL_ID_FROM, i);
397 pSetting->option.cbMsgOpt.channelData.channelInfo[i].from = MsgSettingGetInt(keyName);
399 memset(keyName, 0x00, sizeof(keyName));
400 sprintf(keyName, "%s/%d", CB_CHANNEL_ID_TO, i);
402 pSetting->option.cbMsgOpt.channelData.channelInfo[i].to = MsgSettingGetInt(keyName);
404 memset(keyName, 0x00, sizeof(keyName));
405 sprintf(keyName, "%s/%d", CB_CHANNEL_NAME, i);
407 tmpValue = MsgSettingGetString(keyName);
409 if (tmpValue != NULL)
411 strncpy(pSetting->option.cbMsgOpt.channelData.channelInfo[i].name, tmpValue, CB_CHANNEL_NAME_MAX);
417 for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) {
418 memset(keyName, 0x00, sizeof(keyName));
419 sprintf(keyName, "%s/%d", CB_LANGUAGE, i);
421 MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]);
427 void SmsPluginSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
431 TelSmsParams_t smsParam = {0};
433 int ret = TAPI_API_SUCCESS;
435 for (int index = 0; index < pSMSCList->totalCnt; index++) {
436 /*Setting the SMSP Record index value*/
437 smsParam.RecordIndex = (unsigned char)index;
439 /*Setting the SMSP Record Length value = 28 + alphaId_len*/
440 smsParam.RecordLen = 28 + strlen(pSMSCList->smscData[index].name);
442 /*Setting the SMSP Alpha ID value*/
443 smsParam.AlphaIdLen = strlen(pSMSCList->smscData[index].name);
444 MSG_DEBUG("AlphaIdLen = %ld", smsParam.AlphaIdLen);
446 if (smsParam.AlphaIdLen > 0 && smsParam.AlphaIdLen <= SMSC_NAME_MAX) {
447 memcpy(smsParam.szAlphaId, pSMSCList->smscData[index].name, smsParam.AlphaIdLen);
448 smsParam.szAlphaId[smsParam.AlphaIdLen] = '\0';
449 MSG_DEBUG("szAlphaId = %s", smsParam.szAlphaId);
452 smsParam.ParamIndicator = 0x00;
454 if (strlen(pSMSCList->smscData[index].smscAddr.address) > 0) {
455 smsParam.ParamIndicator |= 0x02 ; //enable 2nd Bit
456 MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
458 if (pSMSCList->smscData[index].smscAddr.address[0] == '+')
459 smsParam.TpSvcCntrAddr.Ton = TAPI_SIM_TON_INTERNATIONAL;
461 smsParam.TpSvcCntrAddr.Ton = TAPI_SIM_TON_NATIONAL;
463 smsParam.TpSvcCntrAddr.Npi = TAPI_SIM_NPI_ISDN_TEL; // app cannot set this value
465 MSG_DEBUG("SMSC TON = [%d] NPI = [%d]", smsParam.TpSvcCntrAddr.Ton, smsParam.TpSvcCntrAddr.Npi);
467 MSG_DEBUG("address = %s", pSMSCList->smscData[index].smscAddr.address);
469 smsParam.TpSvcCntrAddr.DialNumLen = SmsPluginParamCodec::encodeSMSC(pSMSCList->smscData[index].smscAddr.address, smsParam.TpSvcCntrAddr.szDiallingNum);
471 MSG_DEBUG("SMSC Addr is not present");
474 /*Setting the PID value*/
475 smsParam.ParamIndicator |= 0x04 ; //enable 3nd Bit
476 MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
478 smsParam.TpProtocolId = (unsigned short)convertPid(pSMSCList->smscData[index].pid);
480 /*Setting the ValidityPeriod value*/
481 smsParam.ParamIndicator |= 0x10 ; //enable 5nd Bit
482 MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
484 smsParam.TpValidityPeriod = (unsigned short)pSMSCList->smscData[index].valPeriod;
486 smsParam.ParamIndicator = ~(smsParam.ParamIndicator);
487 MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
489 ret = tel_set_sms_parameters(pTapiHandle, (const TelSmsParams_t*)&smsParam, TapiEventSetConfigData, NULL);
491 if (ret != TAPI_API_SUCCESS)
492 THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_parameters() Error. [%d]", ret);
494 if (!getResultFromSim())
495 THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_parameters() Result Error.");
502 void SmsPluginSetting::getParamList(MSG_SMSC_LIST_S *pSMSCList)
508 paramCnt = getParamCount();
510 MSG_DEBUG("Parameter Count [%d]", paramCnt);
512 int ret = TAPI_API_SUCCESS;
514 MSG_SMSC_DATA_S tmpSmscData = {};
516 for (int index = 0; index < paramCnt; index++) {
517 ret = tel_get_sms_parameters(pTapiHandle, index, TapiEventGetParam, NULL);
519 if (ret == TAPI_API_SUCCESS) {
520 MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
522 THROW(MsgException::SMS_PLG_ERROR, "######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
525 if (getParamEvent(&tmpSmscData) == true) {
526 MSG_DEBUG("######## Get Parameter was Successful !!! #######");
528 THROW(MsgException::SMS_PLG_ERROR, "######## Get Parameter was Failed !!! #######");
531 memcpy(&(pSMSCList->smscData[index]), &tmpSmscData, sizeof(MSG_SMSC_DATA_S));
533 MSG_DEBUG("pid[%d]", pSMSCList->smscData[index].pid);
534 MSG_DEBUG("val_period[%d]", pSMSCList->smscData[index].valPeriod);
535 MSG_DEBUG("name[%s]", pSMSCList->smscData[index].name);
537 MSG_DEBUG("ton[%d]", pSMSCList->smscData[index].smscAddr.ton);
538 MSG_DEBUG("npi[%d]", pSMSCList->smscData[index].smscAddr.npi);
539 MSG_DEBUG("address[%s]", pSMSCList->smscData[index].smscAddr.address);
542 pSMSCList->totalCnt = paramCnt;
543 pSMSCList->selected = selectedParam;
545 MSG_DEBUG("total_count[%d]", pSMSCList->totalCnt);
551 int SmsPluginSetting::getParamCount()
553 int ret = TAPI_API_SUCCESS;
555 ret = tel_get_sms_parameter_count(pTapiHandle, TapiEventGetParamCnt, NULL);
557 if (ret == TAPI_API_SUCCESS) {
558 MSG_DEBUG("######## tel_get_sms_parameter_count() Success !!! #######");
560 THROW(MsgException::SMS_PLG_ERROR, "tel_get_sms_parameter_count() Error. [%d]", ret);
563 return getParamCntEvent();
567 bool SmsPluginSetting::getParam(int Index, MSG_SMSC_DATA_S *pSmscData)
569 int ret = TAPI_API_SUCCESS;
571 ret = tel_get_sms_parameters(pTapiHandle, Index, TapiEventGetParam, NULL);
573 if (ret == TAPI_API_SUCCESS) {
574 MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
576 MSG_DEBUG("######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
580 if (getParamEvent(pSmscData) == true) {
581 MSG_DEBUG("######## Get Parameter was Successful !!! #######");
583 MSG_DEBUG("######## Get Parameter was Failed !!! #######");
591 bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
593 int ret = TAPI_API_SUCCESS;
595 TelSmsCbConfig_t cbConfig = {};
597 cbConfig.CBEnabled = (int)pCbOpt->bReceive;
598 cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
599 cbConfig.MsgIdMaxCount = pCbOpt->maxSimCnt;
600 cbConfig.MsgIdRangeCount = pCbOpt->channelData.channelCnt;
602 for (int i = 0; i < cbConfig.MsgIdRangeCount; i++) {
603 cbConfig.MsgIDs[i].Net3gpp.Selected = (unsigned short)pCbOpt->channelData.channelInfo[i].bActivate;
604 cbConfig.MsgIDs[i].Net3gpp.FromMsgId = (unsigned short)pCbOpt->channelData.channelInfo[i].from;
605 cbConfig.MsgIDs[i].Net3gpp.ToMsgId = (unsigned short)pCbOpt->channelData.channelInfo[i].to;
607 MSG_DEBUG("FROM: %d, TO: %d", cbConfig.MsgIDs[i].Net3gpp.FromMsgId, cbConfig.MsgIDs[i].Net3gpp.ToMsgId);
609 MSG_DEBUG("CBEnabled: %d, range_count: %d", cbConfig.CBEnabled, cbConfig.MsgIdRangeCount);
611 ret = tel_set_sms_cb_config(pTapiHandle, &cbConfig, TapiEventSetConfigData, NULL);
613 if (ret == TAPI_API_SUCCESS) {
614 MSG_DEBUG("######## tel_set_sms_cb_config() Success !!! #######");
616 MSG_DEBUG("######## tel_set_sms_cb_config() Fail !!! return : %d #######", ret);
620 if (getResultFromSim() == true) {
621 MSG_DEBUG("######## Set Cb Config was Successful !!! #######");
623 MSG_DEBUG("######## Set Cb Config was Failed !!! #######");
631 bool SmsPluginSetting::getCbConfig(MSG_CBMSG_OPT_S *pCbOpt)
633 int ret = TAPI_API_SUCCESS;
635 ret = tel_get_sms_cb_config(pTapiHandle, TapiEventGetCBConfig, NULL);
637 if (ret == TAPI_API_SUCCESS) {
638 MSG_DEBUG("######## tel_get_sms_cb_config() Success !!! #######");
640 MSG_DEBUG("######## tel_get_sms_cb_config() Fail !!! return : %d #######", ret);
644 if (getCbConfigEvent(pCbOpt) == true) {
645 MSG_DEBUG("######## Get Cb Config was Successful !!! #######");
647 MSG_DEBUG("######## Get Cb Config was Failed !!! #######");
654 void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
656 int ret = TAPI_API_SUCCESS;
658 TelSimMailBoxNumber_t mailboxInfo = {0,};
660 for (int i = 0; i < simMailboxList.count; i++) {
661 if (simMailboxList.list[i].mb_type == TAPI_SIM_MAILBOX_VOICE) {
662 memset(&simMailboxList.list[i].num, 0x00, sizeof(simMailboxList.list[i].num));
663 snprintf(simMailboxList.list[i].num, sizeof(simMailboxList.list[i].num), "%s", pVoiceOpt->mailNumber);
664 MSG_DEBUG("Mailbox number config [%s]", simMailboxList.list[i].num);
666 mailboxInfo.b_cphs = simMailboxList.list[i].b_cphs;
667 mailboxInfo.alpha_id_max_len = simMailboxList.list[i].alpha_id_max_len;
668 mailboxInfo.mb_type = (TelSimMailboxType_t)simMailboxList.list[i].mb_type;
669 mailboxInfo.profile_num = simMailboxList.list[i].profile_num;
670 mailboxInfo.rec_index = simMailboxList.list[i].rec_index;
671 mailboxInfo.ton = (TelSimTypeOfNum_t)simMailboxList.list[i].ton;
672 mailboxInfo.npi = (TelSimNumberingPlanIdentity_t)simMailboxList.list[i].npi;
673 snprintf(mailboxInfo.alpha_id, sizeof(mailboxInfo.alpha_id), "%s", simMailboxList.list[i].alpha_id);
674 snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", simMailboxList.list[i].num);
675 mailboxInfo.cc_id = simMailboxList.list[i].cc_id;
676 mailboxInfo.ext1_id = simMailboxList.list[i].ext1_id;
682 ret = tel_set_sim_mailbox_info(pTapiHandle, &mailboxInfo, TapiEventSetMailboxInfo, NULL);
684 if (ret == TAPI_API_SUCCESS) {
685 MSG_DEBUG("######## tel_set_sim_mailbox_info() Success !!! #######");
687 MSG_DEBUG("######## tel_set_sim_mailbox_info() Fail !!! return : %d #######", ret);
690 if (getResultFromSim() == true) {
691 MSG_DEBUG("######## Set mailbox info Success !!! #######");
693 THROW(MsgException::SMS_PLG_ERROR, "######## Set mailbox info Failed !!!#######");
699 bool SmsPluginSetting::getVoiceMailInfo(MSG_VOICEMAIL_OPT_S *pVoiceOpt)
701 int ret = TAPI_API_SUCCESS;
703 ret = tel_get_sim_mailbox_info(pTapiHandle, TapiEventGetMailboxInfo, NULL);
705 if (ret == TAPI_API_SUCCESS) {
706 MSG_DEBUG("######## tel_get_sim_mailbox_info() Success !!! #######");
708 MSG_DEBUG("######## tel_get_sim_mailbox_info() Fail !!! return : %d #######", ret);
712 if (getMailboxInfoEvent(pVoiceOpt) == true) {
713 MSG_DEBUG("######## Get MWI info was Successful !!! #######");
715 MSG_DEBUG("######## Get MWI info was Failed !!! #######");
722 void SmsPluginSetting::setMwiInfo(MSG_SUB_TYPE_T type, int count)
724 if (type < MSG_MWI_VOICE_SMS || type > MSG_MWI_OTHER_SMS) {
725 MSG_DEBUG("Invalid parameter");
729 int ret = TAPI_API_SUCCESS;
731 TelSimMessageWaitingReq_t mwReq = {0,};
733 if (simMwiInfo.b_cphs) {
734 if (type == MSG_MWI_VOICE_SMS)
735 simMwiInfo.cphs_mwi.b_voice1 = true;
736 else if (type == MSG_MWI_FAX_SMS)
737 simMwiInfo.cphs_mwi.b_fax = true;
739 MSG_DEBUG("There is no type [%d] in CPHS.", type);
741 mwReq.mw_data_u.cphs_mw.b_voice1 = simMwiInfo.cphs_mwi.b_voice1;
742 mwReq.mw_data_u.cphs_mw.b_voice2 = simMwiInfo.cphs_mwi.b_voice2;
743 mwReq.mw_data_u.cphs_mw.b_fax = simMwiInfo.cphs_mwi.b_fax;
744 mwReq.mw_data_u.cphs_mw.b_data = simMwiInfo.cphs_mwi.b_data;
746 if (type == MSG_MWI_VOICE_SMS)
747 simMwiInfo.mwi_list.mw_info[0].voice_count = count;
748 else if (type == MSG_MWI_FAX_SMS)
749 simMwiInfo.mwi_list.mw_info[0].fax_count = count;
750 else if (type == MSG_MWI_EMAIL_SMS)
751 simMwiInfo.mwi_list.mw_info[0].email_count = count;
752 else // MSG_MWI_OTHER_SMS
753 simMwiInfo.mwi_list.mw_info[0].other_count = count;
755 mwReq.mw_data_u.mw.rec_index = simMwiInfo.mwi_list.mw_info[0].rec_index;
756 mwReq.mw_data_u.mw.indicator_status = simMwiInfo.mwi_list.mw_info[0].indicator_status;
757 mwReq.mw_data_u.mw.voice_count = simMwiInfo.mwi_list.mw_info[0].voice_count;
758 mwReq.mw_data_u.mw.fax_count = simMwiInfo.mwi_list.mw_info[0].fax_count;
759 mwReq.mw_data_u.mw.email_count = simMwiInfo.mwi_list.mw_info[0].email_count;
760 mwReq.mw_data_u.mw.other_count = simMwiInfo.mwi_list.mw_info[0].other_count;
761 mwReq.mw_data_u.mw.video_count = simMwiInfo.mwi_list.mw_info[0].video_count;
764 mwReq.b_cphs = simMwiInfo.b_cphs;
766 ret = tel_set_sim_messagewaiting_info(pTapiHandle, &mwReq, TapiEventSetMwiInfo, NULL);
768 if (ret == TAPI_API_SUCCESS) {
769 MSG_DEBUG("######## tel_set_sim_messagewaiting_info() Success !!! #######");
771 MSG_DEBUG("######## tel_set_sim_messagewaiting_info() Fail !!! return : %d #######", ret);
778 bool SmsPluginSetting::getMwiInfo(void)
780 int ret = TAPI_API_SUCCESS;
782 ret = tel_get_sim_messagewaiting_info(pTapiHandle, TapiEventGetMwiInfo, NULL);
784 if (ret == TAPI_API_SUCCESS) {
785 MSG_DEBUG("######## tel_get_sim_messagewaiting_info() Success !!! #######");
787 MSG_DEBUG("######## tel_get_sim_messagewaiting_info() Fail !!! return : %d #######", ret);
791 if (getResultFromSim() == true) {
792 MSG_DEBUG("######## Get Mainbox info was Successful !!! #######");
794 MSG_DEBUG("######## Get Mainbox info was Failed !!! #######");
802 bool SmsPluginSetting::getMsisdnInfo(void)
804 int ret = TAPI_API_SUCCESS;
807 ret = tel_get_sim_msisdn(pTapiHandle, TapiEventGetMsisdnInfo, NULL);
809 if (ret == TAPI_API_SUCCESS) {
811 MSG_DEBUG("######## tel_get_sim_msisdn() Success !!! #######");
814 MSG_DEBUG("######## tel_get_sim_msisdn() Fail !!! return : %d #######", ret);
821 void SmsPluginSetting::setParamCntEvent(int ParamCnt)
833 int SmsPluginSetting::getParamCntEvent()
839 ret = cv.timedwait(mx.pMutex(), 10);
843 if (ret == ETIMEDOUT) {
844 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
852 void SmsPluginSetting::setParamEvent(const MSG_SMSC_DATA_S *pSmscData, int RecordIdx, bool bSuccess)
856 bTapiResult = bSuccess;
858 memset(&smscData, 0x00, sizeof(MSG_SMSC_DATA_S));
860 if (bTapiResult == true) {
861 MSG_DEBUG("Success to get parameter data");
863 selectedParam = RecordIdx;
865 memcpy(&smscData, pSmscData, sizeof(MSG_SMSC_DATA_S));
874 bool SmsPluginSetting::getParamEvent(MSG_SMSC_DATA_S *pSmscData)
881 ret = cv.timedwait(mx.pMutex(), 10);
885 if (ret == ETIMEDOUT) {
886 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
890 memset(pSmscData, 0x00, sizeof(MSG_SMSC_DATA_S));
892 if (bTapiResult == true) {
893 memcpy(pSmscData, &smscData, sizeof(MSG_SMSC_DATA_S));
900 void SmsPluginSetting::setCbConfigEvent(const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess)
904 bTapiResult = bSuccess;
906 memset(&cbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
908 if (bTapiResult == true) {
909 MSG_DEBUG("Success to get cb config data");
911 memcpy(&cbOpt, pCbOpt, sizeof(MSG_CBMSG_OPT_S));
920 bool SmsPluginSetting::getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt)
927 ret = cv.timedwait(mx.pMutex(), 10);
931 if (ret == ETIMEDOUT) {
932 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
936 memset(pCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
938 if (bTapiResult == true) {
939 memcpy(pCbOpt, &cbOpt, sizeof(MSG_CBMSG_OPT_S));
946 void SmsPluginSetting::setMailboxInfoEvent(SMS_SIM_MAILBOX_LIST_S *pMailboxList, bool bSuccess)
950 bTapiResult = bSuccess;
952 memset(&simMailboxList, 0x00, sizeof(SMS_SIM_MAILBOX_LIST_S));
954 if (bTapiResult == true) {
957 if (pMailboxList && pMailboxList->count > 0) {
958 memcpy(&simMailboxList, pMailboxList, sizeof(SMS_SIM_MAILBOX_LIST_S));
960 /* Temp :: Save voicemail number with VOICE1 line number */
961 for (i = 0; i < pMailboxList->count ; i++) {
962 MSG_DEBUG("Mailbox list[%d] type=[%d] address = [%s]", i, pMailboxList->list[i].mb_type, pMailboxList->list[i].num);
963 if (pMailboxList->list[i].mb_type == TAPI_SIM_MAILBOX_VOICE) {
964 char mailNumber[MAX_PHONE_NUMBER_LEN+1];
965 memset(mailNumber, 0x00 , sizeof(mailNumber));
966 if (simMailboxList.list[i].ton == MSG_TON_INTERNATIONAL && simMailboxList.list[i].num[0] != '+') {
967 snprintf(mailNumber, MAX_PHONE_NUMBER_LEN, "+%s", simMailboxList.list[i].num);
968 MSG_DEBUG("MSG_TON_INTERNATIONAL [%s]", mailNumber);
970 snprintf(mailNumber, MAX_PHONE_NUMBER_LEN, "%s", simMailboxList.list[i].num);
971 MSG_DEBUG("[%s]", mailNumber);
974 if (mailNumber[0] != '\0') {
975 if (MsgSettingSetString(VOICEMAIL_NUMBER, mailNumber) != MSG_SUCCESS)
976 MSG_DEBUG("MsgSettingSetString is failed!!");
989 bool SmsPluginSetting::getMailboxInfoEvent(MSG_VOICEMAIL_OPT_S *pVoiceOpt)
996 ret = cv.timedwait(mx.pMutex(), 10);
1000 if (ret == ETIMEDOUT) {
1001 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
1005 memset(pVoiceOpt, 0x00, sizeof(MSG_VOICEMAIL_OPT_S));
1007 if (bTapiResult == true) {
1008 for(int i = 0; i < simMailboxList.count; i++) {
1009 if (simMailboxList.list[i].mb_type == MSG_SIM_MAILBOX_VOICE) {
1010 if (simMailboxList.list[i].ton == MSG_TON_INTERNATIONAL && simMailboxList.list[i].num[0] != '+') {
1011 snprintf(pVoiceOpt->mailNumber, sizeof(pVoiceOpt->mailNumber), "+%s", simMailboxList.list[i].num);
1013 snprintf(pVoiceOpt->mailNumber, sizeof(pVoiceOpt->mailNumber), "%s", simMailboxList.list[i].num);
1024 void SmsPluginSetting::setMwiInfoEvent(SMS_SIM_MWI_INFO_S *pMwiInfo, bool bSuccess)
1028 bTapiResult = bSuccess;
1030 memset(&simMwiInfo, 0x00, sizeof(SMS_SIM_MWI_INFO_S));
1032 if (bTapiResult == true) {
1036 memcpy(&simMwiInfo, pMwiInfo, sizeof(SMS_SIM_MWI_INFO_S));
1038 /* Save MW count with VOICE line number */
1039 for(int i = 0; i < simMailboxList.count; i++) {
1041 if (simMailboxList.list[i].mb_type == MSG_SIM_MAILBOX_VOICE) {
1043 index = simMailboxList.list[i].profile_num - 1;
1045 MSG_DEBUG("SIM profile number is invalid.");
1049 MSG_DEBUG("SIM MWI profile number=[%d], index=[%d]", simMailboxList.list[i].profile_num, index);
1051 if (simMwiInfo.b_cphs == false) { // Normal case
1052 mwi_cnt = simMwiInfo.mwi_list.mw_info[index].voice_count;
1053 } else { // CPHS case
1054 /* For CPHS case, mwi_cnt value is boolean */
1055 mwi_cnt = simMwiInfo.cphs_mwi.b_voice1;
1058 if (MsgSettingSetInt(VOICEMAIL_COUNT, mwi_cnt) != MSG_SUCCESS)
1059 MSG_DEBUG("MsgSettingSetInt is failed!!");
1062 MSG_MESSAGE_INFO_S msgInfo = {0,};
1064 msgInfo.displayTime = time(NULL);
1065 snprintf(msgInfo.addressList[0].addressVal, sizeof(msgInfo.addressList[0].addressVal), \
1066 "%s", simMailboxList.list[i].num);
1067 memset(msgInfo.addressList[0].displayName, 0x00, sizeof(msgInfo.addressList[0].displayName));
1068 msgInfo.msgType.mainType = MSG_SMS_TYPE;
1069 msgInfo.msgType.subType = MSG_MWI_VOICE_SMS;
1071 snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new voice message", mwi_cnt);
1073 MsgSoundPlayStart(false);
1074 MsgInsertNoti(&msgInfo);
1086 void SmsPluginSetting::setResultFromSim(bool bResult)
1090 bTapiResult = bResult;
1098 bool SmsPluginSetting::getResultFromSim()
1104 ret = cv.timedwait(mx.pMutex(), 10);
1108 if (ret == ETIMEDOUT) {
1109 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
1117 SMS_PID_T SmsPluginSetting::convertPid(MSG_SMS_PID_T pid)
1124 retPid = SMS_PID_NORMAL;
1126 case MSG_PID_VOICE :
1127 retPid = SMS_PID_VOICE;
1130 retPid = SMS_PID_TELEX;
1133 retPid = SMS_PID_x400;
1135 case MSG_PID_ERMES :
1136 retPid = SMS_PID_ERMES;
1138 case MSG_PID_EMAIL :
1139 retPid = SMS_PID_EMAIL;
1142 retPid = SMS_PID_NORMAL;