[P161125-03865] add code for storage full notification 66/101566/3
authorKyeonghun Lee <kh9090.lee@samsung.com>
Thu, 1 Dec 2016 12:15:29 +0000 (21:15 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Fri, 2 Dec 2016 03:47:32 +0000 (12:47 +0900)
Change-Id: I5a8069ddfcefaf5f90a5a2826f8a05bb7e12534d
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
framework/transaction-manager/MsgCmdHandlerStorage.cpp
framework/transaction-manager/MsgCmdHandlerTransport.cpp
manager/inc/msg-manager-notification.h
manager/src/msg-manager-notification.cpp

index cbae6c5..e0e30da 100755 (executable)
@@ -22,6 +22,7 @@
 #include "MsgException.h"
 #include "MsgCppTypes.h"
 #include "MsgUtilFunction.h"
+#include "MsgUtilStorage.h"
 #include "MsgStorageHandler.h"
 #include "MsgPluginManager.h"
 #include "MsgTransManager.h"
@@ -65,6 +66,10 @@ int MsgAddMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                return 0;
        }
 
+       err = MsgStocheckMemoryStatus();
+       if (err != MSG_SUCCESS)
+               return MsgMakeEvent(NULL, 0, MSG_EVENT_ADD_MSG, err, (void**)ppEvent);
+
        char* encodedData = NULL;
        unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter);
 
@@ -144,6 +149,10 @@ int MsgAddSyncMLMessageHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                return 0;
        }
 
+       err = MsgStocheckMemoryStatus();
+       if (err != MSG_SUCCESS)
+               return MsgMakeEvent(NULL, 0, MSG_EVENT_ADD_SYNCML_MSG, err, (void**)ppEvent);
+
        char* encodedData = NULL;
        unique_ptr<char*, void(*)(char**)> buf(&encodedData, unique_ptr_deleter);
 
index 85eb318..8ad9f7c 100755 (executable)
@@ -51,6 +51,10 @@ int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
                return 0;
        }
 
+       err = MsgStocheckMemoryStatus();
+       if (err != MSG_SUCCESS)
+               return MsgMakeEvent(NULL, 0, MSG_EVENT_SUBMIT_REQ, err, (void**)ppEvent);
+
        int ret[3];
        int eventSize = 0;
 
@@ -68,7 +72,6 @@ int MsgSubmitReqHandler(const MSG_CMD_S *pCmd, char **ppEvent)
 
        MsgDecodeMsgInfo((char *)(pCmd->cmdData+sizeof(msg_request_id_t)+sizeof(MSG_PROXY_INFO_S)), &reqInfo.msgInfo, &reqInfo.sendOptInfo);
 
-
        if (reqInfo.msgInfo.msgType.mainType == MSG_MMS_TYPE
                        && reqInfo.msgInfo.msgType.subType == MSG_SENDREQ_MMS) {
                int fd = 0;
index 8837c76..829b076 100644 (file)
@@ -73,6 +73,7 @@
 #define MSG_READ_REPORT_STATUS_ICON            "reserved://indicator/icons/read_report_message"
 #define MSG_VOICE_MSG_STATUS_ICON                      "reserved://indicator/icons/notify_voicemail"
 #define MSG_SIM_FULL_STATUS_ICON                       "reserved://indicator/icons/sim_card_full"
+#define MSG_STORAGE_FULL_STATUS_ICON           "/usr/apps/org.tizen.indicator/res/resource/icons/Storage/b03_storage_memoryfull.png"
 
 #ifndef TIZEN_I586_ENABLED
 /* system string */
 #define SIM_MSG_NOTI_PRIV_ID   "db/private/msg-service/sim_msg_noti_priv_id"
 #define MSG_SENTFAIL_NOTI_ID           "db/private/msg-service/sentfail_noti_id"
 #define SIM_FULL_NOTI_PRIV_ID  "db/private/msg-service/sim_full_noti_id"
+#define STORAGE_FULL_NOTI_PRIV_ID      "db/private/msg-service/storage_full_noti_id"
 
 #define MSG_SETTING_NOTIFICATION       "db/private/msg-service/general/notification"
 #define MSG_SETTING_VIBRATION          "db/private/msg-service/general/vibration"
@@ -245,6 +247,7 @@ enum _msg_mgr_notification_type_e {
        MSG_MGR_NOTI_TYPE_MMS_READ_REPORT_SENT,
 
        MSG_MGR_NOTI_TYPE_SIM_FULL,
+       MSG_MGR_NOTI_TYPE_STORAGE_FULL,
 };
 
 
index 23e2d34..b99c753 100644 (file)
@@ -807,6 +807,10 @@ void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
                notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
                break;
        }
