Update change log and spec for wrt-plugins-tizen_0.4.65
[platform/framework/web/wrt-plugins-tizen.git] / src / Messaging / Mms.cpp
index b48920e..4fcffeb 100644 (file)
@@ -23,8 +23,9 @@
 #include "Messaging.h"
 #include "CallbackMgr.h"
 #include "MsgServiceHandleMgr.h"
+#include "WidgetFilePathMgr.h"
 #include <Logger.h>
-#include <net_connection.h>
+#include <vconf.h>
 
 extern "C" {
 #include <msg.h>
@@ -35,7 +36,7 @@ extern "C" {
 namespace {
 const char* TEXT_AREA = "Text";
 const char* TEXT_FILE_EXTENSION = ".txt";
-const char* TEXT_DIR_PREFIX = "/tmp/";
+const char* TEXT_DIR_SEPERATOR = "/";
 const int WHITE_COLOR = 0xffffff;
 const int BLACK_COLOR = 0x000000;
 const int ROOT_LAYOUT_WIDTH = 100;
@@ -50,11 +51,9 @@ namespace Messaging {
 
 Mms::Mms(const string& id) :
     IMessage(MMS, id),
-//    m_bodyFilePath(string(tmpnam(NULL)) + TEXT_FILE_EXTENSION),
     m_messageData(NULL)
 {
        LoggerD("m_id=" << getIdRef());
-       LoggerD("m_msgType=" << getMessageType());
 
        char buf[] = "XXXXXX";
        mode_t mask = umask(S_IWGRP | S_IWOTH);
@@ -62,15 +61,11 @@ Mms::Mms(const string& id) :
        LoggerD("buf : " << buf << " i : " << i);
        umask(mask);
        m_bodyFilePath = buf;
-       m_bodyFilePath = TEXT_DIR_PREFIX+m_bodyFilePath+TEXT_FILE_EXTENSION;
-
-       LoggerD("m_bodyFilePath : " << m_bodyFilePath);
+       m_bodyFilePath = getWidgetPath()+TEXT_DIR_SEPERATOR+m_bodyFilePath+TEXT_FILE_EXTENSION;
 
        if (getIdRef().empty()) {
-               LoggerD("create new message");
                createNewMessage();
        } else {
-               LoggerD("read existing message");
                readExistingMessage();
        }
 }
@@ -80,11 +75,8 @@ Mms::Mms(const string& id, const msg_struct_t msg_data) :
        m_messageData(NULL)
 {
        LoggerD("m_id=" << getIdRef());
-       LoggerD("m_msgType=" << getMessageType());
 
-       LoggerD("created msg_data : " << msg_data);
        m_messageData = createNewCopyOfPLatformMsgWithAddressList(msg_data);
-       LoggerD("created m_messageData : " << m_messageData);
 
        char buf[] = "XXXXXX";
        mode_t mask = umask(S_IWGRP | S_IWOTH);
@@ -92,10 +84,8 @@ Mms::Mms(const string& id, const msg_struct_t msg_data) :
        LoggerD("buf : " << buf << " i : " << i);
        umask(mask);
        m_bodyFilePath = buf;
-       m_bodyFilePath = TEXT_DIR_PREFIX+m_bodyFilePath+TEXT_FILE_EXTENSION;
-       
-       LoggerD("m_bodyFilePath : " << m_bodyFilePath);
-       
+       m_bodyFilePath = getWidgetPath()+TEXT_DIR_SEPERATOR+m_bodyFilePath+TEXT_FILE_EXTENSION;
+
        readConversationId(m_messageData);
        readRecipientList(m_messageData);
        readPriority(m_messageData);
@@ -105,7 +95,6 @@ Mms::Mms(const string& id, const msg_struct_t msg_data) :
        readDateTime(m_messageData);
        readReadStatus(m_messageData);
        readMessageStatus(m_messageData);
-//     setMessageStatus(MESSAGE_STATUS_LOADED);
 
 }
 
@@ -1105,6 +1094,8 @@ void Mms::updateMessage()
 {
        LoggerD("updating m_id=" << getIdRef());
        msg_error_t err = MSG_SUCCESS;
+       int tempInt = 0;
+
        msg_struct_t msg = NULL;
        msg_struct_t sendOpt = NULL;
        
@@ -1124,8 +1115,8 @@ void Mms::updateMessage()
                
                if (err != MSG_SUCCESS)
                {
-                       LoggerE("Get Message Failed!");
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to update message");
+                       LoggerE("msg_get_message() Failed!");
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to get message for update");
                }
        
                if (this->getIdRef().empty()) {
@@ -1133,12 +1124,24 @@ void Mms::updateMessage()
                        ThrowMsg(WrtDeviceApis::Commons::PlatformException,
                                        "existing msgId is zero, update msg not done");
                }
-               
+
+               err = msg_get_int_value(msg, MSG_MESSAGE_NETWORK_STATUS_INT, &tempInt);
+               if(err == MSG_SUCCESS)
+               {
+                       msg_set_int_value(m_messageData, MSG_MESSAGE_NETWORK_STATUS_INT, tempInt);
+               }
+
+               err = msg_get_int_value(msg, MSG_MESSAGE_FOLDER_ID_INT, &tempInt);
+               if(err == MSG_SUCCESS)
+               {
+                       msg_set_int_value(m_messageData, MSG_MESSAGE_FOLDER_ID_INT, tempInt);
+               }
+
                update(TRUE);
                
                if (MSG_SUCCESS != msg_update_message(MsgGetCommonHandle(), m_messageData, sendOpt))
                {
-                       LoggerE("Failed to update message");
+                       LoggerE("msg_update_message() Failed!");
                        ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to update message");
                }
                msg_release_struct(&msg);
@@ -1678,21 +1681,26 @@ FolderType Mms::toFolder(const std::string &folder)
 bool Mms::getCellularOn()
 {
     auto cellularOn = true;
-    void* connectionHandle;
-    if (CONNECTION_ERROR_NONE == connection_create(&connectionHandle)) {
-        connection_cellular_state_e cellularState;
-        if (CONNECTION_ERROR_NONE == connection_get_cellular_state (connectionHandle,
-                                                         &cellularState)) {
-            if (CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE  == cellularState || CONNECTION_CELLULAR_STATE_FLIGHT_MODE == cellularState) {
-                cellularOn = false;
-                LoggerW("Cellular State Error" << cellularState);
-            }
-        } else {
-            LoggerE("Can't obtain state of cellular connection");
-        }
-        connection_destroy(connectionHandle);
-    } else {
-        LoggerE("Can't obtain state of cellular connection");
+    int tempInt;
+    int tempbool;
+
+    vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &tempInt);
+    vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &tempbool);
+    if(tempInt <= VCONFKEY_TELEPHONY_SVCTYPE_SEARCH || tempbool == TRUE)
+    {
+        LoggerE("VCONFKEY_TELEPHONY_SVCTYPE error " << tempInt);
+        LoggerE("VCONFKEY_TELEPHONY_FLIGHT_MODE error " << tempbool);
+        cellularOn = false;
+        return cellularOn;
+    }
+
+    vconf_get_bool(VCONFKEY_3G_ENABLE, &tempbool);
+    vconf_get_int(VCONFKEY_TELEPHONY_SVC_PS, &tempInt);
+    if(tempbool == FALSE || tempInt != VCONFKEY_TELEPHONY_SVC_PS_ON)
+    {
+        LoggerE("VCONFKEY_3G_ENABLE error " << tempbool);
+        LoggerE("VCONFKEY_TELEPHONY_SVC_PS_ON error " << tempInt);
+        cellularOn = false;
     }
     return cellularOn;
 }