group message feature refactoring 64/135364/2 accepted/tizen/unified/20170704.084338 submit/tizen/20170630.081347 submit/tizen/20170703.030428 submit/tizen/20170703.233424
authorKyeonghun Lee <kh9090.lee@samsung.com>
Thu, 22 Jun 2017 05:14:08 +0000 (14:14 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Fri, 23 Jun 2017 04:33:00 +0000 (04:33 +0000)
Change-Id: I7d59f08e1cc084a3792152df3f1a7e2a09f71174
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
framework/setting-handler/MsgSettingHandler.cpp
framework/storage-handler/MsgStorageMessage.cpp
framework/transaction-manager/MsgCmdHandlerTransport.cpp
include/common/MsgSettingTypes.h
mapi/msg_setting.cpp
plugin/mms_plugin/MmsPluginInternal.cpp
plugin/sms_plugin/SmsPluginCallback.cpp

index 87944f3..9c9d931 100755 (executable)
@@ -636,12 +636,12 @@ msg_error_t MsgSetMMSRecvOpt(const MSG_SETTING_S *pSetting)
                g_mmsRecvOpt.bRejectAdvertisement = recvOpt.bRejectAdvertisement;
        }
 
-       if (g_mmsRecvOpt.bGroupMessage != recvOpt.bGroupMessage) {
-               if (MsgSettingSetInt(MMS_RECV_GROUP_MESSAGE, recvOpt.bGroupMessage) != MSG_SUCCESS) {
+       if (g_mmsRecvOpt.groupMessage != recvOpt.groupMessage) {
+               if (MsgSettingSetInt(MMS_RECV_GROUP_MESSAGE, recvOpt.groupMessage) != MSG_SUCCESS) {
                        MSG_ERR("Error to set config data [%s]", MMS_RECV_GROUP_MESSAGE);
                        return MSG_ERR_SET_SETTING;
                }
-               g_mmsRecvOpt.bGroupMessage = recvOpt.bGroupMessage;
+               g_mmsRecvOpt.groupMessage = recvOpt.groupMessage;
        }
 
        return MSG_SUCCESS;
@@ -1156,7 +1156,11 @@ void MsgGetMMSRecvOpt(MSG_SETTING_S *pSetting)
 
        if (MsgSettingGetInt(MMS_RECV_GROUP_MESSAGE, &tmpVal) != MSG_SUCCESS)
                MSG_INFO("MsgSettingGetInt() is failed");
-       pSetting->option.mmsRecvOpt.bGroupMessage = (MSG_MMS_GROUP_MESSAGE_MODE_T)tmpVal;
+
+       if (tmpVal < 0)
+               tmpVal = MSG_GROUP_MESSAGE_NOT_AVAILABLE;
+
+       pSetting->option.mmsRecvOpt.groupMessage = (MSG_MMS_GROUP_MESSAGE_MODE_T)tmpVal;
 }
 
 
index 9864e58..e5e9ce4 100755 (executable)
@@ -2157,7 +2157,6 @@ msg_error_t MsgStoGetMessage(msg_message_id_t msgId, MSG_MESSAGE_INFO_S *pMsg, M
 
        dbHandle->finalizeQuery();
 
-#if 0 /* This block will be activated after find way to get own number with any SIMs */
        if (pMsg->msgType.mainType == MSG_MMS_TYPE && pMsg->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS) {
                /* get recipients information. */
                MsgStoGetRecipientsByMsgId(dbHandle, pMsg->msgId, &pMsg->nAddressCnt, &pMsg->addressList);
@@ -2165,10 +2164,7 @@ msg_error_t MsgStoGetMessage(msg_message_id_t msgId, MSG_MESSAGE_INFO_S *pMsg, M
                /* get address information. */
                MsgStoGetAddressByMsgId(dbHandle, pMsg->msgId, &pMsg->nAddressCnt, &pMsg->addressList);
        }
-#else
-       /* get address information. */
-       MsgStoGetAddressByMsgId(dbHandle, pMsg->msgId, &pMsg->nAddressCnt, &pMsg->addressList);
-#endif
+
        /* Get MMS body if it is MMS. */
        if ((pMsg->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS &&
                        (pMsg->msgType.subType == MSG_RETRIEVE_MMS || pMsg->msgType.subType == MSG_RETRIEVE_AUTOCONF_MMS || pMsg->msgType.subType == MSG_RETRIEVE_MANUALCONF_MMS)) ||
index a566771..47de67e 100755 (executable)
@@ -614,12 +614,12 @@ int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
        msgIds[0] = msgInfo.msgId;
        msgIdList.msgIdList = msgIds;
 
-       bool is_group_on = false;
-       if (MsgSettingGetBool(MMS_RECV_GROUP_MESSAGE, &is_group_on) != MSG_SUCCESS) {
+       int groupMsg;
+       if (MsgSettingGetInt(MMS_RECV_GROUP_MESSAGE, &groupMsg) != MSG_SUCCESS) {
                MSG_INFO("MsgSettingGetBool() is failed");
        }
 
-       MSG_INFO("Group Message Setting Value [%d]", is_group_on);
+       MSG_INFO("Group Message Setting Value [%d]", groupMsg);
 
        MsgDbHandler *dbHandle = getDbHandle();
        int tmpAddrCnt = 0;
@@ -639,7 +639,7 @@ int MsgIncomingMMSConfMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                        tmpAddr[0].addressType = msgInfo.addressList[0].addressType;
                }
 
-               if (is_group_on == false || msgInfo.networkStatus != MSG_NETWORK_RETRIEVE_SUCCESS) {
+               if (groupMsg != MSG_GROUP_MESSAGE_ON || msgInfo.networkStatus != MSG_NETWORK_RETRIEVE_SUCCESS) {
                        if (msgInfo.addressList) {
                                delete[] msgInfo.addressList;
                                msgInfo.addressList = NULL;
index 7aa6b67..095d594 100755 (executable)
@@ -336,7 +336,7 @@ typedef struct {
        bool                            bDeliveryReceipt;                       /**< Indicates whether the delivery report will be sent or not. */
        bool                            bRejectUnknown;                 /**< Indicates whether unknown addresses are rejected or not. */
        bool                            bRejectAdvertisement;   /**< Indicates whether advertisement is rejected or not. */
-       MSG_MMS_GROUP_MESSAGE_MODE_T    bGroupMessage;                  /**< Indicates whether group message option. */
+       MSG_MMS_GROUP_MESSAGE_MODE_T    groupMessage;                   /**< Indicates whether group message option. */
 } MSG_MMS_RECVOPT_S;
 
 
index 739dde1..acab56b 100755 (executable)
@@ -1229,7 +1229,7 @@ int msg_get_mms_recv_opt_int(void *mms_recv_opt, int field, int *value)
                *value = recv_opt->abroadNetwork;
                break;
        case MSG_MMS_RECVOPT_GROUP_MESSAGE_INT:
-               *value = recv_opt->bGroupMessage;
+               *value = recv_opt->groupMessage;
                break;
        default:
                ret = MSG_ERR_INVALID_PARAMETER;
@@ -1256,7 +1256,7 @@ int msg_set_mms_recv_opt_int(void *mms_recv_opt, int field, int value)
                recv_opt->abroadNetwork = value;
                break;
        case MSG_MMS_RECVOPT_GROUP_MESSAGE_INT:
-               recv_opt->bGroupMessage = value;
+               recv_opt->groupMessage = value;
                break;
        default:
                ret = MSG_ERR_INVALID_PARAMETER;
index f50d68d..6b1f5e7 100755 (executable)
@@ -603,9 +603,7 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
 /*             pMsgInfo->msgType.subType = MSG_NOTIFICATIONIND_MMS; */
        }
 
-       char keyName[MAX_VCONFKEY_NAME_LEN];
-       memset(keyName, 0x00, sizeof(keyName));
-
+       char keyName[MAX_VCONFKEY_NAME_LEN] = {0};
        snprintf(keyName, sizeof(keyName), "%s/%d", MSG_SIM_MSISDN, pMsgInfo->sim_idx);
        char *msisdn = NULL;
        if (MsgSettingGetString(keyName, &msisdn) != MSG_SUCCESS) {
@@ -615,6 +613,11 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
        if (msisdn)
                normal_msisdn = msg_normalize_number(msisdn);
 
+       int groupMsg = 0;
+       if (MsgSettingGetInt(MMS_RECV_GROUP_MESSAGE, &groupMsg) != MSG_SUCCESS)
+               MSG_INFO("MsgSettingGetInt() is failed");
+       bool disabled_group_msg = groupMsg < MSG_GROUP_MESSAGE_OFF ? true : false;
+
        int addr_cnt = 0;
        int recipients_cnt = 0;
        MsgHeaderAddress *iter = NULL;
@@ -626,25 +629,28 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
                addr_cnt++;
                iter = iter->pNext;
        }
-#if 0 /* This block will be activated after find way to get own number with any SIMs */
-       iter = mmsHeader.pTo;
-       while (iter) {
-               MmsAddrUtilRemovePlmnString(iter->szAddr);
-               recipients_cnt++;
-               if (normal_msisdn == NULL || normal_msisdn[0] == '\0' || !g_str_has_suffix(iter->szAddr, normal_msisdn))
-                       addr_cnt++;
-               iter = iter->pNext;
-       }
 
-       iter = mmsHeader.pCc;
-       while (iter) {
-               MmsAddrUtilRemovePlmnString(iter->szAddr);
-               recipients_cnt++;
-               if (normal_msisdn == NULL || normal_msisdn[0] == '\0' || !g_str_has_suffix(iter->szAddr, normal_msisdn))
-                       addr_cnt++;
-               iter = iter->pNext;
+       /* If group message feature is available, parse to, cc */
+       if (!disabled_group_msg) {
+               iter = mmsHeader.pTo;
+               while (iter) {
+                       MmsAddrUtilRemovePlmnString(iter->szAddr);
+                       recipients_cnt++;
+                       if (normal_msisdn == NULL || normal_msisdn[0] == '\0' || !g_str_has_suffix(iter->szAddr, normal_msisdn))
+                               addr_cnt++;
+                       iter = iter->pNext;
+               }
+
+               iter = mmsHeader.pCc;
+               while (iter) {
+                       MmsAddrUtilRemovePlmnString(iter->szAddr);
+                       recipients_cnt++;
+                       if (normal_msisdn == NULL || normal_msisdn[0] == '\0' || !g_str_has_suffix(iter->szAddr, normal_msisdn))
+                               addr_cnt++;
+                       iter = iter->pNext;
+               }
        }
-#endif
+
        MSG_ADDRESS_INFO_S *recipients_addr_info = NULL;
        if (recipients_cnt > 0) {
                recipients_addr_info = (MSG_ADDRESS_INFO_S *)new char[sizeof(MSG_ADDRESS_INFO_S)*recipients_cnt];
@@ -667,37 +673,39 @@ void MmsPluginInternal::processRetrieveConf(MSG_MESSAGE_INFO_S *pMsgInfo, mmsTra
                        __fillAddressInfo(&(pMsgInfo->addressList[0]), mmsHeader.pFrom->szAddr, MSG_RECIPIENTS_TYPE_UNKNOWN);
                        __fillAddressInfo(&recipients_addr_info[0], mmsHeader.pFrom->szAddr, MSG_RECIPIENTS_TYPE_UNKNOWN);
                }
-#if 0 /* This block will be activated after find way to get own number with any SIMs */
-               int addr_idx = 0;
-               int recipients_idx = 0;
-               if (mmsHeader.pTo) {
-                       MsgHeaderAddress *iter = mmsHeader.pTo;
-                       while (iter) {
-                               MSG_DEBUG("TO : [%s]", iter->szAddr);
-                               /* To */
-                               if (normal_msisdn == NULL || normal_msisdn[0] == '\0' || !g_str_has_suffix(iter->szAddr, normal_msisdn)) {
-                                       __fillAddressInfo(&(pMsgInfo->addressList[++addr_idx]), iter->szAddr, MSG_RECIPIENTS_TYPE_TO);
-                               }
-                               __fillAddressInfo(&recipients_addr_info[++recipients_idx], iter->szAddr, MSG_RECIPIENTS_TYPE_TO);
 
-                               iter = iter->pNext;
+               /* If group message feature is available, parse to, cc */
+               if (!disabled_group_msg) {
+                       int addr_idx = 0;
+                       int recipients_idx = 0;
+                       if (mmsHeader.pTo) {
+                               MsgHeaderAddress *iter = mmsHeader.pTo;
+                               while (iter) {
+                                       MSG_DEBUG("TO : [%s]", iter->szAddr);
+                                       /* To */
+                                       if (normal_msisdn == NULL || normal_msisdn[0] == '\0' || !g_str_has_suffix(iter->szAddr, normal_msisdn)) {
+                                               __fillAddressInfo(&(pMsgInfo->addressList[++addr_idx]), iter->szAddr, MSG_RECIPIENTS_TYPE_TO);
+                                       }
+                                       __fillAddressInfo(&recipients_addr_info[++recipients_idx], iter->szAddr, MSG_RECIPIENTS_TYPE_TO);
+
+                                       iter = iter->pNext;
+                               }
                        }
-               }
 
-               if (mmsHeader.pCc) {
-                       MsgHeaderAddress *iter = mmsHeader.pCc;
-                       while (iter) {
-                               MSG_DEBUG("CC : [%s]", iter->szAddr);
-                               /* Cc */
-                               if (normal_msisdn == NULL || normal_msisdn[0] == '\0' || !g_str_has_suffix(iter->szAddr, normal_msisdn)) {
-                                       __fillAddressInfo(&(pMsgInfo->addressList[++addr_idx]), iter->szAddr, MSG_RECIPIENTS_TYPE_CC);
+                       if (mmsHeader.pCc) {
+                               MsgHeaderAddress *iter = mmsHeader.pCc;
+                               while (iter) {
+                                       MSG_DEBUG("CC : [%s]", iter->szAddr);
+                                       /* Cc */
+                                       if (normal_msisdn == NULL || normal_msisdn[0] == '\0' || !g_str_has_suffix(iter->szAddr, normal_msisdn)) {
+                                               __fillAddressInfo(&(pMsgInfo->addressList[++addr_idx]), iter->szAddr, MSG_RECIPIENTS_TYPE_CC);
+                                       }
+                                       __fillAddressInfo(&recipients_addr_info[++recipients_idx], iter->szAddr, MSG_RECIPIENTS_TYPE_CC);
+
+                                       iter = iter->pNext;
                                }
-                               __fillAddressInfo(&recipients_addr_info[++recipients_idx], iter->szAddr, MSG_RECIPIENTS_TYPE_CC);
-
-                               iter = iter->pNext;
                        }
                }
-#endif
        }
 
        MSG_SEC_DEBUG("%d, MMS Receive %s End %s->%s %s", pMsgInfo->msgId
index 985d8a1..72d77fa 100755 (executable)
@@ -948,6 +948,7 @@ void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *us
        MSG_DEBUG("TapiEventGetMsisdnInfo is called.");
 
        bool bRet = false;
+       bool bDisableGroupMessage = false;
 
        if (result != TAPI_SIM_ACCESS_SUCCESS || data == NULL) {
                MSG_ERR("Error. data is NULL. result:0x%x", result);
@@ -972,9 +973,21 @@ void TapiEventGetMsisdnInfo(TapiHandle *handle, int result, void *data, void *us
                                MSG_DEBUG("Getting MSISDN is failed!");
                        }
                        break;
+               } else {
+                       bDisableGroupMessage = true;
                }
        }
 
+       int tmpVal = 0;
+       if (MsgSettingGetInt(MMS_RECV_GROUP_MESSAGE, &tmpVal) != MSG_SUCCESS)
+               MSG_INFO("MsgSettingGetInt() is failed");
+
+       /* If the value from MMS_RECV_GROUP_MESSAGE is less than 0, it means group message mode is disabled. */
+       if ((tmpVal < 0 && bDisableGroupMessage == false) || (tmpVal > 0 && bDisableGroupMessage == true)) {
+               if (MsgSettingSetInt(MMS_RECV_GROUP_MESSAGE, -tmpVal))
+                       MSG_ERR("Error to set config data [%s]", MMS_RECV_GROUP_MESSAGE);
+       }
+
        SmsPluginSetting::instance()->setResultFromSim(bRet);
 }