apply outgoing msg event 73/61273/12 accepted/tizen/common/20160318.150054 accepted/tizen/ivi/20160318.113044 accepted/tizen/mobile/20160318.113853 accepted/tizen/tv/20160318.113956 accepted/tizen/wearable/20160318.113950 submit/tizen/20160318.072059
authorKyeonghun Lee <kh9090.lee@samsung.com>
Mon, 7 Mar 2016 06:03:52 +0000 (15:03 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Fri, 18 Mar 2016 07:07:42 +0000 (16:07 +0900)
Change-Id: If3a5e1ad5d18408dfc0c6138ebb4464832948de5
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
19 files changed:
externals/CMakeLists.txt
externals/MsgNotificationWrapper.cpp
framework/CMakeLists.txt
framework/deliver-handler/MsgDeliverHandler.cpp
framework/transaction-manager/MsgCmdHandlerTransport.cpp
framework/transaction-manager/MsgTransManager.cpp
include/common/MsgInternalTypes.h
include/externals/MsgNotificationWrapper.h
include/utils/MsgUtilFunction.h
manager/src/msg-manager-contact.cpp
manager/src/msg-manager.cpp
manager/tizen-manifest.xml
packaging/msg-service.spec
plugin/sms_cdma_plugin/CMakeLists.txt
plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp
plugin/sms_plugin/CMakeLists.txt
plugin/sms_plugin/SmsPluginEventHandler.cpp
utils/CMakeLists.txt
utils/MsgUtilFunction.cpp

index c7774a0..d27d430 100755 (executable)
@@ -32,7 +32,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(externals_pkgs REQUIRED glib-2.0 alarm-service notification badge iniparser capi-appfw-application lbs-dbus feedback capi-system-device motion capi-media-player capi-media-sound-manager)
+pkg_check_modules(externals_pkgs REQUIRED glib-2.0 alarm-service notification badge iniparser capi-appfw-package-manager capi-appfw-application lbs-dbus feedback capi-system-device motion capi-media-player capi-media-sound-manager)
 
 FOREACH(flag ${externals_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index baa3474..b3269e3 100755 (executable)
@@ -45,6 +45,7 @@ extern "C"
 #include <notification_setting_internal.h>
 #include <feedback.h>
 #include <badge_internal.h>
+#include <package_manager.h>
 #endif /* MSG_WEARABLE_PROFILE */
 }
 
@@ -107,6 +108,7 @@ void createInfoData(MSG_NOTI_INFO_S *noti_info, msg_active_notification_type_t a
 void createActiveInfoData(MSG_NOTI_INFO_S *noti_info, MSG_MESSAGE_INFO_S *msg_info);
 void clearInfoData(notification_h noti_h, MSG_NOTI_INFO_S *noti_info);
 
+msg_error_t getAppIcon(const char *app_id, char **icon_path);
 msg_error_t getLatestMsgInfo(MSG_NOTI_INFO_S *noti_info, bool isForInstantMessage);
 
 void setProperty(notification_h noti_h, MSG_NOTI_INFO_S *noti_info);
@@ -1803,7 +1805,13 @@ void setIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
                                        setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
                                }
 
-                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, MSG_MESSAGE_APP_SUB_ICON);
+                               char *msg_icon_path = NULL;
+                               if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == MSG_SUCCESS) {
+                                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
+                                       g_free(msg_icon_path);
+                               } else {
+                                       MSG_ERR("fail to get message-app icon");
+                               }
                        }
                }
                break;
@@ -1954,7 +1962,14 @@ void setActiveIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info)
                        else
                                setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH);
 
-                       setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, MSG_MESSAGE_APP_SUB_ICON);
+                       char *msg_icon_path = NULL;
+                       if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == MSG_SUCCESS) {
+                               setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path);
+                               g_free(msg_icon_path);
+                       } else {
+                               MSG_ERR("fail to get message-app icon");
+                       }
+
                        break;
                }
 
@@ -2265,6 +2280,51 @@ void setNotification(notification_h noti_h, MSG_NOTI_INFO_S *noti_info, bool bFe
 }
 
 
