#include <msg-manager-debug.h>
#include <msg-manager-notification.h>
#include <msg-manager-sound.h>
+#include <msg-manager-profile.h>
#define EMAIL_AT '@'
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};
/*==================================================================================================
/*==================================================================================================
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)
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);
}
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;
}
/* 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");
}
}
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 {
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 {
}
/* 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");
}
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 {
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);
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");
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
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");
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);
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);
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);
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;
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)
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;
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 {
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);
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);