msg-service bugs fixed(cherry-picks from product git) 05/77805/2
authorKyeonghun Lee <kh9090.lee@samsung.com>
Fri, 1 Jul 2016 06:56:46 +0000 (15:56 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Fri, 1 Jul 2016 07:40:56 +0000 (16:40 +0900)
Change-Id: Ie5d7c201c2fcd7def4f2b3a365d37ba9be51b6e1
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
framework/plugin-manager/MsgPluginManager.cpp
include/utils/MsgMutex.h
manager/src/msg-manager-notification.cpp
plugin/mms_plugin/MmsPluginConnManWrapper.cpp
plugin/mms_plugin/MmsPluginHttp.cpp
plugin/sms_cdma_plugin/SmsCdmaPluginCallback.cpp
plugin/sms_plugin/SmsPluginCallback.cpp
proxy/MsgHandleStorage.cpp
utils/MsgMmsMessage.cpp

index 97e86b4..9fd26ef 100755 (executable)
@@ -593,7 +593,7 @@ msg_error_t MsgSimMessageListener(MSG_MESSAGE_INFO_S *pMsg, int *simIdList, msg_
 
        MSG_DEBUG("simIdList[0] [%d]", simIdList[0]);
 
-       dataSize += ((sizeof(int)*size) + 1);
+       dataSize += ((sizeof(int))*(size + 1));
 
        /* composing command */
        int cmdSize = sizeof(MSG_CMD_S) + dataSize; /* cmd type, MSG_MESSAGE_INFO_S */
index 39d7525..5fb2581 100755 (executable)
@@ -77,16 +77,20 @@ private:
 class MsgCndVar
 {
 public:
-       MsgCndVar() { pthread_cond_init(&c, 0); }
+       MsgCndVar() {
+               pthread_condattr_t attr;
+               pthread_condattr_init(&attr);
+               pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
+               pthread_cond_init(&c, &attr);
+               pthread_condattr_destroy(&attr);
+       }
        ~MsgCndVar() { pthread_cond_destroy(&c); }
        void wait(pthread_mutex_t* m) { pthread_cond_wait(&c, m); }
        int timedwait(pthread_mutex_t* m, int sec)
        {
-               struct timeval now = {0};
                struct timespec timeout = {0};
-               gettimeofday(&now, NULL);
-               timeout.tv_sec = now.tv_sec+sec;
-               timeout.tv_nsec = now.tv_usec;
+               clock_gettime(CLOCK_MONOTONIC, &timeout);
+               timeout.tv_sec += sec;
                int retcode = pthread_cond_timedwait(&c, m, &timeout);
                return retcode;
        }
index 3049caf..ac4e516 100644 (file)
@@ -128,7 +128,7 @@ int getAppIcon(const char *app_id, char **icon_path);
 int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage);
 
 void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
-void setTextDomain(notification_h noti_h, msg_mgr_notification_type_t noti_type);
+void setTextDomain(notification_h noti_h);
 void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
 void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info);
 void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail);
@@ -748,7 +748,7 @@ void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
 }
 
 
-void setTextDomain(notification_h noti_h, msg_mgr_notification_type_t noti_type)
+void setTextDomain(notification_h noti_h)
 {
        MSG_MGR_BEGIN();
 
@@ -1330,7 +1330,7 @@ void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info
 
        setActiveProperty(noti_h, noti_info);
 
-       setTextDomain(noti_h, noti_info->type);
+       setTextDomain(noti_h);
 
        setActiveText(noti_h, noti_info);
 
@@ -1365,7 +1365,7 @@ void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool
 
        setProperty(noti_h, noti_info);
 
-       setTextDomain(noti_h, noti_info->type);
+       setTextDomain(noti_h);
 
        setText(noti_h, noti_info);
 
@@ -2796,7 +2796,7 @@ int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type)
                        } else if (noti_info.count > 1) {
                                gchar *cnt_string = g_strdup_printf("%i", noti_info.count);
 
-                               notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGE);
+                               notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGES);
                                gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL);
                                setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL);
                                setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL);
index ca073fc..3e93f91 100755 (executable)
@@ -579,6 +579,28 @@ void MmsPluginCmAgent::connection_profile_open_callback(connection_error_e resul
                                MSG_ERR("Failed connection_profile_get_cellular_home_url");
                        }
 
+                       this->dns_address_list = (char *)calloc(1, 51);
+                       for (int i = 1; i <= 2; i++) {
+                               char *dns = NULL;
+                               err = connection_profile_get_dns_address(profile, i, CONNECTION_ADDRESS_FAMILY_IPV4, &dns);
+                               if (err != CONNECTION_ERROR_NONE) {
+                                       MSG_ERR("Failed connection_profile_get_cellular_home_url");
+                               }
+
+                               if (dns != NULL) {
+                                       MSG_INFO("dns [%s]", dns);
+                                       if (g_strcmp0(dns, "0.0.0.0")) {
+                                               if (!(strlen(this->dns_address_list) > 1)) {
+                                                       snprintf(this->dns_address_list, 50, "%s", dns);
+                                               } else {
+                                                       snprintf(this->dns_address_list  + strlen(this->dns_address_list ), 50 - strlen(this->dns_address_list ), ",%s", dns);
+                                               }
+                                       }
+                                       MSG_FREE(dns);
+                               }
+                               MSG_INFO("dns list[%s]", this->dns_address_list);
+                       }
+
                        isCmOpened = true;
 
                        goto __SIGNAL_RETURN; /* open success */