+msg_error_t getAppIcon(const char *app_id, char **icon_path)
+{
+       MSG_BEGIN();
+
+       package_info_h pkg_info_h = NULL;
+       int pkg_err = PACKAGE_MANAGER_ERROR_NONE;
+       int ret = MSG_SUCCESS;
+
+       if (app_id == NULL) {
+               MSG_ERR("app id is NULL");
+               ret = MSG_ERR_UNKNOWN;
+               goto END_OF_GET_APP_ICON;
+       }
+
+       pkg_err = package_info_create(app_id, &pkg_info_h);
+       if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
+               MSG_ERR("package_info_create failed (%d)", pkg_err);
+               ret = MSG_ERR_UNKNOWN;
+               goto END_OF_GET_APP_ICON;
+       }
+
+       pkg_err = package_info_get_icon(pkg_info_h, icon_path);
+       if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
+               MSG_ERR("package_info_get_icon failed (%d)", pkg_err);
+       } else {
+               if (icon_path == NULL) {
+                       MSG_WARN("icon path is NULL");
+                       ret = MSG_ERR_UNKNOWN;
+               }
+       }
+
+END_OF_GET_APP_ICON:
+       if (pkg_info_h) {
+               pkg_err = package_info_destroy(pkg_info_h);
+               if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) {
+                       MSG_ERR("package_info_destroy failed (%d)", pkg_err);
+               }
+
+               pkg_info_h = NULL;
+       }
+
+       return ret;
+}
+
+
 msg_error_t getLatestMsgInfo(MSG_NOTI_INFO_S *noti_info, bool isForInstantMessage)
 {
        MSG_BEGIN();
index 2e639c3..f525d68 100755 (executable)
@@ -70,7 +70,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(fw_handler_pkgs REQUIRED glib-2.0 gio-2.0 dlog vconf capi-appfw-application)
+pkg_check_modules(fw_handler_pkgs REQUIRED glib-2.0 gio-2.0 dlog vconf capi-appfw-application aul)
 
 FOREACH(flag ${fw_handler_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -std=c++0x")
index ada7597..30d9b75 100755 (executable)
 
 #ifndef MSG_WEARABLE_PROFILE
 #include <app_control.h>
+#include <aul.h>
 #endif // MSG_WEARABLE_PROFILE
+#include <bundle.h>
+#include <eventsystem.h>
 
 #include "MsgDebug.h"
 #include "MsgUtilFile.h"
 #include "MsgContact.h"
+#include "MsgUtilFunction.h"
 #include "MsgUtilStorage.h"
 #include "MsgGconfWrapper.h"
 #include "MsgSoundPlayer.h"
@@ -257,6 +261,22 @@ msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_reques
                        // add phone log
                        MSG_DEBUG("Enter MsgAddPhoneLog() for mms message.");
                        MsgAddPhoneLog(pMsgInfo);
+                       /* Send system event */
+                       bundle *b = NULL;
+                       b = bundle_create();
+                       if (b) {
+                               bundle_add_str(b, EVT_KEY_MSG_TYPE, EVT_VAL_MMS);
+                               char msgId[MSG_EVENT_MSG_ID_LEN] = {0, };
+                               snprintf(msgId, sizeof(msgId), "%u", pMsgInfo->msgId);
+                               bundle_add_str(b, EVT_KEY_MSG_ID, msgId);
+                               eventsystem_send_system_event(SYS_EVENT_INCOMMING_MSG, b);
+                               bundle_add_str(b, "cmd", "incoming_msg");
+                               int ret = aul_launch_app_for_uid("org.tizen.msg-manager", b, msg_get_login_user());
+                               if (ret <= 0) {
+                                       MSG_DEBUG("aul_launch_app_for_uid() is failed : %d", ret);
+                               }
+                               bundle_free(b);
+                       }
 #endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED
 
                        if (pMsgInfo->folderId == MSG_INBOX_ID)
index 3579615..17bb937 100755 (executable)
 
 #include <time.h>
 
+#include <aul.h>
+#include <bundle.h>
+#include <eventsystem.h>
+
 #include "MsgDebug.h"
 #include "MsgException.h"
 #include "MsgUtilFile.h"
@@ -479,6 +483,30 @@ int MsgIncomingMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent)
        /* normal process */
        err = MsgHandleIncomingMsg(&msgInfo, &sendNoti);
 
+       if (msgInfo.msgType.mainType == MSG_SMS_TYPE) {
+               /* Send system event */
+               bundle *b = NULL;
+               b = bundle_create();
+               if (b) {
+                       char msgId[MSG_EVENT_MSG_ID_LEN] = {0, };
+                       snprintf(msgId, sizeof(msgId), "%u", msgInfo.msgId);
+                       bundle_add_str(b, EVT_KEY_MSG_ID, msgId);
+
+                       if (msgInfo.msgType.subType >= MSG_WAP_SI_SMS && msgInfo.msgType.subType <= MSG_WAP_CO_SMS) {
+                               bundle_add_str(b, EVT_KEY_MSG_TYPE, EVT_VAL_PUSH);
+                       } else {
+                               bundle_add_str(b, EVT_KEY_MSG_TYPE, EVT_VAL_SMS);
+                               bundle_add_str(b, "cmd", "incoming_msg");
+                               int ret = aul_launch_app_for_uid("org.tizen.msg-manager", b, msg_get_login_user());
+                               if (ret <= 0) {
+                                       MSG_DEBUG("aul_launch_app_for_uid() is failed : %d", ret);
+                               }
+                       }
+                       eventsystem_send_system_event(SYS_EVENT_INCOMMING_MSG, b);
+                       bundle_free(b);
+               }
+       }
+
        if (isClass2msg == true) {
                msgIdList.nCount = 2;
                msgIds[0] = class2msgId;
@@ -704,6 +732,22 @@ __BYPASS_UPDATE:
 #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED
                        MSG_SEC_DEBUG("Enter MsgAddPhoneLog() : msgInfo.addressList[0].addressVal [%s]", msgInfo.addressList[0].addressVal);
                        MsgAddPhoneLog(&msgInfo);
+                       /* Send system event */
+                       bundle *b = NULL;
+                       b = bundle_create();
+                       if (b) {
+                               bundle_add_str(b, EVT_KEY_MSG_TYPE, EVT_VAL_MMS);
+                               char msgId[MSG_EVENT_MSG_ID_LEN] = {0, };
+                               snprintf(msgId, sizeof(msgId), "%u", msgInfo.msgId);
+                               bundle_add_str(b, EVT_KEY_MSG_ID, msgId);
+                               eventsystem_send_system_event(SYS_EVENT_INCOMMING_MSG, b);
+                               bundle_add_str(b, "cmd", "incoming_msg");
+                               int ret = aul_launch_app_for_uid("org.tizen.msg-manager", b, msg_get_login_user());
+                               if (ret <= 0) {
+                                       MSG_DEBUG("aul_launch_app_for_uid() is failed : %d", ret);
+                               }
+                               bundle_free(b);
+                       }
 #endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
                }
 
index 725d673..a7528d1 100755 (executable)
@@ -20,7 +20,7 @@
 #include <sys/stat.h>
 #include <pthread.h>
 
-#include <bundle_internal.h>
+#include <bundle.h>
 #include <eventsystem.h>
 
 #include "MsgDebug.h"
@@ -40,7 +40,6 @@
 #include "MsgTransManager.h"
 
 #define MSG_CHECK_PRIVILEGE
-#define MSG_EVENT_MSG_ID_LEN   (32)
 
 void MsgMakeErrorEvent(MSG_CMD_TYPE_T cmdType, msg_error_t errType, int *pEventSize, char **ppEvent)
 {
@@ -987,22 +986,6 @@ void MsgTransactionManager::broadcastIncomingMsgCB(const msg_error_t err, const
                }
        }
 
-       /* Send system event */
-       bundle *b = NULL;
-       b = bundle_create();
-       if (b) {
-               if (msgInfo->msgType.subType >= MSG_WAP_SI_SMS && msgInfo->msgType.subType <= MSG_WAP_CO_SMS) {
-                       bundle_add(b, EVT_KEY_MSG_TYPE, EVT_VAL_PUSH);
-               } else {
-                       bundle_add(b, EVT_KEY_MSG_TYPE, EVT_VAL_SMS);
-               }
-               char msgId[MSG_EVENT_MSG_ID_LEN] = {0, };
-               snprintf(msgId, sizeof(msgId), "%u", msgInfo->msgId);
-               bundle_add(b, EVT_KEY_MSG_ID, msgId);
-               eventsystem_send_system_event(SYS_EVENT_INCOMMING_MSG, b);
-               bundle_free(b);
-       }
-
        MSG_END();
 }
 
@@ -1090,10 +1073,10 @@ void MsgTransactionManager::broadcastCBMsgCB(const msg_error_t err, const MSG_CB
        bundle *b = NULL;
        b = bundle_create();
        if (b) {
-               bundle_add(b, EVT_KEY_MSG_TYPE, EVT_VAL_CB);
+               bundle_add_str(b, EVT_KEY_MSG_TYPE, EVT_VAL_CB);
                char msgId[MSG_EVENT_MSG_ID_LEN] = {0, };
                snprintf(msgId, sizeof(msgId), "%u", cbMsgId);
-               bundle_add(b, EVT_KEY_MSG_ID, msgId);
+               bundle_add_str(b, EVT_KEY_MSG_ID, msgId);
                eventsystem_send_system_event(SYS_EVENT_INCOMMING_MSG, b);
                bundle_free(b);
        }
index 1731e72..084db74 100755 (executable)
@@ -55,6 +55,7 @@
 #define MAX_VCONFKEY_NAME_LEN  128
 #define MAX_SIM_IMSI_LEN               16
 #define MAX_TAPI_SIM_API_TIMEOUT 70
+#define MSG_EVENT_MSG_ID_LEN   (32)
 
 #define SMS_MINIMUM_SPACE      (1 * 1024 * 1024)
 #define MMS_MINIMUM_SPACE      (1 * 1024 * 1024)
 #define MSG_TELEPHONY_SMS_FEATURE      "http://tizen.org/feature/network.telephony.sms"
 #define MSG_TELEPHONY_MMS_FEATURE      "http://tizen.org/feature/network.telephony.mms"
 
+/*below defines will be removed */
+#define SYS_EVENT_OUTGOING_MSG "tizen.system.event.outgoing_msg"
+#define EVT_VAL_MMS "mms"
+#define EVT_KEY_OUT_MSG_ID "msg_id"
+#define EVT_KEY_OUT_MSG_TYPE "msg_type"
+
 /*==================================================================================================
                                          TYPES
 ==================================================================================================*/
index df41f74..7bb8c11 100755 (executable)
@@ -48,7 +48,6 @@
 #define MSG_EMERGENCY_ICON_PATH                TZ_SYS_RO_APP_PATH MSG_DEFAULT_APP_ID "/res/icons/default/small/noti_emergency_mode.png"
 #define MSG_NO_CONTACT_PROFILE_ICON_PATH       TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Contact/noti_contact_default.png"
 #define MSG_ACTIVE_PUSH_ICON_PATH              "reserved:push_message"
-#define MSG_MESSAGE_APP_SUB_ICON               TZ_SYS_RO_APP_PATH MSG_DEFAULT_APP_ID "/res/icons/default/small/org.tizen.message.png"
 
 /* status bar icon */
 #define MSG_NORMAL_STATUS_ICON                         TZ_SYS_RO_APP_PATH MSG_STATUS_ICON_DIR "/Notify/B03_notify_message.png"
index 0a174e2..9b68fbd 100755 (executable)
@@ -150,6 +150,8 @@ void msg_replace_space_char(char *pszText);
 
 gchar * msg_replace_non_ascii_char(const gchar *pszText, gunichar replacementChar);
 
+uid_t msg_get_login_user();
+
 /* Dbus function */
 void MsgDbusInit();
 void MsgDbusDeinit();
index b8339ac..cd8a319 100644 (file)
@@ -153,7 +153,7 @@ void MsgMgrAddPhoneLog(contactInfo *contact_info)
                                contacts_record_set_int(plog, _contacts_phone_log.log_type, CONTACTS_PLOG_TYPE_SMS_INCOMING);
                        else
                                contacts_record_set_int(plog, _contacts_phone_log.log_type, CONTACTS_PLOG_TYPE_MMS_INCOMING);
-               } else if (contact_info->folderId == MSG_OUTBOX_ID) {
+               } else if (contact_info->folderId == MSG_OUTBOX_ID || contact_info->folderId == MSG_SENTBOX_ID) {
                        if (contact_info->msgType != MSG_TYPE_MMS && contact_info->msgType != MSG_TYPE_MMS_NOTI && contact_info->msgType != MSG_TYPE_MMS_JAVA)
                                contacts_record_set_int(plog, _contacts_phone_log.log_type, CONTACTS_PLOG_TYPE_SMS_OUTGOING);
                        else
index 073e5f1..17f896f 100644 (file)
 #include "msg-manager-contact.h"
 #include "msg-manager-debug.h"
 
+/* below defines will be removed */
+#define EVENT_KEY_OUT_MSG_TYPE "msg_type"
+#define EVENT_KEY_OUT_MSG_ID "msg_id"
+
 
 bool service_app_create(void *data)
 {
-       MSG_MGR_DEBUG("app_create");
+       MSG_MGR_INFO("app_create");
 
        return true;
 }
 
 void service_app_terminate(void *data)
 {
-       // Todo: add your code here.
+       MSG_MGR_INFO("app_terminate");
+
+       MsgMgrCloseContactSvc();
+
        return;
 }
 
@@ -37,19 +44,20 @@ void _incoming_msg_func(app_control_h app_control)
        char *rcv_msg_type = NULL;
        char *rcv_msg_id = NULL;
 
-       ret = app_control_get_extra_data(app_control, EVENT_KEY_MSG_TYPE, &rcv_msg_type);
-       if (ret != APP_CONTROL_ERROR_NONE || rcv_msg_type == NULL)
-               return;
-
-       MSG_MGR_INFO("rcv_msg_type(%s)", rcv_msg_type);
-       if (g_strcmp0(rcv_msg_type, EVENT_VAL_SMS) != 0)
+       ret = app_control_get_extra_data(app_control, EVENT_KEY_MSG_ID, &rcv_msg_id);
+       if (ret != APP_CONTROL_ERROR_NONE || rcv_msg_id == NULL) {
+               MSG_MGR_ERR("app_control_get_extra_data failed");
                return;
+       }
 
-       ret = app_control_get_extra_data(app_control, EVENT_KEY_MSG_ID, &rcv_msg_id);
-       if (ret != APP_CONTROL_ERROR_NONE || rcv_msg_id == NULL)
+       ret = app_control_get_extra_data(app_control, EVENT_KEY_MSG_TYPE, &rcv_msg_type);
+       if (ret != APP_CONTROL_ERROR_NONE || rcv_msg_type == NULL) {
+               MSG_MGR_ERR("app_control_get_extra_data failed");
+               g_free(rcv_msg_id);
                return;
+       }
 
-       MSG_MGR_INFO("rcv_msg_id(%s)", rcv_msg_id);
+       MSG_MGR_INFO("rcv_msg_type(%s), rcv_msg_id(%s)", rcv_msg_type, rcv_msg_id);
 
        int msg_err = MSG_SUCCESS;
        msg_message_id_t msg_id = atoi(rcv_msg_id);
@@ -90,35 +98,10 @@ void _incoming_msg_func(app_control_h app_control)
        msg_release_struct(&msg);
        msg_release_struct(&opt);
 
-#if 0
-       char **db_res = NULL;
-       int row_cnt = 0, col_cnt = 0;
-       msg_err = msg_db_select_with_query(msg_handle, "MSG_ID FROM MSG_MESSAGE_TABLE;", &db_res, &row_cnt, &col_cnt);
-       if (msg_err != MSG_SUCCESS) {
-               MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err);
-               return;
-       }
-
-       MSG_MGR_DEBUG("row count [%d] col count [%d]", row_cnt, col_cnt);
-       if (db_res == NULL || *db_res == NULL) {
-               MSG_MGR_DEBUG("NULL");
-       } else {
-               for (int i = col_cnt; i < col_cnt * (row_cnt + 1); i++) {
-                       MSG_MGR_DEBUG("db_res[%d] [%s]", i, db_res[i]);
-               }
-       }
-
-       msg_err = msg_db_free(msg_handle, db_res);
-       if (msg_err != MSG_SUCCESS) {
-               MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err);
-               return;
-       }
-#endif
-
        msg_close_msg_handle(&msg_handle);
 
