TSAM-5333 Auto clear Message saved on SIM after restart Device 13/76313/2 submit/tizen/20160623.110047 submit/tizen/20160624.093431
authorOleksander Kostenko <o.kostenko@samsung.com>
Thu, 23 Jun 2016 10:23:53 +0000 (13:23 +0300)
committerOleksander Kostenko <o.kostenko@samsung.com>
Thu, 23 Jun 2016 10:33:00 +0000 (13:33 +0300)
Change-Id: I67bfbc843545cd6959dd55e4bd0bcc60738fa8a4
Signed-off-by: Oleksander Kostenko <o.kostenko@samsung.com>
src/Common/MsgEngine/src/private/MsgStoragePrivate.cpp
src/Common/MsgEngine/src/private/MsgStoragePrivate.h

index 435bffd..1965c41 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <msg_storage.h>
 #include <algorithm>
+#include <telephony_network.h>
 
 using namespace Msg;
 
@@ -78,6 +79,28 @@ void MsgStoragePrivate::msg_storage_change_cb(msg_handle_t handle, msg_storage_c
     }
 }
 
+bool MsgStoragePrivate::isSimActive() const
+{
+    bool res = false;
+    telephony_handle_list_s tel_handle_list;
+    if(telephony_init(&tel_handle_list) == TELEPHONY_ERROR_NONE)
+    {
+        if(tel_handle_list.count > 0)
+        {
+            telephony_h tel_handle = tel_handle_list.handle[0];
+            telephony_network_service_state_e serv_state;
+            if(telephony_network_get_service_state(tel_handle, &serv_state) == TELEPHONY_ERROR_NONE)
+            {
+                res = (serv_state == TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE);
+                MSG_LOG("serv_state = ", serv_state);
+            }
+        }
+        telephony_deinit(&tel_handle_list);
+    }
+
+    return res;
+}
+
 MsgStoragePrivate::~MsgStoragePrivate()
 {
 }
@@ -113,11 +136,18 @@ MessageSMSListRef MsgStoragePrivate::getSimMsgList()
     msg_set_int_value(listCond, MSG_LIST_CONDITION_SIM_INDEX_INT, 1);
     msg_set_int_value(listCond, MSG_LIST_CONDITION_STORAGE_ID_INT, MSG_STORAGE_SIM);
 
+    if(!isSimActive())
+    {
+        MSG_LOG_ERROR("SIM_CARD_IS_NOT_ACTIVE!");
+        msg_release_struct(&listCond);
+        return nullptr;
+    }
+
     if(msg_get_message_list2(m_ServiceHandle, listCond, &msgList) == 0)
     {
         res.reset(new SmsStructListPrivate(true, msgList));
     }
-
+    msg_release_struct(&listCond);
     return res;
 }
 
@@ -315,6 +345,7 @@ MsgId MsgStoragePrivate::saveMessage(Message &msg, bool updateExisting)
         if(tmpMsgId > 0)
         {
             newMsgId = tmpMsgId;
+            msg_move_msg_to_storage(m_ServiceHandle, newMsgId, msg.getMessageStorageType());
         }
     }
     msg_release_struct(&sendOpt);
index a21cc13..8d05bd5 100644 (file)
@@ -77,6 +77,7 @@ namespace Msg
             static void msg_storage_change_cb(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_id_list_s *pMsgIdList, void *user_param);
 
             MessageSMS *createSms();
+            bool isSimActive() const;
 
         private:
             msg_handle_t m_ServiceHandle;