diff options
author | Jeesun Kim <iamjs.kim@samsung.com> | 2017-07-06 14:43:29 +0900 |
---|---|---|
committer | Jeesun Kim <iamjs.kim@samsung.com> | 2017-07-06 15:00:17 +0900 |
commit | 090e7fee07666d26c478a7902e07686db4bb3b59 (patch) | |
tree | 7969c4b94e19a24e0d3aa244a68cd8973cd8548e | |
parent | f049bb912d33ef88681f92ea9498dac39945d54d (diff) | |
download | msg-service-090e7fee07666d26c478a7902e07686db4bb3b59.tar.gz msg-service-090e7fee07666d26c478a7902e07686db4bb3b59.tar.bz2 msg-service-090e7fee07666d26c478a7902e07686db4bb3b59.zip |
app name could be changed depending on profilesubmit/tizen/20170707.010432accepted/tizen/unified/20170707.154604
Signed-off-by: Jeesun Kim <iamjs.kim@samsung.com>
Change-Id: I8d4f9904434e941125649f46f0abab0ae7d3d3f7
-rw-r--r-- | manager/inc/msg-manager-notification.h | 1 | ||||
-rw-r--r-- | manager/inc/msg-manager-profile.h | 76 | ||||
-rw-r--r-- | manager/src/msg-manager-notification.cpp | 84 |
3 files changed, 131 insertions, 30 deletions
diff --git a/manager/inc/msg-manager-notification.h b/manager/inc/msg-manager-notification.h index edab972..82199c1 100644 --- a/manager/inc/msg-manager-notification.h +++ b/manager/inc/msg-manager-notification.h @@ -40,6 +40,7 @@ #define MSG_MGR_APP_ID "org.tizen.msg-manager" #define MSG_DEFAULT_APP_ID "org.tizen.message" +#define MSG_WEARABLE_APP_ID "org.tizen.w-message" #define MSG_QUICKPANEL_APP_ID "org.tizen.quickpanel" #define MSG_CALL_APP_ID "org.tizen.call-ui" #define MSG_SETTING_APP_ID "org.tizen.setting" diff --git a/manager/inc/msg-manager-profile.h b/manager/inc/msg-manager-profile.h new file mode 100644 index 0000000..e777420 --- /dev/null +++ b/manager/inc/msg-manager-profile.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef __MSG_MGR_PROFILE_H__ +#define __MSG_MGR_PROFILE_H__ + +#include <stdlib.h> +#include <system_info.h> + +typedef enum { + _PROFILE_UNKNOWN = 0, + _PROFILE_MOBILE = 0x1, + _PROFILE_WEARABLE = 0x2, + _PROFILE_TV = 0x4, + _PROFILE_IVI = 0x8, + _PROFILE_COMMON = 0x10, +} tizen_profile_t; + +/* For optimization, make this extern and define in a shared C file */ +extern tizen_profile_t profile; + +/* Accessing system info */ +int system_info_get_platform_string(const char *key, char **value); + +static inline tizen_profile_t get_tizen_profile() +{ + char *profileName = NULL; + + if (__builtin_expect(profile != _PROFILE_UNKNOWN, 1)) + return profile; + + system_info_get_platform_string("http://tizen.org/feature/profile", &profileName); + + /* To pass the checking of g_ir */ + if (!profileName) + return _PROFILE_UNKNOWN; + + switch (*profileName) { + case 'm': + case 'M': + profile = _PROFILE_MOBILE; + break; + case 'w': + case 'W': + profile = _PROFILE_WEARABLE; + break; + case 't': + case 'T': + profile = _PROFILE_TV; + break; + case 'i': + case 'I': + profile = _PROFILE_IVI; + break; + default: // common or unknown ==> ALL ARE COMMON. + profile = _PROFILE_COMMON; + } + free(profileName); + + return profile; +} +#endif /*__MSG_MGR_PROFILE_H__ */ + diff --git a/manager/src/msg-manager-notification.cpp b/manager/src/msg-manager-notification.cpp index f1bc3ad..e51b00a 100644 --- a/manager/src/msg-manager-notification.cpp +++ b/manager/src/msg-manager-notification.cpp @@ -45,6 +45,7 @@ #include <msg-manager-debug.h> #include <msg-manager-notification.h> #include <msg-manager-sound.h> +#include <msg-manager-profile.h> #define EMAIL_AT '@' @@ -57,6 +58,8 @@ static GList *msg_report_notification_list = NULL; static bool is_init = false; extern msg_handle_t msg_handle; int g_alarmId = 0; +tizen_profile_t profile = _PROFILE_UNKNOWN; +char g_app_id[32] = {0}; /*================================================================================================== @@ -172,6 +175,27 @@ char *get_translate_text(const char *pkg_name, const char *locale_dir, const cha /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ +char *_get_app_id(void) +{ + if ('\0' != *g_app_id) + return g_app_id; + + char *app_id = NULL; + switch (get_tizen_profile()) { + case _PROFILE_WEARABLE: + app_id = MSG_WEARABLE_APP_ID; + break; + case _PROFILE_MOBILE: + default: + app_id = MSG_DEFAULT_APP_ID; + break; + } + snprintf(g_app_id, sizeof(g_app_id), "%s", app_id); + MSG_MGR_ERR("app id [%s]", g_app_id); + + return g_app_id; +} + bool _is_valid_email(char *pAddress) { if (!pAddress || pAddress[0] == 0) @@ -639,7 +663,7 @@ void MsgMgrDeleteNotification(msg_mgr_notification_type_t noti_type, int simInde MSG_MGR_DEBUG("deleted notification ID = [%d] Type = [%d]", notiId, noti_type); if (notiId > 0) - noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, notiId); + noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, notiId); } else { MSG_MGR_DEBUG("No matching type [%d]", noti_type); @@ -688,7 +712,7 @@ int MsgMgrDeleteSentReadReportNotification() } if (readReportSentNotiId > 0) { - noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, readReportSentNotiId); + noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, readReportSentNotiId); if (noti_err != 0) { MSG_MGR_DEBUG("notification_delete_by_priv_id() fail [%d]", noti_err); return -1; @@ -825,7 +849,7 @@ void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info) } /* set pkg name */ - noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID); + noti_err = notification_set_pkgname(noti_h, _get_app_id()); if (noti_err != NOTIFICATION_ERROR_NONE) { MSG_MGR_DEBUG("Fail to notification_set_pkgname"); } @@ -1104,7 +1128,7 @@ void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info) } char *msg_icon_path = NULL; - if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) { + if (getAppIcon(_get_app_id(), &msg_icon_path) == 0) { setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path); g_free(msg_icon_path); } else { @@ -1174,7 +1198,7 @@ void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info) break; case MSG_MGR_NOTI_TYPE_STORAGE_FULL: { char *msg_icon_path = NULL; - if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) { + if (getAppIcon(_get_app_id(), &msg_icon_path) == 0) { setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, msg_icon_path); g_free(msg_icon_path); } else { @@ -1230,7 +1254,7 @@ void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info) } /* set pkg name */ - noti_err = notification_set_pkgname(noti_h, MSG_DEFAULT_APP_ID); + noti_err = notification_set_pkgname(noti_h, _get_app_id()); if (noti_err != NOTIFICATION_ERROR_NONE) { MSG_MGR_DEBUG("Fail to notification_set_pkgname"); } @@ -1317,7 +1341,7 @@ void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info) setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NO_CONTACT_PROFILE_ICON_PATH); char *msg_icon_path = NULL; - if (getAppIcon(MSG_DEFAULT_APP_ID, &msg_icon_path) == 0) { + if (getAppIcon(_get_app_id(), &msg_icon_path) == 0) { setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path); g_free(msg_icon_path); } else { @@ -1350,7 +1374,7 @@ int MsgMgrInsertDeliveryReportInstantNotification(msg_mgr_notification_type_t no MSG_MGR_BEGIN(); notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI); - notification_set_pkgname(noti, MSG_DEFAULT_APP_ID); + notification_set_pkgname(noti, _get_app_id()); setTextDomain(noti); setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE); @@ -1504,7 +1528,7 @@ void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info createServiceHandle(¬i_info->active_noti_svc_h[2]); if (noti_info->active_noti_svc_h[2]) { - setServicePackageName(noti_info->active_noti_svc_h[2], MSG_DEFAULT_APP_ID); + setServicePackageName(noti_info->active_noti_svc_h[2], _get_app_id()); MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id); addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg"); @@ -1903,7 +1927,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage) if (!isForInstantMessage) { /* No unread message. */ if (noti_info->id > 0) { - noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id); + noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, noti_info->id); if (noti_err != NOTIFICATION_ERROR_NONE) { MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); } @@ -2039,7 +2063,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage) if (!isForInstantMessage) { if (noti_info->id > 0 && noti_info->count == 1) { - noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id); + noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, noti_info->id); if (noti_err != NOTIFICATION_ERROR_NONE) { MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); } @@ -2131,7 +2155,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage) if (!isForInstantMessage) { /* No unread message. */ if (noti_info->id > 0) { - noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id); + noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, noti_info->id); if (noti_err != NOTIFICATION_ERROR_NONE) { MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); } @@ -2229,7 +2253,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage) if (!isForInstantMessage) { /* No unread message. */ if (noti_info->id > 0) { - noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id); + noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, noti_info->id); if (noti_err != NOTIFICATION_ERROR_NONE) { MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); } @@ -2327,7 +2351,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage) if (!isForInstantMessage) { if (noti_info->id > 0 && noti_info->count == 1) { - noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id); + noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, noti_info->id); if (noti_err != NOTIFICATION_ERROR_NONE) { MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); } @@ -2345,7 +2369,7 @@ int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage) if (!isForInstantMessage) { /* No unread message. */ if (noti_info->id > 0) { - noti_err = notification_delete_by_priv_id(MSG_DEFAULT_APP_ID, NOTIFICATION_TYPE_NOTI, noti_info->id); + noti_err = notification_delete_by_priv_id(_get_app_id(), NOTIFICATION_TYPE_NOTI, noti_info->id); if (noti_err != NOTIFICATION_ERROR_NONE) { MSG_MGR_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); } @@ -2652,7 +2676,7 @@ void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_ snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal); if (noti_info->msg_id > 0) { - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + setServiceAppId(noti_info->svc_h, _get_app_id()); addServiceExtraData(noti_info->svc_h, "type", "new_msg"); addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal); @@ -2726,7 +2750,7 @@ void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_ } if (noti_info->msg_id > 0) { - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + setServiceAppId(noti_info->svc_h, _get_app_id()); addServiceExtraData(noti_info->svc_h, "type", "new_msg"); addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); addServiceExtraData(noti_info->svc_h, "address", msg_info->addressVal); @@ -2759,7 +2783,7 @@ void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_ noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; } - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + setServiceAppId(noti_info->svc_h, _get_app_id()); addServiceExtraData(noti_info->svc_h, "type", "new_msg"); addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); addServiceExtraData(noti_info->svc_h, "http://tizen.org/appcontrol/data/notification", "new_message"); @@ -2797,7 +2821,7 @@ void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_ noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; } - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + setServiceAppId(noti_info->svc_h, _get_app_id()); addServiceExtraData(noti_info->svc_h, "type", "new_msg"); addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); @@ -2816,7 +2840,7 @@ void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_ noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; } - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + setServiceAppId(noti_info->svc_h, _get_app_id()); addServiceExtraData(noti_info->svc_h, "type", "new_msg"); addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); @@ -2832,7 +2856,7 @@ void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_ case MSG_MGR_NOTI_TYPE_FAILED: { noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + setServiceAppId(noti_info->svc_h, _get_app_id()); addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg"); addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); @@ -2842,7 +2866,7 @@ void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_ case MSG_MGR_NOTI_TYPE_SIM_FULL: { noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + setServiceAppId(noti_info->svc_h, _get_app_id()); addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting"); noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR; @@ -3097,7 +3121,7 @@ int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type) if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE) MSG_MGR_DEBUG("Fail to notification_set_display_applist"); - if (notification_set_pkgname(noti, MSG_DEFAULT_APP_ID) != NOTIFICATION_ERROR_NONE) + if (notification_set_pkgname(noti, _get_app_id()) != NOTIFICATION_ERROR_NONE) MSG_MGR_DEBUG("Fail to notification_set_pkgname"); if (notification_post(noti) != NOTIFICATION_ERROR_NONE) @@ -3131,10 +3155,10 @@ bool MsgMgrCheckNotificationSettingEnable() int err = NOTIFICATION_ERROR_NONE; - err = notification_setting_get_setting_by_package_name(MSG_DEFAULT_APP_ID, &setting); + err = notification_setting_get_setting_by_package_name(_get_app_id(), &setting); if (err != NOTIFICATION_ERROR_NONE || setting == NULL) { - MSG_MGR_ERR("getting setting handle for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err); + MSG_MGR_ERR("getting setting handle for [%s] is failed. err = %d", _get_app_id(), err); } else { msg_noti_enabled = true; @@ -3169,10 +3193,10 @@ bool MsgMgrCheckNotificationSettingEnable() bool is_msg_excepted = false; err = notification_setting_get_do_not_disturb_except(setting, &is_msg_excepted); if (err != NOTIFICATION_ERROR_NONE) { - MSG_MGR_ERR("getting do not disturb except status for [%s] is failed. err = %d", MSG_DEFAULT_APP_ID, err); + MSG_MGR_ERR("getting do not disturb except status for [%s] is failed. err = %d", _get_app_id(), err); msg_noti_enabled = false; } else { - MSG_MGR_INFO("do not disturb mode status for [%s] : %d", MSG_DEFAULT_APP_ID, is_msg_excepted); + MSG_MGR_INFO("do not disturb mode status for [%s] : %d", _get_app_id(), is_msg_excepted); msg_noti_enabled = (is_msg_excepted) ? true : false; } } else { @@ -3263,7 +3287,7 @@ int MsgMgrInsertBadge(unsigned int unreadMsgCnt) int err = BADGE_ERROR_NONE; bool exist = false; - err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist); + err = badge_is_existing(_get_app_id(), &exist); if (err != BADGE_ERROR_NONE) { MSG_MGR_ERR("Fail to badge_is_existing : %d", err); @@ -3272,14 +3296,14 @@ int MsgMgrInsertBadge(unsigned int unreadMsgCnt) if (!exist) { /* create badge */ - err = badge_add(MSG_DEFAULT_APP_ID); + err = badge_add(_get_app_id()); if (err != BADGE_ERROR_NONE) { MSG_MGR_ERR("Fail to badge_add : %d", err); return -1; } } - err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt); + err = badge_set_count(_get_app_id(), unreadMsgCnt); if (err != BADGE_ERROR_NONE) { MSG_MGR_ERR("Fail to badge_set_count : %d", err); |