-       g_free(rcv_msg_type);
        g_free(rcv_msg_id);
+       g_free(rcv_msg_type);
 
        MSG_MGR_END();
 }
@@ -128,13 +111,23 @@ void _outgoing_msg_func(app_control_h app_control)
        MSG_MGR_BEGIN();
 
        int ret = 0;
+       char *sent_msg_type = NULL;
        char *sent_msg_id = NULL;
 
-       ret = app_control_get_extra_data(app_control, EVENT_KEY_MSG_ID, &sent_msg_id);
-       if (ret != APP_CONTROL_ERROR_NONE || sent_msg_id == NULL)
+       ret = app_control_get_extra_data(app_control, EVENT_KEY_OUT_MSG_ID, &sent_msg_id);
+       if (ret != APP_CONTROL_ERROR_NONE || sent_msg_id == NULL) {
+               MSG_MGR_ERR("app_control_get_extra_data failed");
                return;
+       }
 
-       MSG_MGR_INFO("sent_msg_id(%s)", sent_msg_id);
+       ret = app_control_get_extra_data(app_control, EVENT_KEY_OUT_MSG_TYPE, &sent_msg_type);
+       if (ret != APP_CONTROL_ERROR_NONE || sent_msg_type == NULL) {
+               MSG_MGR_ERR("app_control_get_extra_data failed");
+               g_free(sent_msg_id);
+               return;
+       }
+
+       MSG_MGR_INFO("sent_msg_type(%s) sent_msg_id(%s)", sent_msg_type, sent_msg_id);
 
        int msg_err = MSG_SUCCESS;
        msg_message_id_t msg_id = atoi(sent_msg_id);
