2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "MsgException.h"
21 #include "MsgGconfWrapper.h"
22 #include "MsgNotificationWrapper.h"
23 #include "MsgSoundPlayer.h"
25 #include "SmsPluginParamCodec.h"
26 #include "SmsPluginCallback.h"
27 #include "SmsPluginSetting.h"
32 #include <tapi_common.h>
34 #include <TapiUtility.h>
35 #include <ITapiNetText.h>
39 extern struct tapi_handle *pTapiHandle;
41 /*==================================================================================================
42 IMPLEMENTATION OF SmsPluginSetting - Member Functions
43 ==================================================================================================*/
44 SmsPluginSetting* SmsPluginSetting::pInstance = NULL;
47 SmsPluginSetting::SmsPluginSetting()
49 // Initialize member variables
50 memset(&smscData, 0x00, sizeof(MSG_SMSC_DATA_S));
51 memset(&cbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
52 memset(&simMailboxList, 0x00, sizeof(SMS_SIM_MAILBOX_LIST_S));
60 SmsPluginSetting::~SmsPluginSetting()
67 SmsPluginSetting* SmsPluginSetting::instance()
70 pInstance = new SmsPluginSetting();
76 void SmsPluginSetting::initConfigData(MSG_SIM_STATUS_T SimStatus)
80 msg_error_t err = MSG_SUCCESS;
86 paramCnt = getParamCount();
88 MSG_DEBUG("Parameter Count [%d]", paramCnt);
90 MSG_SMSC_DATA_S tmpSmscData = {};
91 MSG_SMSC_LIST_S tmpSmscList = {};
93 for (int index = 0; index < paramCnt; index++)
95 if (getParam(index, &tmpSmscData) == false) {
100 memcpy(&(tmpSmscList.smscData[index]), &tmpSmscData, sizeof(MSG_SMSC_DATA_S));
102 MSG_DEBUG("pid[%d]", tmpSmscList.smscData[index].pid);
103 MSG_DEBUG("val_period[%d]", tmpSmscList.smscData[index].valPeriod);
104 MSG_DEBUG("name[%s]", tmpSmscList.smscData[index].name);
106 MSG_DEBUG("ton[%d]", tmpSmscList.smscData[index].smscAddr.ton);
107 MSG_DEBUG("npi[%d]", tmpSmscList.smscData[index].smscAddr.npi);
108 MSG_DEBUG("address[%s]", tmpSmscList.smscData[index].smscAddr.address);
111 tmpSmscList.totalCnt = (paramCnt - failCnt);
112 // below is commented to be the first smsc is selected.
113 // tmpSmscList.selected = selectedParam;
116 err = addSMSCList(&tmpSmscList);
118 if (err == MSG_SUCCESS) {
119 MSG_DEBUG("######## Add SMSC List Success !!! #######");
121 MSG_DEBUG("######## Add SMSC List Fail !!! return : %d #######", err);
126 if (SimStatus == MSG_SIM_STATUS_CHANGED) {
127 MSG_DEBUG("simStatus == MSG_SIM_STATUS_CHANGED");
129 MSG_CBMSG_OPT_S cbMsgOpt = {};
131 if (getCbConfig(&cbMsgOpt) == true) {
132 err = addCbOpt(&cbMsgOpt);
134 if (err == MSG_SUCCESS) {
135 MSG_DEBUG("######## Add CB Option Success !!! #######");
137 MSG_DEBUG("######## Add CB Option Fail !!! return : %d #######", err);
140 } else if (SimStatus == MSG_SIM_STATUS_NORMAL) {
141 MSG_DEBUG("simStatus == MSG_SIM_STATUS_NORMAL");
143 // Set CB Data into SIM in case of same SIM
144 MSG_SETTING_S cbSetting;
145 cbSetting.type = MSG_CBMSG_OPT;
147 getCbOpt(&cbSetting);
149 setCbConfig(&(cbSetting.option.cbMsgOpt));
152 if (SimStatus != MSG_SIM_STATUS_NOT_FOUND)
154 MSG_VOICEMAIL_OPT_S tmpVoiceMail;
155 memset(&tmpVoiceMail, 0x00, sizeof(MSG_VOICEMAIL_OPT_S));
157 if (getVoiceMailInfo(&tmpVoiceMail) == true) {
158 MSG_DEBUG("######## getVoiceMailInfo Success !!! #######");
160 MSG_DEBUG("######## getVoiceMailInfo Fail !!! #######");
163 if (getMwiInfo() == true) {
164 MSG_DEBUG("######## getMwiInfo Success !!! #######");
166 MSG_DEBUG("######## getMwiInfo Fail !!! #######");
169 if (getMsisdnInfo() == true) {
170 MSG_DEBUG("######## getMsisdnInfo Success !!! #######");
172 MSG_DEBUG("######## getMsisdnInfo Fail !!! #######");
180 void SmsPluginSetting::setConfigData(const MSG_SETTING_S *pSetting)
182 MSG_DEBUG("Setting Type : [%d]", pSetting->type);
184 switch (pSetting->type)
187 case MSG_SMS_SENDOPT :
188 setNetworkMode(&pSetting->option.smsSendOpt);
192 setParamList(&pSetting->option.smscList);
195 setCbConfig(&pSetting->option.cbMsgOpt);
197 case MSG_VOICEMAIL_OPT:
198 setVoiceMailInfo(&pSetting->option.voiceMailOpt);
201 THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
207 void SmsPluginSetting::getConfigData(MSG_SETTING_S *pSetting)
209 MSG_DEBUG("Setting Type : [%d]", pSetting->type);
211 switch (pSetting->type)
214 getParamList(&pSetting->option.smscList);
218 getCbConfig(&pSetting->option.cbMsgOpt);
222 THROW(MsgException::SMS_PLG_ERROR, "The Setting type is not supported. [%d]", pSetting->type);
228 msg_error_t SmsPluginSetting::addSMSCList(MSG_SMSC_LIST_S *pSmscList)
230 msg_error_t err = MSG_SUCCESS;
232 MSG_DEBUG("total_count[%d]", pSmscList->totalCnt);
233 MSG_DEBUG("selected index[%d]", pSmscList->selected);
235 for (int i = 0; i < pSmscList->totalCnt; i++)
237 MSG_DEBUG("pid[%d]", pSmscList->smscData[i].pid);
238 MSG_DEBUG("val_period[%d]", pSmscList->smscData[i].valPeriod);
239 MSG_DEBUG("name[%s]", pSmscList->smscData[i].name);
241 MSG_DEBUG("ton[%d]", pSmscList->smscData[i].smscAddr.ton);
242 MSG_DEBUG("npi[%d]", pSmscList->smscData[i].smscAddr.npi);
243 MSG_DEBUG("address[%s]", pSmscList->smscData[i].smscAddr.address);
248 if (MsgSettingSetInt(SMSC_TOTAL_COUNT, pSmscList->totalCnt) != MSG_SUCCESS) {
249 MSG_DEBUG("Error to set config data [%s]", SMSC_TOTAL_COUNT);
250 return MSG_ERR_SET_SETTING;
253 if (MsgSettingSetInt(SMSC_SELECTED, pSmscList->selected) != MSG_SUCCESS) {
254 MSG_DEBUG("Error to set config data [%s]", SMSC_SELECTED);
255 return MSG_ERR_SET_SETTING;
258 for (int i = 0; i < pSmscList->totalCnt; i++) {
259 memset(keyName, 0x00, sizeof(keyName));
260 sprintf(keyName, "%s/%d", SMSC_PID, i);
262 if ((err = MsgSettingSetInt(keyName, (int)pSmscList->smscData[i].pid)) != MSG_SUCCESS)
265 memset(keyName, 0x00, sizeof(keyName));
266 sprintf(keyName, "%s/%d", SMSC_VAL_PERIOD, i);
268 if ((err = MsgSettingSetInt(keyName, (int)pSmscList->smscData[i].valPeriod)) != MSG_SUCCESS)
271 memset(keyName, 0x00, sizeof(keyName));
272 sprintf(keyName, "%s/%d", SMSC_NAME, i);
274 if ((err = MsgSettingSetString(keyName, pSmscList->smscData[i].name)) != MSG_SUCCESS)
277 memset(keyName, 0x00, sizeof(keyName));
278 sprintf(keyName, "%s/%d", SMSC_TON, i);
280 if (pSmscList->smscData[i].smscAddr.address[0] == '+')
281 pSmscList->smscData[i].smscAddr.ton = MSG_TON_INTERNATIONAL;
283 pSmscList->smscData[i].smscAddr.ton = MSG_TON_NATIONAL;
285 if ((err = MsgSettingSetInt(keyName, (int)pSmscList->smscData[i].smscAddr.ton)) != MSG_SUCCESS)
288 memset(keyName, 0x00, sizeof(keyName));
289 sprintf(keyName, "%s/%d", SMSC_NPI, i);
291 pSmscList->smscData[i].smscAddr.npi = MSG_NPI_ISDN; // app cannot set this value
293 if ((err = MsgSettingSetInt(keyName, (int)pSmscList->smscData[i].smscAddr.npi)) != MSG_SUCCESS)
296 memset(keyName, 0x00, sizeof(keyName));
297 sprintf(keyName, "%s/%d", SMSC_ADDRESS, i);
299 if ((err = MsgSettingSetString(keyName, pSmscList->smscData[i].smscAddr.address)) != MSG_SUCCESS)
303 if (err != MSG_SUCCESS) {
304 MSG_DEBUG("Error to set config data [%s]", keyName);
311 msg_error_t SmsPluginSetting::addCbOpt(MSG_CBMSG_OPT_S *pCbOpt)
313 msg_error_t err = MSG_SUCCESS;
315 MSG_DEBUG("Receive [%d], Max SIM Count [%d]", pCbOpt->bReceive, pCbOpt->maxSimCnt);
317 MSG_DEBUG("Channel Count [%d]", pCbOpt->channelData.channelCnt);
319 for (int i = 0; i < pCbOpt->channelData.channelCnt; i++)
321 MSG_DEBUG("Channel FROM [%d], Channel TO [%d]", pCbOpt->channelData.channelInfo[i].from, pCbOpt->channelData.channelInfo[i].to);
324 // Set Setting Data into Vconf
325 if (MsgSettingSetBool(CB_RECEIVE, pCbOpt->bReceive) != MSG_SUCCESS) {
326 MSG_DEBUG("Error to set config data [%s]", CB_RECEIVE);
327 return MSG_ERR_SET_SETTING;
330 if (MsgSettingSetInt(CB_MAX_SIM_COUNT, pCbOpt->maxSimCnt) != MSG_SUCCESS) {
331 MSG_DEBUG("Error to set config data [%s]", CB_MAX_SIM_COUNT);
332 return MSG_ERR_SET_SETTING;
335 if (MsgSettingSetInt(CB_CHANNEL_COUNT, pCbOpt->channelData.channelCnt) != MSG_SUCCESS) {
336 MSG_DEBUG("Error to set config data [%s]", CB_CHANNEL_COUNT);
337 return MSG_ERR_SET_SETTING;
342 for (int i = 0; i < pCbOpt->channelData.channelCnt; i++) {
343 memset(keyName, 0x00, sizeof(keyName));
344 sprintf(keyName, "%s/%d", CB_CHANNEL_ACTIVATE, i);
346 if ((err = MsgSettingSetBool(keyName, pCbOpt->channelData.channelInfo[i].bActivate)) != MSG_SUCCESS)
349 memset(keyName, 0x00, sizeof(keyName));
350 sprintf(keyName, "%s/%d", CB_CHANNEL_ID_FROM, i);
352 if ((err = MsgSettingSetInt(keyName, pCbOpt->channelData.channelInfo[i].from)) != MSG_SUCCESS)
355 memset(keyName, 0x00, sizeof(keyName));
356 sprintf(keyName, "%s/%d", CB_CHANNEL_ID_TO, i);
358 if ((err = MsgSettingSetInt(keyName, pCbOpt->channelData.channelInfo[i].to)) != MSG_SUCCESS)
361 memset(keyName, 0x00, sizeof(keyName));
362 sprintf(keyName, "%s/%d", CB_CHANNEL_NAME, i);
364 if ((err = MsgSettingSetString(keyName, pCbOpt->channelData.channelInfo[i].name)) != MSG_SUCCESS)
372 void SmsPluginSetting::getCbOpt(MSG_SETTING_S *pSetting)
375 char *tmpValue = NULL;
377 memset(&(pSetting->option.cbMsgOpt), 0x00, sizeof(MSG_CBMSG_OPT_S));
379 MsgSettingGetBool(CB_RECEIVE, &pSetting->option.cbMsgOpt.bReceive);
381 pSetting->option.cbMsgOpt.maxSimCnt = MsgSettingGetInt(CB_MAX_SIM_COUNT);
383 pSetting->option.cbMsgOpt.channelData.channelCnt = MsgSettingGetInt(CB_CHANNEL_COUNT);
385 for (int i = 0; i < pSetting->option.cbMsgOpt.channelData.channelCnt; i++) {
386 memset(keyName, 0x00, sizeof(keyName));
387 sprintf(keyName, "%s/%d", CB_CHANNEL_ACTIVATE, i);
389 MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.channelData.channelInfo[i].bActivate);
391 memset(keyName, 0x00, sizeof(keyName));
392 sprintf(keyName, "%s/%d", CB_CHANNEL_ID_FROM, i);
394 pSetting->option.cbMsgOpt.channelData.channelInfo[i].from = MsgSettingGetInt(keyName);
396 memset(keyName, 0x00, sizeof(keyName));
397 sprintf(keyName, "%s/%d", CB_CHANNEL_ID_TO, i);
399 pSetting->option.cbMsgOpt.channelData.channelInfo[i].to = MsgSettingGetInt(keyName);
401 memset(keyName, 0x00, sizeof(keyName));
402 sprintf(keyName, "%s/%d", CB_CHANNEL_NAME, i);
404 tmpValue = MsgSettingGetString(keyName);
406 if (tmpValue != NULL)
408 strncpy(pSetting->option.cbMsgOpt.channelData.channelInfo[i].name, tmpValue, CB_CHANNEL_NAME_MAX);
414 for (int i = MSG_CBLANG_TYPE_ALL; i < MSG_CBLANG_TYPE_MAX; i++) {
415 memset(keyName, 0x00, sizeof(keyName));
416 sprintf(keyName, "%s/%d", CB_LANGUAGE, i);
418 MsgSettingGetBool(keyName, &pSetting->option.cbMsgOpt.bLanguage[i]);
424 void SmsPluginSetting::setParamList(const MSG_SMSC_LIST_S *pSMSCList)
428 TelSmsParams_t smsParam = {0};
430 int ret = TAPI_API_SUCCESS;
432 for (int index = 0; index < pSMSCList->totalCnt; index++) {
433 /*Setting the SMSP Record index value*/
434 smsParam.RecordIndex = (unsigned char)index;
436 /*Setting the SMSP Record Length value = 28 + alphaId_len*/
437 smsParam.RecordLen = 28 + strlen(pSMSCList->smscData[index].name);
439 /*Setting the SMSP Alpha ID value*/
440 smsParam.AlphaIdLen = strlen(pSMSCList->smscData[index].name);
441 MSG_DEBUG("AlphaIdLen = %ld", smsParam.AlphaIdLen);
443 if (smsParam.AlphaIdLen > 0 && smsParam.AlphaIdLen <= SMSC_NAME_MAX) {
444 memcpy(smsParam.szAlphaId, pSMSCList->smscData[index].name, smsParam.AlphaIdLen);
445 smsParam.szAlphaId[smsParam.AlphaIdLen] = '\0';
446 MSG_DEBUG("szAlphaId = %s", smsParam.szAlphaId);
449 smsParam.ParamIndicator = 0x00;
451 if (strlen(pSMSCList->smscData[index].smscAddr.address) > 0) {
452 smsParam.ParamIndicator |= 0x02 ; //enable 2nd Bit
453 MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
455 if (pSMSCList->smscData[index].smscAddr.address[0] == '+')
456 smsParam.TpSvcCntrAddr.Ton = TAPI_SIM_TON_INTERNATIONAL;
458 smsParam.TpSvcCntrAddr.Ton = TAPI_SIM_TON_NATIONAL;
460 smsParam.TpSvcCntrAddr.Npi = TAPI_SIM_NPI_ISDN_TEL; // app cannot set this value
462 MSG_DEBUG("SMSC TON = [%d] NPI = [%d]", smsParam.TpSvcCntrAddr.Ton, smsParam.TpSvcCntrAddr.Npi);
464 MSG_DEBUG("address = %s", pSMSCList->smscData[index].smscAddr.address);
466 smsParam.TpSvcCntrAddr.DialNumLen = SmsPluginParamCodec::encodeSMSC(pSMSCList->smscData[index].smscAddr.address, smsParam.TpSvcCntrAddr.szDiallingNum);
468 MSG_DEBUG("SMSC Addr is not present");
471 /*Setting the PID value*/
472 smsParam.ParamIndicator |= 0x04 ; //enable 3nd Bit
473 MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
475 smsParam.TpProtocolId = (unsigned short)convertPid(pSMSCList->smscData[index].pid);
477 /*Setting the ValidityPeriod value*/
478 smsParam.ParamIndicator |= 0x10 ; //enable 5nd Bit
479 MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
481 smsParam.TpValidityPeriod = (unsigned short)pSMSCList->smscData[index].valPeriod;
483 smsParam.ParamIndicator = ~(smsParam.ParamIndicator);
484 MSG_DEBUG("ParamIndicator = [%02x]", smsParam.ParamIndicator);
486 ret = tel_set_sms_parameters(pTapiHandle, (const TelSmsParams_t*)&smsParam, TapiEventSetConfigData, NULL);
488 if (ret != TAPI_API_SUCCESS)
489 THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_parameters() Error. [%d]", ret);
491 if (!getResultFromSim())
492 THROW(MsgException::SMS_PLG_ERROR, "tel_set_sms_parameters() Result Error.");
499 void SmsPluginSetting::getParamList(MSG_SMSC_LIST_S *pSMSCList)
505 paramCnt = getParamCount();
507 MSG_DEBUG("Parameter Count [%d]", paramCnt);
509 int ret = TAPI_API_SUCCESS;
511 MSG_SMSC_DATA_S tmpSmscData = {};
513 for (int index = 0; index < paramCnt; index++) {
514 ret = tel_get_sms_parameters(pTapiHandle, index, TapiEventGetParam, NULL);
516 if (ret == TAPI_API_SUCCESS) {
517 MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
519 THROW(MsgException::SMS_PLG_ERROR, "######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
522 if (getParamEvent(&tmpSmscData) == true) {
523 MSG_DEBUG("######## Get Parameter was Successful !!! #######");
525 THROW(MsgException::SMS_PLG_ERROR, "######## Get Parameter was Failed !!! #######");
528 memcpy(&(pSMSCList->smscData[index]), &tmpSmscData, sizeof(MSG_SMSC_DATA_S));
530 MSG_DEBUG("pid[%d]", pSMSCList->smscData[index].pid);
531 MSG_DEBUG("val_period[%d]", pSMSCList->smscData[index].valPeriod);
532 MSG_DEBUG("name[%s]", pSMSCList->smscData[index].name);
534 MSG_DEBUG("ton[%d]", pSMSCList->smscData[index].smscAddr.ton);
535 MSG_DEBUG("npi[%d]", pSMSCList->smscData[index].smscAddr.npi);
536 MSG_DEBUG("address[%s]", pSMSCList->smscData[index].smscAddr.address);
539 pSMSCList->totalCnt = paramCnt;
540 pSMSCList->selected = selectedParam;
542 MSG_DEBUG("total_count[%d]", pSMSCList->totalCnt);
548 int SmsPluginSetting::getParamCount()
550 int ret = TAPI_API_SUCCESS;
552 ret = tel_get_sms_parameter_count(pTapiHandle, TapiEventGetParamCnt, NULL);
554 if (ret == TAPI_API_SUCCESS) {
555 MSG_DEBUG("######## tel_get_sms_parameter_count() Success !!! #######");
557 THROW(MsgException::SMS_PLG_ERROR, "tel_get_sms_parameter_count() Error. [%d]", ret);
560 return getParamCntEvent();
564 bool SmsPluginSetting::getParam(int Index, MSG_SMSC_DATA_S *pSmscData)
566 int ret = TAPI_API_SUCCESS;
568 ret = tel_get_sms_parameters(pTapiHandle, Index, TapiEventGetParam, NULL);
570 if (ret == TAPI_API_SUCCESS) {
571 MSG_DEBUG("######## tel_get_sms_parameters() Success !!! #######");
573 MSG_DEBUG("######## tel_get_sms_parameters() Fail !!! return : %d #######", ret);
577 if (getParamEvent(pSmscData) == true) {
578 MSG_DEBUG("######## Get Parameter was Successful !!! #######");
580 MSG_DEBUG("######## Get Parameter was Failed !!! #######");
588 bool SmsPluginSetting::setCbConfig(const MSG_CBMSG_OPT_S *pCbOpt)
590 int ret = TAPI_API_SUCCESS;
592 TelSmsCbConfig_t cbConfig = {};
594 cbConfig.CBEnabled = (int)pCbOpt->bReceive;
595 cbConfig.Net3gppType = TAPI_NETTEXT_NETTYPE_3GPP;
596 cbConfig.MsgIdMaxCount = pCbOpt->maxSimCnt;
597 cbConfig.MsgIdRangeCount = pCbOpt->channelData.channelCnt;
599 for (int i = 0; i < cbConfig.MsgIdRangeCount; i++) {
600 cbConfig.MsgIDs[i].Net3gpp.Selected = (unsigned short)pCbOpt->channelData.channelInfo[i].bActivate;
601 cbConfig.MsgIDs[i].Net3gpp.FromMsgId = (unsigned short)pCbOpt->channelData.channelInfo[i].from;
602 cbConfig.MsgIDs[i].Net3gpp.ToMsgId = (unsigned short)pCbOpt->channelData.channelInfo[i].to;
604 MSG_DEBUG("FROM: %d, TO: %d", cbConfig.MsgIDs[i].Net3gpp.FromMsgId, cbConfig.MsgIDs[i].Net3gpp.ToMsgId);
606 MSG_DEBUG("CBEnabled: %d, range_count: %d", cbConfig.CBEnabled, cbConfig.MsgIdRangeCount);
608 ret = tel_set_sms_cb_config(pTapiHandle, &cbConfig, TapiEventSetConfigData, NULL);
610 if (ret == TAPI_API_SUCCESS) {
611 MSG_DEBUG("######## tel_set_sms_cb_config() Success !!! #######");
613 MSG_DEBUG("######## tel_set_sms_cb_config() Fail !!! return : %d #######", ret);
617 if (getResultFromSim() == true) {
618 MSG_DEBUG("######## Set Cb Config was Successful !!! #######");
620 MSG_DEBUG("######## Set Cb Config was Failed !!! #######");
628 bool SmsPluginSetting::getCbConfig(MSG_CBMSG_OPT_S *pCbOpt)
630 int ret = TAPI_API_SUCCESS;
632 ret = tel_get_sms_cb_config(pTapiHandle, TapiEventGetCBConfig, NULL);
634 if (ret == TAPI_API_SUCCESS) {
635 MSG_DEBUG("######## tel_get_sms_cb_config() Success !!! #######");
637 MSG_DEBUG("######## tel_get_sms_cb_config() Fail !!! return : %d #######", ret);
641 if (getCbConfigEvent(pCbOpt) == true) {
642 MSG_DEBUG("######## Get Cb Config was Successful !!! #######");
644 MSG_DEBUG("######## Get Cb Config was Failed !!! #######");
651 void SmsPluginSetting::setVoiceMailInfo(const MSG_VOICEMAIL_OPT_S *pVoiceOpt)
653 int ret = TAPI_API_SUCCESS;
655 TelSimMailBoxNumber_t mailboxInfo = {0,};
657 for (int i = 0; i < simMailboxList.count; i++) {
658 if (simMailboxList.list[i].mb_type == TAPI_SIM_MAILBOX_VOICE) {
659 memset(&simMailboxList.list[i].num, 0x00, sizeof(simMailboxList.list[i].num));
660 snprintf(simMailboxList.list[i].num, sizeof(simMailboxList.list[i].num), "%s", pVoiceOpt->mailNumber);
661 MSG_DEBUG("Mailbox number config [%s]", simMailboxList.list[i].num);
663 mailboxInfo.b_cphs = simMailboxList.list[i].b_cphs;
664 mailboxInfo.alpha_id_max_len = simMailboxList.list[i].alpha_id_max_len;
665 mailboxInfo.mb_type = (TelSimMailboxType_t)simMailboxList.list[i].mb_type;
666 mailboxInfo.profile_num = simMailboxList.list[i].profile_num;
667 mailboxInfo.rec_index = simMailboxList.list[i].rec_index;
668 mailboxInfo.ton = (TelSimTypeOfNum_t)simMailboxList.list[i].ton;
669 mailboxInfo.npi = (TelSimNumberingPlanIdentity_t)simMailboxList.list[i].npi;
670 snprintf(mailboxInfo.alpha_id, sizeof(mailboxInfo.alpha_id), "%s", simMailboxList.list[i].alpha_id);
671 snprintf(mailboxInfo.num, sizeof(mailboxInfo.num), "%s", simMailboxList.list[i].num);
672 mailboxInfo.cc_id = simMailboxList.list[i].cc_id;
673 mailboxInfo.ext1_id = simMailboxList.list[i].ext1_id;
679 ret = tel_set_sim_mailbox_info(pTapiHandle, &mailboxInfo, TapiEventSetMailboxInfo, NULL);
681 if (ret == TAPI_API_SUCCESS) {
682 MSG_DEBUG("######## tel_set_sim_mailbox_info() Success !!! #######");
684 MSG_DEBUG("######## tel_set_sim_mailbox_info() Fail !!! return : %d #######", ret);
687 if (getResultFromSim() == true) {
688 MSG_DEBUG("######## Set mailbox info Success !!! #######");
690 THROW(MsgException::SMS_PLG_ERROR, "######## Set mailbox info Failed !!!#######");
696 bool SmsPluginSetting::getVoiceMailInfo(MSG_VOICEMAIL_OPT_S *pVoiceOpt)
698 int ret = TAPI_API_SUCCESS;
700 ret = tel_get_sim_mailbox_info(pTapiHandle, TapiEventGetMailboxInfo, NULL);
702 if (ret == TAPI_API_SUCCESS) {
703 MSG_DEBUG("######## tel_get_sim_mailbox_info() Success !!! #######");
705 MSG_DEBUG("######## tel_get_sim_mailbox_info() Fail !!! return : %d #######", ret);
709 if (getMailboxInfoEvent(pVoiceOpt) == true) {
710 MSG_DEBUG("######## Get MWI info was Successful !!! #######");
712 MSG_DEBUG("######## Get MWI info was Failed !!! #######");
719 void SmsPluginSetting::setMwiInfo(MSG_SUB_TYPE_T type, int count)
721 if (type < MSG_MWI_VOICE_SMS || type > MSG_MWI_OTHER_SMS) {
722 MSG_DEBUG("Invalid parameter");
726 int ret = TAPI_API_SUCCESS;
728 TelSimMessageWaitingReq_t mwReq = {0,};
730 if (simMwiInfo.b_cphs) {
731 if (type == MSG_MWI_VOICE_SMS)
732 simMwiInfo.cphs_mwi.b_voice1 = true;
733 else if (type == MSG_MWI_FAX_SMS)
734 simMwiInfo.cphs_mwi.b_fax = true;
736 MSG_DEBUG("There is no type [%d] in CPHS.", type);
738 mwReq.mw_data_u.cphs_mw.b_voice1 = simMwiInfo.cphs_mwi.b_voice1;
739 mwReq.mw_data_u.cphs_mw.b_voice2 = simMwiInfo.cphs_mwi.b_voice2;
740 mwReq.mw_data_u.cphs_mw.b_fax = simMwiInfo.cphs_mwi.b_fax;
741 mwReq.mw_data_u.cphs_mw.b_data = simMwiInfo.cphs_mwi.b_data;
743 if (type == MSG_MWI_VOICE_SMS)
744 simMwiInfo.mwi_list.mw_info[0].voice_count = count;
745 else if (type == MSG_MWI_FAX_SMS)
746 simMwiInfo.mwi_list.mw_info[0].fax_count = count;
747 else if (type == MSG_MWI_EMAIL_SMS)
748 simMwiInfo.mwi_list.mw_info[0].email_count = count;
749 else // MSG_MWI_OTHER_SMS
750 simMwiInfo.mwi_list.mw_info[0].other_count = count;
752 mwReq.mw_data_u.mw.rec_index = simMwiInfo.mwi_list.mw_info[0].rec_index;
753 mwReq.mw_data_u.mw.indicator_status = simMwiInfo.mwi_list.mw_info[0].indicator_status;
754 mwReq.mw_data_u.mw.voice_count = simMwiInfo.mwi_list.mw_info[0].voice_count;
755 mwReq.mw_data_u.mw.fax_count = simMwiInfo.mwi_list.mw_info[0].fax_count;
756 mwReq.mw_data_u.mw.email_count = simMwiInfo.mwi_list.mw_info[0].email_count;
757 mwReq.mw_data_u.mw.other_count = simMwiInfo.mwi_list.mw_info[0].other_count;
758 mwReq.mw_data_u.mw.video_count = simMwiInfo.mwi_list.mw_info[0].video_count;
761 mwReq.b_cphs = simMwiInfo.b_cphs;
763 ret = tel_set_sim_messagewaiting_info(pTapiHandle, &mwReq, TapiEventSetMwiInfo, NULL);
765 if (ret == TAPI_API_SUCCESS) {
766 MSG_DEBUG("######## tel_set_sim_messagewaiting_info() Success !!! #######");
768 MSG_DEBUG("######## tel_set_sim_messagewaiting_info() Fail !!! return : %d #######", ret);
771 if (getResultFromSim() == true) {
772 MSG_DEBUG("######## Set message waiting info Success !!! #######");
774 MSG_DEBUG("######## Set message waiting info fail !!! #######");
781 bool SmsPluginSetting::getMwiInfo(void)
783 int ret = TAPI_API_SUCCESS;
785 ret = tel_get_sim_messagewaiting_info(pTapiHandle, TapiEventGetMwiInfo, NULL);
787 if (ret == TAPI_API_SUCCESS) {
788 MSG_DEBUG("######## tel_get_sim_messagewaiting_info() Success !!! #######");
790 MSG_DEBUG("######## tel_get_sim_messagewaiting_info() Fail !!! return : %d #######", ret);
794 if (getResultFromSim() == true) {
795 MSG_DEBUG("######## Get Mainbox info was Successful !!! #######");
797 MSG_DEBUG("######## Get Mainbox info was Failed !!! #######");
805 bool SmsPluginSetting::getMsisdnInfo(void)
807 int ret = TAPI_API_SUCCESS;
810 ret = tel_get_sim_msisdn(pTapiHandle, TapiEventGetMsisdnInfo, NULL);
812 if (ret == TAPI_API_SUCCESS) {
814 MSG_DEBUG("######## tel_get_sim_msisdn() Success !!! #######");
817 MSG_DEBUG("######## tel_get_sim_msisdn() Fail !!! return : %d #######", ret);
824 void SmsPluginSetting::setParamCntEvent(int ParamCnt)
836 int SmsPluginSetting::getParamCntEvent()
842 ret = cv.timedwait(mx.pMutex(), 10);
846 if (ret == ETIMEDOUT) {
847 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
855 void SmsPluginSetting::setParamEvent(const MSG_SMSC_DATA_S *pSmscData, int RecordIdx, bool bSuccess)
859 bTapiResult = bSuccess;
861 memset(&smscData, 0x00, sizeof(MSG_SMSC_DATA_S));
863 if (bTapiResult == true) {
864 MSG_DEBUG("Success to get parameter data");
866 selectedParam = RecordIdx;
868 memcpy(&smscData, pSmscData, sizeof(MSG_SMSC_DATA_S));
877 bool SmsPluginSetting::getParamEvent(MSG_SMSC_DATA_S *pSmscData)
885 ret = cv.timedwait(mx.pMutex(), 10);
889 if (ret == ETIMEDOUT) {
890 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
894 memset(pSmscData, 0x00, sizeof(MSG_SMSC_DATA_S));
896 if (bTapiResult == true) {
897 memcpy(pSmscData, &smscData, sizeof(MSG_SMSC_DATA_S));
904 void SmsPluginSetting::setCbConfigEvent(const MSG_CBMSG_OPT_S *pCbOpt, bool bSuccess)
908 bTapiResult = bSuccess;
910 memset(&cbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
912 if (bTapiResult == true) {
913 MSG_DEBUG("Success to get cb config data");
915 memcpy(&cbOpt, pCbOpt, sizeof(MSG_CBMSG_OPT_S));
924 bool SmsPluginSetting::getCbConfigEvent(MSG_CBMSG_OPT_S *pCbOpt)
932 ret = cv.timedwait(mx.pMutex(), 10);
936 if (ret == ETIMEDOUT) {
937 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
941 memset(pCbOpt, 0x00, sizeof(MSG_CBMSG_OPT_S));
943 if (bTapiResult == true) {
944 memcpy(pCbOpt, &cbOpt, sizeof(MSG_CBMSG_OPT_S));
951 void SmsPluginSetting::setMailboxInfoEvent(SMS_SIM_MAILBOX_LIST_S *pMailboxList, bool bSuccess)
955 bTapiResult = bSuccess;
957 memset(&simMailboxList, 0x00, sizeof(SMS_SIM_MAILBOX_LIST_S));
959 if (bTapiResult == true) {
962 if (pMailboxList && pMailboxList->count > 0) {
963 memcpy(&simMailboxList, pMailboxList, sizeof(SMS_SIM_MAILBOX_LIST_S));
965 /* Temp :: Save voicemail number with VOICE1 line number */
966 for (i = 0; i < pMailboxList->count ; i++) {
967 MSG_DEBUG("Mailbox list[%d] type=[%d] address = [%s]", i, pMailboxList->list[i].mb_type, pMailboxList->list[i].num);
968 if (pMailboxList->list[i].mb_type == TAPI_SIM_MAILBOX_VOICE) {
969 char mailNumber[MAX_PHONE_NUMBER_LEN+1];
970 memset(mailNumber, 0x00 , sizeof(mailNumber));
971 if (simMailboxList.list[i].ton == MSG_TON_INTERNATIONAL && simMailboxList.list[i].num[0] != '+') {
972 snprintf(mailNumber, MAX_PHONE_NUMBER_LEN, "+%s", simMailboxList.list[i].num);
973 MSG_DEBUG("MSG_TON_INTERNATIONAL [%s]", mailNumber);
975 snprintf(mailNumber, MAX_PHONE_NUMBER_LEN, "%s", simMailboxList.list[i].num);
976 MSG_DEBUG("[%s]", mailNumber);
978 if (MsgSettingSetString(VOICEMAIL_NUMBER, mailNumber) != MSG_SUCCESS)
979 MSG_DEBUG("MsgSettingSetString is failed!!");
991 bool SmsPluginSetting::getMailboxInfoEvent(MSG_VOICEMAIL_OPT_S *pVoiceOpt)
999 ret = cv.timedwait(mx.pMutex(), 10);
1003 if (ret == ETIMEDOUT) {
1004 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
1008 memset(pVoiceOpt, 0x00, sizeof(MSG_VOICEMAIL_OPT_S));
1010 if (bTapiResult == true) {
1011 for(int i = 0; i < simMailboxList.count; i++) {
1012 if (simMailboxList.list[i].mb_type == MSG_SIM_MAILBOX_VOICE) {
1013 if (simMailboxList.list[i].ton == MSG_TON_INTERNATIONAL && simMailboxList.list[i].num[0] != '+') {
1014 snprintf(pVoiceOpt->mailNumber, sizeof(pVoiceOpt->mailNumber), "+%s", simMailboxList.list[i].num);
1016 snprintf(pVoiceOpt->mailNumber, sizeof(pVoiceOpt->mailNumber), "%s", simMailboxList.list[i].num);
1027 void SmsPluginSetting::setMwiInfoEvent(SMS_SIM_MWI_INFO_S *pMwiInfo, bool bSuccess)
1031 bTapiResult = bSuccess;
1033 memset(&simMwiInfo, 0x00, sizeof(SMS_SIM_MWI_INFO_S));
1035 if (bTapiResult == true) {
1039 memcpy(&simMwiInfo, pMwiInfo, sizeof(SMS_SIM_MWI_INFO_S));
1041 /* Save MW count with VOICE line number */
1042 for(int i = 0; i < simMailboxList.count; i++) {
1044 if (simMailboxList.list[i].mb_type == MSG_SIM_MAILBOX_VOICE) {
1046 index = simMailboxList.list[i].profile_num - 1;
1048 MSG_DEBUG("SIM profile number is invalid.");
1052 MSG_DEBUG("SIM MWI profile number=[%d], index=[%d]", simMailboxList.list[i].profile_num, index);
1054 if (simMwiInfo.b_cphs == false) { // Normal case
1055 mwi_cnt = simMwiInfo.mwi_list.mw_info[index].voice_count;
1056 } else { // CPHS case
1057 /* For CPHS case, mwi_cnt value is boolean */
1058 mwi_cnt = simMwiInfo.cphs_mwi.b_voice1;
1061 if (MsgSettingSetInt(VOICEMAIL_COUNT, mwi_cnt) != MSG_SUCCESS)
1062 MSG_DEBUG("MsgSettingSetInt is failed!!");
1065 MSG_MESSAGE_INFO_S msgInfo = {0,};
1067 msgInfo.displayTime = time(NULL);
1068 snprintf(msgInfo.addressList[0].addressVal, sizeof(msgInfo.addressList[0].addressVal), \
1069 "%s", simMailboxList.list[i].num);
1070 memset(msgInfo.addressList[0].displayName, 0x00, sizeof(msgInfo.addressList[0].displayName));
1071 msgInfo.msgType.mainType = MSG_SMS_TYPE;
1072 msgInfo.msgType.subType = MSG_MWI_VOICE_SMS;
1074 snprintf(msgInfo.msgText, sizeof(msgInfo.msgText), "%d new voice message", mwi_cnt);
1076 MsgSoundPlayStart(false);
1077 MsgInsertNoti(&msgInfo);
1089 void SmsPluginSetting::setResultFromSim(bool bResult)
1093 bTapiResult = bResult;
1101 bool SmsPluginSetting::getResultFromSim()
1107 ret = cv.timedwait(mx.pMutex(), 10);
1111 if (ret == ETIMEDOUT) {
1112 MSG_DEBUG("WARNING: TAPI callback TIME-OUT");
1120 SMS_PID_T SmsPluginSetting::convertPid(MSG_SMS_PID_T pid)
1127 retPid = SMS_PID_NORMAL;
1129 case MSG_PID_VOICE :
1130 retPid = SMS_PID_VOICE;
1133 retPid = SMS_PID_TELEX;
1136 retPid = SMS_PID_x400;
1138 case MSG_PID_ERMES :
1139 retPid = SMS_PID_ERMES;
1141 case MSG_PID_EMAIL :
1142 retPid = SMS_PID_EMAIL;
1145 retPid = SMS_PID_NORMAL;