@@ -673,6 +695,28 @@ void MmsPluginCmAgent::connection_profile_state_changed_cb(connection_profile_st
                        MSG_ERR("Failed connection_profile_get_cellular_home_url");
                }
 
+               this->dns_address_list = (char *)calloc(1, 51);
+               for (int i = 1; i <= 2; i++) {
+                       char *dns = NULL;
+                       err = connection_profile_get_dns_address(profile, i, CONNECTION_ADDRESS_FAMILY_IPV4, &dns);
+                       if (err != CONNECTION_ERROR_NONE) {
+                               MSG_ERR("Failed connection_profile_get_cellular_home_url");
+                       }
+
+                       if (dns != NULL) {
+                               MSG_INFO("dns [%s]", dns);
+                               if (g_strcmp0(dns, "0.0.0.0")) {
+                                       if (!(strlen(this->dns_address_list) > 1)) {
+                                               snprintf(this->dns_address_list, 50, "%s", dns);
+                                       } else {
+                                               snprintf(this->dns_address_list  + strlen(this->dns_address_list ), 50 - strlen(this->dns_address_list ), ",%s", dns);
+                                       }
+                               }
+                               MSG_FREE(dns);
+                       }
+                       MSG_INFO("dns list[%s]", this->dns_address_list);
+               }
+
                isCmOpened = true;
                goto __SIGNAL_RETURN;
        }
index 186fedb..5547e64 100755 (executable)
@@ -626,6 +626,10 @@ MMS_HTTP_ERROR_E MmsPluginHttpAgent::setSession(http_request_info_s &request_inf
 /*             curl_easy_setopt(session_option, CURLOPT_TCP_NODELAY, 1); */
        }
 
+       if (request_info.dns_list != NULL && strlen(request_info.dns_list) > 1) {
+               curl_easy_setopt(session_option, CURLOPT_DNS_SERVERS, request_info.dns_list);
+       }
+
        MSG_END();
        return http_error;
 
index 6cfcaff..4c20502 100755 (executable)
@@ -405,6 +405,7 @@ void TapiEventSetConfigData(TapiHandle *handle, int result, void *data, void *us
 
        if (data == NULL) {
                MSG_DEBUG("Error. data is NULL.");
+               SmsPluginSetting::instance()->setResultFromEvent(false);
                return;
        }
 
index 5b09c26..985d8a1 100755 (executable)
@@ -580,6 +580,7 @@ void TapiEventSetConfigData(TapiHandle *handle, int result, void *data, void *us
 
        if (data == NULL) {
                MSG_ERR("Error. data is NULL. result:%d", result);
+               SmsPluginSetting::instance()->setResultFromSim(false);
                return;
        }
 
index 94d8ed2..bc30ecb 100755 (executable)
@@ -1361,11 +1361,15 @@ msg_error_t MsgHandle::regStorageChangeCallback(msg_storage_change_cb onStorageC
 
        int remoteFd = eventListener->getRemoteFd(); /* fd that is reserved to the "listener thread" by msgfw daemon */
 
-       if (remoteFd == -1 )
+       if (remoteFd == -1 ) {
+               eventListener->stop();
                return MSG_ERR_INVALID_MSGHANDLE;
+       }
 
-       if (eventListener->regStorageChangeEventCB(this, remoteFd, onStorageChange, pUserParam) == false)
+       if (eventListener->regStorageChangeEventCB(this, remoteFd, onStorageChange, pUserParam) == false) {
+               eventListener->stop();
                return MSG_ERR_INVALID_PARAMETER;
+       }
 
        /* Allocate Memory to Command Data */
        int cmdSize = sizeof(MSG_CMD_S) + sizeof(int); /* cmd type, listenerFd */
index 64a7c71..688085e 100755 (executable)
@@ -1235,6 +1235,20 @@ static bool IsMatchedMedia(MMS_MEDIA_S *media, MMS_MULTIPART_DATA_S *pMultipart)
                if (strcmp(media->szContentLocation,  szTempContentID) == 0) {
                        return true;
                }
+
+               if (media->szContentID[0] != '\0') {
+                       char *pszExt = strrchr(media->szContentID, '.');
+                       if (pszExt) {
+                               char tmpContentID[MSG_MSG_ID_LEN+1] = {0};
+                               strncpy(tmpContentID, media->szContentID, strlen(media->szContentID));
+                               int extLength = strlen(pszExt);
+                               int contentIDLength = strlen(media->szContentID);
+                               tmpContentID[contentIDLength-extLength] = '\0';
+
+                               if (g_strcmp0(tmpContentID, szTempContentID) == 0)
+                                       return true;
+                       }
+               }
        }
 
        if (strlen(pMultipart->szContentLocation) > 0) {