@@ -176,6 +169,7 @@ void _outgoing_msg_func(app_control_h app_control)
        msg_close_msg_handle(&msg_handle);
 
        g_free(sent_msg_id);
+       g_free(sent_msg_type);
 
        MSG_MGR_END();
 }
@@ -189,82 +183,43 @@ void service_app_control(app_control_h app_control, void *data)
 {
        MSG_MGR_INFO("service_app_control called");
 
-       //check "launch on event"
        int ret = 0;
-       const char *incoming_event_uri = "event://tizen.system.event.incoming_msg";
-       const char *outgoing_event_uri = "event://tizen.system.event.outgoing_msg";
        char *operation = NULL;
-       char *uri = NULL;
+       char *cmd = NULL;
 
        ret = app_control_get_operation(app_control, &operation);
        if (ret == APP_CONTROL_ERROR_NONE && operation) {
-               if (g_strcmp0(operation, APP_CONTROL_OPERATION_LAUNCH_ON_EVENT) == 0) {
-                       /* launch by system event */
-                       ret = app_control_get_uri(app_control, &uri);
-                       if (ret == APP_CONTROL_ERROR_NONE && uri) {
-                               if (g_strcmp0(uri, incoming_event_uri) == 0) {
-                                       _incoming_msg_func(app_control);
-                               } else if (g_strcmp0(uri, outgoing_event_uri) == 0) {
-                                       _outgoing_msg_func(app_control);
-                               }
-                               g_free(uri);
-                       }
-               } else if (g_strcmp0(operation, APP_CONTROL_OPERATION_DEFAULT) == 0) {
-                       /* launch by default */
-                       char *cmd;
+               MSG_MGR_DEBUG("operation [%s]", operation);
+
+               if (g_strcmp0(operation, APP_CONTROL_OPERATION_DEFAULT) == 0) {
                        ret = app_control_get_extra_data(app_control, "cmd", &cmd);
                        if (ret == APP_CONTROL_ERROR_NONE && cmd) {
-                               if (g_strcmp0(cmd, "refresh") == 0)
+                               MSG_MGR_DEBUG("cmd [%s]", cmd);
+
+                               if (g_strcmp0(cmd, "incoming_msg") == 0) {
+                                       _incoming_msg_func(app_control);
+                               } else if (g_strcmp0(cmd, "outgoing_msg") == 0) {
+                                       _outgoing_msg_func(app_control);
+                               } else if (g_strcmp0(cmd, "refresh") == 0) {
                                        _refresh_noti_func(app_control);
+                               }
 
                                g_free(cmd);
                        }
                }
-
                g_free(operation);
        }
 
        return;
 }
 
-static void
-service_app_lang_changed(app_event_info_h event_info, void *user_data)
-{
-       /*APP_EVENT_LANGUAGE_CHANGED*/
-}
-
-static void
-service_app_region_changed(app_event_info_h event_info, void *user_data)
-{
-       /*APP_EVENT_REGION_FORMAT_CHANGED*/
-}
-
-static void
-service_app_low_battery(app_event_info_h event_info, void *user_data)
-{
-       /*APP_EVENT_LOW_BATTERY*/
-}
-
-static void
-service_app_low_memory(app_event_info_h event_info, void *user_data)
-{
-       /*APP_EVENT_LOW_MEMORY*/
-}
-
 int main(int argc, char* argv[])
 {
-       char ad[50] = {0,};
-       service_app_lifecycle_callback_s event_callback;
-       app_event_handler_h handlers[5] = {NULL, };
+       service_app_lifecycle_callback_s event_callback = {0,};
 
        event_callback.create = service_app_create;
        event_callback.terminate = service_app_terminate;
        event_callback.app_control = service_app_control;
 
-       service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad);
-       service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad);
-       service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
-       service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
-
-       return service_app_main(argc, argv, &event_callback, ad);
+       return service_app_main(argc, argv, &event_callback, NULL);
 }
