[TSAM-8885] implmentation for reply on active notification 10/95810/2
authorKyeonghun Lee <kh9090.lee@samsung.com>
Sun, 6 Nov 2016 23:56:12 +0000 (08:56 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Sun, 6 Nov 2016 23:59:06 +0000 (08:59 +0900)
Change-Id: I261271a6de14302c58c1f330f0e12f9b8a5e537a
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
manager/src/msg-manager-notification.cpp
manager/src/msg-manager.cpp
manager/tizen-manifest.xml

index 7773359..26bff49 100644 (file)
@@ -1474,14 +1474,14 @@ void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info
 
                createServiceHandle(&noti_info->active_noti_svc_h[1]);
                if (noti_info->active_noti_svc_h[1]) {
-                       setServicePackageName(noti_info->active_noti_svc_h[1], MSG_DEFAULT_APP_ID);
+                       setServicePackageName(noti_info->active_noti_svc_h[1], MSG_MGR_APP_ID);
 
-                       MSG_MGR_DEBUG("Active Notification button 2 - Msg Id = [%d]", noti_info->msg_id);
-                       addServiceExtraData(noti_info->active_noti_svc_h[1], "type", "reply");
-                       addServiceExtraData(noti_info->active_noti_svc_h[1], "msgId", noti_info->msg_id);
+                       MSG_MGR_DEBUG("Active Notification button 2 - number = [%s] slot_id = [%d]", noti_info->number, noti_info->sim_idx);
+                       addServiceExtraData(noti_info->active_noti_svc_h[1], "cmd", "reply_msg");
+                       addServiceExtraData(noti_info->active_noti_svc_h[1], "addr", noti_info->number);
 
                        char slot_id[5] = {0, };
-                       snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1);
+                       snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx);
                        addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id);
                }
        }
@@ -1503,6 +1503,8 @@ void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info
        if (noti_info->active_noti_button_num > 1) {
                setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[0]);
                setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_2, noti_info->active_noti_svc_h[1]);
+               notification_set_text_input(noti_h, 100);
+               setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_TEXT_INPUT_BUTTON, noti_info->active_noti_svc_h[1]);
                setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_3, noti_info->active_noti_svc_h[2]);
 
                setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "Call", NULL);
@@ -1887,7 +1889,8 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                                "B.MAIN_TYPE, "
                                "B.CONV_ID, "
                                "(CASE WHEN B.MAIN_TYPE = %d AND B.NETWORK_STATUS = %d THEN (SELECT C.MSG_SIZE FROM %s C WHERE B.MSG_ID = C.MSG_ID) ELSE -1 END), "
-                               "B.ATTACHMENT_COUNT "
+                               "B.ATTACHMENT_COUNT, "
+                               "B.SIM_INDEX "
                                "FROM %s B "
                                "LEFT JOIN %s A ON A.CONV_ID=B.CONV_ID "
                                "WHERE B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) "
@@ -1930,6 +1933,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage)
                if (row_cnt > 0) {
                        msgSize = atoi(db_res[col_cnt+7]);
                        attachmentCnt = atoi(db_res[col_cnt+8]);
+                       noti_info->sim_idx = atoi(db_res[col_cnt+9]);
 
                        noti_info->count = smsUnreadCnt + mmsUnreadCnt;
 
index 5409030..1bba7bb 100644 (file)
@@ -36,6 +36,7 @@ extern "C"
 
 #include "msg.h"
 #include "msg_storage.h"
+#include "msg_transport.h"
 
 #include "msg-manager-contact.h"
 #include "msg-manager-debug.h"
@@ -654,6 +655,67 @@ void _on_boot_func(app_control_h app_control)
        MsgMgrOnBoot();
 }
 
+void _reply_msg_func(app_control_h app_control)
+{
+       char *text = NULL;
+       char *addr = NULL;
+       char *slot_id = NULL;
+
+       int ret = app_control_get_extra_data(app_control, APP_CONTROL_DATA_TEXT, &text);
+       if (ret != APP_CONTROL_ERROR_NONE || text == NULL) {
+               MSG_MGR_ERR("app_control_get_extra_data failed");
+               return;
+       }
+
+       ret = app_control_get_extra_data(app_control, "addr", &addr);
+       if (ret != APP_CONTROL_ERROR_NONE || addr == NULL) {
+               MSG_MGR_ERR("app_control_get_extra_data failed");
+               g_free(text);
+               return;
+       }
+
+       ret = app_control_get_extra_data(app_control, "slot_id", &slot_id);
+       if (ret != APP_CONTROL_ERROR_NONE || slot_id == NULL) {
+               MSG_MGR_ERR("app_control_get_extra_data failed");
+               g_free(text);
+               g_free(addr);
+               return ;
+       }
+
+       MSG_MGR_DEBUG("text [%s]", text);
+       MSG_MGR_DEBUG("addr [%s]", addr);
+       MSG_MGR_DEBUG("slot_id [%s]", slot_id);
+
+       msg_struct_t msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
+       msg_struct_t opt = msg_create_struct(MSG_STRUCT_SENDOPT);
+
+       msg_struct_t addr_item = NULL;
+       msg_list_add_item(msg, MSG_MESSAGE_ADDR_LIST_HND, &addr_item);
+       msg_set_int_value(addr_item, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MSG_ADDRESS_TYPE_PLMN);
+       msg_set_int_value(addr_item, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MSG_RECIPIENTS_TYPE_TO);
+       msg_set_str_value(addr_item, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, addr, strlen(addr));
+
+       msg_set_int_value(msg, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS);
+       msg_set_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, atoi(slot_id));
+       msg_set_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, text, strlen(text));
+
+       msg_struct_t req = msg_create_struct(MSG_STRUCT_REQUEST_INFO);
+       msg_set_struct_handle(req, MSG_REQUEST_MESSAGE_HND, msg);
+       msg_set_struct_handle(req, MSG_REQUEST_SENDOPT_HND, opt);
+
+       int msg_err = msg_sms_send_message(msg_handle, req);
+       if (msg_err != MSG_SUCCESS)
+               MSG_MGR_ERR("msg_sms_send_message() failed [%d]", msg_err);
+
+       msg_release_struct(&msg);
+       msg_release_struct(&opt);
+       msg_release_struct(&req);
+
+       g_free(text);
+       g_free(addr);
+       g_free(slot_id);
+}
+
 void service_app_control(app_control_h app_control, void *data)
 {
        MSG_MGR_INFO("service_app_control called");
@@ -699,6 +761,8 @@ void service_app_control(app_control_h app_control, void *data)
                                        _change_pm_state_func(app_control);
                                } else if (g_strcmp0(cmd, "on_boot") == 0) {
                                        _on_boot_func(app_control);
+                               } else if (g_strcmp0(cmd, "reply_msg") == 0) {
+                                       _reply_msg_func(app_control);
                                }
 
                                g_free(cmd);
index d4056db..673dd76 100644 (file)
@@ -9,6 +9,7 @@
     <privileges>
         <privilege>http://tizen.org/privilege/alarm.set</privilege>
         <privilege>http://tizen.org/privilege/message.read</privilege>
+        <privilege>http://tizen.org/privilege/message.write</privilege>
         <privilege>http://tizen.org/privilege/callhistory.read</privilege>
         <privilege>http://tizen.org/privilege/callhistory.write</privilege>
         <privilege>http://tizen.org/privilege/contact.read</privilege>