+       case MSG_MGR_NOTI_TYPE_STORAGE_FULL: {
+               notification_set_launch_option(noti_h, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, noti_info->svc_h);
+               break;
+       }
        case MSG_MGR_NOTI_TYPE_VOICE_1:
        case MSG_MGR_NOTI_TYPE_VOICE_2:
        case MSG_MGR_NOTI_TYPE_MWI:
@@ -1058,6 +1062,12 @@ void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
                setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL);
                break;
        }
+       case MSG_MGR_NOTI_TYPE_STORAGE_FULL: {
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Not enough space", NULL);
+               setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Couldn't receive new messages", NULL);
+               setNotiTime(noti_h, time(NULL));
+               break;
+       }
        default:
                MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
                break;
@@ -1170,6 +1180,17 @@ void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info)
                setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH);
                setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_FULL_STATUS_ICON);
                break;
+       case MSG_MGR_NOTI_TYPE_STORAGE_FULL: {
+               char *msg_icon_path = NULL;
+               if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) {
+                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, msg_icon_path);
+                       g_free(msg_icon_path);
+               } else {
+                       MSG_MGR_ERR("fail to get message-app icon");
+               }
+               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_STORAGE_FULL_STATUS_ICON);
+               break;
+       }
        default:
                MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type);
                break;
@@ -2355,6 +2376,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                break;
        }
        case MSG_MGR_NOTI_TYPE_SIM_FULL:
+       case MSG_MGR_NOTI_TYPE_STORAGE_FULL:
                break;
        default:
                MSG_MGR_DEBUG("No matching type [%d]", noti_info->type);
@@ -2438,6 +2460,9 @@ int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx)
        case MSG_MGR_NOTI_TYPE_SIM_FULL:
                vconf_get_int(SIM_FULL_NOTI_PRIV_ID, &noti_id);
                break;
+       case MSG_MGR_NOTI_TYPE_STORAGE_FULL:
+               vconf_get_int(STORAGE_FULL_NOTI_PRIV_ID, &noti_id);
+               break;
        default:
                MSG_MGR_DEBUG("No matching noti type [%d]", noti_type);
                break;
@@ -2498,6 +2523,9 @@ void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_id
        case MSG_MGR_NOTI_TYPE_SIM_FULL:
                err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id);
                break;
+       case MSG_MGR_NOTI_TYPE_STORAGE_FULL:
+               err = vconf_set_int(STORAGE_FULL_NOTI_PRIV_ID, noti_id);
+               break;
        default:
                MSG_MGR_DEBUG("No matching type [%d]", noti_type);
                break;
@@ -2828,6 +2856,10 @@ void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_
                noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR;
                break;
        }
+       case MSG_MGR_NOTI_TYPE_STORAGE_FULL: {
+               noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
+               noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR|NOTIFICATION_DISPLAY_APP_TICKER;
+       }
        default:
                break;
        }
@@ -3187,6 +3219,7 @@ int MsgMgrInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, boo
 
        if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_SENDING_FAIL) != 0 &&
                g_strcmp0(pLocaleTickerMsg, SENDING_MULTIMEDIA_MESSAGE_FAILED) != 0 &&
+               g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_MEMORY_FULL) != 0 &&
                g_strcmp0(pLocaleTickerMsg, MESSAGE_RETRIEVED) != 0) {
                if (g_strcmp0(pLocaleTickerMsg, notiMsg) == 0) {
                        notification_status_message_post(pTickerMsg);
@@ -3217,6 +3250,11 @@ int MsgMgrInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, boo
                                MSG_MGR_DEBUG("MsgRefreshSimFullNoti err=[%d]", err);
                        }
 #endif
+               } else if (g_strcmp0(pLocaleTickerMsg, SMS_MESSAGE_MEMORY_FULL) == 0) {
+                       err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_STORAGE_FULL, true, MSG_MGR_ACTIVE_NOTI_TYPE_NONE);
+                       if (err != 0) {
+                               MSG_MGR_DEBUG("MsgRefreshFailedNoti err=[%d]", err);
+                       }
                } else {
                        MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT);
                }