index 7b15b0d..98a5607 100644 (file)
@@ -4,10 +4,6 @@
     <service-application appid="org.tizen.msg-manager" auto-restart="false" exec="msg-manager" multiple="false" nodisplay="true" on-boot="false" taskmanage="false" type="capp">
         <label>msg-manager</label>
         <icon>msg-manager.png</icon>
-        <app-control>
-            <operation name="http://tizen.org/appcontrol/operation/launch_on_event"/>
-            <uri name="event://tizen.system.event.incoming_msg"/>
-        </app-control>
     </service-application>
     <privileges>
         <privilege>http://tizen.org/privilege/message.read</privilege>
index e0d68b9..3c41330 100755 (executable)
@@ -25,6 +25,7 @@ BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(badge)
 BuildRequires: pkgconfig(bundle)
 BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-appfw-package-manager)
 BuildRequires: pkgconfig(capi-content-media-content)
 BuildRequires: pkgconfig(capi-media-image-util)
 BuildRequires: pkgconfig(capi-media-metadata-extractor)
@@ -51,6 +52,7 @@ BuildRequires: pkgconfig(iniparser)
 BuildRequires: pkgconfig(json-glib-1.0)
 BuildRequires: pkgconfig(lbs-dbus)
 BuildRequires: pkgconfig(libcurl)
+BuildRequires: pkgconfig(libsystemd-login)
 BuildRequires: pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(libxml-2.0)
 BuildRequires: pkgconfig(libwbxml2)
index 35a7fbe..2c63f6a 100755 (executable)
@@ -36,7 +36,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0)
+pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0 bundle eventsystem aul)
 
 FOREACH(flag ${sms_plugin_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 78b9b42..2de05f2 100755 (executable)
 #include <errno.h>
 #include <time.h>
 
+#include <aul.h>
+#include <bundle.h>
+#include <eventsystem.h>
+
 #include "MsgDebug.h"
 #include "MsgUtilFile.h"
 #include "MsgUtilFunction.h"
@@ -457,6 +461,26 @@ void SmsPluginEventHandler::handleSentStatus(msg_network_status_t NetStatus)
                                MSG_DEBUG("Add phone log");
                                MsgAddPhoneLog(&(sentInfo.reqInfo.msgInfo));
                                sentInfo.reqInfo.msgInfo.folderId = MSG_SENTBOX_ID;
+                               /* Send system event */
+                               bundle *b = NULL;
+                               b = bundle_create();
+                               if (b) {
+                                       if (sentInfo.reqInfo.msgInfo.msgType.mainType == MSG_SMS_TYPE)
+                                               bundle_add_str(b, EVT_KEY_OUT_MSG_TYPE, EVT_VAL_SMS);
+                                       else
+                                               bundle_add_str(b, EVT_KEY_OUT_MSG_TYPE, EVT_VAL_MMS);
+
+                                       char msgId[MSG_EVENT_MSG_ID_LEN] = {0, };
+                                       snprintf(msgId, sizeof(msgId), "%u", sentInfo.reqInfo.msgInfo.msgId);
+                                       bundle_add_str(b, EVT_KEY_OUT_MSG_ID, msgId);
+                                       eventsystem_send_system_event(SYS_EVENT_OUTGOING_MSG, b);
+                                       bundle_add_str(b, "cmd", "outgoing_msg");
+                                       int ret = aul_launch_app_for_uid("org.tizen.msg-manager", b, msg_get_login_user());
+                                       if (ret <= 0) {
+                                               MSG_DEBUG("aul_launch_app_for_uid() is failed : %d", ret);
+                                       }
+                                       bundle_free(b);
+                               }
                        } else {
                                sentInfo.reqInfo.msgInfo.bRead = false;
                        }
index 5ecebab..d5e1a0d 100755 (executable)
@@ -42,7 +42,7 @@ INCLUDE_DIRECTORIES(
 )
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0 capi-telephony)
+pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0 capi-telephony bundle eventsystem aul)
 
 FOREACH(flag ${sms_plugin_pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 78f990a..985dccf 100755 (executable)
 #include <stdlib.h>
 #include <errno.h>
 
+#include <aul.h>
+#include <bundle.h>
+#include <eventsystem.h>
+
 #include "MsgDebug.h"
 #include "MsgUtilFile.h"
 #include "MsgUtilFunction.h"
@@ -95,6 +99,26 @@ void SmsPluginEventHandler::handleSentStatus(msg_network_status_t NetStatus)
                                MsgAddPhoneLog(&(sentInfo.reqInfo.msgInfo));
 #endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */
                                sentInfo.reqInfo.msgInfo.folderId = MSG_SENTBOX_ID; /* It should be set after adding phone log. */
+                               /* Send system event */
+                               bundle *b = NULL;
+                               b = bundle_create();
+                               if (b) {
+                                       if (sentInfo.reqInfo.msgInfo.msgType.mainType == MSG_SMS_TYPE)
+                                               bundle_add_str(b, EVT_KEY_OUT_MSG_TYPE, EVT_VAL_SMS);
+                                       else
+                                               bundle_add_str(b, EVT_KEY_OUT_MSG_TYPE, EVT_VAL_MMS);
+
+                                       char msgId[MSG_EVENT_MSG_ID_LEN] = {0, };
+                                       snprintf(msgId, sizeof(msgId), "%u", sentInfo.reqInfo.msgInfo.msgId);
+                                       bundle_add_str(b, EVT_KEY_OUT_MSG_ID, msgId);
+                                       eventsystem_send_system_event(SYS_EVENT_OUTGOING_MSG, b);
+                                       bundle_add_str(b, "cmd", "outgoing_msg");
+                                       int ret = aul_launch_app_for_uid("org.tizen.msg-manager", b, msg_get_login_user());
+                                       if (ret <= 0) {
+                                               MSG_DEBUG("aul_launch_app_for_uid() is failed : %d", ret);
+                                       }
+                                       bundle_free(b);
+                               }
                        } else {
                                sentInfo.reqInfo.msgInfo.bRead = false;
                        }
index b26fa27..276172d 100755 (executable)
@@ -47,9 +47,9 @@ INCLUDE_DIRECTORIES(
 INCLUDE(FindPkgConfig)
 
 IF(_MSG_WEARABLE_PROFILE)
-SET(PKG_MODULES glib-2.0 vconf dlog libxml-2.0 storage json-glib-1.0 capi-system-info capi-media-thumbnail-util capi-media-image-util capi-content-media-content aul sqlite3 capi-media-metadata-extractor icu-uc)
+SET(PKG_MODULES glib-2.0 vconf dlog libxml-2.0 storage json-glib-1.0 capi-system-info capi-media-thumbnail-util capi-media-image-util capi-content-media-content aul sqlite3 capi-media-metadata-extractor icu-uc libsystemd-login)
 ELSE()
-SET(PKG_MODULES glib-2.0 vconf contacts-service2 dlog libxml-2.0 storage json-glib-1.0 capi-system-info capi-media-thumbnail-util capi-media-image-util capi-content-media-content aul sqlite3 capi-media-metadata-extractor icu-uc)
+SET(PKG_MODULES glib-2.0 vconf contacts-service2 dlog libxml-2.0 storage json-glib-1.0 capi-system-info capi-media-thumbnail-util capi-media-image-util capi-content-media-content aul sqlite3 capi-media-metadata-extractor icu-uc libsystemd-login)
 ENDIF()
 pkg_check_modules(utils_pkgs REQUIRED ${PKG_MODULES})
 
index 09482ef..9ca6cc8 100755 (executable)
@@ -15,6 +15,7 @@
 */
 
 #include <gio/gio.h>
+#include <systemd/sd-login.h>
 
 #include "MsgDebug.h"
 #include "MsgContact.h"
@@ -1175,6 +1176,51 @@ gchar * msg_replace_non_ascii_char(const gchar *pszText, gunichar replacementCha
        return res;
 }
 
+
+static int __find_login_user(uid_t *uid)
+{
+       uid_t *uids = NULL;
+       char *state = NULL;
+
+       int uids_len = sd_get_uids(&uids);
+       if (uids_len <= 0)
+               return -1;
+
+       for (int i = 0; i < uids_len; i++) {
+               if (sd_uid_get_state(uids[i], &state) < 0) {
+                       free(uids);
+                       return -1;
+               } else {
+                       if (g_strcmp0(state, "online") == 0) {
+                               *uid = uids[i];
+                               free(uids);
+                               free(state);
+                               return 0;
+                       }
+               }
+
+               free(state);
+       }
+
+       free(uids);
+       return -1;
+}
+
+
+uid_t msg_get_login_user()
+{
+       uid_t uid = -1;
+
+       if (__find_login_user(&uid) < 0) {
+               MSG_WARN("Cannot find login user");
+       }
+
+       MSG_DEBUG("login user id [%d]", uid);
+
+       return uid;
+}
+
+
 void MsgDbusInit()
 {
        MSG_DEBUG();