diff options
40 files changed, 4937 insertions, 4025 deletions
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index d27d430..d2facf8 100755 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -15,7 +15,6 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -O2 -g -Wall") ########################################################## SET(EXTERNALS-SRCS - ${CMAKE_SOURCE_DIR}/externals/MsgSoundPlayer.cpp ${CMAKE_SOURCE_DIR}/externals/MsgNotificationWrapper.cpp ${CMAKE_SOURCE_DIR}/externals/MsgSpamFilter.cpp ${CMAKE_SOURCE_DIR}/externals/MsgLbs.cpp @@ -32,7 +31,7 @@ INCLUDE_DIRECTORIES( ) INCLUDE(FindPkgConfig) -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) +pkg_check_modules(externals_pkgs REQUIRED glib-2.0 alarm-service notification iniparser lbs-dbus feedback capi-system-device motion) FOREACH(flag ${externals_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/externals/MsgNotificationWrapper.cpp b/externals/MsgNotificationWrapper.cpp index 1b4a5f8..108d3bf 100755 --- a/externals/MsgNotificationWrapper.cpp +++ b/externals/MsgNotificationWrapper.cpp @@ -16,36 +16,19 @@ #include "MsgDebug.h" -#include "MsgCppTypes.h" -#include "MsgDrmWrapper.h" -#include "MsgContact.h" -#include "MsgStorageTypes.h" -#include "MsgUtilFile.h" #include "MsgUtilFunction.h" -#include "MsgUtilStorage.h" -#include "MsgAlarm.h" #include "MsgGconfWrapper.h" #include "MsgNotificationWrapper.h" -#include "MsgSoundPlayer.h" #include "MsgDevicedWrapper.h" -#include <libintl.h> -#include <locale.h> -#include <stdarg.h> extern "C" { -#include <bundle_internal.h> -#include <app_control_internal.h> +#include <bundle.h> #ifndef MSG_WEARABLE_PROFILE -#include <notification_list.h> -#include <notification_text_domain.h> #include <notification_internal.h> #include <notification_status.h> #include <notification_setting.h> #include <notification_setting_internal.h> -#include <feedback.h> -#include <badge_internal.h> -#include <package_manager.h> #endif /* MSG_WEARABLE_PROFILE */ } @@ -55,105 +38,21 @@ extern "C" /* VARIABLES AND STRUCTURES */ /*======================================================================================*/ -int g_alarmId = 0; -bool bFeedbackInit; - -GList *msg_report_notification_list; - - -typedef struct _msg_noti_info_s +typedef struct _del_noti_info_s { msg_notification_type_t type; - int id; - int layout; - int count; - int senderCount; - time_t time; - char sender[MSG_NOTI_TEXT_LEN_S]; - char text[MSG_NOTI_TEXT_LEN]; - char number[MSG_NOTI_TEXT_LEN_S]; - char imagePath[MAX_IMAGE_PATH_LEN + 1]; /**< Indicates the image path of contact. */ - int applist; - app_control_h svc_h; - app_control_h active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM]; - msg_message_id_t msg_id; - unsigned char extra_data; int sim_idx; - int active_noti_button_num; - int active_media_cnt; - int active_media_size; - MSG_SUB_TYPE_T active_subtype; /**< to distinguish cb, push message */ - char active_sender[MSG_NOTI_TEXT_LEN_S]; - char active_subject[MSG_NOTI_TEXT_LEN_S]; - char active_text[MSG_NOTI_TEXT_LEN]; -}MSG_NOTI_INFO_S; - -typedef struct _report_notification_s -{ - int priv_id; - char addressVal[MAX_ADDRESS_VAL_LEN+1]; -}report_notification_s; +}DEL_NOTI_INFO_S; + /*======================================================================================*/ /* FUNCTION DEFINE */ /*======================================================================================*/ -notification_h getHandle(int *noti_id); - int getPrivId(msg_notification_type_t noti_type, int sim_idx); void updatePrivId(msg_notification_type_t noti_type, int noti_id, int sim_idx); -void createInfoData(MSG_NOTI_INFO_S *noti_info, MSG_MESSAGE_INFO_S *msg_info); /* For addNoti() */ -void createInfoData(MSG_NOTI_INFO_S *noti_info, msg_active_notification_type_t active_noti); /* For refreshNoti() */ -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); -void setTextDomain(notification_h noti_h, msg_notification_type_t noti_type); -void setText(notification_h noti_h, MSG_NOTI_INFO_S *noti_info); -void setIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info); -void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail); -void setActiveNotification(notification_h noti_h, MSG_NOTI_INFO_S *noti_info); -void setActiveProperty(notification_h noti_h, MSG_NOTI_INFO_S *noti_info); -void setActiveText(notification_h noti_h, MSG_NOTI_INFO_S *noti_info); -void setActiveIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info); - -void setNotification(notification_h noti_h, MSG_NOTI_INFO_S *noti_info, bool bFeedback); - void MsgDeleteNotiCb(void *data); -void MsgRefreshNotiCb(void *data); - -bool isExistAddressInReportTable(const char *addr); - -/* Wrapper */ -void createServiceHandle(app_control_h *svc_h); -void setServiceAppId(app_control_h svc_h, const char* app_id); -void setServiceUri(app_control_h svc_h, const char* uri); -void setServiceOperation(app_control_h svc_h, const char* operation); -void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val); -void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val); -void setServicePackageName(app_control_h svc_h, const char* pkg_name); -void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data); - -void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir); -void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key); -void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time); -void setNotiTime(notification_h noti_h, time_t time); -void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path); -void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path); -void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path); -void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler); - - -/* Alarm */ -void MsgNotiSoundRepeatAlarmCB(int alarmId); -void MsgSoundCreateRepeatAlarm(int RepeatTime); -void MsgSoundSetRepeatAlarm(); - -void sendMsgReplyPopup(MSG_NOTI_INFO_S *noti_info); #endif /* MSG_WEARABLE_PROFILE */ @@ -265,258 +164,160 @@ msg_error_t MsgInsertNotification(MSG_MESSAGE_INFO_S *msg_info) msg_error_t MsgInsertOnlyActiveNotification(msg_notification_type_t noti_type, MSG_MESSAGE_INFO_S *msg_info) { MSG_BEGIN(); - - msg_error_t msg_err = MSG_SUCCESS; #ifndef MSG_WEARABLE_PROFILE - notification_h noti_h = NULL; - - MSG_NOTI_INFO_S noti_info = {0, }; + bundle *bundle_data = bundle_create(); - noti_info.type = noti_type; - noti_info.active_noti_button_num = 1; + bundle_add_str(bundle_data, "cmd", "insert_only_active_noti"); + if (noti_type == MSG_NOTI_TYPE_NORMAL) + bundle_add_str(bundle_data, "type", "normal"); + else if (noti_type == MSG_NOTI_TYPE_CLASS0) + bundle_add_str(bundle_data, "type", "class0"); - createActiveInfoData(¬i_info, msg_info); + msg_error_t err = msg_launch_app(MSG_MGR_APP_ID, bundle_data); - noti_h = notification_create(NOTIFICATION_TYPE_NOTI); - - setActiveNotification(noti_h, ¬i_info); - - clearInfoData(noti_h, ¬i_info); + bundle_free(bundle_data); #endif /* MSG_WEARABLE_PROFILE */ MSG_END(); - return msg_err; + return err; } msg_error_t MsgDeleteReportNotification(const char *addr) { MSG_BEGIN(); - - msg_error_t msg_err = MSG_SUCCESS; - #ifndef MSG_WEARABLE_PROFILE + bundle *bundle_data = bundle_create(); - notification_h noti_h = NULL; - bool bNotification = true; + bundle_add_str(bundle_data, "cmd", "del_report_noti"); + bundle_add_str(bundle_data, "address", addr); - MSG_NOTI_INFO_S noti_info; - memset(¬i_info, 0x00, sizeof(MSG_NOTI_INFO_S)); - - if (MsgSettingGetBool(MSG_SETTING_NOTIFICATION, &bNotification) != MSG_SUCCESS) { - MSG_DEBUG("MsgSettingGetBool is failed."); - } - - if (bNotification == false) { - MSG_DEBUG("Msg Alert notification is off."); - return msg_err; - } - - char normalAddr[MAX_ADDRESS_VAL_LEN+1]; - unsigned int list_length = g_list_length(msg_report_notification_list); - bool isDelete = false; - - MSG_DEBUG("list length [%d]", list_length); - - if (list_length > 0) { - GList *iter = g_list_first(msg_report_notification_list); - - while (iter != NULL) { - isDelete = false; - report_notification_s *info = (report_notification_s*)(iter->data); - if (info == NULL) { - MSG_DEBUG("info is NULL!"); - return MSG_ERR_UNKNOWN; - } - - MSG_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal); - - noti_h = notification_load(NULL, info->priv_id); - if (noti_h == NULL) { - MSG_DEBUG("notification with priv_id [%d] is NULL", info->priv_id); - isDelete = true; - } else { - memset(normalAddr, 0x00, sizeof(normalAddr)); - MsgConvertNumber(info->addressVal, normalAddr, sizeof(normalAddr)); - MSG_SEC_DEBUG("normalized number = %s", normalAddr); - - if (g_str_has_suffix(addr, normalAddr)) { - if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) { - MSG_SEC_DEBUG("delete report notification address [%s]", info->addressVal); - isDelete = true; - } else { - MSG_DEBUG("delete notification failed"); - } - } - - notification_free(noti_h); - noti_h = NULL; - } - - iter = g_list_next(iter); - - if (isDelete) { - msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info); - if (info) { - delete info; - info = NULL; - } - } - } - } + msg_error_t err = msg_launch_app(MSG_MGR_APP_ID, bundle_data); + bundle_free(bundle_data); #endif /* MSG_WEARABLE_PROFILE */ - MSG_END(); - return msg_err; + return err; } msg_error_t MsgAddReportNotification(msg_notification_type_t noti_type, MSG_MESSAGE_INFO_S *msg_info) { - msg_error_t msg_err = MSG_SUCCESS; - #ifndef MSG_WEARABLE_PROFILE - notification_h noti_h = NULL; - - MSG_NOTI_INFO_S noti_info; - memset(¬i_info, 0x00, sizeof(MSG_NOTI_INFO_S)); - - report_notification_s *info = new report_notification_s; - memset(info, 0x00, sizeof(report_notification_s)); - - noti_info.type = noti_type; - - createInfoData(¬i_info, msg_info); - - noti_h = getHandle(¬i_info.id); + bundle *bundle_data = bundle_create(); - if (noti_h == NULL) { - MSG_DEBUG("Notification handle is NULL"); - msg_err = MSG_ERR_NULL_POINTER; - goto __END_OF_REFRESH_NOTI; + bundle_add_str(bundle_data, "cmd", "add_report_noti"); + switch (noti_type) { + case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT: + bundle_add_str(bundle_data, "type", "sms_delivery"); + break; + case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT: + bundle_add_str(bundle_data, "type", "mms_delivery"); + break; + case MSG_NOTI_TYPE_MMS_READ_REPORT: + bundle_add_str(bundle_data, "type", "mms_read"); + break; + default: + break; } - setNotification(noti_h, ¬i_info, true); - - info->priv_id = noti_info.id; - snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressList->addressVal); - msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info); - MSG_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal); + char *msg_id = g_strdup_printf("%d", msg_info->msgId); + if (msg_id) { + bundle_add_str(bundle_data, "msg_id", msg_id); + g_free(msg_id); + } -__END_OF_REFRESH_NOTI : - clearInfoData(noti_h, ¬i_info); + msg_error_t err = msg_launch_app(MSG_MGR_APP_ID, bundle_data); + bundle_free(bundle_data); #endif /* MSG_WEARABLE_PROFILE */ - return msg_err; + return err; } + msg_error_t MsgRefreshNotification(msg_notification_type_t noti_type, bool bFeedback, msg_active_notification_type_t active_type) { - msg_error_t msg_err = MSG_SUCCESS; - #ifndef MSG_WEARABLE_PROFILE - notification_h noti_h = NULL; - bool bNotification = true; -/* bool bReplyPopup = false; */ - - MSG_NOTI_INFO_S noti_info; - memset(¬i_info, 0x00, sizeof(MSG_NOTI_INFO_S)); - - noti_info.type = noti_type; - - noti_info.id = getPrivId(noti_info.type, -1); + bundle *bundle_data = bundle_create(); - msg_err = getLatestMsgInfo(¬i_info, false); - - if (msg_err != MSG_SUCCESS) { - MSG_DEBUG("getLatestMsgInfo() err = [%d]", msg_err); - goto __END_OF_REFRESH_NOTI; - } - - if (active_type == MSG_ACTIVE_NOTI_TYPE_INSTANT) { - msg_err = MsgInsertInstantMessage(noti_type); - - if (msg_err != MSG_SUCCESS) { - MSG_DEBUG(" MsgInsertInstantMessage() err = [%d]", msg_err); - goto __END_OF_REFRESH_NOTI; - } - } - - if (MsgSettingGetBool(MSG_SETTING_NOTIFICATION, &bNotification) != MSG_SUCCESS) { - MSG_DEBUG("MsgSettingGetBool is failed."); - } - - if (bNotification == false) { - MSG_DEBUG("Msg Alert notification is off."); - goto __END_OF_REFRESH_NOTI; - } - - createInfoData(¬i_info, active_type); - - noti_h = getHandle(¬i_info.id); - - if (noti_h == NULL) { - MSG_DEBUG("Notification handle is NULL"); - msg_err = MSG_ERR_NULL_POINTER; - goto __END_OF_REFRESH_NOTI; + bundle_add_str(bundle_data, "cmd", "refresh_noti"); + switch (noti_type) { + case MSG_NOTI_TYPE_NORMAL: + bundle_add_str(bundle_data, "type", "normal"); + break; + case MSG_NOTI_TYPE_CB: + bundle_add_str(bundle_data, "type", "cb"); + break; + case MSG_NOTI_TYPE_SIM: + bundle_add_str(bundle_data, "type", "sim"); + break; + case MSG_NOTI_TYPE_FAILED: + bundle_add_str(bundle_data, "type", "failed"); + break; + default: + break; } - setNotification(noti_h, ¬i_info, bFeedback); - -#if 0 - if (MsgSettingGetBool(VCONFKEY_MESSAGE_POPUP_DISPLAY_ENABLE , &bReplyPopup) != MSG_SUCCESS) { - MSG_DEBUG("MsgSettingGetBool is failed."); + switch (active_type) { + case MSG_ACTIVE_NOTI_TYPE_NONE: + bundle_add_str(bundle_data, "active_type", "none"); + break; + case MSG_ACTIVE_NOTI_TYPE_ACTIVE: + bundle_add_str(bundle_data, "active_type", "active"); + break; + case MSG_ACTIVE_NOTI_TYPE_INSTANT: + bundle_add_str(bundle_data, "active_type", "instant"); + break; + default: + break; } - if (bReplyPopup == true && bFeedback == true && noti_info.type == MSG_NOTI_TYPE_NORMAL) { - MSG_DEBUG("Msg reply popup is on."); - sendMsgReplyPopup(¬i_info); - } -#endif + if (bFeedback) + bundle_add_str(bundle_data, "feedback", "true"); + else + bundle_add_str(bundle_data, "feedback", "false"); -__END_OF_REFRESH_NOTI : - clearInfoData(noti_h, ¬i_info); + msg_error_t err = msg_launch_app(MSG_MGR_APP_ID, bundle_data); + bundle_free(bundle_data); #endif /* MSG_WEARABLE_PROFILE */ - return msg_err; + return err; } msg_error_t MsgAddNotification(msg_notification_type_t noti_type, MSG_MESSAGE_INFO_S *msg_info) { - msg_error_t msg_err = MSG_SUCCESS; - #ifndef MSG_WEARABLE_PROFILE - notification_h noti_h = NULL; - - MSG_NOTI_INFO_S noti_info = {0, }; + bundle *bundle_data = bundle_create(); - noti_info.type = noti_type; - - createInfoData(¬i_info, msg_info); - - /* check mwi or voicemail count is 0 then skip add notification */ - if (noti_info.count == 0) { - MSG_DEBUG("Notification count is 0"); - msg_err = MSG_ERR_INVALID_MESSAGE; - goto __END_OF_ADD_NOTI; + bundle_add_str(bundle_data, "cmd", "add_noti"); + switch (noti_type) { + case MSG_NOTI_TYPE_VOICE_1: + bundle_add_str(bundle_data, "type", "voice1"); + break; + case MSG_NOTI_TYPE_VOICE_2: + bundle_add_str(bundle_data, "type", "voice2"); + break; + case MSG_NOTI_TYPE_MWI: + bundle_add_str(bundle_data, "type", "mwi"); + break; + case MSG_NOTI_TYPE_CLASS0: + bundle_add_str(bundle_data, "type", "class0"); + break; + default: + break; } - noti_h = getHandle(¬i_info.id); - - if (noti_h == NULL) { - MSG_DEBUG("Notification handle is NULL"); - msg_err = MSG_ERR_NULL_POINTER; - goto __END_OF_ADD_NOTI; + char *msg_id = g_strdup_printf("%d", msg_info->msgId); + if (msg_id) { + bundle_add_str(bundle_data, "msg_id", msg_id); + g_free(msg_id); } - setNotification(noti_h, ¬i_info, true); - -__END_OF_ADD_NOTI : - clearInfoData(noti_h, ¬i_info); + msg_error_t err = msg_launch_app(MSG_MGR_APP_ID, bundle_data); + bundle_free(bundle_data); #endif /* MSG_WEARABLE_PROFILE */ - return msg_err; + return err; } @@ -659,152 +460,65 @@ EXIT: return msg_noti_enabled; } -bool isExistAddressInReportTable(const char *addr) -{ - char sqlQuery[MAX_QUERY_LEN+1]; - char normalAddr[MAX_ADDRESS_VAL_LEN+1]; - MsgDbHandler *dbHandle = getDbHandle(); - int rowCnt = 0; - - memset(normalAddr, 0x00, sizeof(normalAddr)); - MsgConvertNumber(addr, normalAddr, sizeof(normalAddr)); - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_SMS_REPORT_TABLE_NAME, normalAddr); - if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) == MSG_SUCCESS) { - dbHandle->freeTable(); - return true; - } - - dbHandle->freeTable(); - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT * FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_REPORT_TABLE_NAME, normalAddr); - if (dbHandle->getTable(sqlQuery, &rowCnt, NULL) == MSG_SUCCESS) { - dbHandle->freeTable(); - return true; - } - - dbHandle->freeTable(); - - return false; -} - -void MsgInitReportNotiList() +msg_error_t MsgDeleteNoti(msg_notification_type_t noti_type, int simIndex) { - MSG_BEGIN(); - #ifndef MSG_WEARABLE_PROFILE - msg_report_notification_list = NULL; - - notification_h noti = NULL; - notification_list_h noti_list = NULL; - notification_list_h head_noti_list = NULL; - int noti_err = NOTIFICATION_ERROR_NONE; - bundle *b = NULL; - - noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("notification_get_list() is failed!!"); - return; - } - - head_noti_list = noti_list; - - while (noti_list != NULL) { - noti = notification_list_get_data(noti_list); - - char tempAddr[MAX_ADDRESS_VAL_LEN+1]; - memset(tempAddr, 0x00, sizeof(tempAddr)); - - noti_err = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &b); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("notification_get_excute_option() failed!!"); - break; - } - - const char *bundle_addr = bundle_get_val(b, "address"); - - if (bundle_addr != NULL) { - if (isExistAddressInReportTable(bundle_addr)) { - report_notification_s *info = new report_notification_s; - memset(info, 0x00, sizeof(report_notification_s)); - - notification_get_id(noti, NULL, &(info->priv_id)); - snprintf(info->addressVal, sizeof(info->addressVal), "%s", bundle_addr); + bool bNotiSvcReady = false; - msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info); - MSG_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal); - } - } + DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)calloc(1, sizeof(DEL_NOTI_INFO_S)); - noti_list = notification_list_get_next(noti_list); + if (delNotiInfo) { + delNotiInfo->type = noti_type; + delNotiInfo->sim_idx = simIndex; } - if (head_noti_list) - notification_free_list(head_noti_list); - -#endif /* MSG_WEARABLE_PROFILE */ - MSG_END(); -} - - -msg_error_t MsgInitNoti() -{ -#ifndef MSG_WEARABLE_PROFILE - bool bNotiSvcReady = false; - bNotiSvcReady = notification_is_service_ready(); if (bNotiSvcReady == true) { MSG_DEBUG("Notification server is available"); -#ifndef MSG_NOTI_INTEGRATION - MsgDeleteNotification(MSG_NOTI_TYPE_SIM, -1); -#endif - MsgRefreshAllNotification(false, true, MSG_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */ - MsgInitReportNotiList(); + MsgDeleteNotiCb((void *)delNotiInfo); } else { - MSG_DEBUG("Notification server is not available. Init is defered"); -#ifndef MSG_NOTI_INTEGRATION - MSG_NOTI_INFO_S *delNotiInfo = (MSG_NOTI_INFO_S *)calloc(1, sizeof(MSG_NOTI_INFO_S)); - if (delNotiInfo) { - delNotiInfo->type = MSG_NOTI_TYPE_SIM; - delNotiInfo->sim_idx = -1; - } + MSG_DEBUG("Notification server is not available. Delete is defered"); notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo); -#endif - notification_add_deferred_task(MsgRefreshNotiCb, (void *)NULL); } - #endif /* MSG_WEARABLE_PROFILE */ return MSG_SUCCESS; } -msg_error_t MsgDeleteNoti(msg_notification_type_t noti_type, int simIndex) +void MsgSoundPlayStart(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_SOUND_TYPE_T soundType) { + MSG_BEGIN(); #ifndef MSG_WEARABLE_PROFILE - bool bNotiSvcReady = false; - - MSG_NOTI_INFO_S *delNotiInfo = (MSG_NOTI_INFO_S *)calloc(1, sizeof(MSG_NOTI_INFO_S)); + bundle *bundle_data = bundle_create(); - if (delNotiInfo) { - delNotiInfo->type = noti_type; - delNotiInfo->sim_idx = simIndex; + bundle_add_str(bundle_data, "cmd", "sound_play_start"); + switch (soundType) { + case MSG_SOUND_PLAY_DEFAULT: + bundle_add_str(bundle_data, "type", "default"); + break; + case MSG_SOUND_PLAY_USER: + bundle_add_str(bundle_data, "type", "user"); + break; + case MSG_SOUND_PLAY_EMERGENCY: + bundle_add_str(bundle_data, "type", "emergency"); + break; + case MSG_SOUND_PLAY_VOICEMAIL: + bundle_add_str(bundle_data, "type", "voicemail"); + break; + default: + break; } - bNotiSvcReady = notification_is_service_ready(); + if (pAddrInfo && pAddrInfo->addressVal != '\0') + bundle_add_str(bundle_data, "address", pAddrInfo->addressVal); - if (bNotiSvcReady == true) { - MSG_DEBUG("Notification server is available"); - MsgDeleteNotiCb((void *)delNotiInfo); - } else { - MSG_DEBUG("Notification server is not available. Delete is defered"); - notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo); - } + msg_launch_app(MSG_MGR_APP_ID, bundle_data); + + bundle_free(bundle_data); #endif /* MSG_WEARABLE_PROFILE */ - return MSG_SUCCESS; + MSG_END(); } @@ -856,7 +570,7 @@ msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg MSG_DEBUG("MsgRefreshSimFullNoti err=[%d]", err); } } else { - MsgSoundPlayer::instance()->MsgSoundPlayStart(NULL, MSG_SOUND_PLAY_DEFAULT); + MsgSoundPlayStart(NULL, MSG_SOUND_PLAY_DEFAULT); } } @@ -865,61 +579,11 @@ msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg } -msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt) -{ #ifndef MSG_WEARABLE_PROFILE - MSG_DEBUG("Start to set badge to [%d].", unreadMsgCnt); - - int err = BADGE_ERROR_NONE; - bool exist = false; - - err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist); - - if (err != BADGE_ERROR_NONE) { - MSG_ERR("Fail to badge_is_existing : %d", err); - return MSG_ERR_UNKNOWN; - } - - if (!exist) { - /* create badge */ - err = badge_create(MSG_DEFAULT_APP_ID, "/usr/bin/msg-server"); - if (err != BADGE_ERROR_NONE) { - MSG_ERR("Fail to badge_new : %d", err); - return MSG_ERR_UNKNOWN; - } - } - - err = badge_set_count(MSG_DEFAULT_APP_ID, unreadMsgCnt); - - if (err != BADGE_ERROR_NONE) { - MSG_ERR("Fail to badge_set_count : %d", err); - return MSG_ERR_UNKNOWN; - } - -#endif /* MSG_WEARABLE_PROFILE */ - return MSG_SUCCESS; -} - -#ifndef MSG_WEARABLE_PROFILE - -void MsgRefreshNotiCb(void *data) -{ - MsgRefreshAllNotification(false, true, MSG_ACTIVE_NOTI_TYPE_INSTANT); - MsgInitReportNotiList(); - - if (data) { - free(data); - data = NULL; - } - - return; -} - - void MsgDeleteNotiCb(void *data) { if (data) { - MSG_NOTI_INFO_S *delNotiInfo = (MSG_NOTI_INFO_S *)data; + DEL_NOTI_INFO_S *delNotiInfo = (DEL_NOTI_INFO_S *)data; MsgDeleteNotification(delNotiInfo->type, delNotiInfo->sim_idx); @@ -931,32 +595,6 @@ void MsgDeleteNotiCb(void *data) } -notification_h getHandle(int *noti_id) -{ - notification_h noti_h = NULL; - - if (*noti_id > 0) { - MSG_DEBUG("Notification load"); - noti_h = notification_load(NULL, *noti_id); - if (noti_h == NULL) - MSG_DEBUG("notification_load is failed."); - } - - if (noti_h == NULL) { - MSG_DEBUG("Notification create"); - noti_h = notification_create(NOTIFICATION_TYPE_NOTI); - if (noti_h == NULL) { - MSG_DEBUG("notification_create is failed."); - return NULL; - } - - *noti_id = 0; - } - - return noti_h; -} - - int getPrivId(msg_notification_type_t noti_type, int sim_idx) { MSG_BEGIN(); @@ -1077,2187 +715,4 @@ void updatePrivId(msg_notification_type_t noti_type, int noti_id, int sim_idx) MSG_END(); } - -void createInfoData(MSG_NOTI_INFO_S *noti_info, msg_active_notification_type_t active_noti) -{ - MSG_BEGIN(); - - createServiceHandle(¬i_info->svc_h); - - switch (noti_info->type) { - case MSG_NOTI_TYPE_NORMAL: { - if (noti_info->count > 1) { - noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE; - } else { - noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; - } - - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_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"); - -#if 0 - bool bReplyPopup = false; - if (MsgSettingGetBool(VCONFKEY_MESSAGE_POPUP_DISPLAY_ENABLE , &bReplyPopup) != MSG_SUCCESS) { - MSG_DEBUG("MsgSettingGetBool is failed."); - } -#endif - noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER; - - if (noti_info->active_noti_button_num == 0) - noti_info->active_noti_button_num = 3; - break; - } - case MSG_NOTI_TYPE_CB: { - if (noti_info->count > 1) { - noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE; - } else { - noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; - } - - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); - addServiceExtraData(noti_info->svc_h, "type", "new_msg"); - addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); - - if (active_noti == MSG_ACTIVE_NOTI_TYPE_INSTANT) - noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK; - else - noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR; - - noti_info->active_noti_button_num = 1; - break; - } - case MSG_NOTI_TYPE_SIM: { - if (noti_info->count > 1) { - noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE; - } else { - noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; - } - - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); - addServiceExtraData(noti_info->svc_h, "type", "new_msg"); - addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); - - if (active_noti == MSG_ACTIVE_NOTI_TYPE_INSTANT) - noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK; - else - noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR; - - if (noti_info->active_noti_button_num == 0) - noti_info->active_noti_button_num = 3; - break; - } - case MSG_NOTI_TYPE_FAILED: { - noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; - - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); - addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg"); - addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); - - noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK; - break; - } - case MSG_NOTI_TYPE_SIM_FULL: { - noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; - - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); - addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting"); - - noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR; - break; - } - default: - break; - } - - if (active_noti != MSG_ACTIVE_NOTI_TYPE_ACTIVE) - noti_info->active_noti_button_num = 0; - - MSG_END(); -} - - -void createInfoData(MSG_NOTI_INFO_S *noti_info, MSG_MESSAGE_INFO_S *msg_info) -{ - MSG_BEGIN(); - - if (msg_info) { - noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx); - noti_info->msg_id = msg_info->msgId; - } else { - MSG_DEBUG("msg_info is NULL"); - return; - } - - noti_info->sim_idx = msg_info->sim_idx; - - createServiceHandle(¬i_info->svc_h); - char keyName[MAX_VCONFKEY_NAME_LEN]; - - switch (noti_info->type) { - case MSG_NOTI_TYPE_VOICE_1: - case MSG_NOTI_TYPE_VOICE_2: { - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx); - if (MsgSettingGetInt(keyName, &(noti_info->count)) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetInt() is failed"); - } - noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; - noti_info->time = msg_info->displayTime; - - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx); - char *voiceNumber = NULL; - if (MsgSettingGetString(keyName, &voiceNumber) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetString() is failed"); - } - memset(keyName, 0x00, sizeof(keyName)); - snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx); - char *voiceAlphaId = NULL; - if (MsgSettingGetString(keyName, &voiceAlphaId) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetString() is failed"); - } - char *dialNumber = NULL; - - MSG_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber); - - if (voiceNumber && strlen(voiceNumber)) - dialNumber = voiceNumber; - - if (voiceAlphaId && strlen(voiceAlphaId) > 0) { - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId); - } else if (dialNumber && strlen(dialNumber) > 0) { - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber); - } - - if (dialNumber && strlen(dialNumber) > 0) - snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber); - - if (noti_info->svc_h) { - setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL); - setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL); - - char slot_id[5] = {0, }; - snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1); - addServiceExtraData(noti_info->svc_h, "slot_id", slot_id); - } - - MSG_FREE(voiceNumber); - MSG_FREE(voiceAlphaId); - break; - } - case MSG_NOTI_TYPE_MWI: - case MSG_NOTI_TYPE_CLASS0: { - noti_info->count = 1; - noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; - noti_info->time = msg_info->displayTime; - - if (msg_info->addressList[0].displayName[0] == '\0') - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].addressVal); - else - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].displayName); - - snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressList[0].addressVal); - - snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText); - - if (noti_info->type == MSG_NOTI_TYPE_MWI) { - if (noti_info->svc_h) { - setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL); - setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL); - - char slot_id[5] = {0, }; - snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1); - addServiceExtraData(noti_info->svc_h, "slot_id", slot_id); - } - - } else { - setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0"); - addServiceExtraData(noti_info->svc_h, "type", "new_msg"); - addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); - } - break; - } - case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT: { - noti_info->count = 1; - noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; - noti_info->time = msg_info->displayTime; - noti_info->extra_data = msg_info->networkStatus; - -/* contacts-service is not used for gear */ -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - MSG_CONTACT_INFO_S contactInfo; - memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S)); - - if (MsgGetContactInfo(&(msg_info->addressList[0]), &contactInfo) != MSG_SUCCESS) { - MSG_WARN("MsgGetContactInfo() fail."); - } - - snprintf(msg_info->addressList[0].displayName, sizeof(msg_info->addressList[0].displayName), "%s", contactInfo.firstName); -#endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - - if (msg_info->addressList[0].displayName[0] == '\0') - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].addressVal); - else - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].displayName); - - snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressList[0].addressVal); - - if (noti_info->msg_id > 0) { - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_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->addressList[0].addressVal); - } - break; - } - case MSG_NOTI_TYPE_MMS_READ_REPORT: - case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT: { - noti_info->count = 1; - noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; - noti_info->time = msg_info->displayTime; - -/* contacts-service is not used for gear */ -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - MSG_CONTACT_INFO_S contactInfo; - memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S)); - - if (MsgGetContactInfo(&(msg_info->addressList[0]), &contactInfo) != MSG_SUCCESS) { - MSG_WARN("MsgGetContactInfo() fail."); - } - - snprintf(msg_info->addressList[0].displayName, sizeof(msg_info->addressList[0].displayName), "%s", contactInfo.firstName); -#endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - if (msg_info->addressList[0].displayName[0] == '\0') - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].addressVal); - else - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].displayName); - - if (msg_info->addressList[0].displayName[0] == '\0') - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].addressVal); - else - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressList[0].displayName); - - snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressList[0].addressVal); - - MsgDbHandler *dbhandler = getDbHandle(); - char sqlQuery[MAX_QUERY_LEN+1]; - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - int report_status_type; - int report_status_value; - - if (noti_info->type == MSG_NOTI_TYPE_MMS_READ_REPORT) { - report_status_type = MSG_REPORT_TYPE_READ; - } else { - report_status_type = MSG_REPORT_TYPE_DELIVERY; - } - - char *normalNum = NULL; - if (msg_info->addressList[0].addressVal[0] != '\0') { - normalNum = msg_normalize_number(msg_info->addressList[0].addressVal); - } - - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " - "STATUS " - "FROM %s " - "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE '%%%s';", - MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, normalNum); - - MSG_DEBUG("sqlQuery = [%s]", sqlQuery); - - if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) { - MSG_DEBUG("prepareQuery is failed"); - return; - } - - if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) { - report_status_value = dbhandler->columnInt(0); - MSG_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value); - } else { - MSG_DEBUG("DB Query Result Fail"); - dbhandler->finalizeQuery(); - return; - } - - dbhandler->finalizeQuery(); - - if (noti_info->msg_id > 0) { - setServiceAppId(noti_info->svc_h, MSG_DEFAULT_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->addressList[0].addressVal); - } - - noti_info->extra_data = (unsigned char)report_status_value; - break; - } - default: - MSG_DEBUG("No matching type [%d]", noti_info->type); - break; - } - - noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK; - MSG_END(); -} - - -void createActiveInfoData(MSG_NOTI_INFO_S *noti_info, MSG_MESSAGE_INFO_S *msg_info) -{ - MSG_BEGIN(); - - if (!msg_info) { - MSG_DEBUG("msg_info is NULL"); - return; - } - - noti_info->msg_id = msg_info->msgId; - noti_info->sim_idx = msg_info->sim_idx; - - switch (noti_info->type) { - case MSG_NOTI_TYPE_NORMAL: { - char *senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE); - snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr); - if (senderStr) { - free(senderStr); - senderStr = NULL; - } - break; - } - case MSG_NOTI_TYPE_CLASS0: { - if (msg_info->addressList[0].displayName[0] == '\0') - snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressList[0].addressVal); - else - snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressList[0].displayName); - - snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText); - break; - } - default: - MSG_DEBUG("No matching type [%d]", noti_info->type); - break; - } - - MSG_END(); -} - - -void clearInfoData(notification_h noti_h, MSG_NOTI_INFO_S *noti_info) -{ - MSG_BEGIN(); - - if (noti_h) { - notification_free(noti_h); - noti_h = NULL; - } - - if (noti_info->svc_h) { - app_control_destroy(noti_info->svc_h); - noti_info->svc_h = NULL; - } - - for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) { - if (noti_info->active_noti_svc_h[i]) { - app_control_destroy(noti_info->active_noti_svc_h[i]); - noti_info->active_noti_svc_h[i] = NULL; - } - } - - MSG_END(); -} - - -void setProperty(notification_h noti_h, MSG_NOTI_INFO_S *noti_info) -{ - MSG_BEGIN(); - - int noti_err = NOTIFICATION_ERROR_NONE; - - /* set layout */ - noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_set_layout : %d", noti_err); - } - - /* set led */ - noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_set_led."); - } - - /* set execute option */ - bundle *bundle_data = NULL; - bundle *reply_msg = NULL; - - app_control_to_bundle(noti_info->svc_h, &bundle_data); - - if (bundle_data == NULL) { - MSG_DEBUG("bundle is NULL"); - } - - /* set execute option and property */ - switch (noti_info->type) { - case MSG_NOTI_TYPE_NORMAL: { - if (noti_info->count > 1) { - notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data); - notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, NULL); - } else { - if (noti_info->svc_h) { /* overwrite bundle key "type" */ - /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */ - addServiceExtraData(noti_info->svc_h, "show_list", "list_show"); - - app_control_to_bundle(noti_info->svc_h, &reply_msg); - } - notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); - notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, reply_msg); - } - - notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE); - break; - } - case MSG_NOTI_TYPE_CB: - case MSG_NOTI_TYPE_SIM: { - if (noti_info->count > 1) { - notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data); - } else { - notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); - } - - notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY); - break; - } - case MSG_NOTI_TYPE_FAILED: { - notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); - notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE); - break; - } - case MSG_NOTI_TYPE_SIM_FULL: { - notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); - break; - } - case MSG_NOTI_TYPE_VOICE_1: - case MSG_NOTI_TYPE_VOICE_2: - case MSG_NOTI_TYPE_MWI: - case MSG_NOTI_TYPE_CLASS0: - case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT: - case MSG_NOTI_TYPE_MMS_READ_REPORT: - case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT: { - notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); - break; - } - default: - MSG_DEBUG("No matching type for notification_set_execute_option() [%d]", noti_info->type); - break; - } - - /* set applist */ - noti_err = notification_set_display_applist(noti_h, noti_info->applist); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_set_display_applist"); - } - - - MSG_END(); -} - - -void setTextDomain(notification_h noti_h, msg_notification_type_t noti_type) -{ - MSG_BEGIN(); - - setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR); - MSG_END(); -} - - -void setText(notification_h noti_h, MSG_NOTI_INFO_S *noti_info) -{ - MSG_BEGIN(); - - char unreadMsgCntStr[10] = {0, }; - bool bPreview; - - if (MsgSettingGetBool(MSG_SETTING_PREVIEW, &bPreview) != MSG_SUCCESS) { - MSG_DEBUG("MsgSettingGetBool is failed."); - } - - /* set title and content */ - switch (noti_info->type) { -#ifdef MSG_NOTI_INTEGRATION - case MSG_NOTI_TYPE_NORMAL: - case MSG_NOTI_TYPE_CB: - case MSG_NOTI_TYPE_SIM: { - if (noti_info->count > 1) { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - setNotiTime(noti_h, noti_info->time); - - snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); - - } else { - if (bPreview) { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL); - } else { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - } - setNotiTime(noti_h, noti_info->time); - } - break; - } -#else - case MSG_NOTI_TYPE_NORMAL: { - if (noti_info->count > 1) { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - setNotiTime(noti_h, noti_info->time); - - snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); - } else { - if (bPreview) { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL); - } else { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - } - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL); - setNotiTime(noti_h, noti_info->time); - } - break; - } - case MSG_NOTI_TYPE_CB: { - if (noti_info->count > 1) { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE); - snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - setNotiTime(noti_h, noti_info->time); - - } else { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL); - setNotiTime(noti_h, noti_info->time); - - if (bPreview) { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL); - } else { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - } - } - break; - } - case MSG_NOTI_TYPE_SIM: { - if (noti_info->count > 1) { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE); - snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); - - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - setNotiTime(noti_h, noti_info->time); - } else { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL); - setNotiTime(noti_h, noti_info->time); - - if (bPreview) { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL); - } else { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - } - } - break; - } -#endif - case MSG_NOTI_TYPE_FAILED: { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE); - if (noti_info->count > 1) { - snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); - } - setNotiTime(noti_h, noti_info->time); - break; - } - case MSG_NOTI_TYPE_VOICE_1: - case MSG_NOTI_TYPE_VOICE_2: { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - setNotiTime(noti_h, noti_info->time); - - if (noti_info->count == 1) { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL); - } else if (noti_info->count > 1) { - snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); - } else { - MSG_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count); - } - break; - } - case MSG_NOTI_TYPE_MWI: { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - setNotiTime(noti_h, noti_info->time); - break; - } - case MSG_NOTI_TYPE_CLASS0: { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - setNotiTime(noti_h, noti_info->time); - break; - } - case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT: { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - - if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE); - } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE); - } else { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE); - } - - setNotiTime(noti_h, noti_info->time); - break; - } - case MSG_NOTI_TYPE_MMS_READ_REPORT: { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - - if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE); - /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */ -#if 0 - } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) { - /* notification free */ -#endif - } else { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ); - } - - setNotiTime(noti_h, noti_info->time); - break; - } - case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT: { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); - - if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED) - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE); - else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED) - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", REJECTED_MESSAGE); - else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED) - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE); - else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED) - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unrecognised", UNRECOGNISED_MESSAGE); - else if (noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE) - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message indeterminate", INDETEMINATE_MESSAGE); - else if (noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED) - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message forwarded", NULL); - else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE) - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unreachable", UNREACHABLE_MESSAGE); - else if (noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR) - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message error", NULL); - /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */ -#if 0 - else if (noti_info->extra_data == MSG_DELIVERY_REPORT_NONE) { - /* notification free */ - } -#endif - else - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE); - - setNotiTime(noti_h, noti_info->time); - break; - } - case MSG_NOTI_TYPE_SIM_FULL: { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL); - break; - } - default: - MSG_DEBUG("No matching type [%d]", noti_info->type); - break; - } - - MSG_END(); -} - -void setIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info) -{ - MSG_BEGIN(); - - switch (noti_info->type) { -#ifdef MSG_NOTI_INTEGRATION - case MSG_NOTI_TYPE_NORMAL: - case MSG_NOTI_TYPE_CB: - case MSG_NOTI_TYPE_SIM: { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); - if (noti_info->count > 1 && noti_info->senderCount > 1) { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, ""); - } else { - if (noti_info->active_subtype == MSG_CB_SMS) { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH); - } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH); - } else if (noti_info->active_subtype == MSG_SYNCML_CP) { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH); - } else { - if (noti_info->imagePath[0] != '\0') { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath); - } else { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH); - 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) == 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; - } -#else - case MSG_NOTI_TYPE_NORMAL: { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH); - - if (noti_info->count > 1) { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); - } else { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH); - } - break; - } - case MSG_NOTI_TYPE_CB: { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH); - break; - } - case MSG_NOTI_TYPE_SIM: { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH); - break; - } -#endif - case MSG_NOTI_TYPE_FAILED: { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SMS_SENDING_FAILED_ICON_PATH); - break; - } - case MSG_NOTI_TYPE_VOICE_1: - case MSG_NOTI_TYPE_VOICE_2: - case MSG_NOTI_TYPE_MWI: { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH); - break; - } - case MSG_NOTI_TYPE_CLASS0: - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); - break; - case MSG_NOTI_TYPE_SMS_DELIVERY_REPORT: - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); - break; - case MSG_NOTI_TYPE_MMS_READ_REPORT: - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); - break; - case MSG_NOTI_TYPE_MMS_DELIVERY_REPORT: - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); - break; - case MSG_NOTI_TYPE_SIM_FULL: - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); - break; - default: - MSG_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type); - break; - } - - MSG_END(); -} - -void setActiveProperty(notification_h noti_h, MSG_NOTI_INFO_S *noti_info) -{ - MSG_BEGIN(); - - int noti_err = NOTIFICATION_ERROR_NONE; - - /* set layout */ - noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_set_layout : %d", noti_err); - } - - /* set led */ - noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_set_led."); - } - - /* set applist */ - noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_set_display_applist"); - } - - MSG_END(); -} - - -void setActiveText(notification_h noti_h, MSG_NOTI_INFO_S *noti_info) -{ - MSG_BEGIN(); - - switch (noti_info->type) { - case MSG_NOTI_TYPE_NORMAL: - case MSG_NOTI_TYPE_SIM: - case MSG_NOTI_TYPE_CB: { - if (noti_info->active_subject[0] == '\0') { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL); - } else { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL); - } - break; - } - case MSG_NOTI_TYPE_CLASS0: { - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL); - break; - } - default: - MSG_DEBUG("No matching type [%d]", noti_info->type); - break; - } - - MSG_END(); -} - - -void setActiveIcon(notification_h noti_h, MSG_NOTI_INFO_S *noti_info) -{ - MSG_BEGIN(); - - switch (noti_info->type) { - case MSG_NOTI_TYPE_NORMAL: - case MSG_NOTI_TYPE_SIM: { - switch (noti_info->active_subtype) { - case MSG_CB_SMS: - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH); - break; - case MSG_WAP_SI_SMS: - case MSG_WAP_SL_SMS: - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH); - break; - case MSG_SYNCML_CP: - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH); - break; - default: - if (noti_info->imagePath[0] != '\0') - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath); - else - 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) == 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; - } - - break; - } - case MSG_NOTI_TYPE_CB: { - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH); - break; - } - case MSG_NOTI_TYPE_CLASS0: - setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); - break; - default: - MSG_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type); - break; - } - - MSG_END(); -} - -msg_error_t MsgInsertInstantMessage(msg_notification_type_t noti_type) -{ - MSG_BEGIN(); - - msg_error_t msg_err = MSG_SUCCESS; - char *notiMsg = NULL; - - notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI); - - switch (noti_type) { - case MSG_NOTI_TYPE_NORMAL: - case MSG_NOTI_TYPE_SIM: - case MSG_NOTI_TYPE_CB: { - MSG_NOTI_INFO_S noti_info; - memset(¬i_info, 0x00, sizeof(MSG_NOTI_INFO_S)); - - noti_info.type = noti_type; - msg_err = getLatestMsgInfo(¬i_info, true); - - if (msg_err == MSG_SUCCESS) { - MSG_DEBUG("Unread count [%d]", noti_info.count); - if (noti_info.count == 1) { - MSG_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender); - setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL); - setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL); - } else if (noti_info.count > 1) { - gchar *cnt_string = g_strdup_printf("%i", noti_info.count); - - notiMsg = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGE); - gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL); - setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL); - setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL); - g_free(outString); - g_free(cnt_string); - } - - setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); - } - break; - } - case MSG_NOTI_TYPE_FAILED: { - notiMsg = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE); - setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL); - setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH); - break; - } - default: - MSG_DEBUG("No matching type for MsgNotiType%d]", noti_type); - goto _END_OF_INSTANT_NOTI; - break; - } - - if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE) - MSG_DEBUG("Fail to notification_set_display_applist"); - - if (notification_post(noti) != NOTIFICATION_ERROR_NONE) - MSG_DEBUG("Fail to notification_post"); - -_END_OF_INSTANT_NOTI: - - if (notification_delete(noti) != NOTIFICATION_ERROR_NONE) - MSG_DEBUG("Fail to notification_delete"); - if (notiMsg) { - free(notiMsg); - notiMsg = NULL; - } - - if (noti) { - if (notification_free(noti) != NOTIFICATION_ERROR_NONE) - MSG_DEBUG("Fail to notification_free"); - noti = NULL; - } - - MSG_END(); - return MSG_SUCCESS; -} - - -void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail) -{ - MSG_BEGIN(); - - bool bBlockingMode = false; - - MSG_ADDRESS_INFO_S addrInfo; - memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); - -/* contacts-service is not used for gear */ -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - MSG_CONTACT_INFO_S contactInfo; - memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S)); - - if (addressVal != NULL) { - snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal); - /* Get Contact Info */ - if (MsgGetContactInfo(&addrInfo, &contactInfo) != MSG_SUCCESS) { - MSG_DEBUG("MsgGetContactInfo() fail."); - } - bBlockingMode = checkBlockingMode(addressVal, NULL); - } else { - MSG_DEBUG("addressVal is NULL."); - } - - char *msg_tone_file_path = NULL; - unique_ptr<char*, void(*)(char**)> buf(&msg_tone_file_path, unique_ptr_deleter); - - MsgSoundPlayer::instance()->MsgGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path); - - MSG_SEC_DEBUG("Sound File [%s]", msg_tone_file_path); -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - - bool bPlaySound = false; - bool bPlayVibration = false; - bool bOnCall = false; - - MsgSoundPlayer::instance()->MsgGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall); - - if (!bBlockingMode) { /* check blocking mode. */ - if (bPlaySound) { -/* contacts-service is not used for gear */ -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - if (msg_tone_file_path) - setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path); - else { -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - int tmpVal = 0; - if (MsgSettingGetInt(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetInt() is failed"); - } - MSG_RINGTONE_TYPE_T ringtoneType = (MSG_RINGTONE_TYPE_T)tmpVal; - if (ringtoneType == MSG_RINGTONE_TYPE_SILENT) - setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL); - else - setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL); -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - } -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - } else { - setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL); - } - - if (bPlayVibration) { -/* contacts-service is not used for gear */ -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - if (contactInfo.vibrationPath[0] == '\0') - setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL); - else - setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath); -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - } else { - setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL); - } - } else { - setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL); - setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL); - } - MSG_END(); -} - - -void setActiveNotification(notification_h noti_h, MSG_NOTI_INFO_S *noti_info) -{ - MSG_BEGIN(); - - int noti_err = NOTIFICATION_ERROR_NONE; - - setActiveProperty(noti_h, noti_info); - - setTextDomain(noti_h, noti_info->type); - - setActiveText(noti_h, noti_info); - - setActiveIcon(noti_h, noti_info); - - if (noti_info->active_noti_button_num > 1) { - createServiceHandle(¬i_info->active_noti_svc_h[0]); - if (noti_info->active_noti_svc_h[0]) { - setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID); - setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL); - - MSG_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id); - - char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, }; - snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number); - MSG_SEC_DEBUG("Active sender number [%s]", noti_info->number); - setServiceUri(noti_info->active_noti_svc_h[0], tel_num); - } - - createServiceHandle(¬i_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); - - MSG_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); - - char slot_id[5] = {0, }; - snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1); - addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id); - } - } - - 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); - - MSG_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id); - addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg"); - addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id); - addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti"); - - char slot_id[5] = {0, }; - snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1); - addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id); - } - - 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]); - 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); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL); - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL); - } else { - setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]); - - setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL); - } - - noti_err = notification_post(noti_h); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_post"); - } - - MSG_END(); -} - - -void setNotification(notification_h noti_h, MSG_NOTI_INFO_S *noti_info, bool bFeedback) -{ - MSG_BEGIN(); - - int noti_err = NOTIFICATION_ERROR_NONE; - - if (bFeedback && noti_info->active_noti_button_num > 0 && - ((noti_info->type >= MSG_NOTI_TYPE_NORMAL && noti_info->type <= MSG_NOTI_TYPE_SIM) || noti_info->type == MSG_NOTI_TYPE_CLASS0)) { - notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI); - - setActiveNotification(active_noti_h, noti_info); - - notification_free(active_noti_h); - active_noti_h = NULL; - } - - setProperty(noti_h, noti_info); - - setTextDomain(noti_h, noti_info->type); - - setText(noti_h, noti_info); - - setIcon(noti_h, noti_info); - - if (bFeedback) { - if (noti_info->type == MSG_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_NOTI_TYPE_VOICE_2) - setSoundAndVibration(noti_h, noti_info->number, true); - else - setSoundAndVibration(noti_h, noti_info->number, false); - - } else { - setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL); - setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL); - } - - if (noti_info->id > 0) { - MSG_DEBUG("Notification update"); - noti_err = notification_update(noti_h); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_update"); - } - } else { - MSG_DEBUG("Notification insert"); - noti_err = notification_insert(noti_h, ¬i_info->id); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_insert"); - } - - updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx); - } - - MSG_END(); -} - - -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(); - - MsgDbHandler *dbhandler = getDbHandle(); - int noti_err = NOTIFICATION_ERROR_NONE; - msg_error_t msg_err = MSG_SUCCESS; - - switch (noti_info->type) { - case MSG_NOTI_TYPE_NORMAL: -#ifdef MSG_NOTI_INTEGRATION - case MSG_NOTI_TYPE_CB: - case MSG_NOTI_TYPE_SIM: -#endif - { - int smsUnreadCnt = 0; - int mmsUnreadCnt = 0; - - char sqlQuery[MAX_QUERY_LEN+1]; - MSG_MAIN_TYPE_T mainType; - MSG_SUB_TYPE_T subType; - int msgSize; - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); -#ifdef MSG_NOTI_INTEGRATION - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT " - "A.ADDRESS_VAL, " - "B.SUB_TYPE " - "FROM %s A, %s B " - "WHERE A.CONV_ID=B.CONV_ID " - "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) " - "AND B.STORAGE_ID = %d " - "GROUP BY A.ADDRESS_VAL " - "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;", - MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, - MSG_INBOX_ID, MSG_CBMSGBOX_ID, - MSG_STORAGE_PHONE); -#else - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT DISTINCT " - "A.ADDRESS_VAL, " - "B.SUB_TYPE " - "FROM %s A, %s B " - "WHERE A.CONV_ID=B.CONV_ID " - "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d " - "AND B.STORAGE_ID = %d " - "GROUP BY A.ADDRESS_VAL " - "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;", - MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, - MSG_INBOX_ID, - MSG_STORAGE_PHONE); -#endif - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - - int rowCnt = 0, index = 0; - - msg_err = dbhandler->getTable(sqlQuery, &rowCnt, &index); - MSG_DEBUG("getTable() ret=[%d], rowCnt=[%d]", msg_err, rowCnt); - -/* contacts-service is not used for gear */ -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - MSG_ADDRESS_INFO_S tmpAddressInfo; - int normalAddCnt = 0; - - for (int i = 1; i <= rowCnt; i++) { - memset(&tmpAddressInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); - - char *address = dbhandler->getColumnToString(index++); - normalAddCnt++; - if (address) { - snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address); - if (msg_is_valid_email(address)) { - tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL; - } else { - tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN; - } - } - subType = dbhandler->getColumnToInt(index++); - - MSG_CONTACT_INFO_S tmpContact; - memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S)); - - MsgGetContactInfo(&tmpAddressInfo, &tmpContact); - - if (rowCnt == 1) { - snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath); - } - - if (normalAddCnt > 1) { - g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender)); - } - - if (tmpContact.firstName[0] != '\0') { - g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender)); - } else if (tmpAddressInfo.addressVal[0] == '\0') { - char *senderStr = NULL; - senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER); - g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); - if (senderStr) { - free(senderStr); - senderStr = NULL; - } - - if (i == 1) { - noti_info->active_noti_button_num = 1; - } - } else { - char *senderStr = NULL; - if (subType == MSG_CB_SMS) { - senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE); - g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); - noti_info->active_noti_button_num = 1; - } else if (subType == MSG_SYNCML_CP) { - senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE); - g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); - noti_info->active_noti_button_num = 1; - } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) { - senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE); - g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); - noti_info->active_noti_button_num = 1; - } else { - g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender)); - } - - if (senderStr) { - free(senderStr); - senderStr = NULL; - } - } - - if (i == 1) { - noti_info->active_subtype = subType; - snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender); - snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath); - } - } - - noti_info->senderCount = normalAddCnt; -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - dbhandler->freeTable(); - - MSG_SEC_DEBUG("sender info = [%s]", noti_info->sender); - - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - -#ifdef MSG_NOTI_INTEGRATION - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " - "A.ADDRESS_VAL, " - "B.DISPLAY_TIME, " - "B.MSG_ID, " - "B.SUBJECT, " - "B.MSG_TEXT, " - "B.MAIN_TYPE, " - "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, " - "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, " - "(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) " - "FROM %s A, %s B " - "WHERE A.CONV_ID=B.CONV_ID " - "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) " - "AND B.STORAGE_ID = %d " - "ORDER BY B.DISPLAY_TIME DESC;", - MSG_SMS_TYPE, - MSG_MMS_TYPE, - MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME, - MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, - MSG_INBOX_ID, MSG_CBMSGBOX_ID, - MSG_STORAGE_PHONE); -#else - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " - "A.ADDRESS_VAL, " - "B.DISPLAY_TIME, " - "B.MSG_ID, " - "B.SUBJECT, " - "B.MSG_TEXT, " - "B.MAIN_TYPE, " - "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, " - "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT " - "FROM %s A, %s B " - "WHERE A.CONV_ID=B.CONV_ID " - "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d " - "AND B.STORAGE_ID = %d " - "ORDER BY B.DISPLAY_TIME DESC;", - MSG_SMS_TYPE, - MSG_MMS_TYPE, - MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, - MSG_INBOX_ID, - MSG_STORAGE_PHONE); -#endif - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - - if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) - return MSG_ERR_DB_PREPARE; - - if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) { - smsUnreadCnt = dbhandler->columnInt(6); - mmsUnreadCnt = dbhandler->columnInt(7); - msgSize = dbhandler->columnInt(8); - - noti_info->count = smsUnreadCnt + mmsUnreadCnt; - - if (noti_info->count > 0) { - snprintf(noti_info->number, sizeof(noti_info->number), "%s", (char*)dbhandler->columnText(0)); - - noti_info->time = (time_t)dbhandler->columnInt(1); - - noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2); - - mainType = (MSG_MAIN_TYPE_T)dbhandler->columnInt(5); - - if (mainType == MSG_MMS_TYPE) { - snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3)); - if (noti_info->text[0] == '\0') { - char *noti_text = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT); - snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text); - g_free(noti_text); - } - - char *prefix_subject = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON); - if (prefix_subject) { - snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text); - g_free(prefix_subject); - } else { - snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text); - } - - if (msgSize > -1) { - int kb_msg_size = msgSize / 1024; - if (kb_msg_size == 0 && msgSize > 0) - kb_msg_size = 1; - else if (msgSize % 1024 >= 512) - kb_msg_size++; - - char *msg_size_string = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING); - char *msg_size_unit_kb = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB); - - snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb); - - g_free(msg_size_string); - g_free(msg_size_unit_kb); - } - - } else { - snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(4)); - } - - if (noti_info->active_text[0] == '\0') - snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", (char*)dbhandler->columnText(4)); - - MSG_DEBUG("unread message ID [%d].", noti_info->msg_id); - - MSG_DEBUG("active sender [%s]", noti_info->active_sender); - MSG_DEBUG("active subject [%s]", noti_info->active_subject); - MSG_DEBUG("active text [%s]", noti_info->active_text); - - if (!isForInstantMessage) { - if (noti_info->id > 0 && noti_info->count == 1) { - noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); - } - - noti_info->id = 0; - if (MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_info->id) != MSG_SUCCESS) - MSG_DEBUG("MsgSettingSetInt fail : NOTIFICATION_PRIV_ID"); - } - MsgSettingHandleNewMsg(smsUnreadCnt, mmsUnreadCnt); - MsgInsertBadge(noti_info->count); - MsgSoundSetRepeatAlarm(); - } - } else { - MSG_DEBUG("No unread message."); - MSG_DEBUG("notiPrivId [%d]", noti_info->id); - - dbhandler->finalizeQuery(); - - if (!isForInstantMessage) { - /* No unread message. */ - if (noti_info->id > 0) { - noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); - } - } - - noti_info->id = 0; - - if (MsgSettingSetInt(NOTIFICATION_PRIV_ID, noti_info->id) != MSG_SUCCESS) - MSG_DEBUG("MsgSettingSetInt fail : NOTIFICATION_PRIV_ID"); - - MsgSettingHandleNewMsg(0, 0); - MsgInsertBadge(0); - MsgSoundSetRepeatAlarm(); - } - - return MSG_ERR_DB_STEP; - } - } else { - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - dbhandler->finalizeQuery(); - return MSG_ERR_DB_STEP; - } - - dbhandler->finalizeQuery(); - break; - } - -#ifndef MSG_NOTI_INTEGRATION - case MSG_NOTI_TYPE_CB: { - char sqlQuery[MAX_QUERY_LEN+1]; - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " - "A.ADDRESS_VAL, " - "B.DISPLAY_TIME, " - "B.MSG_ID, " - "B.MSG_TEXT " - "FROM %s A, %s B " - "WHERE A.CONV_ID=B.CONV_ID " - "AND B.READ_STATUS=0 " - "AND B.FOLDER_ID=%d " - "AND B.STORAGE_ID = %d " - "ORDER BY B.DISPLAY_TIME DESC;", - MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, - MSG_CBMSGBOX_ID, - MSG_STORAGE_PHONE); - - if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) - return MSG_ERR_DB_PREPARE; - - if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) { - MSG_ADDRESS_INFO_S addrInfo; - memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); - - if (dbhandler->columnText(0) != NULL) - snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0)); - - MSG_CONTACT_INFO_S tmpContact; - memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S)); - - MsgGetContactInfo(&addrInfo, &tmpContact); - - if (tmpContact.firstName[0] != '\0') { - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName); - } else if (addrInfo.addressVal[0] == '\0') { - char *senderStr = NULL; - senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER); - g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); - if (senderStr) { - free(senderStr); - senderStr = NULL; - } - } else { - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal); - } - - snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal); - - noti_info->time = (time_t)dbhandler->columnInt(1); - - noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2); - - snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3)); - - MSG_DEBUG("unread CB message [%d].", noti_info->msg_id); - } else { - MSG_DEBUG("No unread CB message."); - MSG_DEBUG("notiCbId [%d]", noti_info->id); - - dbhandler->finalizeQuery(); - - if (!isForInstantMessage) { - /* No unread message. */ - if (noti_info->id > 0) { - noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); - } - } - - noti_info->id = 0; - - if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS) - MSG_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID"); - } - return MSG_ERR_DB_STEP; - } - - dbhandler->finalizeQuery(); - - if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) { - MSG_DEBUG("getTable is failed"); - dbhandler->freeTable(); - return MSG_ERR_DB_GETTABLE; - } - - dbhandler->freeTable(); - MSG_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count); - break; - } - case MSG_NOTI_TYPE_SIM: { - char sqlQuery[MAX_QUERY_LEN+1]; - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " - "A.ADDRESS_VAL, " - "B.DISPLAY_TIME, " - "B.MSG_ID, " - "B.MSG_TEXT, " - "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT " - "FROM %s A, %s B " - "WHERE A.CONV_ID=B.CONV_ID " - "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d " - "AND B.STORAGE_ID = %d " - "ORDER BY B.DISPLAY_TIME DESC;", - MSG_SMS_TYPE, - MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, - MSG_INBOX_ID, - MSG_STORAGE_SIM); - - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - - if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) - return MSG_ERR_DB_PREPARE; - - if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) { - noti_info->count = dbhandler->columnInt(4); - - if (noti_info->count > 0) { - MSG_ADDRESS_INFO_S addrInfo; - memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); - - if (dbhandler->columnText(0) != NULL) - snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0)); - - MSG_CONTACT_INFO_S tmpContact; - memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S)); - - MsgGetContactInfo(&addrInfo, &tmpContact); - - if (tmpContact.firstName[0] != '\0') { - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName); - } else if (addrInfo.addressVal[0] == '\0') { - char *senderStr = NULL; - senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER); - g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); - if (senderStr) { - free(senderStr); - senderStr = NULL; - } - } else { - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal); - } - - snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal); - - noti_info->time = (time_t)dbhandler->columnInt(1); - - noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2); - - snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3)); - - MSG_DEBUG("unread SIM message [%d].", noti_info->msg_id); - } else { - MSG_DEBUG("No unread SIM message."); - MSG_DEBUG("notiPrivId [%d]", noti_info->id); - - dbhandler->finalizeQuery(); - - if (!isForInstantMessage) { - /* No unread message. */ - if (noti_info->id > 0) { - noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); - } - } - - noti_info->id = 0; - - if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS) - MSG_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID"); - } - - return MSG_ERR_DB_STEP; - } - } else { - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - dbhandler->finalizeQuery(); - return MSG_ERR_DB_STEP; - } - - dbhandler->finalizeQuery(); - break; - } -#endif - case MSG_NOTI_TYPE_FAILED: { - MSG_MAIN_TYPE_T mainType; - char sqlQuery[MAX_QUERY_LEN+1]; - memset(sqlQuery, 0x00, sizeof(sqlQuery)); - - snprintf(sqlQuery, sizeof(sqlQuery), "SELECT " - "A.ADDRESS_VAL, " - "B.DISPLAY_TIME, " - "B.MSG_ID, " - "B.MSG_TEXT, " - "B.SUBJECT, " - "B.MAIN_TYPE, " - "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT " - "FROM %s A, %s B " - "WHERE A.CONV_ID=B.CONV_ID " - "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d " - "AND B.STORAGE_ID = %d " - "ORDER BY B.DISPLAY_TIME DESC;", - MSG_NETWORK_SEND_FAIL, - MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, - MSG_OUTBOX_ID, - MSG_STORAGE_PHONE); - - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - - if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) - return MSG_ERR_DB_PREPARE; - - if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) { - noti_info->count = dbhandler->columnInt(6); - - if (noti_info->count > 0) { - MSG_ADDRESS_INFO_S addrInfo; - memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); - - if (dbhandler->columnText(0) != NULL) - snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0)); - -/* contacts-service is not used for gear */ -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - MSG_CONTACT_INFO_S tmpContact; - memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S)); - - MsgGetContactInfo(&addrInfo, &tmpContact); - - if (tmpContact.firstName[0] != '\0') { - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName); - } else if (addrInfo.addressVal[0] == '\0') { -#else /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - if (addrInfo.addressVal[0] == '\0') { -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - char *senderStr = NULL; - senderStr = getTranslateText(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER); - g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); - if (senderStr) { - free(senderStr); - senderStr = NULL; - } - } else { - snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal); - } - - snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal); - - noti_info->time = (time_t)dbhandler->columnInt(1); - - noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2); - - mainType = (MSG_MAIN_TYPE_T)dbhandler->columnInt(5); - - if (mainType == MSG_TYPE_MMS) - snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(4)); - else - snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3)); - - MSG_DEBUG("Sent failed message ID [%d].", noti_info->msg_id); - - if (!isForInstantMessage) { - if (noti_info->id > 0 && noti_info->count == 1) { - noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); - } - noti_info->id = 0; - if (MsgSettingSetInt(MSG_SENTFAIL_NOTI_ID, noti_info->id) != MSG_SUCCESS) - MSG_DEBUG("MsgSettingSetInt fail : MSG_SENTFAIL_NOTI_ID"); - } - } - } else { - MSG_DEBUG("No sent failed message."); - MSG_DEBUG("failedNotiId [%d]", noti_info->id); - - dbhandler->finalizeQuery(); - - if (!isForInstantMessage) { - /* No unread message. */ - if (noti_info->id > 0) { - noti_err = notification_delete_by_priv_id(NULL, NOTIFICATION_TYPE_NOTI, noti_info->id); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("Fail to notification_delete_by_priv_id : %d", noti_err); - } - } - - noti_info->id = 0; - - if (MsgSettingSetInt(MSG_SENTFAIL_NOTI_ID, noti_info->id) != MSG_SUCCESS) - MSG_DEBUG("MsgSettingSetInt fail : MSG_SENTFAIL_NOTI_ID"); - } - - return MSG_ERR_DB_STEP; - } - } else { - MSG_DEBUG("sqlQuery [%s]", sqlQuery); - dbhandler->finalizeQuery(); - return MSG_ERR_DB_STEP; - } - - dbhandler->finalizeQuery(); - break; - } - case MSG_NOTI_TYPE_SIM_FULL: - break; - default: - MSG_DEBUG("No matching type [%d]", noti_info->type); - return MSG_ERR_UNKNOWN; - } - - MSG_END(); - - return MSG_SUCCESS; -} - - -void createServiceHandle(app_control_h *svc_h) -{ - int svc_err = APP_CONTROL_ERROR_NONE; - - svc_err = app_control_create(svc_h); - - if (svc_err != APP_CONTROL_ERROR_NONE) - MSG_DEBUG("app_control_create() is failed, [%d]", svc_err); -} - - -void setServiceAppId(app_control_h svc_h, const char* app_id) -{ - int svc_err = APP_CONTROL_ERROR_NONE; - - svc_err = app_control_set_app_id(svc_h, app_id); - - if (svc_err != APP_CONTROL_ERROR_NONE) - MSG_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err); -} - - -void setServiceUri(app_control_h svc_h, const char* uri) -{ - int svc_err = APP_CONTROL_ERROR_NONE; - - svc_err = app_control_set_uri(svc_h, uri); - - if (svc_err != APP_CONTROL_ERROR_NONE) - MSG_DEBUG("app_control_set_uri() was failed, [%d]", svc_err); -} - - -void setServiceOperation(app_control_h svc_h, const char* operation) -{ - int svc_err = APP_CONTROL_ERROR_NONE; - - svc_err = app_control_set_operation(svc_h, operation); - - if (svc_err != APP_CONTROL_ERROR_NONE) - MSG_DEBUG("app_control_set_operation() was failed, [%d]", svc_err); -} - - -void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val) -{ - int svc_err = APP_CONTROL_ERROR_NONE; - - svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val); - - if (svc_err != APP_CONTROL_ERROR_NONE) - MSG_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err); -} - - -void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val) -{ - int svc_err = APP_CONTROL_ERROR_NONE; - - char tempId[10]; - memset(&tempId, 0x00, sizeof(tempId)); - snprintf(tempId, sizeof(tempId), "%d", bundle_val); - - svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId); - - if (svc_err != APP_CONTROL_ERROR_NONE) - MSG_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err); -} - - -void setServicePackageName(app_control_h svc_h, const char* pkg_name) -{ - int svc_err = APP_CONTROL_ERROR_NONE; - - svc_err = app_control_set_app_id(svc_h, pkg_name); - - if (svc_err != APP_CONTROL_ERROR_NONE) - MSG_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err); -} - - -void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data) -{ - int svc_err = APP_CONTROL_ERROR_NONE; - - svc_err = app_control_send_launch_request(svc_h, callback, user_data); - - if (svc_err != APP_CONTROL_ERROR_NONE) - MSG_DEBUG("app_control_send_launch_request() is failed : %d", svc_err); -} - - -void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir) -{ - int noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir); - if (noti_err != NOTIFICATION_ERROR_NONE) { - MSG_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err); - } -} - - -void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key) -{ - int noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE); - - if (noti_err != NOTIFICATION_ERROR_NONE) - MSG_DEBUG("notification_set_text() was failed. [%d]", noti_err); -} - - -void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time) -{ - int noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = notification_set_time_to_text(noti_h, type, time); - - if (noti_err != NOTIFICATION_ERROR_NONE) - MSG_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err); -} - - -void setNotiTime(notification_h noti_h, time_t time) -{ - int noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = notification_set_time(noti_h, time); - - if (noti_err != NOTIFICATION_ERROR_NONE) - MSG_DEBUG("notification_set_time() was failed. [%d]", noti_err); -} - - - -void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path) -{ - int noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = notification_set_image(noti_h, type, image_path); - - if (noti_err != NOTIFICATION_ERROR_NONE) - MSG_DEBUG("notification_set_image() was failed. [%d]", noti_err); -} - - -void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path) -{ - int noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = notification_set_sound(noti_h, type, path); - - if (noti_err != NOTIFICATION_ERROR_NONE) - MSG_DEBUG("notification_set_sound() was failed. [%d]", noti_err); -} - - -void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path) -{ - int noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = notification_set_vibration(noti_h, type, path); - - if (noti_err != NOTIFICATION_ERROR_NONE) - MSG_DEBUG("notification_set_vibration() was failed. [%d]", noti_err); -} - - -void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler) -{ - int noti_err = NOTIFICATION_ERROR_NONE; - - noti_err = notification_set_event_handler(noti_h, type, event_handler); - - if (noti_err != NOTIFICATION_ERROR_NONE) - MSG_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err); -} - - -void MsgNotiSoundRepeatAlarmCB(int alarmId) -{ - MSG_BEGIN(); - - MsgRefreshNotification(MSG_NOTI_TYPE_NORMAL, true, MSG_ACTIVE_NOTI_TYPE_ACTIVE); - -#ifndef MSG_NOTI_INTEGRATION - MsgRefreshNotification(MSG_NOTI_TYPE_SIM, true, MSG_ACTIVE_NOTI_TYPE_ACTIVE); - MsgRefreshNotification(MSG_NOTI_TYPE_CB, true, MSG_ACTIVE_NOTI_TYPE_ACTIVE); -#endif - - MSG_END(); - return; -} - - -void MsgSoundCreateRepeatAlarm(int RepeatTime) -{ - MSG_BEGIN(); - - int tmpAlarmId = 0; - time_t tmp_time; - struct tm repeat_tm; - - time(&tmp_time); - - tmp_time += (RepeatTime*60); - tzset(); - localtime_r(&tmp_time, &repeat_tm); - - if (MsgAlarmRegistration(&repeat_tm, MsgNotiSoundRepeatAlarmCB, &tmpAlarmId) != MSG_SUCCESS) { - MSG_DEBUG("MsgAlarmRegistration fail."); - return; - } - - g_alarmId = tmpAlarmId; - MSG_DEBUG("Set alarmId to [%d]", g_alarmId); - - MSG_END(); - - return; -} - - -void MsgSoundSetRepeatAlarm() -{ - int nRepeatValue = 0; - long nRepeatTime = 0; - - if (MsgSettingGetInt(MSG_ALERT_REP_TYPE, &nRepeatValue) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetInt() is failed"); - } - - switch (nRepeatValue) { - case MSG_ALERT_TONE_ONCE: - nRepeatTime = 0; - break; - case MSG_ALERT_TONE_2MINS: - nRepeatTime = 2; - break; - case MSG_ALERT_TONE_5MINS: - nRepeatTime = 5; - break; - case MSG_ALERT_TONE_10MINS: - nRepeatTime = 10; - break; - default: - MSG_DEBUG("Invalid Repetition time"); - break; - } - - MSG_DEBUG("nRepeatTime = %d", nRepeatTime); - - if (nRepeatTime > 0) { - if (g_alarmId > 0) { - if (MsgAlarmRemove(g_alarmId) != MSG_SUCCESS) { - MSG_FATAL("MsgAlarmRemove fail."); - } - g_alarmId = 0; - } - MsgSoundCreateRepeatAlarm(nRepeatTime); - } - - return; -} - - -void sendMsgReplyPopup(MSG_NOTI_INFO_S *noti_info) -{ - app_control_h svc_h = NULL; - - createServiceHandle(&svc_h); - - if (svc_h) { - setServicePackageName(svc_h, "org.tizen.msg-ui-reply"); - - MSG_DEBUG("Reply-popup display - Msg Id = [%d]", noti_info->msg_id); - addServiceExtraData(svc_h, "msgId", noti_info->msg_id); - - sendServicelaunchRequest(svc_h, NULL, NULL); - - app_control_destroy(svc_h); - } -} - #endif /* MSG_WEARABLE_PROFILE */ diff --git a/externals/MsgSensorWrapper.cpp b/externals/MsgSensorWrapper.cpp index 0cade63..a19e176 100755 --- a/externals/MsgSensorWrapper.cpp +++ b/externals/MsgSensorWrapper.cpp @@ -19,6 +19,7 @@ #include "MsgCppTypes.h" #include "MsgGconfWrapper.h" #include "MsgSensorWrapper.h" +#include "MsgNotificationWrapper.h" #ifndef MSG_WEARABLE_PROFILE #include <gesture_recognition.h> @@ -68,7 +69,35 @@ void MsgGestureCB(gesture_type_e gesture, const gesture_data_h data, double time } } +void MsgSensorCBStop() +{ + MSG_BEGIN(); + + + MsgDeleteNotification(MSG_NOTI_TYPE_ALL, -1); + MsgRefreshNotification(MSG_NOTI_TYPE_ALL, false, MSG_ACTIVE_NOTI_TYPE_NONE); +#ifndef MSG_NOTI_INTEGRATION + MsgRefreshNotification(MSG_NOTI_TYPE_SIM, false, MSG_ACTIVE_NOTI_TYPE_NONE); +#endif + + MSG_END(); +} +#endif /* MSG_WEARABLE_PROFILE */ + +void MsgInitSensor() +{ +#ifndef MSG_WEARABLE_PROFILE + if (MsgSensorConnect() == MSG_SUCCESS) { + if (MsgRegSensorCB(&MsgSensorCBStop) != MSG_SUCCESS) { + MSG_DEBUG("Fail to MsgRegSensorCB."); + MsgSensorDisconnect(); + } + } else { + MSG_DEBUG("Fail to MsgSensorConnect."); + } #endif /* MSG_WEARABLE_PROFILE */ +} + msg_error_t MsgSensorConnect() { diff --git a/externals/MsgSoundPlayer.cpp b/externals/MsgSoundPlayer.cpp deleted file mode 100755 index 89febf9..0000000 --- a/externals/MsgSoundPlayer.cpp +++ /dev/null @@ -1,875 +0,0 @@ -/* - * Copyright (c) 2014 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. -*/ - -#include <wait.h> - -#include "MsgCallStatusManager.h" -#include "MsgDebug.h" -#include "MsgCppTypes.h" -#include "MsgGconfWrapper.h" -#include "MsgSettingTypes.h" -#include "MsgDrmWrapper.h" -#include "MsgSensorWrapper.h" -#include "MsgUtilFile.h" -#include "MsgStorageTypes.h" -#include "MsgContact.h" -#include "MsgAlarm.h" -#include "MsgNotificationWrapper.h" -#include "MsgSoundPlayer.h" - -#ifndef MSG_WEARABLE_PROFILE - -#include <player.h> -#include <sound_manager.h> -#include <feedback.h> -#include <feedback-internal.h> - -/*================================================================================================== - DEFINES -==================================================================================================*/ -#define MAX_SOUND_FILE_LEN 1024 - -#define DEFAULT_ALERT_FILE TZ_SYS_RO_APP_PATH "/" MSG_SETTING_APP_ID "shared/res/settings/Alerts/General notification_sdk.wav" - -#define HAPTIC_TEST_ITERATION 1 -#define MSG_VIBRATION_INTERVAL 3000 -#define MSG_SOUND_TIMEOUT 5500 - - -/*================================================================================================== - VARIABLES -==================================================================================================*/ -player_h g_PlayerHandle = NULL; -sound_stream_info_h g_stream_info = NULL; - -pthread_mutex_t muMmPlay = PTHREAD_MUTEX_INITIALIZER; -pthread_mutex_t muStream = PTHREAD_MUTEX_INITIALIZER; - -#endif /* MSG_WEARABLE_PROFILE */ - -/*================================================================================================== - IMPLEMENTATION OF Functions -==================================================================================================*/ -void MsgSoundRepeatAlarmCB(int alarmId) -{ - MSG_BEGIN(); - -#ifndef MSG_WEARABLE_PROFILE - - MsgSoundPlayer::instance()->MsgSoundInitRepeatAlarm(); - -#endif /* MSG_WEARABLE_PROFILE */ - - MSG_END(); - return; -} - - -void MsgSensorCBStop() -{ - MSG_BEGIN(); - -#ifndef MSG_WEARABLE_PROFILE - -#if 0 - MsgSoundPlayer::instance()->MsgSoundPlayStop(); -#else - MsgDeleteNotification(MSG_NOTI_TYPE_ALL, -1); - - MsgRefreshNotification(MSG_NOTI_TYPE_ALL, false, MSG_ACTIVE_NOTI_TYPE_NONE); - -#ifndef MSG_NOTI_INTEGRATION - MsgRefreshNotification(MSG_NOTI_TYPE_SIM, false, MSG_ACTIVE_NOTI_TYPE_NONE); -#endif - -#endif - -#endif /* MSG_WEARABLE_PROFILE */ - - MSG_END(); -} - -/* -static gboolean MsgSoundMelodyTimeout(gpointer data) -{ - MSG_BEGIN(); - - MsgSoundPlayer::instance()->MsgSoundPlayStop(); - - MSG_END(); - - return FALSE; -} -*/ - -#ifndef MSG_WEARABLE_PROFILE -static void MsgSoundPlayeErrorCallback(int error_code, void *user_data) -{ - MSG_DEBUG("MsgSoundPlayeErrorCallback called [%d]", error_code); - MsgSoundPlayer::instance()->MsgStreamStop(); - MsgSoundPlayer::instance()->MsgSoundPlayStart(NULL, MSG_SOUND_PLAY_DEFAULT); -} - -static void MsgSoundPlayeCompletedCallback(void *user_data) -{ - MSG_DEBUG("MsgSoundPlayeCompletedCallback called"); - MsgSoundPlayer::instance()->MsgSoundPlayStop(); -} - -static void MsgSoundPlayeInterruptedCallback(player_interrupted_code_e code, void *user_data) -{ - MSG_DEBUG("MsgSoundPlayeInterruptedCallback called [%d]", code); - MsgSoundPlayer::instance()->MsgSoundPlayStop(); -} - -static void MsgStreamFocusCallback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data) -{ - MSG_DEBUG("MsgStreamFocusCallback called, reason_for_change [%d], additional_info [%s]", reason_for_change, additional_info); - - sound_stream_focus_state_e playback_focus_state = SOUND_STREAM_FOCUS_STATE_ACQUIRED; - - sound_manager_get_focus_state(stream_info, &playback_focus_state, NULL); - if (playback_focus_state == SOUND_STREAM_FOCUS_STATE_RELEASED) { - MSG_DEBUG("sound stream focus released"); - MsgSoundPlayer::instance()->MsgSoundPlayStop(); - } -} -#endif - -/*================================================================================================== - IMPLEMENTATION OF MsgSoundPlayer - Member Functions -==================================================================================================*/ -MsgSoundPlayer* MsgSoundPlayer::pInstance = NULL; - - -MsgSoundPlayer::MsgSoundPlayer() -{ -#ifndef MSG_WEARABLE_PROFILE - bPlaying = false; - bVibrating = false; - bFeedbackInit = false; - g_alarmId = 0; - - defaultRingtonePath = NULL; - - if (MsgSettingGetString(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR, &defaultRingtonePath) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetString() is failed"); - } - - if (defaultRingtonePath == NULL || MsgGetFileSize(defaultRingtonePath) < 1) { - defaultRingtonePath = (char *)DEFAULT_ALERT_FILE; - } - - MSG_DEBUG("defaultRingtonePath [%s]", defaultRingtonePath); - - if (MsgSensorConnect() == MSG_SUCCESS) { - if (MsgRegSensorCB(&MsgSensorCBStop) != MSG_SUCCESS) { - MSG_DEBUG("Fail to MsgRegSensorCB."); - MsgSensorDisconnect(); - } - } else { - MSG_DEBUG("Fail to MsgSensorConnect."); - } -#endif /* MSG_WEARABLE_PROFILE */ -} - - -MsgSoundPlayer::~MsgSoundPlayer() -{ -} - - -MsgSoundPlayer* MsgSoundPlayer::instance() -{ - if (!pInstance) { - MSG_DEBUG("pInstance is NULL. Now creating instance."); - pInstance = new MsgSoundPlayer(); - } - - return pInstance; -} - - -void MsgSoundPlayer::MsgGetRingtonePath(char *userRingtonePath, char **msg_tone_file_path_p) -{ -#ifndef MSG_WEARABLE_PROFILE - int tmpVal = 0; - if (MsgSettingGetInt(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetInt() is failed"); - } - MSG_RINGTONE_TYPE_T ringtoneType = (MSG_RINGTONE_TYPE_T)tmpVal; - - MSG_DEBUG("Ringtone type = [%d]", ringtoneType); - - if (ringtoneType == MSG_RINGTONE_TYPE_SILENT) { - *msg_tone_file_path_p = NULL; - return; - } - - char *tmpFilePath = NULL; - *msg_tone_file_path_p = new char[MSG_FILEPATH_LEN_MAX+1]; - - char *msg_tone_file_path = *msg_tone_file_path_p; - - bool bUserRingtone = userRingtonePath && userRingtonePath[0] != '\0'; - if (bUserRingtone) { - tmpFilePath = userRingtonePath; - } else { - if (ringtoneType == MSG_RINGTONE_TYPE_DEFAULT) { - if (MsgSettingGetString(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &tmpFilePath) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetString() is failed"); - } - } else { - if (MsgSettingGetString(MSG_SETTING_RINGTONE_PATH, &tmpFilePath) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetString() is failed"); - } - } - } - - memset(msg_tone_file_path, 0x00, sizeof(char)*(MSG_FILEPATH_LEN_MAX+1)); - - if ((tmpFilePath == NULL || MsgGetFileSize(tmpFilePath) < 1) || /* wrong ringtone file path */ - (MsgDrmIsDrmFile(tmpFilePath) && !MsgDrmCheckRingtone(tmpFilePath))) { /* check DRM */ - if (tmpFilePath && (strcmp(tmpFilePath, "silent") == 0)) { - MSG_DEBUG("Set ringtone to NONE(Silent)"); - msg_tone_file_path = NULL; - } else { - MSG_DEBUG("Set ringtone to defaultRingtonePath."); - strncpy(msg_tone_file_path, defaultRingtonePath, MSG_FILEPATH_LEN_MAX); - } - } else { - MSG_DEBUG("Set ringtone to tmpFilePath."); - snprintf(msg_tone_file_path, MSG_FILEPATH_LEN_MAX, "%s", tmpFilePath); - } - - if (tmpFilePath && !bUserRingtone) { - free(tmpFilePath); - tmpFilePath = NULL; - } -#endif /* MSG_WEARABLE_PROFILE */ -} - -#ifndef MSG_WEARABLE_PROFILE -void MsgSoundPlayer::MsgGetPlayStatus(bool bOnCall, bool bSound, bool bVibration, bool bMsgSound, bool bMsgVibration, bool *bPlaySound, bool *bPlayVibration) -{ - MSG_BEGIN(); - - /* samsung basic concept : feedback should follow profile setting. - * And if notification setting exist in msg app, then apply it prior to profile when profile either sound or vibration. - * But, Play sound when profile is vibration during call, if device does not support haptic */ - if (bSound || bVibration) { - bool bHantic_device = false; -#ifdef FEATURE_HAPTIC_ENABLE - bHantic_device = true; -#endif - if (bHantic_device || (bOnCall == false)) { - if (bSound) { - if (bMsgSound) { - MSG_DEBUG("Play sound."); - *bPlaySound = true; - } - - if (bMsgVibration) { - MSG_DEBUG("Play vibration."); - *bPlayVibration = true; - } - } else { - if (bMsgVibration) { - MSG_DEBUG("Play vibration."); - *bPlayVibration = true; - } - } - } else { /* during call */ - if (bMsgSound || bMsgVibration) { - MSG_DEBUG("Play sound."); - *bPlaySound = true; - } - } - } -} -#endif /* MSG_WEARABLE_PROFILE */ - -void MsgSoundPlayer::MsgGetPlayStatus(bool bVoiceMail, bool *bPlaySound, bool *bPlayVibration, bool *bOnCall) -{ - MSG_BEGIN(); - -#ifndef MSG_WEARABLE_PROFILE - - if (!bPlaySound || !bPlayVibration || !bOnCall) { - MSG_DEBUG("IN parameter is NULL."); - return; - } - - *bPlaySound = false; - *bPlayVibration = false; - *bOnCall = false; - - /* Global setting */ - bool bSoundOn = false; /* sound setting on notification panel */ - bool bVibrationOn = false; /* vibration setting on notification panel */ - - if (MsgSettingGetBool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &bSoundOn) != MSG_SUCCESS) - MSG_INFO("MsgSettingGetBool() is failed"); - - if (MsgSettingGetBool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &bVibrationOn) != MSG_SUCCESS) - MSG_INFO("MsgSettingGetBool() is failed"); - - /* Alert setting */ -#if 0 /* not used value */ - bool bNotiVibrationOn = false; /* alert vibration */ - if (MsgSettingGetBool(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, &bNotiVibrationOn) != MSG_SUCCESS) - MSG_INFO("MsgSettingGetBool() is failed"); -#endif - - bool bMsgSettingNoti = true; /* Alert for message notification */ - bool bMsgSettingVibration = false; /* vibration for message notification */ - - MSG_RINGTONE_TYPE_T ringtoneType = MSG_RINGTONE_TYPE_DEFAULT; /*sound type for message notification */ - bool bMsgSettingSound = true; - - if (MsgSettingGetBool(MSG_SETTING_VIBRATION, &bMsgSettingVibration) != MSG_SUCCESS) - MSG_INFO("MsgSettingGetBool() is failed"); - - if (MsgSettingGetBool(MSG_SETTING_NOTIFICATION, &bMsgSettingNoti) != MSG_SUCCESS) - MSG_INFO("MsgSettingGetBool() is failed"); - - int tmpVal = 0; - if (MsgSettingGetInt(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetInt() is failed"); - } - ringtoneType = (MSG_RINGTONE_TYPE_T)tmpVal; - if (ringtoneType == MSG_RINGTONE_TYPE_SILENT) - bMsgSettingSound = false; - - MSG_SEC_DEBUG("Sound status : Sound mode[%d], Manner mode[%d]", bSoundOn, bVibrationOn); - MSG_SEC_DEBUG("Msg Setting : Noti Alert[%d], vibration[%d], sound[%d], ringtoneType[%d]", bMsgSettingNoti, bMsgSettingVibration, bMsgSettingSound, ringtoneType); - - int callStatus = 0; -/* int alertOnCall = 0; */ - - callStatus = MsgGetCallStatus(); - MSG_DEBUG("Call Status [%d]", callStatus); - - /* Check call status */ - if (callStatus > 0 && callStatus < 3) { - /* 1. On Call */ - *bOnCall = true; /* set call status; */ - } else { - /* 2. Call is not active */ - - MSG_DEBUG("Call is not active."); - int voiceRecording = 0; - if (MsgSettingGetInt(VCONFKEY_RECORDER_STATE, &voiceRecording) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetInt() is failed"); - } - - if (bVoiceMail) { /* 2-1. Voice message */ - if (bMsgSettingNoti) { - MsgGetPlayStatus(false, bSoundOn, bVibrationOn, bMsgSettingSound, bMsgSettingVibration, bPlaySound, bPlayVibration); - - } else { - MSG_DEBUG("It doesn't play sound/vibration - voice message."); - } - } else { /* 2-1. Normal message */ - if (bMsgSettingNoti) { - if (voiceRecording != VCONFKEY_RECORDER_STATE_RECORDING) { - MsgGetPlayStatus(false, bSoundOn, bVibrationOn, bMsgSettingSound, bMsgSettingVibration, bPlaySound, bPlayVibration); - } else { - MSG_DEBUG("It doesn't play sound/vibration."); - } - } else { - MSG_DEBUG("It doesn't play sound/vibration."); - } - } - } - -#endif /* MSG_WEARABLE_PROFILE */ - - MSG_END(); -} - - -void MsgSoundPlayer::MsgSoundPlayStart(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_SOUND_TYPE_T soundType) -{ - MSG_BEGIN(); -#ifndef MSG_WEARABLE_PROFILE - - MSG_DEBUG("soundType [%d]", soundType); - - /* check camera state */ - int cameraState = 0; /* camera recording state */ - if (MsgSettingGetInt(VCONFKEY_CAMERA_STATE, &cameraState) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetInt() is failed"); - } - MSG_SEC_DEBUG("Camera state [%d]", cameraState); - - if (cameraState == VCONFKEY_CAMERA_STATE_RECORDING) { - MSG_END(); - return; - } - -/* contacts-service is not used for gear */ -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - /* get contact information */ - MSG_CONTACT_INFO_S contactInfo; - memset(&contactInfo, 0x00, sizeof(MSG_CONTACT_INFO_S)); - - if (pAddrInfo) { - /* Get Contact Info */ - if (MsgGetContactInfo(pAddrInfo, &contactInfo) != MSG_SUCCESS) { - MSG_DEBUG("MsgGetContactInfo() fail."); - } - } -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - /* get ringtone file path */ - char *msg_tone_file_path = NULL; - unique_ptr<char*, void(*)(char**)> buf(&msg_tone_file_path, unique_ptr_deleter); - - if (soundType == MSG_SOUND_PLAY_EMERGENCY) { - msg_tone_file_path = new char[MAX_SOUND_FILE_LEN+1]; - memset(msg_tone_file_path, 0x00, sizeof(char)*(MAX_SOUND_FILE_LEN+1)); - } else if (soundType == MSG_SOUND_PLAY_DEFAULT) { - msg_tone_file_path = new char[MAX_SOUND_FILE_LEN+1]; - memset(msg_tone_file_path, 0x00, sizeof(char)*(MAX_SOUND_FILE_LEN+1)); - strncpy(msg_tone_file_path, DEFAULT_ALERT_FILE, MAX_SOUND_FILE_LEN); - } -/* contacts-service is not used for gear */ -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - else { - MsgGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path); - } -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - MSG_SEC_DEBUG("soundType [%d], Sound File [%s]", soundType, msg_tone_file_path); - - /* get sound play status */ - bool bPlaySound = false; - bool bPlayVibration = false; - bool bVoiceMsg = (soundType == MSG_SOUND_PLAY_VOICEMAIL)?true:false; - bool bOnCall = false; - - MsgGetPlayStatus(bVoiceMsg, &bPlaySound, &bPlayVibration, &bOnCall); - - MSG_SEC_DEBUG("sound=[%d], vibration=[%d], voice_msg?[%d], on_call?[%d]", - bPlaySound, bPlayVibration, bVoiceMsg, bOnCall); - - /* play sound */ - if (bPlaySound) { - int err = MsgStreamStart(soundType); - - if (err != SOUND_MANAGER_ERROR_NONE) - MSG_DEBUG("MsgStreamStart() Failed : %d", err); - else - MsgSoundPlayMelody(msg_tone_file_path); - } - -/* contacts-service is not used for gear */ -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - /* play vibration */ - if (bPlayVibration) { - MsgSoundPlayVibration(contactInfo.vibrationPath); - } -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - - /* For repeatition. */ -/* MsgSoundSetRepeatAlarm(); */ - -#endif /* MSG_WEARABLE_PROFILE */ - MSG_END(); -} - - -void MsgSoundPlayer::MsgSoundPlayStop() -{ - MSG_BEGIN(); -#ifndef MSG_WEARABLE_PROFILE - - int err = 0; - pthread_mutex_lock(&muMmPlay); - - if (bPlaying == true && g_PlayerHandle != NULL) { - MSG_DEBUG("stopping the player."); - /* Stop playing media contents */ - err = player_stop(g_PlayerHandle); - - if (err != PLAYER_ERROR_NONE) - MSG_DEBUG("stopping the player handle failed"); - } - - if (g_PlayerHandle != NULL) { - MSG_DEBUG("destroy the player."); - - player_unset_error_cb(g_PlayerHandle); - player_unset_completed_cb(g_PlayerHandle); - player_unset_interrupted_cb(g_PlayerHandle); - player_unprepare(g_PlayerHandle); - player_destroy(g_PlayerHandle); - } - - g_PlayerHandle = NULL; - bPlaying = false; - - pthread_mutex_unlock(&muMmPlay); - - MsgStreamStop(); - -#endif /* MSG_WEARABLE_PROFILE */ - MSG_END(); -} - - -int MsgSoundPlayer::MsgStreamStart(MSG_SOUND_TYPE_T soundType) -{ - MSG_BEGIN(); - int err = 0; - -#ifndef MSG_WEARABLE_PROFILE - pthread_mutex_lock(&muStream); - - if (g_stream_info != NULL) { - err = sound_manager_destroy_stream_information(g_stream_info); - if (err != SOUND_MANAGER_ERROR_NONE) - MSG_DEBUG("sound_manager_destroy_stream_information() Failed : %d", err); - - g_stream_info = NULL; - } - - if (soundType == MSG_SOUND_PLAY_EMERGENCY) - err = sound_manager_create_stream_information(SOUND_STREAM_TYPE_EMERGENCY, MsgStreamFocusCallback, NULL, &g_stream_info); - else - err = sound_manager_create_stream_information(SOUND_STREAM_TYPE_NOTIFICATION, MsgStreamFocusCallback, NULL, &g_stream_info); - - if (err != SOUND_MANAGER_ERROR_NONE) { - MSG_DEBUG("sound_manager_create_stream_information() Failed : %d", err); - pthread_mutex_unlock(&muStream); - return err; - } - - err = sound_manager_acquire_focus(g_stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL); - pthread_mutex_unlock(&muStream); - -#endif /* MSG_WEARABLE_PROFILE */ - MSG_END(); - return err; -} - - -void MsgSoundPlayer::MsgStreamStop() -{ - MSG_BEGIN(); -#ifndef MSG_WEARABLE_PROFILE - pthread_mutex_lock(&muStream); - - if (g_stream_info != NULL) { - int err = sound_manager_release_focus(g_stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL); - if (err != SOUND_MANAGER_ERROR_NONE) - MSG_DEBUG("sound_manager_release_focus() Failed : %d", err); - - err = sound_manager_destroy_stream_information(g_stream_info); - if (err != SOUND_MANAGER_ERROR_NONE) - MSG_DEBUG("sound_manager_destroy_stream_information() Failed : %d", err); - - g_stream_info = NULL; - } - pthread_mutex_unlock(&muStream); - -#endif /* MSG_WEARABLE_PROFILE */ - MSG_END(); -} - - -void MsgSoundPlayer::MsgSoundPlayMelody(char *pMsgToneFilePath) -{ -#ifndef MSG_WEARABLE_PROFILE - int err = PLAYER_ERROR_NONE; - - if (!pMsgToneFilePath) { - MSG_DEBUG("Ringtone path is NULL"); - return; - } - - pthread_mutex_lock(&muMmPlay); - - if (g_stream_info == NULL) { - MSG_DEBUG("g_stream_info is NULL"); - pthread_mutex_unlock(&muMmPlay); - return; - } - - if (g_PlayerHandle) { - player_unset_error_cb(g_PlayerHandle); - player_unset_completed_cb(g_PlayerHandle); - player_unset_interrupted_cb(g_PlayerHandle); - player_unprepare(g_PlayerHandle); - player_destroy(g_PlayerHandle); - } - - err = player_create(&g_PlayerHandle); - - pthread_mutex_unlock(&muMmPlay); - - if (err != PLAYER_ERROR_NONE) { - MSG_DEBUG("creating the player handle failed"); - return; - } - - /* Setting the call back function msg_callback */ - player_set_error_cb(g_PlayerHandle, MsgSoundPlayeErrorCallback, NULL); - player_set_completed_cb(g_PlayerHandle, MsgSoundPlayeCompletedCallback, NULL); - player_set_interrupted_cb(g_PlayerHandle, MsgSoundPlayeInterruptedCallback, NULL); - - player_set_audio_policy_info(g_PlayerHandle, g_stream_info); - - do { - err = player_set_uri(g_PlayerHandle, (const char *)pMsgToneFilePath); - if (err != PLAYER_ERROR_NONE) - MSG_DEBUG("player_set_uri() error : [%d]", err); - - err = player_prepare(g_PlayerHandle); - if (err != PLAYER_ERROR_NONE) { - MSG_DEBUG("player_prepare() error : [%d]", err); - if (pMsgToneFilePath != defaultRingtonePath) { - pMsgToneFilePath = defaultRingtonePath; - } else { - return; - } - } - } while (err != PLAYER_ERROR_NONE); - - - pthread_mutex_lock(&muMmPlay); - MSG_DEBUG("player_start with [%s]", pMsgToneFilePath); - err = player_start(g_PlayerHandle); - - if (err != PLAYER_ERROR_NONE) { - MSG_DEBUG("player_start, FAIL [%x]", err); - } else { - /* Add Timer to stop playing after 5 sec. */ - /* - int g_contact_timer = -1; - g_contact_timer = g_timeout_add(MSG_SOUND_TIMEOUT, (GSourceFunc)MsgSoundMelodyTimeout, NULL); - */ - - bPlaying = true; - } - pthread_mutex_unlock(&muMmPlay); - -#endif -} - - -void MsgSoundPlayer::MsgSoundPlayVibration(char *vibrationPath) -{ - MSG_BEGIN(); - -#ifndef MSG_WEARABLE_PROFILE - - int ret = 0; - - if (!bFeedbackInit) { - int ret = feedback_initialize(); - - if (ret != FEEDBACK_ERROR_NONE) { - MSG_DEBUG("Fail to feedback_initialize : [%d]", ret); - bFeedbackInit = false; - return; - } else { - MSG_DEBUG("Success to feedback_initialize."); - bFeedbackInit = true; - } - } - - if (vibrationPath && strlen(vibrationPath)) { - MSG_DEBUG("vibrationPath: [%s]", vibrationPath); - ret = feedback_set_resource_path(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE, vibrationPath); - if (ret != FEEDBACK_ERROR_NONE) - MSG_DEBUG("Fail to feedback_set_resource_path"); - ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE); - - if (ret != FEEDBACK_ERROR_NONE) - MSG_DEBUG("Fail to feedback_play_type"); - } else { - ret = feedback_set_resource_path(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE, NULL); - if (ret != FEEDBACK_ERROR_NONE) - MSG_DEBUG("Fail to feedback_set_resource_path"); - - ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE); - if (ret != FEEDBACK_ERROR_NONE) - MSG_DEBUG("Fail to feedback_play_type"); - } - -#endif /* MSG_WEARABLE_PROFILE */ - - MSG_END(); -} - - -void MsgSoundPlayer::MsgSoundSetRepeatAlarm() -{ -#ifndef MSG_WEARABLE_PROFILE - - int nRepeatValue = 0; - long nRepeatTime = 0; - - if (MsgSettingGetInt(MSG_ALERT_REP_TYPE, &nRepeatValue) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetInt() is failed"); - } - - switch (nRepeatValue) { - case MSG_ALERT_TONE_ONCE: - nRepeatTime = 0; - break; - - case MSG_ALERT_TONE_2MINS: - nRepeatTime = 2; - break; - - case MSG_ALERT_TONE_5MINS: - nRepeatTime = 5; - break; - - case MSG_ALERT_TONE_10MINS: - nRepeatTime = 10; - break; - - default: - MSG_DEBUG("Invalid Repetition time"); - break; - } - - MSG_DEBUG("nRepeatTime = %d", nRepeatTime); - - if (nRepeatTime > 0) { - if (g_alarmId > 0) { - if (MsgAlarmRemove(g_alarmId) != MSG_SUCCESS) - MSG_FATAL("MsgAlarmRemove fail."); - - g_alarmId = 0; - } - MsgSoundCreateRepeatAlarm(nRepeatTime); - } - -#endif /* MSG_WEARABLE_PROFILE */ -} - - -void MsgSoundPlayer::MsgSoundCreateRepeatAlarm(int RepeatTime) -{ - MSG_BEGIN(); - -#ifndef MSG_WEARABLE_PROFILE - - int alarmId = 0; - time_t tmp_time; - struct tm repeat_tm; - - time(&tmp_time); - - tmp_time += (RepeatTime*60); - tzset(); - localtime_r(&tmp_time, &repeat_tm); - - if (MsgAlarmRegistration(&repeat_tm, MsgSoundRepeatAlarmCB, &alarmId) != MSG_SUCCESS) { - MSG_DEBUG("MsgAlarmRegistration fail."); - return; - } - - g_alarmId = alarmId; - MSG_DEBUG("Set g_alarmId to [%d]", alarmId); - - MSG_END(); - -#endif /* MSG_WEARABLE_PROFILE */ -} - - -int MsgSoundPlayer::MsgSoundGetUnreadMsgCnt() -{ - int unreadCnt = 0; - -#ifndef MSG_WEARABLE_PROFILE - int unreadSms = 0; - int unreadMms = 0; - - /* Get SMS Count */ - if (MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_SMS_STATE, &unreadSms) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetInt() is failed"); - } - - /* Get MMS Count */ - if (MsgSettingGetInt(VCONFKEY_MESSAGE_RECV_MMS_STATE, &unreadMms) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetInt() is failed"); - } - - unreadCnt = unreadSms + unreadMms; - - MSG_DEBUG("unread count : [%d]", unreadCnt); - -#endif /* MSG_WEARABLE_PROFILE */ - - return unreadCnt; -} - -void MsgSoundPlayer::MsgSoundInitRepeatAlarm() -{ - MSG_BEGIN(); - -#ifndef MSG_WEARABLE_PROFILE - - int nRepeatValue = 0; - long nRepeatTime = 0; - - g_alarmId = 0; - - if (MsgSoundGetUnreadMsgCnt() <= 0) { - MSG_DEBUG("no unread msg"); - return; - } - - if (MsgSettingGetInt(MSG_ALERT_REP_TYPE, &nRepeatValue) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetInt() is failed"); - } - - switch (nRepeatValue) { - case MSG_ALERT_TONE_ONCE: - nRepeatTime = 0; - break; - - case MSG_ALERT_TONE_2MINS: - nRepeatTime = 2; - break; - - case MSG_ALERT_TONE_5MINS: - nRepeatTime = 5; - break; - - case MSG_ALERT_TONE_10MINS: - nRepeatTime = 10; - break; - - default: - MSG_DEBUG("Invalid Repetition time"); - break; - } - - MSG_DEBUG("nRepeatTime = %d", nRepeatTime); - - if (nRepeatTime > 0) - MsgSoundPlayStart(NULL, MSG_SOUND_PLAY_USER); - -#endif /* MSG_WEARABLE_PROFILE */ - - MSG_END(); -} diff --git a/externals/MsgSpamFilter.cpp b/externals/MsgSpamFilter.cpp index 90bd4c3..c0f543d 100755 --- a/externals/MsgSpamFilter.cpp +++ b/externals/MsgSpamFilter.cpp @@ -16,7 +16,7 @@ #include "MsgDebug.h" #include "MsgUtilFile.h" -#include "MsgContact.h" +#include "MsgUtilFunction.h" #include "MsgCppTypes.h" #include "MsgGconfWrapper.h" #include "MsgSpamFilter.h" diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt index f525d68..2e639c3 100755 --- a/framework/CMakeLists.txt +++ b/framework/CMakeLists.txt @@ -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 aul) +pkg_check_modules(fw_handler_pkgs REQUIRED glib-2.0 gio-2.0 dlog vconf capi-appfw-application) FOREACH(flag ${fw_handler_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -std=c++0x") diff --git a/framework/deliver-handler/MsgDeliverHandler.cpp b/framework/deliver-handler/MsgDeliverHandler.cpp index b5df455..3d04847 100755 --- a/framework/deliver-handler/MsgDeliverHandler.cpp +++ b/framework/deliver-handler/MsgDeliverHandler.cpp @@ -16,7 +16,6 @@ #ifndef MSG_WEARABLE_PROFILE #include <app_control.h> -#include <aul.h> #endif // MSG_WEARABLE_PROFILE #include <bundle.h> #include <eventsystem.h> @@ -27,7 +26,6 @@ #include "MsgUtilFunction.h" #include "MsgUtilStorage.h" #include "MsgGconfWrapper.h" -#include "MsgSoundPlayer.h" #include "MsgSpamFilter.h" #include "MsgPluginManager.h" #include "MsgStorageHandler.h" @@ -43,104 +41,6 @@ FUNCTION IMPLEMENTATION ==================================================================================================*/ -void MsgPlayTTSMode(MSG_SUB_TYPE_T msgSubType, msg_message_id_t msgId, bool isFavorites) -{ - MSG_BEGIN(); -#if 0 - bool bNotification = true; - - if (MsgSettingGetBool(MSG_SETTING_NOTIFICATION, &bNotification) != MSG_SUCCESS) { - MSG_DEBUG("MsgSettingGetBool is failed."); - } - - if (bNotification == false) { - MSG_DEBUG("Msg Alert notification is off."); - return; - } - - bool isTTSOn = false; - if (MsgSettingGetBool(VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE, &isTTSOn) != MSG_SUCCESS) - MSG_INFO("MsgSettingGetBool() is failed"); - - MSG_DEBUG("VCONFKEY_SETAPPL_DRIVINGMODE_DRIVINGMODE [%d]", isTTSOn); - - if(isTTSOn) { - bool isVoiceMail = false; - - if (msgSubType == MSG_MWI_VOICE_SMS) { - bool isVoiceMailOn = false; - if (MsgSettingGetBool(VCONFKEY_SETAPPL_DRIVINGMODE_NEWVOICEMAILS, &isVoiceMailOn) != MSG_SUCCESS) - MSG_INFO("MsgSettingGetBool() is failed"); - - MSG_DEBUG("VCONFKEY_SETAPPL_DRIVINGMODE_NEWVOICEMAILS [%d]", isVoiceMailOn); - if (isVoiceMailOn) { - isVoiceMail = true; - } else { - return; - } - } else { - bool isTTSMsgOn = false; - if (MsgSettingGetBool(VCONFKEY_SETAPPL_DRIVINGMODE_MESSAGE, &isTTSMsgOn) != MSG_SUCCESS) - MSG_INFO("MsgSettingGetBool() is failed"); - - MSG_DEBUG("VCONFKEY_SETAPPL_DRIVINGMODE_MESSAGE [%d]", isTTSMsgOn); - if (!isTTSMsgOn || !isFavorites) { - return; - } - } - -#ifndef MSG_WEARABLE_PROFILE - app_control_h svc_h; - - int ret = APP_CONTROL_ERROR_NONE; - - ret = app_control_create(&svc_h); - if (ret != APP_CONTROL_ERROR_NONE) { - MSG_DEBUG("app_control_create() is failed : %d", ret); - app_control_destroy(svc_h); - return; - } - - ret = app_control_set_app_id(svc_h, "org.tizen.msg-ui-tts-play"); - if (ret != APP_CONTROL_ERROR_NONE) { - MSG_DEBUG("app_control_set_app_id() is failed : %d", ret); - app_control_destroy(svc_h); - return; - } - - if (isVoiceMail) { - ret = app_control_add_extra_data(svc_h, "type", "voicemail"); - } else { - char tmpStrMsgId[10]; - memset(&tmpStrMsgId, 0x00, sizeof(tmpStrMsgId)); - snprintf(tmpStrMsgId, sizeof(tmpStrMsgId), "%d", msgId); - MSG_DEBUG("tmpStrMsgId [%s]", tmpStrMsgId); - ret = app_control_add_extra_data(svc_h, "msgId", tmpStrMsgId); - } - - if (ret != APP_CONTROL_ERROR_NONE) { - MSG_DEBUG("app_control_add_extra_data() is failed : %d", ret); - app_control_destroy(svc_h); - return; - } - - ret = app_control_send_launch_request(svc_h, NULL, NULL); - if (ret != APP_CONTROL_ERROR_NONE) { - MSG_DEBUG("app_control_send_launch_request() is failed : %d", ret); - app_control_destroy(svc_h); - return; - } - - app_control_destroy(svc_h); -#endif // MSG_WEARABLE_PROFILE - } - - MsgChangePmState(); -#endif - MSG_END(); -} - - void MsgLaunchClass0(msg_message_id_t msgId) { MSG_BEGIN(); @@ -259,11 +159,6 @@ msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_reques if (subType == MSG_RETRIEVE_AUTOCONF_MMS && pMsgInfo->networkStatus == MSG_NETWORK_RETRIEVE_SUCCESS) { #ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - bool isFavorites = false; - if (!checkBlockingMode(pMsgInfo->addressList[0].addressVal, &isFavorites)) { - MsgPlayTTSMode(subType, pMsgInfo->msgId, isFavorites); - } - // add phone log MSG_DEBUG("Enter MsgAddPhoneLog() for mms message."); MsgAddPhoneLog(pMsgInfo); @@ -277,10 +172,7 @@ msg_error_t MsgHandleMmsConfIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, msg_reques 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); - } + msg_launch_app(MSG_MGR_APP_ID, b); bundle_free(b); } #endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED @@ -350,15 +242,9 @@ msg_error_t MsgHandleIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti) err = MsgHandleSMS(pMsgInfo, pSendNoti, &bOnlyNoti); - if (err == MSG_SUCCESS && ((*pSendNoti) || bOnlyNoti)) { -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - bool isFavorites = false; - if (!checkBlockingMode(pMsgInfo->addressList[0].addressVal, &isFavorites)) { - MsgPlayTTSMode(pMsgInfo->msgType.subType, pMsgInfo->msgId, isFavorites); - } -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ + if (err == MSG_SUCCESS && ((*pSendNoti) || bOnlyNoti)) MsgInsertNotification(pMsgInfo); - } + } else if (pMsgInfo->msgType.mainType == MSG_MMS_TYPE) { err = MsgHandleMMS(pMsgInfo, pSendNoti); } @@ -509,13 +395,8 @@ msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti, bool *bO *bOnlyNoti = false; } else if (pMsgInfo->msgType.classType == MSG_CLASS_0) { MsgLaunchClass0(pMsgInfo->msgId); -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - bool isFavorites = false; - if (!checkBlockingMode(pMsgInfo->addressList[0].addressVal, &isFavorites)) { - MsgPlayTTSMode(pMsgInfo->msgType.subType, pMsgInfo->msgId, isFavorites); - MsgSoundPlayer::instance()->MsgSoundPlayStart(&(pMsgInfo->addressList[0]), MSG_SOUND_PLAY_USER); - } -#endif //MSG_CONTACTS_SERVICE_NOT_SUPPORTED + MsgSoundPlayStart(&(pMsgInfo->addressList[0]), MSG_SOUND_PLAY_USER); + *pSendNoti = false; *bOnlyNoti = false; @@ -733,15 +614,8 @@ msg_error_t MsgHandleMMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti) return err; } } else if (pMsgInfo->msgType.subType == MSG_READORGIND_MMS || pMsgInfo->msgType.subType == MSG_DELIVERYIND_MMS) { - if (MsgInsertNotification(pMsgInfo) == MSG_SUCCESS) { -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - bool isFavorites = false; - if (!checkBlockingMode(pMsgInfo->addressList[0].addressVal, &isFavorites)) { - MsgPlayTTSMode(pMsgInfo->msgType.subType, pMsgInfo->msgId, isFavorites); - } -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ + if (MsgInsertNotification(pMsgInfo) == MSG_SUCCESS) *pSendNoti = false; - } } #if 0 @@ -753,18 +627,10 @@ msg_error_t MsgHandleMMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti) //In the case of m-notification-ind, we should decide whether to send m-notify-response-ind or http 'Get' //submit request if (pMsgInfo->msgType.subType == MSG_NOTIFICATIONIND_MMS) { - if (request.msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS && bReject == false && bFiltered == false) { -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - bool isFavorites = false; - if (!checkBlockingMode(pMsgInfo->addressList[0].addressVal, &isFavorites)) { - MsgPlayTTSMode(pMsgInfo->msgType.subType, pMsgInfo->msgId, isFavorites); - } -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - + if (request.msgInfo.msgType.subType == MSG_NOTIFYRESPIND_MMS && bReject == false && bFiltered == false) MsgInsertNotification(pMsgInfo); - } else { + else *pSendNoti = false; - } MSG_DEBUG("default_sim = %d, pMsgInfo->sim_idx = %d", defaultNetworkSimId, pMsgInfo->sim_idx); diff --git a/framework/main.cpp b/framework/main.cpp index dd7068f..ba9249c 100755 --- a/framework/main.cpp +++ b/framework/main.cpp @@ -23,6 +23,7 @@ #include "MsgContact.h" #include "MsgMemory.h" #include "MsgGconfWrapper.h" +#include "MsgSensorWrapper.h" #include "MsgPluginManager.h" #include "MsgSettingHandler.h" #include "MsgStorageHandler.h" @@ -30,7 +31,6 @@ #include "MsgDeliverHandler.h" #include "MsgTransManager.h" #include "MsgStorageTypes.h" -#include "MsgSoundPlayer.h" #include "MsgCmdHandler.h" #include "MsgUtilFile.h" #include "MsgUtilStorage.h" @@ -53,11 +53,6 @@ void* InitMsgServer(void*) msg_error_t err = MSG_SUCCESS; MSG_DEBUG("Start InitMsgServer."); -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - /* Init contact digit number */ - MsgInitContactSvc(); -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - MsgInitCallStatusManager(); try { @@ -72,7 +67,7 @@ void* InitMsgServer(void*) MSG_ERR("FAIL TO INITIALIZE STORAGE HANDLER [%d]", err); } - MsgInitNoti(); + MsgInitSensor(); /* plugin manager initialize */ MsgPluginManager::instance()->initialize(); @@ -82,8 +77,6 @@ void* InitMsgServer(void*) MSG_FATAL("%s", e.what()); } -/* MsgSoundPlayer::instance()->MsgSoundInitRepeatAlarm(); */ - MsgStoDisconnectDB(); MsgReleaseMemory(); diff --git a/framework/storage-handler/MsgStorageUtil.cpp b/framework/storage-handler/MsgStorageUtil.cpp index 3f7ac9d..ab73816 100755 --- a/framework/storage-handler/MsgStorageUtil.cpp +++ b/framework/storage-handler/MsgStorageUtil.cpp @@ -23,7 +23,6 @@ #include "MsgCppTypes.h" #include "MsgUtilFile.h" #include "MsgContact.h" -#include "MsgSoundPlayer.h" #include "MsgGconfWrapper.h" #include "MsgSqliteWrapper.h" #include "MsgPluginManager.h" diff --git a/framework/transaction-manager/MsgCmdHandlerStorage.cpp b/framework/transaction-manager/MsgCmdHandlerStorage.cpp index ff617b7..915fc71 100755 --- a/framework/transaction-manager/MsgCmdHandlerStorage.cpp +++ b/framework/transaction-manager/MsgCmdHandlerStorage.cpp @@ -15,20 +15,20 @@ */ #include <stdlib.h> +#include <glib.h> #include "MsgDebug.h" #include "MsgUtilFile.h" #include "MsgException.h" #include "MsgCppTypes.h" -/*#include "MsgSoundPlayer.h" */ #include "MsgUtilFunction.h" #include "MsgStorageHandler.h" #include "MsgPluginManager.h" #include "MsgTransManager.h" #include "MsgCmdHandler.h" #include "MsgNotificationWrapper.h" +#include "MsgSqliteWrapper.h" #include "MsgMutex.h" -#include <glib.h> /*================================================================================================== FUNCTION IMPLEMENTATION diff --git a/framework/transaction-manager/MsgCmdHandlerTransport.cpp b/framework/transaction-manager/MsgCmdHandlerTransport.cpp index c69dcb5..272bc53 100755 --- a/framework/transaction-manager/MsgCmdHandlerTransport.cpp +++ b/framework/transaction-manager/MsgCmdHandlerTransport.cpp @@ -16,7 +16,6 @@ #include <time.h> -#include <aul.h> #include <bundle.h> #include <eventsystem.h> @@ -24,7 +23,6 @@ #include "MsgException.h" #include "MsgUtilFile.h" #include "MsgContact.h" -#include "MsgSoundPlayer.h" #include "MsgGconfWrapper.h" #include "MsgNotificationWrapper.h" #include "MsgUtilFunction.h" @@ -497,10 +495,7 @@ int MsgIncomingMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) } 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); - } + msg_launch_app(MSG_MGR_APP_ID, b); } eventsystem_send_system_event(SYS_EVENT_INCOMMING_MSG, b); bundle_free(b); @@ -712,7 +707,6 @@ __BYPASS_UPDATE: if (msgInfo.networkStatus == MSG_NETWORK_SEND_FAIL) { MSG_DEBUG("message-dialog: send fail"); MsgInsertTicker("Sending multimedia message failed.", SENDING_MULTIMEDIA_MESSAGE_FAILED, true, msgInfo.msgId); -/* MsgSoundPlayer::instance()->MsgSoundPlayStart(NULL, MSG_NORMAL_SOUND_PLAY); */ } else { MSG_DEBUG("message-dialog: send success"); @@ -741,10 +735,7 @@ __BYPASS_UPDATE: 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); - } + msg_launch_app(MSG_MGR_APP_ID, b); bundle_free(b); } #endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ @@ -850,11 +841,7 @@ int MsgIncomingCBMsgHandler(const MSG_CMD_S *pCmd, char **ppEvent) if (msgInfo.msgType.classType == MSG_CLASS_0) { MsgLaunchClass0(msgInfo.msgId); - bool isFavorites = false; - if (!checkBlockingMode(msgInfo.addressList[0].addressVal, &isFavorites)) { - MsgPlayTTSMode(msgInfo.msgType.subType, msgInfo.msgId, isFavorites); - MsgSoundPlayer::instance()->MsgSoundPlayStart(&(msgInfo.addressList[0]), MSG_SOUND_PLAY_USER); - } + MsgSoundPlayStart(&(msgInfo.addressList[0]), MSG_SOUND_PLAY_USER); } else { MsgInsertNotification(&msgInfo); } diff --git a/include/common/MsgInternalTypes.h b/include/common/MsgInternalTypes.h index 70a930b..8526dfa 100755 --- a/include/common/MsgInternalTypes.h +++ b/include/common/MsgInternalTypes.h @@ -186,11 +186,7 @@ #define MSG_MESSAGE_DURING_CALL DEFAULT_GENERAL_OPT_PATH"/during_call" #define MSG_DEFAULT_APP_ID "org.tizen.message" -#define MSG_QUICKPANEL_APP_ID "org.tizen.quickpanel" -#define MSG_INDICATOR_APP_ID "org.tizen.indicator" -#define MSG_CALL_APP_ID "org.tizen.call-ui" -#define MSG_SETTING_APP_ID "org.tizen.setting" -#define MSG_TEL_URI_VOICEMAIL "tel:VOICEMAIL" +#define MSG_MGR_APP_ID "org.tizen.msg-manager" #define MSG_TELEPHONY_SMS_FEATURE "http://tizen.org/feature/network.telephony.sms" #define MSG_TELEPHONY_MMS_FEATURE "http://tizen.org/feature/network.telephony.mms" diff --git a/include/externals/MsgNotificationWrapper.h b/include/externals/MsgNotificationWrapper.h index 7bb8c11..ae84c54 100755 --- a/include/externals/MsgNotificationWrapper.h +++ b/include/externals/MsgNotificationWrapper.h @@ -21,7 +21,6 @@ INCLUDE FILES ==================================================================================================*/ #include "MsgInternalTypes.h" -#include "MsgSqliteWrapper.h" /*================================================================================================== DEFINES @@ -30,42 +29,8 @@ #define MSG_APP_LOCALEDIR TZ_SYS_RO_APP_PATH "/" MSG_DEFAULT_APP_ID "/res/locale" -#define MSG_NOTIFICATION_ICON_DIR "/" MSG_QUICKPANEL_APP_ID "/shared/res/noti_icons" -#define MSG_STATUS_ICON_DIR MSG_INDICATOR_APP_ID "/res/icons" - -/* notification icon */ -#define MSG_NORMAL_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message.png" -#define MSG_SIM_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_sim-card.png" -#define MSG_OTA_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_OTA.png" -#define MSG_VOICE_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_voice_mail.png" -#define MSG_CB_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_cb-msg.png" -#define MSG_READ_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_read_report.png" -#define MSG_DELIVERY_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_delivery_report.png" -#define MSG_REPLY_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_reply.png" -#define MSG_SMS_SENDING_FAILED_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_failed.png" -#define MSG_MMS_SENDING_FAILED_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_mms_failed.png" -#define MSG_MMS_RETRIVE_FAILED_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_mms_problem.png" -#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" - -/* status bar icon */ -#define MSG_NORMAL_STATUS_ICON TZ_SYS_RO_APP_PATH MSG_STATUS_ICON_DIR "/Notify/B03_notify_message.png" -#define MSG_FAILED_STATUS_ICON TZ_SYS_RO_APP_PATH MSG_STATUS_ICON_DIR "/Notify/B03_notify_message_failed.png" -#define MSG_DELIVER_REPORT_STATUS_ICON TZ_SYS_RO_APP_PATH MSG_STATUS_ICON_DIR "/Event/B03_event_delivery_report_message.png" -#define MSG_READ_REPORT_STATUS_ICON TZ_SYS_RO_APP_PATH MSG_STATUS_ICON_DIR "/Event/B03_event_read_report_message.png" -#define MSG_VOICE_MSG_STATUS_ICON TZ_SYS_RO_APP_PATH MSG_STATUS_ICON_DIR "/Event/B03_event_voicemail.png" -#define MSG_SIM_FULL_STATUS_ICON TZ_SYS_RO_APP_PATH MSG_STATUS_ICON_DIR "/SIM card full/B03_sim_card_full.png" #ifndef TIZEN_I586_ENABLED -/* system string */ -#define NEW_MESSAGE "IDS_MSGF_POP_NEW_MESSAGE" -#define NEW_MESSAGES "IDS_MSGF_POP_NEW_MESSAGES" -#define MSG_UNKNOWN_SENDER "IDS_MSGF_BODY_UNKNOWN" -#define MSG_NO_SUBJECT "IDS_MSGF_BODY_NO_SUBJECT" -#define MSG_SUBJECT_COLON "IDS_MSGF_OPT_SUBJECT_COLON" - - /* message app string for ticker noti */ #define SENDING_MULTIMEDIA_MESSAGE_FAILED "IDS_MSGF_POP_SENDING_MULTIMEDIA_MESSAGE_FAILED" #define MULTIMEDIA_MESSAGE_SENT "IDS_MSGF_POP_MULTIMEDIA_MESSAGE_SENT" @@ -77,45 +42,9 @@ #define SMS_MESSAGE_SIM_MESSAGE_FULL "IDS_MSGF_BODY_SIM_MEMORY_FULL_DELETE_SOME_ITEMS" #define SMS_MESSAGE_MEMORY_FULL "IDS_MSGF_POP_NOT_ENOUGH_MEMORY_DELETE_SOME_ITEMS" #define SMS_FDN_RESTRICTED "IDS_MSGF_POP_FDN_ENABLED_CANT_SEND_MSG" -#define SMS_SIM_CARD_FULL "IDS_MSG_HEADER_SIM_CARD_FULL" #define SMS_MESSAGE_SIZE_OVER_SIM_SLOT_SIZE "IDS_MSGF_BODY_MESSAGE_IS_TOO_LARGE_TO_STORE_AS_A_SINGLE_MESSAGE_TO_SIM_CARD" -/* message app string for quickpanel noti */ -#define MSG_MESSAGE "IDS_MSGF_BODY_MESSAGE" -#define VOICE_MAIL "IDS_MSGF_BODY_VOICEMAIL" -#define NEW_VOICE_MAIL "IDS_MSGF_BODY_NEW_VOICEMAIL" -#define CB_MESSAGE "IDS_MSGF_BODY_CB_MESSAGES" -#define CP_MESSAGE "IDS_MSGF_BODY_CP_MESSAGES" -#define PUSH_MESSAGE "IDS_MSGF_BODY_PUSH_MESSAGES" -#define DELIVERY_MESSAGE "IDS_MSGF_BODY_DELIVERY_REPORT" -#define READ_REPORT_MESSAGE "IDS_MSGF_POP_READ_REPORT" -#define EXPIRED_MESSAGE "IDS_MSGF_BODY_MESSAGE_HAS_EXPIRED" -#define REJECTED_MESSAGE "IDS_MSGF_BODY_MMSDELIVERYMSGREJECTED" -#define DEFERRED_MESSAGE "IDS_MSGF_POP_MESSAGE_DEFERRED" -#define UNRECOGNISED_MESSAGE "IDS_MSGF_POP_MESSAGE_UNRECOGNISED" -#define INDETEMINATE_MESSAGE "IDS_MSGF_POP_INDETERMINATE" -#define UNREACHABLE_MESSAGE "IDS_MSGF_POP_UNREACHABLE" -#define DELIVERED_MESSAGE "IDS_MSGF_BODY_MESSAGE_DELIVERED" -#define VOICE_1_MESSAGE "IDS_MSGF_BODY_1_MESSAGE" -#define VOICE_N_MESSAGE "IDS_MSGF_BODY_PD_MESSAGES" -#define SIM_CARD_MESSAGE "IDS_MSGF_BODY_SIM_CARD_MESSAGES" -#define READ_REPORT_READ "IDS_COM_BODY_READ" -#define READ_REPORT_DELETE "IDS_MSG_OPT_DELETE" -#define FAILED_MSG_EXIST "IDS_MSG_BODY_FAILED_MESSAGES_EXIST" -#define ENABLE_EMERGENCY_MODE "IDS_MSG_BODY_ENABLE_EMERGENCY_MODE_JPN_DCM" -#define EMERGENCY_MODE_DESCRIPTION "IDS_MSG_SBODY_TAP_HERE_TO_ENABLE_EMERGENCY_MODE_TO_SAVE_BATTERY_POWER_JPN_DCM" -#define FAILED_TO_SEND_MESSAGE "IDS_MSG_HEADER_FAILED_TO_SEND_MESSAGE_ABB" -#define MESSAGE_SIZE_UNIT_KB "IDS_MSGF_BODY_MSGSIZE_KB" -#define MESSAGE_SIZE_STRING "IDS_MSGF_BODY_MESSAGE_SIZE" -#define MSG_SUBJECT_COLON "IDS_MSGF_OPT_SUBJECT_COLON" #else -/* system string */ -#define NEW_MESSAGE "New message" -#define NEW_MESSAGES "New messages" -#define MSG_UNKNOWN_SENDER "New message from Unknown." -#define MSG_NO_SUBJECT "No subject" - - /* message app string for ticker noti */ #define SENDING_MULTIMEDIA_MESSAGE_FAILED "Sending multimedia message failed" #define MULTIMEDIA_MESSAGE_SENT "Multimedia message sent." @@ -127,37 +56,8 @@ #define SMS_MESSAGE_SIM_MESSAGE_FULL "SIM memory full. Delete some items." #define SMS_MESSAGE_MEMORY_FULL "Not enough memory. Delete some items." #define SMS_FDN_RESTRICTED "Unable to send the message while Fixed dialling mode is enabled." -#define SMS_SIM_CARD_FULL "SIM card full" #define SMS_MESSAGE_SIZE_OVER_SIM_SLOT_SIZE "Message is too large to store as a single message to SIM card." -/* message app string for quickpanel noti */ -#define MSG_MESSAGE "Message" -#define VOICE_MAIL "Voicemail" -#define NEW_VOICE_MAIL "New voicemail" -#define CB_MESSAGE "CB messages" -#define CP_MESSAGE "CP messages" -#define PUSH_MESSAGE "Push messages" -#define DELIVERY_MESSAGE "Delivery report" -#define READ_REPORT_MESSAGE "Read report" -#define EXPIRED_MESSAGE "Message expired." -#define REJECTED_MESSAGE "Message rejected." -#define DEFERRED_MESSAGE "Message deferred" -#define UNRECOGNISED_MESSAGE "Message unrecognised" -#define INDETEMINATE_MESSAGE "Indeterminate." -#define UNREACHABLE_MESSAGE "Unreachable" -#define DELIVERED_MESSAGE "Message delivered" -#define VOICE_1_MESSAGE "1 message" -#define VOICE_N_MESSAGE "%d messages" -#define SIM_CARD_MESSAGE "SIM card messages" -#define READ_REPORT_READ "Read" -#define READ_REPORT_DELETE "Deleted." -#define FAILED_MSG_EXIST "Failed messages exist." -#define ENABLE_EMERGENCY_MODE "Enable Emergency mode" -#define EMERGENCY_MODE_DESCRIPTION "Tap here to enable Emergency mode to save battery power." -#define FAILED_TO_SEND_MESSAGE "Failed to send message." -#define MESSAGE_SIZE_UNIT_KB "KB" -#define MESSAGE_SIZE_STRING "Message Size" -#define MSG_SUBJECT_COLON "Subject:" #endif #define NOTIFICATION_PRIV_ID DEFAULT_SETTING_PATH"/notification_priv_id" @@ -168,10 +68,6 @@ #define MSG_SENTFAIL_NOTI_ID DEFAULT_SETTING_PATH"/sentfail_noti_id" #define SIM_FULL_NOTI_PRIV_ID DEFAULT_SETTING_PATH"/sim_full_noti_id" -#define MSG_NOTI_TEXT_LEN (512) -#define MSG_NOTI_TEXT_LEN_S (256) -#define MSG_ACTIVE_NOTI_BUTTON_NUM 3 - enum _msg_notification_type_e { MSG_NOTI_TYPE_ALL = 0x00, @@ -199,8 +95,17 @@ enum _msg_active_notification_type_e { MSG_ACTIVE_NOTI_TYPE_INSTANT, }; +enum _MSG_SOUND_TYPE_E +{ + MSG_SOUND_PLAY_DEFAULT = 0, + MSG_SOUND_PLAY_USER, + MSG_SOUND_PLAY_EMERGENCY, + MSG_SOUND_PLAY_VOICEMAIL, +}; + typedef unsigned char msg_notification_type_t; /* _msg_notification_type_e */ typedef unsigned char msg_active_notification_type_t; /* _msg_active_notification_type_e */ +typedef unsigned char MSG_SOUND_TYPE_T; msg_error_t MsgInsertNotification(MSG_MESSAGE_INFO_S *msg_info); @@ -211,14 +116,12 @@ msg_error_t MsgInsertOnlyActiveNotification(msg_notification_type_t noti_type, M msg_error_t MsgDeleteReportNotification(const char *addr); msg_error_t MsgInsertTicker(const char* pTickerMsg, const char* pLocaleTickerMsg, bool bPlayFeedback, int msgId); -msg_error_t MsgInsertInstantMessage(msg_notification_type_t noti_type); -msg_error_t MsgInitNoti(); -msg_error_t MsgInsertBadge(unsigned int unreadMsgCnt); msg_error_t MsgDeleteNoti(msg_notification_type_t noti_type, int simIndex); +void MsgSoundPlayStart(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_SOUND_TYPE_T soundType); + void MsgRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_active_notification_type_t active_type); void MsgDeleteNotification(msg_notification_type_t noti_type, int simIndex); -void MsgInitReportNotiList(); bool MsgCheckNotificationSettingEnable(void); #endif diff --git a/include/externals/MsgSensorWrapper.h b/include/externals/MsgSensorWrapper.h index ed7014f..8a6bc57 100755 --- a/include/externals/MsgSensorWrapper.h +++ b/include/externals/MsgSensorWrapper.h @@ -30,6 +30,7 @@ typedef void (*msg_sensor_cb)(); FUNCTION PROTOTYPES ==================================================================================================*/ +void MsgInitSensor(); msg_error_t MsgSensorConnect(); void MsgSensorDisconnect(); msg_error_t MsgRegSensorCB(msg_sensor_cb cb); diff --git a/include/externals/MsgSoundPlayer.h b/include/externals/MsgSoundPlayer.h deleted file mode 100755 index 200390e..0000000 --- a/include/externals/MsgSoundPlayer.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014 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_SOUND_PLAYER_H -#define MSG_SOUND_PLAYER_H - - -/*================================================================================================== - TYPES -==================================================================================================*/ -typedef unsigned char MSG_SOUND_TYPE_T; - -/*================================================================================================== - ENUMS -==================================================================================================*/ -enum _MSG_SOUND_TYPE_E -{ - MSG_SOUND_PLAY_DEFAULT = 0, - MSG_SOUND_PLAY_USER, - MSG_SOUND_PLAY_EMERGENCY, - MSG_SOUND_PLAY_VOICEMAIL, -}; - -/*================================================================================================== - CLASS DEFINITIONS -==================================================================================================*/ -class MsgSoundPlayer { -public: - static MsgSoundPlayer* instance(); - - void MsgSoundPlayStart(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_SOUND_TYPE_T soundType); - void MsgSoundPlayStop(); - - int MsgStreamStart(MSG_SOUND_TYPE_T soundType); - void MsgStreamStop(); - - void MsgSoundInitRepeatAlarm(); - - void MsgGetRingtonePath(char *userRingtonePath, char **msg_tone_file_path_p); - void MsgGetPlayStatus(bool bVoiceMail, bool *bPlaySound, bool *bPlayVibration, bool *bOnCall); - -private: - MsgSoundPlayer(); - ~MsgSoundPlayer(); - - void MsgSoundPlayMelody(char *pMsgToneFilePath); - void MsgSoundPlayVibration(char *vibrationPath); - - void MsgSoundSetRepeatAlarm(); - void MsgSoundCreateRepeatAlarm(int RepeatTime); - int MsgSoundGetUnreadMsgCnt(); - void MsgGetPlayStatus(bool bOnCall, bool bSound, bool bVibration, bool bMsgSound, bool bMsgVibration, bool *bPlaySound, bool *bPlayVibration); - - static MsgSoundPlayer* pInstance; - - bool bPlaying; - bool bVibrating; - bool bFeedbackInit; - - int g_alarmId; - - char *defaultRingtonePath; -}; - -#endif /* MSG_SOUND_PLAYER_H */ - diff --git a/include/framework/MsgDeliverHandler.h b/include/framework/MsgDeliverHandler.h index 8baf4af..b18a97e 100755 --- a/include/framework/MsgDeliverHandler.h +++ b/include/framework/MsgDeliverHandler.h @@ -32,7 +32,6 @@ msg_error_t MsgHandleIncomingMsg(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti); msg_error_t MsgHandleSMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti, bool *bOnlyNoti); msg_error_t MsgHandleMMS(MSG_MESSAGE_INFO_S *pMsgInfo, bool *pSendNoti); -void MsgPlayTTSMode(MSG_SUB_TYPE_T msgSubType, msg_message_id_t msgId, bool isFavorites); void MsgLaunchClass0(msg_message_id_t msgId); /*================================================================================================== diff --git a/include/utils/MsgContact.h b/include/utils/MsgContact.h index b71fc07..3337d31 100755 --- a/include/utils/MsgContact.h +++ b/include/utils/MsgContact.h @@ -26,8 +26,6 @@ /*================================================================================================== FUNCTION PROTOTYPES ==================================================================================================*/ -msg_error_t MsgInitContactSvc(); - msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_INFO_S *pContactInfo); msg_error_t MsgGetContactStyleDisplayName(const char *first, const char *last, const char *middle, const char *prefix, const char *suffix, int contactNameOrder, char *displayName, unsigned int size); @@ -37,7 +35,6 @@ void MsgDeletePhoneLog(msg_message_id_t msgId); bool checkBlockingMode(char *address, bool *pisFavorites); -int MsgContactGetMinMatchDigit(); void MsgConvertNumber(const char* pSrcNum, char* pDestNum, int destSize); bool MsgIsNumber(const char* pSrc); #endif /* MSG_CONTACT_H */ diff --git a/include/utils/MsgUtilFunction.h b/include/utils/MsgUtilFunction.h index 9b68fbd..8472c2a 100755 --- a/include/utils/MsgUtilFunction.h +++ b/include/utils/MsgUtilFunction.h @@ -28,6 +28,8 @@ #include "MsgInternalTypes.h" #include "MsgCmdTypes.h" +#include <bundle.h> + /*================================================================================================== DEFINES ==================================================================================================*/ @@ -45,6 +47,8 @@ bool MsgCheckFeatureSupport(const char *feature_name); +int MsgContactGetMinMatchDigit(); + /* Encoders */ int MsgEncodeCountInfo(MSG_COUNT_INFO_S *pCountInfo, char **ppDest); @@ -152,6 +156,8 @@ gchar * msg_replace_non_ascii_char(const gchar *pszText, gunichar replacementCha uid_t msg_get_login_user(); +msg_error_t msg_launch_app(const char *app_id, bundle *bundle_data); + /* Dbus function */ void MsgDbusInit(); void MsgDbusDeinit(); diff --git a/manager/CMakeLists.txt b/manager/CMakeLists.txt index 3bf5a2a..aff20c4 100755 --- a/manager/CMakeLists.txt +++ b/manager/CMakeLists.txt @@ -1,5 +1,4 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -include(CheckCCompilerFlag) SET(MSG-MGR-PKGNAME org.tizen.msg-manager) @@ -20,17 +19,19 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -O2 -g -Wall") SET(MSG-MANAGER-SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/msg-manager.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/msg-manager-alarm.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/msg-manager-contact.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/msg-manager-notification.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/msg-manager-sound.cpp ) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include/mapi - ${CMAKE_CURRENT_SOURCE_DIR}/inc/ + ${CMAKE_CURRENT_SOURCE_DIR}/inc/ ) INCLUDE(FindPkgConfig) -pkg_check_modules(mgr_pkgs REQUIRED glib-2.0 dlog appcore-agent bundle contacts-service2 capi-appfw-application notification) +pkg_check_modules(mgr_pkgs REQUIRED glib-2.0 dlog alarm-service appcore-agent badge bundle callmgr_client contacts-service2 capi-appfw-application capi-appfw-package-manager notification vconf phonenumber-utils feedback capi-media-player capi-media-sound-manager) INCLUDE_DIRECTORIES(${mgr_pkgs_INCLUDE_DIRS}) LINK_DIRECTORIES(${mgr_pkgs_LIBRARY_DIRS}) diff --git a/manager/inc/msg-manager-alarm.h b/manager/inc/msg-manager-alarm.h new file mode 100644 index 0000000..e86d230 --- /dev/null +++ b/manager/inc/msg-manager-alarm.h @@ -0,0 +1,42 @@ +/* + * 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_ALARM_H__ +#define __MSG_MGR_ALARM_H__ + +/*================================================================================================== + INCLUDE FILES +==================================================================================================*/ +#include <time.h> + +#include <msg.h> +#include <alarm.h> + +/*================================================================================================== + DEFINES +==================================================================================================*/ + +typedef void (*msg_mgr_alarm_cb)(int alarmId); + +/*================================================================================================== + FUNCTION PROTOTYPES +==================================================================================================*/ +int MsgMgrAlarmRegistration(struct tm *timeInfo, msg_mgr_alarm_cb userCB, int *alarmId); +int MsgMgrAlarmRemove(int alarmId); + + +#endif /*__MSG_MGR_ALARM_H__ */ + diff --git a/manager/inc/msg-manager-contact.h b/manager/inc/msg-manager-contact.h index 232e110..ed5fab4 100644 --- a/manager/inc/msg-manager-contact.h +++ b/manager/inc/msg-manager-contact.h @@ -33,15 +33,37 @@ STRUCTURES ==================================================================================================*/ typedef struct _contactInfo { - int msgId; - int msgType; - int folderId; - int simIndex; - char msgText[MAX_CONTACT_TEXT_LEN + 1]; - char subject[MAX_CONTACT_TEXT_LEN + 1]; - msg_list_handle_t addrList; + msg_message_id_t msgId; + int msgType; + int folderId; + int simIndex; + char msgText[MAX_CONTACT_TEXT_LEN + 1]; + char subject[MAX_CONTACT_TEXT_LEN + 1]; + msg_list_handle_t addrList; } contactInfo; +typedef struct +{ + msg_contact_id_t contactId; /**< Indicates the unique contact ID. */ + int addrbookId; /**< Indicates the address book ID. */ + char firstName[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the first name of contact. */ + char lastName[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the last name of contact. */ + char middleName[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the middle name of contact. */ + char prefix[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the prefix of contact. */ + char suffix[MAX_DISPLAY_NAME_LEN+1]; /**< Indicates the suffix of contact. */ + char imagePath[MSG_FILEPATH_LEN_MAX+1]; /**< Indicates the image path of contact. */ + char alerttonePath[MSG_FILEPATH_LEN_MAX+1]; /**< Indicates the message alert tone path of contact. */ + char vibrationPath[MSG_FILEPATH_LEN_MAX+1]; /**< Indicates the vibration path of contact. */ +} MSG_MGR_CONTACT_INFO_S; + +typedef struct +{ + msg_address_type_t addressType; /**< The type of an address in case of an Email or a mobile phone */ + msg_recipient_type_t recipientType; /**< The type of recipient address in case of To, Cc, and Bcc */ + msg_contact_id_t contactId; /**< The contact ID of address */ + char addressVal[MAX_ADDRESS_VAL_LEN+1]; /**< The actual value of an address */ + char displayName[MAX_DISPLAY_NAME_LEN+1]; /**< The display name of an address */ +} MSG_MGR_ADDRESS_INFO_S; /*================================================================================================== FUNCTION PROTOTYPES @@ -50,6 +72,7 @@ typedef struct _contactInfo { int MsgMgrOpenContactSvc(); int MsgMgrCloseContactSvc(); void MsgMgrAddPhoneLog(contactInfo *contact_info); +int MsgMgrGetContactInfo(const MSG_MGR_ADDRESS_INFO_S *pAddrInfo, MSG_MGR_CONTACT_INFO_S *pContactInfo); #endif /*__MSG_MGR_CONTACT_H__ */ diff --git a/manager/inc/msg-manager-notification.h b/manager/inc/msg-manager-notification.h index d8f1117..f27a139 100644 --- a/manager/inc/msg-manager-notification.h +++ b/manager/inc/msg-manager-notification.h @@ -22,20 +22,276 @@ ==================================================================================================*/ #include <msg.h> +#include <app_control.h> + /*================================================================================================== DEFINES ==================================================================================================*/ +#define MSG_NOTI_INTEGRATION + +#define MSGFW_MESSAGE_TABLE_NAME "MSG_MESSAGE_TABLE" +#define MSGFW_FOLDER_TABLE_NAME "MSG_FOLDER_TABLE" +#define MSGFW_ADDRESS_TABLE_NAME "MSG_ADDRESS_TABLE" +#define MSGFW_CONVERSATION_TABLE_NAME "MSG_CONVERSATION_TABLE" +#define MMS_PLUGIN_MESSAGE_TABLE_NAME "MSG_MMS_MESSAGE_TABLE" +#define MSGFW_SMS_REPORT_TABLE_NAME "MSG_SMS_REPORT_TABLE" +#define MSGFW_REPORT_TABLE_NAME "MSG_REPORT_TABLE" + +#define MSG_DEFAULT_APP_ID "org.tizen.message" +#define MSG_QUICKPANEL_APP_ID "org.tizen.quickpanel" +#define MSG_INDICATOR_APP_ID "org.tizen.indicator" +#define MSG_CALL_APP_ID "org.tizen.call-ui" +#define MSG_SETTING_APP_ID "org.tizen.setting" + +#define MSG_APP_PACKAGE_NAME "message" + +#define MSG_APP_LOCALEDIR TZ_SYS_RO_APP_PATH "/" MSG_DEFAULT_APP_ID "/res/locale" + +#define MSG_NOTIFICATION_ICON_DIR "/" MSG_QUICKPANEL_APP_ID "/shared/res/noti_icons" +#define MSG_STATUS_ICON_DIR MSG_INDICATOR_APP_ID "/res/icons" + +/* notification icon */ +#define MSG_NORMAL_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message.png" +#define MSG_SIM_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_sim-card.png" +#define MSG_OTA_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_OTA.png" +#define MSG_VOICE_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_voice_mail.png" +#define MSG_CB_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_cb-msg.png" +#define MSG_READ_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_read_report.png" +#define MSG_DELIVERY_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_delivery_report.png" +#define MSG_REPLY_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_reply.png" +#define MSG_SMS_SENDING_FAILED_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_failed.png" +#define MSG_MMS_SENDING_FAILED_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_mms_failed.png" +#define MSG_MMS_RETRIVE_FAILED_ICON_PATH TZ_SYS_RO_APP_PATH MSG_NOTIFICATION_ICON_DIR "/Message/noti_message_mms_problem.png" +#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" + +/* status bar icon */ +#define MSG_NORMAL_STATUS_ICON TZ_SYS_RO_APP_PATH MSG_STATUS_ICON_DIR "/Notify/B03_notify_message.png" +#define MSG_FAILED_STATUS_ICON TZ_SYS_RO_APP_PATH MSG_STATUS_ICON_DIR "/Notify/B03_notify_message_failed.png" +#define MSG_DELIVER_REPORT_STATUS_ICON TZ_SYS_RO_APP_PATH MSG_STATUS_ICON_DIR "/Event/B03_event_delivery_report_message.png" +#define MSG_READ_REPORT_STATUS_ICON TZ_SYS_RO_APP_PATH MSG_STATUS_ICON_DIR "/Event/B03_event_read_report_message.png" +#define MSG_VOICE_MSG_STATUS_ICON TZ_SYS_RO_APP_PATH MSG_STATUS_ICON_DIR "/Event/B03_event_voicemail.png" +#define MSG_SIM_FULL_STATUS_ICON TZ_SYS_RO_APP_PATH MSG_STATUS_ICON_DIR "/SIM card full/B03_sim_card_full.png" + +#ifndef TIZEN_I586_ENABLED +/* system string */ +#define NEW_MESSAGE "IDS_MSGF_POP_NEW_MESSAGE" +#define NEW_MESSAGES "IDS_MSGF_POP_NEW_MESSAGES" +#define MSG_UNKNOWN_SENDER "IDS_MSGF_BODY_UNKNOWN" +#define MSG_NO_SUBJECT "IDS_MSGF_BODY_NO_SUBJECT" + + +/* message app string for ticker noti */ +#define SMS_MESSAGE_MEMORY_FULL "IDS_MSGF_POP_NOT_ENOUGH_MEMORY_DELETE_SOME_ITEMS" +#define SMS_SIM_CARD_FULL "IDS_MSG_HEADER_SIM_CARD_FULL" + +/* message app string for quickpanel noti */ +#define MSG_MESSAGE "IDS_MSGF_BODY_MESSAGE" +#define VOICE_MAIL "IDS_MSGF_BODY_VOICEMAIL" +#define NEW_VOICE_MAIL "IDS_MSGF_BODY_NEW_VOICEMAIL" +#define CB_MESSAGE "IDS_MSGF_BODY_CB_MESSAGES" +#define CP_MESSAGE "IDS_MSGF_BODY_CP_MESSAGES" +#define PUSH_MESSAGE "IDS_MSGF_BODY_PUSH_MESSAGES" +#define DELIVERY_MESSAGE "IDS_MSGF_BODY_DELIVERY_REPORT" +#define READ_REPORT_MESSAGE "IDS_MSGF_POP_READ_REPORT" +#define EXPIRED_MESSAGE "IDS_MSGF_BODY_MESSAGE_HAS_EXPIRED" +#define REJECTED_MESSAGE "IDS_MSGF_BODY_MMSDELIVERYMSGREJECTED" +#define DEFERRED_MESSAGE "IDS_MSGF_POP_MESSAGE_DEFERRED" +#define UNRECOGNISED_MESSAGE "IDS_MSGF_POP_MESSAGE_UNRECOGNISED" +#define INDETEMINATE_MESSAGE "IDS_MSGF_POP_INDETERMINATE" +#define UNREACHABLE_MESSAGE "IDS_MSGF_POP_UNREACHABLE" +#define DELIVERED_MESSAGE "IDS_MSGF_BODY_MESSAGE_DELIVERED" +#define VOICE_1_MESSAGE "IDS_MSGF_BODY_1_MESSAGE" +#define VOICE_N_MESSAGE "IDS_MSGF_BODY_PD_MESSAGES" +#define SIM_CARD_MESSAGE "IDS_MSGF_BODY_SIM_CARD_MESSAGES" +#define READ_REPORT_READ "IDS_COM_BODY_READ" +#define READ_REPORT_DELETE "IDS_MSG_OPT_DELETE" +#define FAILED_MSG_EXIST "IDS_MSG_BODY_FAILED_MESSAGES_EXIST" +#define ENABLE_EMERGENCY_MODE "IDS_MSG_BODY_ENABLE_EMERGENCY_MODE_JPN_DCM" +#define EMERGENCY_MODE_DESCRIPTION "IDS_MSG_SBODY_TAP_HERE_TO_ENABLE_EMERGENCY_MODE_TO_SAVE_BATTERY_POWER_JPN_DCM" +#define FAILED_TO_SEND_MESSAGE "IDS_MSG_HEADER_FAILED_TO_SEND_MESSAGE_ABB" +#define MESSAGE_SIZE_UNIT_KB "IDS_MSGF_BODY_MSGSIZE_KB" +#define MESSAGE_SIZE_STRING "IDS_MSGF_BODY_MESSAGE_SIZE" +#define MSG_SUBJECT_COLON "IDS_MSGF_OPT_SUBJECT_COLON" +#else +/* system string */ +#define NEW_MESSAGE "New message" +#define NEW_MESSAGES "New messages" +#define MSG_UNKNOWN_SENDER "New message from Unknown." +#define MSG_NO_SUBJECT "No subject" + + +/* message app string for ticker noti */ +#define SMS_MESSAGE_MEMORY_FULL "Not enough memory. Delete some items." +#define SMS_SIM_CARD_FULL "SIM card full" + +/* message app string for quickpanel noti */ +#define MSG_MESSAGE "Message" +#define VOICE_MAIL "Voicemail" +#define NEW_VOICE_MAIL "New voicemail" +#define CB_MESSAGE "CB messages" +#define CP_MESSAGE "CP messages" +#define PUSH_MESSAGE "Push messages" +#define DELIVERY_MESSAGE "Delivery report" +#define READ_REPORT_MESSAGE "Read report" +#define EXPIRED_MESSAGE "Message expired." +#define REJECTED_MESSAGE "Message rejected." +#define DEFERRED_MESSAGE "Message deferred" +#define UNRECOGNISED_MESSAGE "Message unrecognised" +#define INDETEMINATE_MESSAGE "Indeterminate." +#define UNREACHABLE_MESSAGE "Unreachable" +#define DELIVERED_MESSAGE "Message delivered" +#define VOICE_1_MESSAGE "1 message" +#define VOICE_N_MESSAGE "%d messages" +#define SIM_CARD_MESSAGE "SIM card messages" +#define READ_REPORT_READ "Read" +#define READ_REPORT_DELETE "Deleted." +#define FAILED_MSG_EXIST "Failed messages exist." +#define ENABLE_EMERGENCY_MODE "Enable Emergency mode" +#define EMERGENCY_MODE_DESCRIPTION "Tap here to enable Emergency mode to save battery power." +#define FAILED_TO_SEND_MESSAGE "Failed to send message." +#define MESSAGE_SIZE_UNIT_KB "KB" +#define MESSAGE_SIZE_STRING "Message Size" +#define MSG_SUBJECT_COLON "Subject:" +#endif + + +#define NOTIFICATION_PRIV_ID "db/private/msg-service/notification_priv_id" +#define VOICE_NOTI_ID_1 "db/private/msg-service/voice_noti_id1" +#define VOICE_NOTI_ID_2 "db/private/msg-service/voice_noti_id2" +#define CB_NOTI_PRIV_ID "db/private/msg-service/cb_noti_priv_id" +#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 MSG_SETTING_NOTIFICATION "db/private/msg-service/general/notification" +#define MSG_SETTING_VIBRATION "db/private/msg-service/general/vibration" +#define MSG_SETTING_PREVIEW "db/private/msg-service/general/preview" +#define MSG_SETTING_RINGTONE_PATH "db/private/msg-service/general/ringtone_path" +#define MSG_SETTING_RINGTONE_TYPE "db/private/msg-service/general/ringtone_type" + +#define VOICEMAIL_NUMBER "db/private/msg-service/voice_mail/voice_mail_number" +#define VOICEMAIL_COUNT "db/private/msg-service/voice_mail/voice_mail_count" +#define VOICEMAIL_ALPHA_ID "db/private/msg-service/voice_mail/voice_mail_alphaid" +#define VOICEMAIL_DEFAULT_NUMBER "db/private/msg-service/voice_mail/voice_mail_default_number" +#define VOICEMAIL_DEFAULT_ALPHA_ID "" + +#define MSG_ALERT_REP_TYPE "db/setting/sound/noti/msg_alert_rep_type" + +#define MSG_TEL_URI_VOICEMAIL "tel:VOICEMAIL" + +#define MSG_NOTI_TEXT_LEN (512) +#define MSG_NOTI_TEXT_LEN_S (256) +#define MAX_VCONFKEY_NAME_LEN 128 +#define MSG_ACTIVE_NOTI_BUTTON_NUM 3 +#define MAX_QUERY_LEN 4096 + + + +typedef unsigned char msg_mgr_notification_type_t; /* _msg_notification_type_e */ +typedef unsigned char msg_mgr_active_notification_type_t; /* _msg_active_notification_type_e */ + /*================================================================================================== - STRUCTURES + ENUMS ==================================================================================================*/ +enum _msg_mgr_notification_type_e { + MSG_MGR_NOTI_TYPE_ALL = 0x00, + + /* Refresh single/multiple notification */ + MSG_MGR_NOTI_TYPE_NORMAL, + MSG_MGR_NOTI_TYPE_CB, + MSG_MGR_NOTI_TYPE_SIM, + MSG_MGR_NOTI_TYPE_FAILED, + + /* Add only single notification */ + MSG_MGR_NOTI_TYPE_VOICE_1, + MSG_MGR_NOTI_TYPE_VOICE_2, + MSG_MGR_NOTI_TYPE_MWI, + MSG_MGR_NOTI_TYPE_CLASS0, + MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT, + MSG_MGR_NOTI_TYPE_MMS_READ_REPORT, + MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT, + + MSG_MGR_NOTI_TYPE_SIM_FULL, +}; + + +enum _msg_mgr_active_notification_type_e { + MSG_MGR_ACTIVE_NOTI_TYPE_NONE, + MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE, + MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT, +}; + + +enum _msg_maintype_e +{ + MSG_UNKNOWN_TYPE = 0, /**< Unknown main type */ + MSG_SMS_TYPE, /**< SMS */ + MSG_MMS_TYPE, /**< MMS */ +}; + + +enum _msg_subtype_e +{ + /* SMS Specific Message Type */ + MSG_NORMAL_SMS = 0, /**< Text SMS message */ + MSG_CB_SMS, /**< Cell Broadcasting message */ + MSG_JAVACB_SMS, /**< JAVA Cell Broadcasting message */ + MSG_TYPE0_SMS, /**< Short Message Type 0 */ + MSG_REPLACE_TYPE1_SMS, /**< Replace Short Message Type 1 */ + MSG_REPLACE_TYPE2_SMS, /**< Replace Short Message Type 2 */ + MSG_REPLACE_TYPE3_SMS, /**< Replace Short Message Type 3 */ + MSG_REPLACE_TYPE4_SMS, /**< Replace Short Message Type 4 */ + MSG_REPLACE_TYPE5_SMS, /**< Replace Short Message Type 5 */ + MSG_REPLACE_TYPE6_SMS, /**< Replace Short Message Type 6 */ + MSG_REPLACE_TYPE7_SMS, /**< Replace Short Message Type 7 */ + MSG_WAP_SI_SMS, /**< WAP Push Message SI */ + MSG_WAP_SL_SMS, /**< WAP Push Message SL */ + MSG_WAP_CO_SMS, /**< WAP Push Message CO */ + MSG_MWI_VOICE_SMS, /**< MWI Message Voice */ + MSG_MWI_FAX_SMS, /**< MWI Message Fax */ + MSG_MWI_EMAIL_SMS, /**< MWI Message Email */ + MSG_MWI_OTHER_SMS, /**< MWI Message Other */ + MSG_STATUS_REPORT_SMS, /**< SMS-STATUS-REPORT */ + MSG_SYNCML_CP, /**< SyncML Message CP */ + MSG_LBS_SMS, /**< LBS Message */ + MSG_REJECT_SMS, /**< Reject Message */ + MSG_CONCAT_SIM_SMS, /**< Concatenated Message in SIM */ +}; + +/*================================================================================================== + STRUCTURES +==================================================================================================*/ +typedef struct _msg_mgr_message_info_s { + msg_message_id_t msgId; + int sim_idx; + time_t displayTime; + msg_network_status_t networkStatus; + char displayName[MAX_DISPLAY_NAME_LEN+1]; + char addressVal[MAX_ADDRESS_VAL_LEN+1]; + char msgText[MAX_MSG_TEXT_LEN+1]; +} MSG_MGR_MESSAGE_INFO_S; /*================================================================================================== FUNCTION PROTOTYPES ==================================================================================================*/ +void MsgMgrInitNoti(); + +int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info); +int MsgMgrRefreshNotification(msg_mgr_notification_type_t noti_type, bool bFeedback, msg_mgr_active_notification_type_t active_type); +int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info); +int MsgMgrDeleteReportNotification(const char *addr); +int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info); + +void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type); +int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type); +int MsgMgrInsertBadge(unsigned int unreadMsgCnt); + #endif /*__MSG_MGR_NOTIFICATION_H__ */ diff --git a/manager/inc/msg-manager-sound.h b/manager/inc/msg-manager-sound.h new file mode 100755 index 0000000..ec85c4c --- /dev/null +++ b/manager/inc/msg-manager-sound.h @@ -0,0 +1,64 @@ +/* + * 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_SOUND_H__ +#define __MSG_MGR_SOUND_H__ + +/*================================================================================================== + INCLUDE FILES +==================================================================================================*/ + +/*================================================================================================== + DEFINES +==================================================================================================*/ + + +/*================================================================================================== + TYPES +==================================================================================================*/ +typedef unsigned char MSG_MGR_SOUND_TYPE_T; + +/*================================================================================================== + ENUMS +==================================================================================================*/ +enum _MSG_MGR_SOUND_TYPE_E +{ + MSG_MGR_SOUND_PLAY_DEFAULT = 0, + MSG_MGR_SOUND_PLAY_USER, + MSG_MGR_SOUND_PLAY_EMERGENCY, + MSG_MGR_SOUND_PLAY_VOICEMAIL, +}; + + +/*================================================================================================== + STRUCTURES +==================================================================================================*/ + + + +/*================================================================================================== + FUNCTION PROTOTYPES +==================================================================================================*/ +void initMsgMgrSoundPlayer(); + +void MsgMgrSoundPlayStart(const MSG_MGR_ADDRESS_INFO_S *pAddrInfo, MSG_MGR_SOUND_TYPE_T soundType); +void MsgMgrSoundPlayStop(); + +void MsgMgrGetRingtonePath(char *userRingtonePath, char **msg_tone_file_path_p); +void MsgMgrGetPlayStatus(bool bVoiceMail, bool *bPlaySound, bool *bPlayVibration, bool *bOnCall); + +#endif /*__MSG_MGR_SOUND_H__ */ + diff --git a/manager/inc/msg-manager.h b/manager/inc/msg-manager.h deleted file mode 100644 index f11288d..0000000 --- a/manager/inc/msg-manager.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __MESSAGE_MANAGER_H__ -#define __MESSAGE_MANAGER_H__ - -//#include <dlog.h> -// -//#ifdef LOG_TAG -//#undef LOG_TAG -//#endif -//#define LOG_TAG "MSG_MGR" - - -#endif /* __MESSAGE_MANAGER_H__ */ diff --git a/manager/src/msg-manager-alarm.cpp b/manager/src/msg-manager-alarm.cpp new file mode 100644 index 0000000..ab80df5 --- /dev/null +++ b/manager/src/msg-manager-alarm.cpp @@ -0,0 +1,180 @@ +/* + * 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. +*/ + +/*================================================================================================== + INCLUDE FILES +==================================================================================================*/ + +#include <map> +#include <stdlib.h> +#include <stdio.h> +#include <glib.h> + +#include <msg_storage.h> + +#include <msg-manager-alarm.h> +#include <msg-manager-debug.h> + +/*================================================================================================== + DEFINES +==================================================================================================*/ +typedef std::map<int, msg_mgr_alarm_cb> callBackMap; + +/*================================================================================================== + VARIABLES +==================================================================================================*/ +bool alarmInit = false; +callBackMap alarmCBMap; + +/*================================================================================================== + INTERNAL FUNCTION IMPLEMENTATION +==================================================================================================*/ +int MsgMgrAlarmCB(int alarmId, void *pUserParam) +{ + MSG_MGR_DEBUG("MsgMgrAlarmCB is called. alarmId [%d]", alarmId); + + callBackMap::iterator it = alarmCBMap.find(alarmId); + + if (it == alarmCBMap.end()) { + MSG_MGR_DEBUG("alarmId is not found."); + } else { + msg_mgr_alarm_cb alarmCBfunction = it->second; + if (alarmCBfunction) + alarmCBfunction(alarmId); + + alarmCBMap.erase(it); + } + + return 0; +} + + +int MsgMgrAlarmInit() +{ + MSG_MGR_BEGIN(); + + alarmCBMap.clear(); + + int retval = alarmmgr_init("msg-service-tools"); + if (retval != ALARMMGR_RESULT_SUCCESS) { + MSG_MGR_DEBUG("alarmmgr_init error [%d]", retval); + return -1; + } + + retval = alarmmgr_set_cb(MsgMgrAlarmCB, NULL); + if (retval != ALARMMGR_RESULT_SUCCESS) + MSG_MGR_DEBUG("alarmmgr_set_cb() [%d]", retval); + + alarmInit = true; + + MSG_MGR_END(); + return 0; +} + +/*================================================================================================== + FUNCTION IMPLEMENTATION +==================================================================================================*/ +int MsgMgrAlarmRegistration(struct tm *timeInfo, msg_mgr_alarm_cb userCB, int *alarmId) +{ + MSG_MGR_BEGIN(); + + if (!alarmInit) { + MSG_MGR_DEBUG("alarm manager is not initialized. Retry once."); + MsgMgrAlarmInit(); + if (!alarmInit) { + MSG_MGR_DEBUG("alarm manager is still not initialized. So return error."); + return -1; + } + } + + if (timeInfo == NULL || alarmId == NULL) { + MSG_MGR_DEBUG("(timeInfo == NULL || alarmId == NULL)"); + return -1; + } + + *alarmId = 0; + alarm_info_t *alarm_info = NULL; + alarm_id_t alarm_id = -1; + alarm_date_t target_time; + + int retval = ALARMMGR_RESULT_SUCCESS; + + alarm_info = alarmmgr_create_alarm(); + if (alarm_info == NULL) { + MSG_MGR_DEBUG("alarmmgr_create_alarm error."); + return -1; + } + + target_time.year = timeInfo->tm_year + 1900; + target_time.month = timeInfo->tm_mon + 1; + target_time.day = timeInfo->tm_mday; + target_time.hour = timeInfo->tm_hour; + target_time.min = timeInfo->tm_min; + target_time.sec = timeInfo->tm_sec; + + MSG_MGR_DEBUG("Alarm Time : [%d-%d-%d %d:%d:%d] ", + target_time.year, target_time.month, target_time.day, + target_time.hour, target_time.min, target_time.sec); + + retval = alarmmgr_set_time(alarm_info, target_time); + if (retval != ALARMMGR_RESULT_SUCCESS) + MSG_MGR_DEBUG("alarmmgr_set_time ret[%d]", retval); + + retval = alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_ONCE, 0); + if (retval != ALARMMGR_RESULT_SUCCESS) + MSG_MGR_DEBUG("alarmmgr_set_repeat_mode ret[%d]", retval); + + retval = alarmmgr_set_type(alarm_info, ALARM_TYPE_DEFAULT); + if (retval != ALARMMGR_RESULT_SUCCESS) + MSG_MGR_DEBUG("alarmmgr_set_type ret[%d]", retval); + + retval = alarmmgr_add_alarm_with_localtime(alarm_info, NULL, &alarm_id); + MSG_MGR_DEBUG("alarmmgr_add_alarm_with_localtime ret[%d], alarm_id[%d]", retval, alarm_id); + + retval = alarmmgr_free_alarm(alarm_info); + if (retval != ALARMMGR_RESULT_SUCCESS) + MSG_MGR_DEBUG("alarmmgr_free_alarm ret[%d]", retval); + + *alarmId = (int)alarm_id; + + alarmCBMap[*alarmId] = userCB; + + MSG_MGR_END(); + return 0; +} + + +int MsgMgrAlarmRemove(int alarmId) +{ + MSG_MGR_BEGIN(); + + if (!alarmInit) { + MSG_MGR_DEBUG("alarm manager is not initialized. Retry once."); + MsgMgrAlarmInit(); + if (!alarmInit) { + MSG_MGR_DEBUG("alarm manager is still not initialized. So return error."); + return -1; + } + } + + if (alarmmgr_remove_alarm(alarmId) != ALARMMGR_RESULT_SUCCESS) { + MSG_MGR_DEBUG("alarmmgr_remove_alarm faild."); + return -1; + } + + MSG_MGR_END(); + return 0; +} diff --git a/manager/src/msg-manager-contact.cpp b/manager/src/msg-manager-contact.cpp index cd8a319..b0e6485 100644 --- a/manager/src/msg-manager-contact.cpp +++ b/manager/src/msg-manager-contact.cpp @@ -19,7 +19,7 @@ ==================================================================================================*/ #include <stdlib.h> -#include <stdbool.h> +#include <stdio.h> #include <glib.h> #include <msg_storage.h> @@ -173,3 +173,233 @@ void MsgMgrAddPhoneLog(contactInfo *contact_info) contacts_record_destroy(plog, true); } } + +int MsgMgrGetContactInfo(const MSG_MGR_ADDRESS_INFO_S *pAddrInfo, MSG_MGR_CONTACT_INFO_S *pContactInfo) +{ + MSG_MGR_BEGIN(); +#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED + int err = 0; + + if ((err = MsgMgrOpenContactSvc()) != 0) { + MSG_MGR_DEBUG("MsgMgrOpenContactSvc fail."); + return err; + } + + if (!isContactSvcConnected) { + MSG_MGR_DEBUG("Contact Service Not Opened."); + return -1; + } + + MSG_MGR_SEC_DEBUG("Address Type [%d], Address Value [%s]", pAddrInfo->addressType, pAddrInfo->addressVal); + + memset(pContactInfo, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S)); + + if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_PLMN && strlen(pAddrInfo->addressVal) > (MAX_PHONE_NUMBER_LEN+1)) { + MSG_MGR_SEC_DEBUG("Phone Number is too long [%s]", pAddrInfo->addressVal); + return -1; + } + + int ret = 0; + int index = 0; + int count = 0; + contacts_query_h query = NULL; + contacts_filter_h filter = NULL; + contacts_list_h contacts = NULL; + + if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_PLMN || pAddrInfo->addressType == MSG_ADDRESS_TYPE_UNKNOWN) { + ret = contacts_query_create(_contacts_contact_number._uri, &query); + ret = contacts_filter_create(_contacts_contact_number._uri, &filter); + + ret = contacts_filter_add_str(filter, _contacts_contact_number.number_filter, CONTACTS_MATCH_EXACTLY, pAddrInfo->addressVal); + + } else if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_EMAIL) { + ret = contacts_query_create(_contacts_contact_email._uri, &query); + ret = contacts_filter_create(_contacts_contact_email._uri, &filter); + + ret = contacts_filter_add_str(filter, _contacts_contact_email.email, CONTACTS_MATCH_EXACTLY, pAddrInfo->addressVal); + + } else { + MSG_MGR_DEBUG("Invalid pAddrInfo->addressType."); + return -1; + } + + ret = contacts_query_set_filter(query, filter); + ret = contacts_db_get_records_with_query(query, 0, 1, &contacts); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_db_get_records_with_query() Error [%d]", ret); + contacts_query_destroy(query); + contacts_filter_destroy(filter); + contacts_list_destroy(contacts, true); + return -1; + } + + ret = contacts_list_get_count(contacts, &count); + + if (count == 0 || ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("No Serach Data from Contact Service."); + contacts_query_destroy(query); + contacts_filter_destroy(filter); + contacts_list_destroy(contacts, true); + return 0; + } + + contacts_query_destroy(query); + contacts_filter_destroy(filter); + + contacts_record_h contact = NULL; + + if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_PLMN || pAddrInfo->addressType == MSG_ADDRESS_TYPE_UNKNOWN) { + contacts_record_h number = NULL; + + ret = contacts_list_get_current_record_p(contacts, &number); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_list_get_current_record_p() Error [%d]", ret); + contacts_list_destroy(contacts, true); + return -1; + } + + ret = contacts_record_get_int(number, _contacts_contact_number.contact_id, &index); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_record_get_int() Error [%d]", ret); + contacts_list_destroy(contacts, true); + return -1; + } + + ret = contacts_db_get_record(_contacts_contact._uri, index, &contact); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_db_get_record() Error [%d]", ret); + contacts_list_destroy(contacts, true); + return -1; + } + } else if (pAddrInfo->addressType == MSG_ADDRESS_TYPE_EMAIL) { + contacts_record_h email = NULL; + + ret = contacts_list_get_current_record_p(contacts, &email); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_list_get_current_record_p() Error [%d]", ret); + contacts_list_destroy(contacts, true); + return -1; + } + + ret = contacts_record_get_int(email, _contacts_contact_email.contact_id, &index); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_record_get_int() Error [%d]", ret); + contacts_list_destroy(contacts, true); + return -1; + } + + ret = contacts_db_get_record(_contacts_contact._uri, index, &contact); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_db_get_record() Error [%d]", ret); + contacts_list_destroy(contacts, true); + return -1; + } + } + + contacts_list_destroy(contacts, true); + + ret = contacts_record_get_int(contact, _contacts_contact.id, (int*)&pContactInfo->contactId); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_db_get_record() Error [%d]", ret); + contacts_record_destroy(contact, true); + return -1; + } + + MSG_MGR_DEBUG("Contact ID [%d]", pContactInfo->contactId); + + ret = contacts_record_get_int(contact, _contacts_contact.address_book_id, (int*)&pContactInfo->addrbookId); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_db_get_record() Error [%d]", ret); + contacts_record_destroy(contact, true); + return -1; + } + + MSG_MGR_DEBUG("Address Book ID [%d]", pContactInfo->addrbookId); + + char* strImagePath = NULL; + ret = contacts_record_get_str_p(contact, _contacts_contact.image_thumbnail_path, &strImagePath); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_record_get_str_p() Error [%d]", ret); + } + if (strImagePath != NULL) { + strncpy(pContactInfo->imagePath , strImagePath, MAX_IMAGE_PATH_LEN); + MSG_MGR_DEBUG("Image Path [%s]", pContactInfo->imagePath); + } + + char* alerttonePath = NULL; + ret = contacts_record_get_str_p(contact, _contacts_contact.message_alert, &alerttonePath); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_record_get_str_p() Error [%d]", ret); + } + + if (alerttonePath != NULL && access(alerttonePath, F_OK) != 0) { + alerttonePath = NULL; + } + + if (alerttonePath != NULL) { + MSG_MGR_DEBUG("alert tone Path [%s]", alerttonePath); + strncpy(pContactInfo->alerttonePath , alerttonePath, MSG_FILEPATH_LEN_MAX); + } else { + MSG_MGR_DEBUG("alert tone Path for this contact is default"); + count = 0; + ret = contacts_record_get_child_record_count(contact, _contacts_contact.group_relation, &count); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_record_get_child_record_count() Error [%d]", ret); + } + + contacts_record_h group_relation_record; + + for (int i = 0; i < count; i++) { + int group_id = 0; + contacts_record_get_child_record_at_p(contact, _contacts_contact.group_relation, i, &group_relation_record); + contacts_record_get_int(group_relation_record, _contacts_group_relation.group_id, &group_id); + + contacts_record_h group_record; + contacts_db_get_record(_contacts_group._uri, group_id, &group_record); + + MSG_MGR_DEBUG("Group ID = [%d]", group_id); + + char *group_ringtone_path; + ret = contacts_record_get_str_p(group_record, _contacts_group.message_alert, &group_ringtone_path); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_record_get_child_record_count() Error [%d]", ret); + } else { + if (group_ringtone_path) { + MSG_MGR_DEBUG("Msg alert_tone is change to [%s] as contact group", group_ringtone_path); + memset(pContactInfo->alerttonePath, 0x00, sizeof(pContactInfo->alerttonePath)); + snprintf(pContactInfo->alerttonePath, sizeof(pContactInfo->alerttonePath), "%s", group_ringtone_path); + contacts_record_destroy(group_record, true); + break; + } + } + contacts_record_destroy(group_record, true); + } + } + + char* vibrationPath = NULL; + ret = contacts_record_get_str_p(contact, _contacts_contact.vibration, &vibrationPath); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_record_get_str_p() Error [%d]", ret); + } + if (vibrationPath != NULL) { + MSG_MGR_DEBUG("vibration Path [%s]", vibrationPath); + strncpy(pContactInfo->vibrationPath , vibrationPath, MSG_FILEPATH_LEN_MAX); + } + + char* displayName = NULL; + ret = contacts_record_get_str_p(contact, _contacts_contact.display_name, &displayName); + if (ret != CONTACTS_ERROR_NONE) { + MSG_MGR_DEBUG("contacts_record_get_str_p() Error [%d]", ret); + } + if (displayName != NULL) { + MSG_MGR_DEBUG("displayName [%s]", displayName); + strncpy(pContactInfo->firstName , displayName, MAX_DISPLAY_NAME_LEN); + } + + contacts_record_destroy(contact, true); + +#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ + MSG_MGR_END(); + + return 0; +} diff --git a/manager/src/msg-manager-notification.cpp b/manager/src/msg-manager-notification.cpp index c406161..a36bdcc 100644 --- a/manager/src/msg-manager-notification.cpp +++ b/manager/src/msg-manager-notification.cpp @@ -19,21 +19,2934 @@ ==================================================================================================*/ #include <stdlib.h> -#include <stdbool.h> +#include <stdio.h> #include <glib.h> +#include <libintl.h> +#include <locale.h> +#include <stdarg.h> + +#include <app_control_internal.h> +#include <badge_internal.h> +#include <bundle.h> +#include <notification_list.h> +#include <notification_text_domain.h> +#include <notification_internal.h> +#include <notification_status.h> +#include <package_manager.h> +#include <phone_number.h> +#include <vconf.h> + +#include <msg.h> #include <msg_storage.h> +#include <msg-manager-alarm.h> #include <msg-manager-contact.h> #include <msg-manager-debug.h> +#include <msg-manager-notification.h> +#include <msg-manager-sound.h> + + +#define EMAIL_AT '@' /*================================================================================================== VARIABLES ==================================================================================================*/ +static GList *msg_report_notification_list = NULL; +static bool is_init = false; +extern msg_handle_t msg_handle; +int g_alarmId = 0; /*================================================================================================== - FUNCTION IMPLEMENTATION + STRUCTURES ==================================================================================================*/ +typedef struct _report_notification_s +{ + int priv_id; + char addressVal[MAX_ADDRESS_VAL_LEN+1]; +} report_notification_s; + + +typedef struct _msg_mgr_noti_info_s +{ + msg_mgr_notification_type_t type; + int id; + int layout; + int count; + int senderCount; + time_t time; + char sender[MSG_NOTI_TEXT_LEN_S+1]; + char text[MSG_NOTI_TEXT_LEN+1]; + char number[MSG_NOTI_TEXT_LEN_S+1]; + char imagePath[MAX_IMAGE_PATH_LEN+1]; /**< Indicates the image path of contact. */ + int applist; + app_control_h svc_h; + app_control_h active_noti_svc_h[MSG_ACTIVE_NOTI_BUTTON_NUM]; + msg_message_id_t msg_id; + unsigned char extra_data; + int sim_idx; + int active_noti_button_num; + int active_media_cnt; + int active_media_size; + unsigned char active_subtype; /**< to distinguish cb, push message */ + char active_sender[MSG_NOTI_TEXT_LEN_S+1]; + char active_subject[MSG_NOTI_TEXT_LEN_S+1]; + char active_text[MSG_NOTI_TEXT_LEN+1]; +} MSG_MGR_NOTI_INFO_S; + + +/*================================================================================================== + FUNCTION DEFINE +===================================================================================================*/ + +void MsgMgrInitReportNotiList(); +void MsgRefreshNotiCb(void *data); + +notification_h getHandle(int *noti_id); + +int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx); +void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx); + +void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); /* For addNoti() */ +void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti); +void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info); +void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info); + +int getAppIcon(const char *app_id, char **icon_path); +int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage); + +void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info); +void setTextDomain(notification_h noti_h, msg_mgr_notification_type_t noti_type); +void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info); +void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info); +void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail); +void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info); +void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info); +void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info); +void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info); + +void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback); + +bool isExistAddressInReportTable(const char *addr); + +/* Wrapper */ +void createServiceHandle(app_control_h *svc_h); +void setServiceAppId(app_control_h svc_h, const char* app_id); +void setServiceUri(app_control_h svc_h, const char* uri); +void setServiceOperation(app_control_h svc_h, const char* operation); +void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val); +void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val); +void setServicePackageName(app_control_h svc_h, const char* pkg_name); +void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data); + +void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir); +void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key); +void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time); +void setNotiTime(notification_h noti_h, time_t time); +void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path); +void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path); +void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path); +void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler); + +/* Alarm */ +void MsgMgrNotiSoundRepeatAlarmCB(int alarmId); +void MsgMgrSoundCreateRepeatAlarm(int RepeatTime); +void MsgMgrSoundSetRepeatAlarm(); + +char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text); + +/*================================================================================================== + FUNCTION IMPLEMENTATION +==================================================================================================*/ +bool _is_valid_email(char *pAddress) +{ + if (!pAddress || pAddress[0] == 0) + return false; + if (!strchr (pAddress, EMAIL_AT)) + return false; + return true; +} + + +bool isExistAddressInReportTable(const char *addr) +{ + char sqlQuery[MAX_QUERY_LEN+1]; + char *normal_addr = NULL; + int rowCnt = 0, colCnt = 0; + char **db_res = NULL; + int msg_err = 0; + + int ret = phone_number_get_normalized_number(addr, &normal_addr); + if (ret != PHONE_NUMBER_ERROR_NONE) { + MSG_MGR_ERR("phone_number_get_normalized_number() failed [%d]", ret); + return false; + } + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_SMS_REPORT_TABLE_NAME, normal_addr); + + msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt); + if (msg_err != MSG_SUCCESS) { + MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err); + g_free(normal_addr); + return false; + } + + msg_err = msg_db_free(msg_handle, db_res); + if (msg_err != MSG_SUCCESS) { + MSG_MGR_ERR("msg_db_free() failed [%d]", msg_err); + g_free(normal_addr); + return false; + } + + if (rowCnt > 0) { + g_free(normal_addr); + return true; + } + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + snprintf(sqlQuery, sizeof(sqlQuery), "* FROM %s WHERE ADDRESS_VAL LIKE '%%%%%s'", MSGFW_REPORT_TABLE_NAME, normal_addr); + + g_free(normal_addr); + + msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &rowCnt, &colCnt); + if (msg_err != MSG_SUCCESS) { + MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err); + return false; + } + + 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 false; + } + + if (rowCnt > 0) + return true; + + return false; +} + + +void MsgMgrInitReportNotiList() +{ + MSG_MGR_BEGIN(); + + if (msg_report_notification_list) { + MSG_MGR_DEBUG("Report Noti List is already inited"); + return; + } + + msg_report_notification_list = NULL; + + notification_h noti = NULL; + notification_list_h noti_list = NULL; + notification_list_h head_noti_list = NULL; + int noti_err = NOTIFICATION_ERROR_NONE; + bundle *b = NULL; + + noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_MGR_DEBUG("notification_get_list() is failed!!"); + return; + } + + head_noti_list = noti_list; + + while (noti_list != NULL) { + noti = notification_list_get_data(noti_list); + + char tempAddr[MAX_ADDRESS_VAL_LEN+1]; + memset(tempAddr, 0x00, sizeof(tempAddr)); + + noti_err = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &b); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_MGR_DEBUG("notification_get_excute_option() failed!!"); + break; + } + + char *bundle_addr = NULL; + + int ret = bundle_get_str(b, "address", &bundle_addr); + if (ret == BUNDLE_ERROR_NONE && bundle_addr != NULL) { + if (isExistAddressInReportTable(bundle_addr)) { + report_notification_s *info = new report_notification_s; + memset(info, 0x00, sizeof(report_notification_s)); + + notification_get_id(noti, NULL, &(info->priv_id)); + snprintf(info->addressVal, sizeof(info->addressVal), "%s", bundle_addr); + + msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info); + MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal); + } + } + + noti_list = notification_list_get_next(noti_list); + } + + if (head_noti_list) + notification_free_list(head_noti_list); + + MSG_MGR_END(); +} + + +void MsgMgrInitNoti() +{ + if (is_init) + return; + + bool bNotiSvcReady = false; + + bNotiSvcReady = notification_is_service_ready(); + + if (bNotiSvcReady == true) { + MSG_MGR_DEBUG("Notification server is available"); +#ifndef MSG_NOTI_INTEGRATION + MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM, -1); +#endif + MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); /* On Booting */ + MsgMgrInitReportNotiList(); + } else { + MSG_MGR_DEBUG("Notification server is not available. Init is defered"); +#ifndef MSG_NOTI_INTEGRATION + MSG_MGR_NOTI_INFO_S *delNotiInfo = (MSG_MGR_NOTI_INFO_S *)calloc(1, sizeof(MSG_MGR_NOTI_INFO_S)); + if (delNotiInfo) { + delNotiInfo->type = MSG_MGR_NOTI_TYPE_SIM; + delNotiInfo->sim_idx = -1; + } + notification_add_deferred_task(MsgDeleteNotiCb, (void *)delNotiInfo); +#endif + notification_add_deferred_task(MsgRefreshNotiCb, (void *)NULL); + } + + is_init = true; +} + + +void MsgRefreshNotiCb(void *data) +{ + MsgMgrRefreshAllNotification(false, true, MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT); + MsgMgrInitReportNotiList(); + + if (data) { + free(data); + data = NULL; + } + + return; +} + + +int MsgMgrInsertOnlyActiveNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info) +{ + MSG_MGR_BEGIN(); + + notification_h noti_h = NULL; + + MSG_MGR_NOTI_INFO_S noti_info = {0, }; + + noti_info.type = noti_type; + noti_info.active_noti_button_num = 1; + + createActiveInfoData(¬i_info, msg_info); + + noti_h = notification_create(NOTIFICATION_TYPE_NOTI); + + setActiveNotification(noti_h, ¬i_info); + + clearInfoData(noti_h, ¬i_info); + + MSG_MGR_END(); + return 0; +} + + +int MsgMgrRefreshNotification(msg_mgr_notification_type_t noti_type, bool bFeedback, msg_mgr_active_notification_type_t active_type) +{ + int err = 0; + notification_h noti_h = NULL; + int bNotification = 1; +/* bool bReplyPopup = false; */ + + MSG_MGR_NOTI_INFO_S noti_info = {0,}; + noti_info.type = noti_type; + noti_info.id = getPrivId(noti_info.type, -1); + + err = getLatestMsgInfo(¬i_info, false); + + if (err != 0) { + MSG_MGR_DEBUG("getLatestMsgInfo() err = [%d]", err); + goto __END_OF_REFRESH_NOTI; + } + + if (active_type == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) { + err = MsgMgrInsertInstantMessage(noti_type); + + if (err != 0) { + MSG_MGR_DEBUG(" MsgMgrInsertInstantMessage() err = [%d]", err); + goto __END_OF_REFRESH_NOTI; + } + } + + if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) { + MSG_MGR_DEBUG("vconf_get_bool is failed."); + } + + if (bNotification == 0) { + MSG_MGR_DEBUG("Msg Alert notification is off."); + goto __END_OF_REFRESH_NOTI; + } + + createInfoData(¬i_info, active_type); + + noti_h = getHandle(¬i_info.id); + + if (noti_h == NULL) { + MSG_MGR_DEBUG("Notification handle is NULL"); + err = MSG_ERR_NULL_POINTER; + goto __END_OF_REFRESH_NOTI; + } + + setNotification(noti_h, ¬i_info, bFeedback); + +__END_OF_REFRESH_NOTI : + clearInfoData(noti_h, ¬i_info); + + return err; +} + + +int MsgMgrAddReportNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info) +{ + int ret = 0; + + notification_h noti_h = NULL; + + report_notification_s *info = new report_notification_s; + memset(info, 0x00, sizeof(report_notification_s)); + + MSG_MGR_NOTI_INFO_S noti_info = {0,}; + noti_info.type = noti_type; + + createInfoData(¬i_info, msg_info); + + noti_h = getHandle(¬i_info.id); + + if (noti_h == NULL) { + MSG_MGR_DEBUG("Notification handle is NULL"); + ret = -1; + goto __END_OF_ADD_REPORT_NOTI; + } + + setNotification(noti_h, ¬i_info, true); + + info->priv_id = noti_info.id; + snprintf(info->addressVal, sizeof(info->addressVal), "%s", msg_info->addressVal); + msg_report_notification_list = g_list_append(msg_report_notification_list, (void *)info); + MSG_MGR_SEC_DEBUG("appended list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal); + +__END_OF_ADD_REPORT_NOTI : + clearInfoData(noti_h, ¬i_info); + + return ret; +} + + +int MsgMgrDeleteReportNotification(const char *addr) +{ + MSG_MGR_BEGIN(); + + notification_h noti_h = NULL; + int bNotification = 1; + + if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bNotification) != 0) { + MSG_MGR_DEBUG("vconf_get_bool is failed."); + } + + if (bNotification == 0) { + MSG_MGR_DEBUG("Msg Alert notification is off."); + return 0; + } + + char* normalAddr = NULL; + unsigned int list_length = g_list_length(msg_report_notification_list); + bool isDelete = false; + + MSG_MGR_DEBUG("list length [%d]", list_length); + + if (list_length > 0) { + GList *iter = g_list_first(msg_report_notification_list); + + while (iter != NULL) { + isDelete = false; + report_notification_s *info = (report_notification_s*)(iter->data); + if (info == NULL) { + MSG_MGR_DEBUG("info is NULL!"); + return -1; + } + + MSG_MGR_SEC_DEBUG("list data = [priv_id = %d address = %s]", info->priv_id, info->addressVal); + + noti_h = notification_load(NULL, info->priv_id); + if (noti_h == NULL) { + MSG_MGR_DEBUG("notification with priv_id [%d] is NULL", info->priv_id); + isDelete = true; + } else { + phone_number_get_normalized_number(info->addressVal, &normalAddr); + + if (normalAddr) { + MSG_MGR_SEC_DEBUG("normalized number = %s", normalAddr); + + if (g_str_has_suffix(addr, normalAddr)) { + if (notification_delete(noti_h) == NOTIFICATION_ERROR_NONE) { + MSG_MGR_SEC_DEBUG("delete report notification address [%s]", info->addressVal); + isDelete = true; + } else { + MSG_MGR_DEBUG("delete notification failed"); + } + } + + g_free(normalAddr); + normalAddr = NULL; + } + + notification_free(noti_h); + noti_h = NULL; + } + + iter = g_list_next(iter); + + if (isDelete) { + msg_report_notification_list = g_list_remove(msg_report_notification_list, (void *)info); + if (info) { + delete info; + info = NULL; + } + } + } + } + + MSG_MGR_END(); + + return 0; +} + +int MsgMgrAddNotification(msg_mgr_notification_type_t noti_type, MSG_MGR_MESSAGE_INFO_S *msg_info) +{ + int ret = 0; + + notification_h noti_h = NULL; + + MSG_MGR_NOTI_INFO_S noti_info = {0, }; + + noti_info.type = noti_type; + + createInfoData(¬i_info, msg_info); + + /* check mwi or voicemail count is 0 then skip add notification */ + if (noti_info.count == 0) { + MSG_MGR_DEBUG("Notification count is 0"); + ret = -1; + goto __END_OF_ADD_NOTI; + } + + noti_h = getHandle(¬i_info.id); + + if (noti_h == NULL) { + MSG_MGR_DEBUG("Notification handle is NULL"); + ret = -1; + goto __END_OF_ADD_NOTI; + } + + setNotification(noti_h, ¬i_info, true); + +__END_OF_ADD_NOTI : + clearInfoData(noti_h, ¬i_info); + + return ret; +} + + +void MsgMgrRefreshAllNotification(bool bWithSimNoti, bool bFeedback, msg_mgr_active_notification_type_t active_type) +{ + MSG_MGR_BEGIN(); + + int err = 0; + +#ifndef MSG_NOTI_INTEGRATION + MsgDeleteNotification(MSG_MGR_NOTI_TYPE_SIM); +#endif + +#ifdef MSG_NOTI_INTEGRATION + err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type); + if (err != 0) + MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err); +#else + err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, bFeedback, active_type); + if (err != 0) + MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_NORMAL, err); + + err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, bFeedback, active_type); + if (err != 0) + MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_CB, err); + + if (bWithSimNoti) { + err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, bFeedback, active_type); + if (err != 0) + MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_SIM, err); + } +#endif + + err = MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_FAILED, bFeedback, active_type); + if (err != 0) + MSG_MGR_DEBUG("refreshNoti is failed, [type=%d, err=%d]", MSG_MGR_NOTI_TYPE_FAILED, err); + + MSG_MGR_END(); +} + + +void setProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info) +{ + MSG_MGR_BEGIN(); + + int noti_err = NOTIFICATION_ERROR_NONE; + + /* set layout */ + noti_err = notification_set_layout(noti_h, (notification_ly_type_e)noti_info->layout); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err); + } + + /* set led */ + noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_MGR_DEBUG("Fail to notification_set_led."); + } + + /* set execute option */ + bundle *bundle_data = NULL; + bundle *reply_msg = NULL; + + app_control_to_bundle(noti_info->svc_h, &bundle_data); + + if (bundle_data == NULL) { + MSG_MGR_DEBUG("bundle is NULL"); + } + + /* set execute option and property */ + switch (noti_info->type) { + case MSG_MGR_NOTI_TYPE_NORMAL: { + if (noti_info->count > 1) { + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data); + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, NULL); + } else { + if (noti_info->svc_h) { /* overwrite bundle key "type" */ + /* addServiceExtraData(noti_info->svc_h, "type", "reply"); */ + addServiceExtraData(noti_info->svc_h, "show_list", "list_show"); + + app_control_to_bundle(noti_info->svc_h, &reply_msg); + } + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_RESPONDING, NULL, NULL, reply_msg); + } + + notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE); + break; + } + case MSG_MGR_NOTI_TYPE_CB: + case MSG_MGR_NOTI_TYPE_SIM: { + if (noti_info->count > 1) { + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, NULL, bundle_data); + } else { + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); + } + + notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE|NOTIFICATION_PROP_VOLATILE_DISPLAY); + break; + } + case MSG_MGR_NOTI_TYPE_FAILED: { + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); + notification_set_property(noti_h, NOTIFICATION_PROP_DISABLE_AUTO_DELETE); + break; + } + case MSG_MGR_NOTI_TYPE_SIM_FULL: { + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); + break; + } + case MSG_MGR_NOTI_TYPE_VOICE_1: + case MSG_MGR_NOTI_TYPE_VOICE_2: + case MSG_MGR_NOTI_TYPE_MWI: + case MSG_MGR_NOTI_TYPE_CLASS0: + case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: + case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: + case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: { + notification_set_execute_option(noti_h, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, bundle_data); + break; + } + default: + MSG_MGR_DEBUG("No matching type for notification_set_execute_option() [%d]", noti_info->type); + break; + } + + /* set applist */ + noti_err = notification_set_display_applist(noti_h, noti_info->applist); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_MGR_DEBUG("Fail to notification_set_display_applist"); + } + + + MSG_MGR_END(); +} + + +void setTextDomain(notification_h noti_h, msg_mgr_notification_type_t noti_type) +{ + MSG_MGR_BEGIN(); + + setNotiTextDomain(noti_h, MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR); + MSG_MGR_END(); +} + + +void setText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info) +{ + MSG_MGR_BEGIN(); + + char unreadMsgCntStr[10] = {0}; + int bPreview = 1; + + if (vconf_get_bool(MSG_SETTING_PREVIEW, &bPreview) != 0) { + MSG_MGR_DEBUG("vconf_get_bool is failed."); + } + + /* set title and content */ + switch (noti_info->type) { +#ifdef MSG_NOTI_INTEGRATION + case MSG_MGR_NOTI_TYPE_NORMAL: + case MSG_MGR_NOTI_TYPE_CB: + case MSG_MGR_NOTI_TYPE_SIM: { + if (noti_info->count > 1) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + + snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); + + } else { + if (bPreview) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL); + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + } + setNotiTime(noti_h, noti_info->time); + } + break; + } +#else + case MSG_MGR_NOTI_TYPE_NORMAL: { + if (noti_info->count > 1) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Messages", NEW_MESSAGES); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + + snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); + } else { + if (bPreview) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL); + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "New Message", NEW_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + } + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL); + setNotiTime(noti_h, noti_info->time); + } + break; + } + case MSG_MGR_NOTI_TYPE_CB: { + if (noti_info->count > 1) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE); + snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL); + setNotiTime(noti_h, noti_info->time); + + if (bPreview) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL); + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Broadcast message", CB_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + } + } + break; + } + case MSG_MGR_NOTI_TYPE_SIM: { + if (noti_info->count > 1) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE); + snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); + + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL); + setNotiTime(noti_h, noti_info->time); + + if (bPreview) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->sender, NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->text, NULL); + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card Message", SIM_CARD_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + } + } + break; + } +#endif + case MSG_MGR_NOTI_TYPE_FAILED: { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Message", MSG_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Failed to send message.", FAILED_TO_SEND_MESSAGE); + if (noti_info->count > 1) { + snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); + } + setNotiTime(noti_h, noti_info->time); + break; + } + case MSG_MGR_NOTI_TYPE_VOICE_1: + case MSG_MGR_NOTI_TYPE_VOICE_2: { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Voicemail", VOICE_MAIL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + + if (noti_info->count == 1) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "1", NULL); + } else if (noti_info->count > 1) { + snprintf(unreadMsgCntStr, sizeof(unreadMsgCntStr), "%d", noti_info->count); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, unreadMsgCntStr, NULL); + } else { + MSG_MGR_DEBUG("Invalid notification count, [cnt = %d]", noti_info->count); + } + break; + } + case MSG_MGR_NOTI_TYPE_MWI: { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "MWI Message", NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + break; + } + case MSG_MGR_NOTI_TYPE_CLASS0: { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + setNotiTime(noti_h, noti_info->time); + break; + } + case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery report", DELIVERY_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + + if (noti_info->extra_data == MSG_NETWORK_DELIVER_SUCCESS) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE); + } else if (noti_info->extra_data == MSG_NETWORK_DELIVER_EXPIRED) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE); + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE); + } + + setNotiTime(noti_h, noti_info->time); + break; + } + case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Read Report", READ_REPORT_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + + if (noti_info->extra_data == MSG_READ_REPORT_IS_DELETED) { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deleted", READ_REPORT_DELETE); + /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */ +#if 0 + } else if (noti_info->extra_data == MSG_READ_REPORT_NONE) { + /* notification free */ +#endif + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message read", READ_REPORT_READ); + } + + setNotiTime(noti_h, noti_info->time); + break; + } + case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "Delivery Report", DELIVERY_MESSAGE); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->sender, NULL); + + if (noti_info->extra_data == MSG_DELIVERY_REPORT_EXPIRED) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message expired", EXPIRED_MESSAGE); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_REJECTED) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message rejected", REJECTED_MESSAGE); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_DEFERRED) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message deferred", DEFERRED_MESSAGE); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNRECOGNISED) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unrecognised", UNRECOGNISED_MESSAGE); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_INDETERMINATE) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message indeterminate", INDETEMINATE_MESSAGE); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_FORWARDED) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message forwarded", NULL); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_UNREACHABLE) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message unreachable", UNREACHABLE_MESSAGE); + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_ERROR) + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message error", NULL); + /* CID 45672: noti_info->extra_data in unsigned char but MSG_READ_REPORT_NONE is -1. So the expression is always false */ +#if 0 + else if (noti_info->extra_data == MSG_DELIVERY_REPORT_NONE) { + /* notification free */ + } +#endif + else + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, "Message delivered", DELIVERED_MESSAGE); + + setNotiTime(noti_h, noti_info->time); + break; + } + case MSG_MGR_NOTI_TYPE_SIM_FULL: { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "SIM card full", SMS_SIM_CARD_FULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, "Not enough memory. Delete some items.", SMS_MESSAGE_MEMORY_FULL); + break; + } + default: + MSG_MGR_DEBUG("No matching type [%d]", noti_info->type); + break; + } + + MSG_MGR_END(); +} + +void setIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info) +{ + MSG_MGR_BEGIN(); + + switch (noti_info->type) { +#ifdef MSG_NOTI_INTEGRATION + case MSG_MGR_NOTI_TYPE_NORMAL: + case MSG_MGR_NOTI_TYPE_CB: + case MSG_MGR_NOTI_TYPE_SIM: { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); + if (noti_info->count > 1 && noti_info->senderCount > 1) { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, ""); + } else { + if (noti_info->active_subtype == MSG_CB_SMS) { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_CB_ICON_PATH); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH); + } else if (noti_info->active_subtype == MSG_WAP_SI_SMS || noti_info->active_subtype == MSG_WAP_SL_SMS) { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_ACTIVE_PUSH_ICON_PATH); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH); + } else if (noti_info->active_subtype == MSG_SYNCML_CP) { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH); + } else { + if (noti_info->imagePath[0] != '\0') { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, noti_info->imagePath); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath); + } else { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NO_CONTACT_PROFILE_ICON_PATH); + 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) { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path); + g_free(msg_icon_path); + } else { + MSG_MGR_ERR("fail to get message-app icon"); + } + } + } + break; + } +#else + case MSG_MGR_NOTI_TYPE_NORMAL: { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_LOCK, MSG_NORMAL_ICON_PATH); + + if (noti_info->count > 1) { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + } else { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_REPLY_ICON_PATH); + } + break; + } + case MSG_MGR_NOTI_TYPE_CB: { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_CB_ICON_PATH); + break; + } + case MSG_MGR_NOTI_TYPE_SIM: { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SIM_ICON_PATH); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SIM_ICON_PATH); + break; + } +#endif + case MSG_MGR_NOTI_TYPE_FAILED: { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_SMS_SENDING_FAILED_ICON_PATH); + break; + } + case MSG_MGR_NOTI_TYPE_VOICE_1: + case MSG_MGR_NOTI_TYPE_VOICE_2: + case MSG_MGR_NOTI_TYPE_MWI: { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_VOICE_MSG_STATUS_ICON); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_VOICE_ICON_PATH); + break; + } + case MSG_MGR_NOTI_TYPE_CLASS0: + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + break; + case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + break; + case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + break; + case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + break; + case MSG_MGR_NOTI_TYPE_SIM_FULL: + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, MSG_NORMAL_STATUS_ICON); + break; + default: + MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type); + break; + } + + MSG_MGR_END(); +} + +void setActiveProperty(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info) +{ + MSG_MGR_BEGIN(); + + int noti_err = NOTIFICATION_ERROR_NONE; + + /* set layout */ + noti_err = notification_set_layout(noti_h, NOTIFICATION_LY_NOTI_EVENT_SINGLE); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_MGR_DEBUG("Fail to notification_set_layout : %d", noti_err); + } + + /* set led */ + noti_err = notification_set_led(noti_h, NOTIFICATION_LED_OP_ON, 0x00); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_MGR_DEBUG("Fail to notification_set_led."); + } + + /* set applist */ + noti_err = notification_set_display_applist(noti_h, NOTIFICATION_DISPLAY_APP_ACTIVE); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_MGR_DEBUG("Fail to notification_set_display_applist"); + } + + MSG_MGR_END(); +} + + +void setActiveText(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info) +{ + MSG_MGR_BEGIN(); + + switch (noti_info->type) { + case MSG_MGR_NOTI_TYPE_NORMAL: + case MSG_MGR_NOTI_TYPE_SIM: + case MSG_MGR_NOTI_TYPE_CB: { + if (noti_info->active_subject[0] == '\0') { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL); + } else { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, noti_info->active_sender, NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_INFO_1, noti_info->active_subject, NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_text, NULL); + } + break; + } + case MSG_MGR_NOTI_TYPE_CLASS0: { + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_TITLE, "CLASS 0 Message", NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info->active_sender, NULL); + break; + } + default: + MSG_MGR_DEBUG("No matching type [%d]", noti_info->type); + break; + } + + MSG_MGR_END(); +} + + +void setActiveIcon(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info) +{ + MSG_MGR_BEGIN(); + + switch (noti_info->type) { + case MSG_MGR_NOTI_TYPE_NORMAL: + case MSG_MGR_NOTI_TYPE_SIM: { + switch (noti_info->active_subtype) { + case MSG_CB_SMS: + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH); + break; + case MSG_WAP_SI_SMS: + case MSG_WAP_SL_SMS: + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_ACTIVE_PUSH_ICON_PATH); + break; + case MSG_SYNCML_CP: + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_OTA_ICON_PATH); + break; + default: + if (noti_info->imagePath[0] != '\0') + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, noti_info->imagePath); + else + 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) { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON_SUB, msg_icon_path); + g_free(msg_icon_path); + } else { + MSG_MGR_ERR("fail to get message-app icon"); + } + + break; + } + + break; + } + case MSG_MGR_NOTI_TYPE_CB: { + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_CB_ICON_PATH); + break; + } + case MSG_MGR_NOTI_TYPE_CLASS0: + setNotiImage(noti_h, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + break; + default: + MSG_MGR_DEBUG("No matching type for MsgNotiSetImage [%d]", noti_info->type); + break; + } + + MSG_MGR_END(); +} + + +void setSoundAndVibration(notification_h noti_h, char *addressVal, bool bVoiceMail) +{ + MSG_MGR_BEGIN(); + + MSG_MGR_ADDRESS_INFO_S addrInfo = {0,}; + MSG_MGR_CONTACT_INFO_S contactInfo = {0,}; + + if (addressVal != NULL) { + snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", addressVal); + /* Get Contact Info */ + if (MsgMgrGetContactInfo(&addrInfo, &contactInfo) != 0) { + MSG_MGR_DEBUG("MsgMgrGetContactInfo() fail."); + } + } else { + MSG_MGR_DEBUG("addressVal is NULL."); + } + + char *msg_tone_file_path = NULL; + + MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path); + + MSG_MGR_SEC_DEBUG("Sound File [%s]", msg_tone_file_path); + + bool bPlaySound = false; + bool bPlayVibration = false; + bool bOnCall = false; + + MsgMgrGetPlayStatus(bVoiceMail, &bPlaySound, &bPlayVibration, &bOnCall); + + if (bPlaySound) { + if (msg_tone_file_path) + setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_USER_DATA, msg_tone_file_path); + else { + int tmpVal = 0; + if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) { + MSG_MGR_INFO("MsgSettingGetInt() is failed"); + } + int ringtoneType = tmpVal; + if (ringtoneType == MSG_RINGTONE_TYPE_SILENT) + setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL); + else + setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL); + } + } else { + setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL); + } + + if (bPlayVibration) { + if (contactInfo.vibrationPath[0] == '\0') + setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL); + else + setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_USER_DATA, contactInfo.vibrationPath); + } else { + setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL); + } + + if (msg_tone_file_path) + delete [] msg_tone_file_path; + + MSG_MGR_END(); +} + + +void setActiveNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info) +{ + MSG_MGR_BEGIN(); + + int noti_err = NOTIFICATION_ERROR_NONE; + + setActiveProperty(noti_h, noti_info); + + setTextDomain(noti_h, noti_info->type); + + setActiveText(noti_h, noti_info); + + setActiveIcon(noti_h, noti_info); + + if (noti_info->active_noti_button_num > 1) { + createServiceHandle(¬i_info->active_noti_svc_h[0]); + if (noti_info->active_noti_svc_h[0]) { + setServicePackageName(noti_info->active_noti_svc_h[0], MSG_CALL_APP_ID); + setServiceOperation(noti_info->active_noti_svc_h[0], APP_CONTROL_OPERATION_CALL); + + MSG_MGR_DEBUG("Active Notification button 1 - Msg Id = [%d]", noti_info->msg_id); + + char tel_num[MSG_NOTI_TEXT_LEN_S] = {0, }; + snprintf(tel_num, sizeof(tel_num), "tel:%s", noti_info->number); + MSG_MGR_SEC_DEBUG("Active sender number [%s]", noti_info->number); + setServiceUri(noti_info->active_noti_svc_h[0], tel_num); + } + + createServiceHandle(¬i_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); + + 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); + + char slot_id[5] = {0, }; + snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1); + addServiceExtraData(noti_info->active_noti_svc_h[1], "slot_id", slot_id); + } + } + + 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); + + MSG_MGR_DEBUG("Active Notification button 3 - msgId = [%d]", noti_info->msg_id); + addServiceExtraData(noti_info->active_noti_svc_h[2], "type", "new_msg"); + addServiceExtraData(noti_info->active_noti_svc_h[2], "msgId", noti_info->msg_id); + addServiceExtraData(noti_info->active_noti_svc_h[2], "CALLER", "active_noti"); + + char slot_id[5] = {0, }; + snprintf(slot_id, sizeof(slot_id), "%d", noti_info->sim_idx - 1); + addServiceExtraData(noti_info->active_noti_svc_h[2], "slot_id", slot_id); + } + + 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]); + 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); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_2, "Reply", NULL); + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_3, "View", NULL); + } else { + setNotiEventHandler(noti_h, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, noti_info->active_noti_svc_h[2]); + + setNotiText(noti_h, NOTIFICATION_TEXT_TYPE_BUTTON_1, "View", NULL); + } + + noti_err = notification_post(noti_h); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_MGR_DEBUG("Fail to notification_post"); + } + + MSG_MGR_END(); +} + + +void setNotification(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info, bool bFeedback) +{ + MSG_MGR_BEGIN(); + + int noti_err = NOTIFICATION_ERROR_NONE; + + MSG_MGR_DEBUG("active num [%d]", noti_info->active_noti_button_num); + + if (bFeedback && noti_info->active_noti_button_num > 0 && + ((noti_info->type >= MSG_MGR_NOTI_TYPE_NORMAL && noti_info->type <= MSG_MGR_NOTI_TYPE_SIM) || noti_info->type == MSG_MGR_NOTI_TYPE_CLASS0)) { + notification_h active_noti_h = notification_create(NOTIFICATION_TYPE_NOTI); + + setActiveNotification(active_noti_h, noti_info); + + notification_free(active_noti_h); + active_noti_h = NULL; + } + + setProperty(noti_h, noti_info); + + setTextDomain(noti_h, noti_info->type); + + setText(noti_h, noti_info); + + setIcon(noti_h, noti_info); + + if (bFeedback) { + if (noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_1 || noti_info->type == MSG_MGR_NOTI_TYPE_VOICE_2) + setSoundAndVibration(noti_h, noti_info->number, true); + else + setSoundAndVibration(noti_h, noti_info->number, false); + + } else { + setNotiSound(noti_h, NOTIFICATION_SOUND_TYPE_NONE, NULL); + setNotiVibration(noti_h, NOTIFICATION_VIBRATION_TYPE_NONE, NULL); + } + + if (noti_info->id > 0) { + MSG_MGR_DEBUG("Notification update"); + noti_err = notification_update(noti_h); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_MGR_DEBUG("Fail to notification_update"); + } + } else { + MSG_MGR_DEBUG("Notification insert"); + noti_err = notification_insert(noti_h, ¬i_info->id); + if (noti_err != NOTIFICATION_ERROR_NONE) { + MSG_MGR_DEBUG("Fail to notification_insert"); + } + + updatePrivId(noti_info->type, noti_info->id, noti_info->sim_idx); + } + + MSG_MGR_END(); +} + + +void createActiveInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info) +{ + MSG_MGR_BEGIN(); + + if (!msg_info) { + MSG_MGR_DEBUG("msg_info is NULL"); + return; + } + + noti_info->msg_id = msg_info->msgId; + noti_info->sim_idx = msg_info->sim_idx; + + switch (noti_info->type) { + case MSG_MGR_NOTI_TYPE_NORMAL: { + char *senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE); + snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", senderStr); + if (senderStr) { + free(senderStr); + senderStr = NULL; + } + break; + } + case MSG_MGR_NOTI_TYPE_CLASS0: { + if (msg_info->displayName[0] == '\0') + snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->addressVal); + else + snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", msg_info->displayName); + + snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", msg_info->msgText); + break; + } + default: + MSG_MGR_DEBUG("No matching type [%d]", noti_info->type); + break; + } + + MSG_MGR_END(); +} + + +void clearInfoData(notification_h noti_h, MSG_MGR_NOTI_INFO_S *noti_info) +{ + MSG_MGR_BEGIN(); + + if (noti_h) { + notification_free(noti_h); + noti_h = NULL; + } + + if (noti_info->svc_h) { + app_control_destroy(noti_info->svc_h); + noti_info->svc_h = NULL; + } + + for (int i = 0; i < MSG_ACTIVE_NOTI_BUTTON_NUM; i++) { + if (noti_info->active_noti_svc_h[i]) { + app_control_destroy(noti_info->active_noti_svc_h[i]); + noti_info->active_noti_svc_h[i] = NULL; + } + } + + MSG_MGR_END(); +} + + +int getAppIcon(const char *app_id, char **icon_path) +{ + MSG_MGR_BEGIN(); + + package_info_h pkg_info_h = NULL; + int pkg_err = PACKAGE_MANAGER_ERROR_NONE; + int ret = 0; + + if (app_id == NULL) { + MSG_MGR_ERR("app id is NULL"); + ret = -1; + goto END_OF_GET_APP_ICON; + } + + pkg_err = package_info_create(app_id, &pkg_info_h); + if (pkg_err != PACKAGE_MANAGER_ERROR_NONE) { + MSG_MGR_ERR("package_info_create failed (%d)", pkg_err); + ret = -1; + 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_MGR_ERR("package_info_get_icon failed (%d)", pkg_err); + ret = -1; + } else { + if (icon_path == NULL) { + MSG_MGR_WARN("icon path is NULL"); + ret = -1; + } + } + +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_MGR_ERR("package_info_destroy failed (%d)", pkg_err); + } + + pkg_info_h = NULL; + } + + MSG_MGR_END(); + + return ret; +} + + +int getLatestMsgInfo(MSG_MGR_NOTI_INFO_S *noti_info, bool isForInstantMessage) +{ + MSG_MGR_BEGIN(); + + int noti_err = 0; + msg_error_t msg_err = MSG_SUCCESS; + char **db_res = NULL; + int row_cnt = 0, col_cnt = 0; + + switch (noti_info->type) { + case MSG_MGR_NOTI_TYPE_NORMAL: +#ifdef MSG_NOTI_INTEGRATION + case MSG_MGR_NOTI_TYPE_CB: + case MSG_MGR_NOTI_TYPE_SIM: +#endif + { + int smsUnreadCnt = 0; + int mmsUnreadCnt = 0; + + char sqlQuery[MAX_QUERY_LEN +1]; + unsigned char mainType; + unsigned char subType; + int msgSize; + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); +#ifdef MSG_NOTI_INTEGRATION + snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT " + "A.ADDRESS_VAL, " + "B.SUB_TYPE " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) " + "AND B.STORAGE_ID = %d " + "GROUP BY A.ADDRESS_VAL " + "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;", + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_INBOX_ID, MSG_CBMSGBOX_ID, + MSG_STORAGE_PHONE); +#else + snprintf(sqlQuery, sizeof(sqlQuery), "DISTINCT " + "A.ADDRESS_VAL, " + "B.SUB_TYPE " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d " + "AND B.STORAGE_ID = %d " + "GROUP BY A.ADDRESS_VAL " + "ORDER BY B.DISPLAY_TIME DESC LIMIT 5;", + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_INBOX_ID, + MSG_STORAGE_PHONE); +#endif + MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery); + + row_cnt = 0, col_cnt = 0; + msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt); + if (msg_err != MSG_SUCCESS) { + MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err); + return -1; + } + +/* contacts-service is not used for gear */ +#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED + MSG_MGR_ADDRESS_INFO_S tmpAddressInfo; + int normalAddCnt = 0; + int index = col_cnt; + + for (int i = 1; i <= row_cnt; i++) { + memset(&tmpAddressInfo, 0x00, sizeof(MSG_MGR_ADDRESS_INFO_S)); + + char *address = db_res[index++]; + normalAddCnt++; + if (address) { + snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", address); + if (_is_valid_email(address)) { + tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL; + } else { + tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN; + } + } + subType = atoi(db_res[index++]); + + MSG_MGR_CONTACT_INFO_S tmpContact; + memset(&tmpContact, 0x00, sizeof(MSG_MGR_CONTACT_INFO_S)); + + MsgMgrGetContactInfo(&tmpAddressInfo, &tmpContact); + + if (row_cnt == 1) { + snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath); + } + + if (normalAddCnt > 1) { + g_strlcat(noti_info->sender, ", ", sizeof(noti_info->sender)-strlen(noti_info->sender)); + } + + if (tmpContact.firstName[0] != '\0') { + g_strlcat(noti_info->sender, tmpContact.firstName, sizeof(noti_info->sender)-strlen(noti_info->sender)); + } else if (tmpAddressInfo.addressVal[0] == '\0') { + char *senderStr = NULL; + senderStr = get_translate_text("message", MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER); + g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); + if (senderStr) { + free(senderStr); + senderStr = NULL; + } + + if (i == 1) { + noti_info->active_noti_button_num = 1; + } + } else { + char *senderStr = NULL; + if (subType == MSG_CB_SMS) { + senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CB_MESSAGE); + g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); + noti_info->active_noti_button_num = 1; + } else if (subType == MSG_SYNCML_CP) { + senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, CP_MESSAGE); + g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); + noti_info->active_noti_button_num = 1; + } else if (subType == MSG_WAP_SI_SMS || subType == MSG_WAP_SL_SMS) { + senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, PUSH_MESSAGE); + g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); + noti_info->active_noti_button_num = 1; + } else { + g_strlcat(noti_info->sender, tmpAddressInfo.addressVal, sizeof(noti_info->sender)-strlen(noti_info->sender)); + } + + if (senderStr) { + free(senderStr); + senderStr = NULL; + } + } + + if (i == 1) { + noti_info->active_subtype = subType; + snprintf(noti_info->active_sender, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->sender); + snprintf(noti_info->imagePath, sizeof(noti_info->imagePath), "%s", tmpContact.imagePath); + } + } + + noti_info->senderCount = normalAddCnt; +#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ + msg_db_free(msg_handle, db_res); + + MSG_MGR_SEC_DEBUG("sender info = [%s]", noti_info->sender); + + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + +#ifdef MSG_NOTI_INTEGRATION + snprintf(sqlQuery, sizeof(sqlQuery), + "A.ADDRESS_VAL, " + "B.DISPLAY_TIME, " + "B.MSG_ID, " + "B.SUBJECT, " + "B.MSG_TEXT, " + "B.MAIN_TYPE, " + "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS SMS_UNREAD_CNT, " + "(COUNT(DISTINCT(CASE WHEN B.MAIN_TYPE = %d THEN B.MSG_ID END))) AS MMS_UNREAD_CNT, " + "(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) " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 AND (B.FOLDER_ID=%d OR B.FOLDER_ID=%d) " + "AND B.STORAGE_ID = %d " + "ORDER BY B.DISPLAY_TIME DESC;", + MSG_SMS_TYPE, + MSG_MMS_TYPE, + MSG_MMS_TYPE, MSG_NETWORK_RECEIVED, MMS_PLUGIN_MESSAGE_TABLE_NAME, + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_INBOX_ID, MSG_CBMSGBOX_ID, + MSG_STORAGE_PHONE); +#else + snprintf(sqlQuery, sizeof(sqlQuery), + "A.ADDRESS_VAL, " + "B.DISPLAY_TIME, " + "B.MSG_ID, " + "B.SUBJECT, " + "B.MSG_TEXT, " + "B.MAIN_TYPE, " + "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT, " + "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS MMS_UNREAD_CNT " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d " + "AND B.STORAGE_ID = %d " + "ORDER BY B.DISPLAY_TIME DESC;", + MSG_SMS_TYPE, + MSG_MMS_TYPE, + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_INBOX_ID, + MSG_STORAGE_PHONE); +#endif + MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery); + + msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt); + if (msg_err != MSG_SUCCESS) { + MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err); + return -1; + } + + if (row_cnt > 0) { + smsUnreadCnt = atoi(db_res[col_cnt+6]); + mmsUnreadCnt = atoi(db_res[col_cnt+7]); + msgSize = atoi(db_res[col_cnt+8]); + + noti_info->count = smsUnreadCnt + mmsUnreadCnt; + + if (noti_info->count > 0) { + snprintf(noti_info->number, sizeof(noti_info->number), "%s", db_res[col_cnt]); + + noti_info->time = (time_t)atoi(db_res[col_cnt+1]); + + noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]); + + mainType = (unsigned char)atoi(db_res[col_cnt+5]); + + if (mainType == MSG_MMS_TYPE) { + snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]); + if (noti_info->text[0] == '\0') { + char *noti_text = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_NO_SUBJECT); + snprintf(noti_info->text, sizeof(noti_info->text), "%s", noti_text); + g_free(noti_text); + } + + char *prefix_subject = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_SUBJECT_COLON); + if (prefix_subject) { + snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s%s", prefix_subject, noti_info->text); + g_free(prefix_subject); + } else { + snprintf(noti_info->active_subject, MSG_NOTI_TEXT_LEN_S, "%s", noti_info->text); + } + + if (msgSize > -1) { + int kb_msg_size = msgSize / 1024; + if (kb_msg_size == 0 && msgSize > 0) + kb_msg_size = 1; + else if (msgSize % 1024 >= 512) + kb_msg_size++; + + char *msg_size_string = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_STRING); + char *msg_size_unit_kb = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MESSAGE_SIZE_UNIT_KB); + + snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s : %d%s", msg_size_string, kb_msg_size, msg_size_unit_kb); + + g_free(msg_size_string); + g_free(msg_size_unit_kb); + } + + } else { + snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]); + } + + if (noti_info->active_text[0] == '\0') + snprintf(noti_info->active_text, MSG_NOTI_TEXT_LEN, "%s", db_res[col_cnt+4]); + + MSG_MGR_DEBUG("unread message ID [%d].", noti_info->msg_id); + + MSG_MGR_DEBUG("active sender [%s]", noti_info->active_sender); + MSG_MGR_DEBUG("active subject [%s]", noti_info->active_subject); + MSG_MGR_DEBUG("active text [%s]", noti_info->active_text); + + if (!isForInstantMessage) { + if (noti_info->id > 0 && noti_info->count == 1) { + noti_err = notification_delete_by_priv_id(NULL, 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); + } + + noti_info->id = 0; + if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0) + MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID"); + } + + vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, smsUnreadCnt); + vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, mmsUnreadCnt); + MsgMgrInsertBadge(noti_info->count); + MsgMgrSoundSetRepeatAlarm(); + } + } else { + MSG_MGR_DEBUG("No unread message."); + MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id); + + msg_db_free(msg_handle, db_res); + + if (!isForInstantMessage) { + /* No unread message. */ + if (noti_info->id > 0) { + noti_err = notification_delete_by_priv_id(NULL, 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); + } + } + + noti_info->id = 0; + + if (vconf_set_int(NOTIFICATION_PRIV_ID, noti_info->id) != 0) + MSG_MGR_DEBUG("vconf_set_int fail : NOTIFICATION_PRIV_ID"); + + vconf_set_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, 0); + vconf_set_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, 0); + MsgMgrInsertBadge(0); + MsgMgrSoundSetRepeatAlarm(); + } + + return -1; + } + } else { + MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery); + msg_db_free(msg_handle, db_res); + return -1; + } + + msg_db_free(msg_handle, db_res); + break; + } + +#ifndef MSG_NOTI_INTEGRATION + case MSG_MGR_NOTI_TYPE_CB: { + char sqlQuery[MAX_QUERY_LEN+1]; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), + "A.ADDRESS_VAL, " + "B.DISPLAY_TIME, " + "B.MSG_ID, " + "B.MSG_TEXT " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 " + "AND B.FOLDER_ID=%d " + "AND B.STORAGE_ID = %d " + "ORDER BY B.DISPLAY_TIME DESC;", + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_CBMSGBOX_ID, + MSG_STORAGE_PHONE); + + if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; + + if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) { + MSG_ADDRESS_INFO_S addrInfo; + memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); + + if (dbhandler->columnText(0) != NULL) + snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0)); + + MSG_CONTACT_INFO_S tmpContact; + memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S)); + + MsgGetContactInfo(&addrInfo, &tmpContact); + + if (tmpContact.firstName[0] != '\0') { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName); + } else if (addrInfo.addressVal[0] == '\0') { + char *senderStr = NULL; + senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER); + g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); + if (senderStr) { + free(senderStr); + senderStr = NULL; + } + } else { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal); + } + + snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal); + + noti_info->time = (time_t)dbhandler->columnInt(1); + + noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2); + + snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3)); + + MSG_MGR_DEBUG("unread CB message [%d].", noti_info->msg_id); + } else { + MSG_MGR_DEBUG("No unread CB message."); + MSG_MGR_DEBUG("notiCbId [%d]", noti_info->id); + + dbhandler->finalizeQuery(); + + if (!isForInstantMessage) { + /* No unread message. */ + if (noti_info->id > 0) { + noti_err = notification_delete_by_priv_id(NULL, 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); + } + } + + noti_info->id = 0; + + if (MsgSettingSetInt(CB_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS) + MSG_MGR_DEBUG("MsgSettingSetInt fail : CB_NOTI_PRIV_ID"); + } + return MSG_ERR_DB_STEP; + } + + dbhandler->finalizeQuery(); + + if (dbhandler->getTable(sqlQuery, ¬i_info->count, NULL) != MSG_SUCCESS) { + MSG_MGR_DEBUG("getTable is failed"); + dbhandler->freeTable(); + return MSG_ERR_DB_GETTABLE; + } + + dbhandler->freeTable(); + MSG_MGR_DEBUG("notiCbId [%d], unreadCbMsgCnt [%d]", noti_info->id, noti_info->count); + break; + } + case MSG_MGR_NOTI_TYPE_SIM: { + char sqlQuery[MAX_QUERY_LEN+1]; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), + "A.ADDRESS_VAL, " + "B.DISPLAY_TIME, " + "B.MSG_ID, " + "B.MSG_TEXT, " + "(COUNT(CASE WHEN B.MAIN_TYPE = %d THEN 1 END)) AS SMS_UNREAD_CNT " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d " + "AND B.STORAGE_ID = %d " + "ORDER BY B.DISPLAY_TIME DESC;", + MSG_SMS_TYPE, + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_INBOX_ID, + MSG_STORAGE_SIM); + + MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery); + + if (dbhandler->prepareQuery(sqlQuery) != MSG_SUCCESS) + return MSG_ERR_DB_PREPARE; + + if (dbhandler->stepQuery() == MSG_ERR_DB_ROW) { + noti_info->count = dbhandler->columnInt(4); + + if (noti_info->count > 0) { + MSG_ADDRESS_INFO_S addrInfo; + memset(&addrInfo, 0x00, sizeof(MSG_ADDRESS_INFO_S)); + + if (dbhandler->columnText(0) != NULL) + snprintf(addrInfo.addressVal, sizeof(addrInfo.addressVal), "%s", (char*)dbhandler->columnText(0)); + + MSG_CONTACT_INFO_S tmpContact; + memset(&tmpContact, 0x00, sizeof(MSG_CONTACT_INFO_S)); + + MsgGetContactInfo(&addrInfo, &tmpContact); + + if (tmpContact.firstName[0] != '\0') { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName); + } else if (addrInfo.addressVal[0] == '\0') { + char *senderStr = NULL; + senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER); + g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); + if (senderStr) { + free(senderStr); + senderStr = NULL; + } + } else { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal); + } + + snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal); + + noti_info->time = (time_t)dbhandler->columnInt(1); + + noti_info->msg_id = (msg_message_id_t)dbhandler->columnInt(2); + + snprintf(noti_info->text, sizeof(noti_info->text), "%s", (char*)dbhandler->columnText(3)); + + MSG_MGR_DEBUG("unread SIM message [%d].", noti_info->msg_id); + } else { + MSG_MGR_DEBUG("No unread SIM message."); + MSG_MGR_DEBUG("notiPrivId [%d]", noti_info->id); + + dbhandler->finalizeQuery(); + + if (!isForInstantMessage) { + /* No unread message. */ + if (noti_info->id > 0) { + noti_err = notification_delete_by_priv_id(NULL, 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); + } + } + + noti_info->id = 0; + + if (MsgSettingSetInt(SIM_MSG_NOTI_PRIV_ID, noti_info->id) != MSG_SUCCESS) + MSG_MGR_DEBUG("MsgSettingSetInt fail : SIM_MSG_NOTI_PRIV_ID"); + } + + return MSG_ERR_DB_STEP; + } + } else { + MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery); + dbhandler->finalizeQuery(); + return MSG_ERR_DB_STEP; + } + + dbhandler->finalizeQuery(); + break; + } +#endif + case MSG_MGR_NOTI_TYPE_FAILED: { + char sqlQuery[MAX_QUERY_LEN+1]; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + snprintf(sqlQuery, sizeof(sqlQuery), + "A.ADDRESS_VAL, " + "B.DISPLAY_TIME, " + "B.MSG_ID, " + "B.MSG_TEXT, " + "B.SUBJECT, " + "B.MAIN_TYPE, " + "(COUNT(CASE WHEN B.NETWORK_STATUS = %d THEN 1 END)) AS SENT_FAILED_CNT " + "FROM %s A, %s B " + "WHERE A.CONV_ID=B.CONV_ID " + "AND B.READ_STATUS=0 AND B.FOLDER_ID=%d " + "AND B.STORAGE_ID = %d " + "ORDER BY B.DISPLAY_TIME DESC;", + MSG_NETWORK_SEND_FAIL, + MSGFW_ADDRESS_TABLE_NAME, MSGFW_MESSAGE_TABLE_NAME, + MSG_OUTBOX_ID, + MSG_STORAGE_PHONE); + + MSG_MGR_DEBUG("sqlQuery [%s]", sqlQuery); + + row_cnt = 0, col_cnt = 0; + msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt); + if (msg_err != MSG_SUCCESS) { + MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err); + return -1; + } + + if (row_cnt > 0) { + noti_info->count = atoi(db_res[col_cnt+6]); + + if (noti_info->count > 0) { + MSG_MGR_ADDRESS_INFO_S addrInfo = {0,}; + + snprintf(addrInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", db_res[col_cnt]); + + MSG_MGR_CONTACT_INFO_S tmpContact = {0,}; + + MsgMgrGetContactInfo(&addrInfo, &tmpContact); + + if (tmpContact.firstName[0] != '\0') { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", tmpContact.firstName); + } else if (addrInfo.addressVal[0] == '\0') { + char *senderStr = NULL; + senderStr = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, MSG_UNKNOWN_SENDER); + g_strlcat(noti_info->sender, senderStr, sizeof(noti_info->sender)-strlen(noti_info->sender)); + if (senderStr) { + free(senderStr); + senderStr = NULL; + } + } else { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", addrInfo.addressVal); + } + + snprintf(noti_info->number, sizeof(noti_info->number), "%s", addrInfo.addressVal); + + noti_info->time = (time_t)atoi(db_res[col_cnt+1]); + + noti_info->msg_id = (msg_message_id_t)atoi(db_res[col_cnt+2]); + + unsigned char mainType = (unsigned char)atoi(db_res[col_cnt+5]); + + if (mainType == MSG_TYPE_MMS) + snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+4]); + else + snprintf(noti_info->text, sizeof(noti_info->text), "%s", db_res[col_cnt+3]); + + MSG_MGR_DEBUG("Sent failed message ID [%d].", noti_info->msg_id); + + if (!isForInstantMessage) { + if (noti_info->id > 0 && noti_info->count == 1) { + noti_err = notification_delete_by_priv_id(NULL, 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); + } + noti_info->id = 0; + if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0) + MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID"); + } + } + } else { + MSG_MGR_DEBUG("No sent failed message."); + MSG_MGR_DEBUG("failedNotiId [%d]", noti_info->id); + + msg_db_free(msg_handle, db_res); + + if (!isForInstantMessage) { + /* No unread message. */ + if (noti_info->id > 0) { + noti_err = notification_delete_by_priv_id(NULL, 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); + } + } + + noti_info->id = 0; + + if (vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_info->id) != 0) + MSG_MGR_DEBUG("vconf_set_int fail : MSG_SENTFAIL_NOTI_ID"); + } + + return -1; + } + } else { + msg_db_free(msg_handle, db_res); + return -1; + } + + msg_db_free(msg_handle, db_res); + break; + } + case MSG_MGR_NOTI_TYPE_SIM_FULL: + break; + default: + MSG_MGR_DEBUG("No matching type [%d]", noti_info->type); + return -1; + } + + MSG_MGR_END(); + + return 0; +} + + +notification_h getHandle(int *noti_id) +{ + notification_h noti_h = NULL; + + if (*noti_id > 0) { + MSG_MGR_DEBUG("Notification load"); + noti_h = notification_load(NULL, *noti_id); + if (noti_h == NULL) + MSG_MGR_DEBUG("notification_load is failed."); + } + + if (noti_h == NULL) { + MSG_MGR_DEBUG("Notification create"); + noti_h = notification_create(NOTIFICATION_TYPE_NOTI); + if (noti_h == NULL) { + MSG_MGR_DEBUG("notification_create is failed."); + return NULL; + } + + *noti_id = 0; + } + + return noti_h; +} + + +int getPrivId(msg_mgr_notification_type_t noti_type, int sim_idx) +{ + MSG_MGR_BEGIN(); + + int noti_id = 0; + + switch (noti_type) { +#ifdef MSG_NOTI_INTEGRATION + case MSG_MGR_NOTI_TYPE_NORMAL: + case MSG_MGR_NOTI_TYPE_SIM: + case MSG_MGR_NOTI_TYPE_CB: + vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id); + break; +#else + case MSG_MGR_NOTI_TYPE_NORMAL: + vconf_get_int(NOTIFICATION_PRIV_ID, ¬i_id); + break; + case MSG_MGR_NOTI_TYPE_SIM: + vconf_get_int(SIM_MSG_NOTI_PRIV_ID, ¬i_id); + break; + case MSG_MGR_NOTI_TYPE_CB: + vconf_get_int(CB_NOTI_PRIV_ID, ¬i_id); + break; +#endif + case MSG_MGR_NOTI_TYPE_FAILED: + vconf_get_int(MSG_SENTFAIL_NOTI_ID, ¬i_id); + break; + case MSG_MGR_NOTI_TYPE_VOICE_1: { + char keyName[MAX_VCONFKEY_NAME_LEN] = {0, }; + snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx); + vconf_get_int(keyName, ¬i_id); + break; + } + case MSG_MGR_NOTI_TYPE_VOICE_2: { + char keyName[MAX_VCONFKEY_NAME_LEN] = {0, }; + snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx); + vconf_get_int(keyName, ¬i_id); + break; + } + case MSG_MGR_NOTI_TYPE_SIM_FULL: + vconf_get_int(SIM_FULL_NOTI_PRIV_ID, ¬i_id); + break; + default: + MSG_MGR_DEBUG("No matching noti type [%d]", noti_type); + break; + } + + MSG_MGR_DEBUG("Get noti type = %d, id = %d, sim_idx:%d", noti_type, noti_id, sim_idx); + + MSG_MGR_END(); + + return noti_id; +} + + +void updatePrivId(msg_mgr_notification_type_t noti_type, int noti_id, int sim_idx) +{ + MSG_MGR_BEGIN(); + + int err = 0; + + MSG_MGR_DEBUG("Update noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx); + + switch (noti_type) { +#ifdef MSG_NOTI_INTEGRATION + case MSG_MGR_NOTI_TYPE_NORMAL: + case MSG_MGR_NOTI_TYPE_SIM: + case MSG_MGR_NOTI_TYPE_CB: + err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id); + break; +#else + case MSG_MGR_NOTI_TYPE_NORMAL: + err = vconf_set_int(NOTIFICATION_PRIV_ID, noti_id); + break; + case MSG_MGR_NOTI_TYPE_SIM: + err = vconf_set_int(SIM_MSG_NOTI_PRIV_ID, noti_id); + break; + case MSG_MGR_NOTI_TYPE_CB: + err = vconf_set_int(CB_NOTI_PRIV_ID, noti_id); + break; +#endif + case MSG_MGR_NOTI_TYPE_FAILED: + err = vconf_set_int(MSG_SENTFAIL_NOTI_ID, noti_id); + break; + case MSG_MGR_NOTI_TYPE_VOICE_1: { + char keyName[MAX_VCONFKEY_NAME_LEN] = {0, }; + snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_1, sim_idx); + err = vconf_set_int(keyName, noti_id); + break; + } + case MSG_MGR_NOTI_TYPE_VOICE_2: { + char keyName[MAX_VCONFKEY_NAME_LEN] = {0, }; + snprintf(keyName, sizeof(keyName), "%s/%d", VOICE_NOTI_ID_2, sim_idx); + err = vconf_set_int(keyName, noti_id); + break; + } + case MSG_MGR_NOTI_TYPE_SIM_FULL: + err = vconf_set_int(SIM_FULL_NOTI_PRIV_ID, noti_id); + break; + default: + MSG_MGR_DEBUG("No matching type [%d]", noti_type); + break; + } + + if (err != 0) + MSG_MGR_INFO("vconf_set_int fail : noti type = %d, id = %d, sim_idx = %d", noti_type, noti_id, sim_idx); + + MSG_MGR_END(); +} + + +void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, MSG_MGR_MESSAGE_INFO_S *msg_info) +{ + MSG_MGR_BEGIN(); + + if (msg_info) { + noti_info->id = getPrivId(noti_info->type, msg_info->sim_idx); + noti_info->msg_id = msg_info->msgId; + } else { + MSG_MGR_DEBUG("msg_info is NULL"); + return; + } + + noti_info->sim_idx = msg_info->sim_idx; + + createServiceHandle(¬i_info->svc_h); + char keyName[MAX_VCONFKEY_NAME_LEN]; + + switch (noti_info->type) { + case MSG_MGR_NOTI_TYPE_VOICE_1: + case MSG_MGR_NOTI_TYPE_VOICE_2: { + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, msg_info->sim_idx); + vconf_get_int(keyName, ¬i_info->count); + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + noti_info->time = msg_info->displayTime; + + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, msg_info->sim_idx); + char *voiceNumber = vconf_get_str(keyName); + memset(keyName, 0x00, sizeof(keyName)); + snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_ALPHA_ID, msg_info->sim_idx); + char *voiceAlphaId = vconf_get_str(keyName); + char *dialNumber = NULL; + + MSG_MGR_SEC_DEBUG("Voice mail server - alpha id = [%s], default num = [%s]", voiceAlphaId, voiceNumber); + + if (voiceNumber && strlen(voiceNumber)) + dialNumber = voiceNumber; + + if (voiceAlphaId && strlen(voiceAlphaId) > 0) { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", voiceAlphaId); + } else if (dialNumber && strlen(dialNumber) > 0) { + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", dialNumber); + } + + if (dialNumber && strlen(dialNumber) > 0) + snprintf(noti_info->number, sizeof(noti_info->number), "%s", dialNumber); + + if (noti_info->svc_h) { + setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL); + setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL); + + char slot_id[5] = {0, }; + snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1); + addServiceExtraData(noti_info->svc_h, "slot_id", slot_id); + } + + if (voiceNumber) g_free(voiceNumber); + if (voiceAlphaId) g_free(voiceAlphaId); + break; + } + case MSG_MGR_NOTI_TYPE_MWI: + case MSG_MGR_NOTI_TYPE_CLASS0: { + noti_info->count = 1; + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + noti_info->time = msg_info->displayTime; + + if (msg_info->displayName[0] == '\0') + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal); + else + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->displayName); + + snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal); + + snprintf(noti_info->text, sizeof(noti_info->text), "%s", msg_info->msgText); + + if (noti_info->type == MSG_MGR_NOTI_TYPE_MWI) { + if (noti_info->svc_h) { + setServiceOperation(noti_info->svc_h, APP_CONTROL_OPERATION_CALL); + setServiceUri(noti_info->svc_h, MSG_TEL_URI_VOICEMAIL); + + char slot_id[5] = {0, }; + snprintf(slot_id, sizeof(slot_id), "%d", msg_info->sim_idx - 1); + addServiceExtraData(noti_info->svc_h, "slot_id", slot_id); + } + + } else { + setServiceAppId(noti_info->svc_h, "org.tizen.msg-ui-class0"); + addServiceExtraData(noti_info->svc_h, "type", "new_msg"); + addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); + } + break; + } + case MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT: { + noti_info->count = 1; + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + noti_info->time = msg_info->displayTime; + noti_info->extra_data = msg_info->networkStatus; + +/* contacts-service is not used for gear */ +#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED + MSG_MGR_CONTACT_INFO_S contactInfo = {0,}; + MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0,}; + if (msg_info->addressVal) { + snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal); + if (_is_valid_email(msg_info->addressVal)) { + tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL; + } else { + tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN; + } + } + + if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) { + MSG_MGR_WARN("MsgMgrGetContactInfo() fail."); + } +#endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ + + if (contactInfo.firstName[0] == '\0') + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal); + else + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName); + + 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); + 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); + } + break; + } + case MSG_MGR_NOTI_TYPE_MMS_READ_REPORT: + case MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT: { + noti_info->count = 1; + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + noti_info->time = msg_info->displayTime; + +/* contacts-service is not used for gear */ +#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED + MSG_MGR_CONTACT_INFO_S contactInfo = {0,}; + MSG_MGR_ADDRESS_INFO_S tmpAddressInfo = {0,}; + if (msg_info->addressVal) { + snprintf(tmpAddressInfo.addressVal, MAX_ADDRESS_VAL_LEN, "%s", msg_info->addressVal); + if (_is_valid_email(msg_info->addressVal)) { + tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_EMAIL; + } else { + tmpAddressInfo.addressType = MSG_ADDRESS_TYPE_UNKNOWN; + } + } + + if (MsgMgrGetContactInfo(&tmpAddressInfo, &contactInfo) != 0) { + MSG_MGR_WARN("MsgMgrGetContactInfo() fail."); + } +#endif /*MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ + if (contactInfo.firstName[0] == '\0') + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", msg_info->addressVal); + else + snprintf(noti_info->sender, sizeof(noti_info->sender), "%s", contactInfo.firstName); + + snprintf(noti_info->number, sizeof(noti_info->number), "%s", msg_info->addressVal); + + char sqlQuery[MAX_QUERY_LEN+1]; + memset(sqlQuery, 0x00, sizeof(sqlQuery)); + + int report_status_type; + int report_status_value; + + if (noti_info->type == MSG_MGR_NOTI_TYPE_MMS_READ_REPORT) { + report_status_type = MSG_REPORT_TYPE_READ; + } else { + report_status_type = MSG_REPORT_TYPE_DELIVERY; + } + + char *normalNum = NULL; + if (msg_info->addressVal[0] != '\0') + phone_number_get_normalized_number(msg_info->addressVal, &normalNum); + + snprintf(sqlQuery, sizeof(sqlQuery), + "STATUS " + "FROM %s " + "WHERE MSG_ID=%d AND STATUS_TYPE=%d AND ADDRESS_VAL LIKE '%%%s';", + MSGFW_REPORT_TABLE_NAME, msg_info->msgId, report_status_type, normalNum); + + MSG_MGR_DEBUG("sqlQuery = [%s]", sqlQuery); + + if (normalNum) + g_free(normalNum); + + char **db_res = NULL; + int row_cnt = 0, col_cnt = 0; + + int msg_err = msg_db_select_with_query(msg_handle, sqlQuery, &db_res, &row_cnt, &col_cnt); + if (msg_err != MSG_SUCCESS || row_cnt <= 0) { + MSG_MGR_ERR("msg_db_select_with_query() failed [%d]", msg_err); + return; + } + + report_status_value = atoi(db_res[col_cnt]); + + MSG_MGR_DEBUG("report status [type = %d, value = %d]", report_status_type, report_status_value); + + 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; + } + + if (noti_info->msg_id > 0) { + setServiceAppId(noti_info->svc_h, MSG_DEFAULT_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->extra_data = (unsigned char)report_status_value; + break; + } + default: + MSG_MGR_DEBUG("No matching type [%d]", noti_info->type); + break; + } + + noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK; + MSG_MGR_END(); +} + + +void createInfoData(MSG_MGR_NOTI_INFO_S *noti_info, msg_mgr_active_notification_type_t active_noti) +{ + MSG_MGR_BEGIN(); + + createServiceHandle(¬i_info->svc_h); + + switch (noti_info->type) { + case MSG_MGR_NOTI_TYPE_NORMAL: { + if (noti_info->count > 1) { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE; + } else { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + } + + setServiceAppId(noti_info->svc_h, MSG_DEFAULT_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->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER; + + if (noti_info->active_noti_button_num == 0) + noti_info->active_noti_button_num = 3; + break; + } + case MSG_MGR_NOTI_TYPE_CB: { + if (noti_info->count > 1) { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE; + } else { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + } + + setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + addServiceExtraData(noti_info->svc_h, "type", "new_msg"); + addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); + + if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) + noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK; + else + noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR; + + noti_info->active_noti_button_num = 1; + break; + } + case MSG_MGR_NOTI_TYPE_SIM: { + if (noti_info->count > 1) { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_MULTIPLE; + } else { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + } + + setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + addServiceExtraData(noti_info->svc_h, "type", "new_msg"); + addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); + + if (active_noti == MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT) + noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_LOCK; + else + noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR; + + if (noti_info->active_noti_button_num == 0) + noti_info->active_noti_button_num = 3; + break; + } + case MSG_MGR_NOTI_TYPE_FAILED: { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + + setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + addServiceExtraData(noti_info->svc_h, "type", "send_failed_msg"); + addServiceExtraData(noti_info->svc_h, "msgId", noti_info->msg_id); + + noti_info->applist = NOTIFICATION_DISPLAY_APP_ALL^NOTIFICATION_DISPLAY_APP_TICKER^NOTIFICATION_DISPLAY_APP_LOCK; + break; + } + case MSG_MGR_NOTI_TYPE_SIM_FULL: { + noti_info->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE; + + setServiceAppId(noti_info->svc_h, MSG_DEFAULT_APP_ID); + addServiceExtraData(noti_info->svc_h, "sim_list_show", "sim_setting"); + + noti_info->applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY|NOTIFICATION_DISPLAY_APP_INDICATOR; + break; + } + default: + break; + } + + if (active_noti != MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE) + noti_info->active_noti_button_num = 0; + + MSG_MGR_END(); +} + + +void createServiceHandle(app_control_h *svc_h) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + svc_err = app_control_create(svc_h); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_MGR_DEBUG("app_control_create() is failed, [%d]", svc_err); +} + + +void setServiceAppId(app_control_h svc_h, const char* app_id) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + svc_err = app_control_set_app_id(svc_h, app_id); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err); +} + + +void setServiceUri(app_control_h svc_h, const char* uri) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + svc_err = app_control_set_uri(svc_h, uri); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_MGR_DEBUG("app_control_set_uri() was failed, [%d]", svc_err); +} + + +void setServiceOperation(app_control_h svc_h, const char* operation) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + svc_err = app_control_set_operation(svc_h, operation); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_MGR_DEBUG("app_control_set_operation() was failed, [%d]", svc_err); +} + + +void addServiceExtraData(app_control_h svc_h, const char* bundle_key, const char* bundle_val) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + svc_err = app_control_add_extra_data(svc_h, bundle_key, bundle_val); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err); +} + + +void addServiceExtraData(app_control_h svc_h, const char* bundle_key, int bundle_val) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + char tempId[10]; + memset(&tempId, 0x00, sizeof(tempId)); + snprintf(tempId, sizeof(tempId), "%d", bundle_val); + + svc_err = app_control_add_extra_data(svc_h, bundle_key, (const char *)tempId); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_MGR_DEBUG("app_control_add_extra_data() was failed, [%d]", svc_err); +} + + +void setServicePackageName(app_control_h svc_h, const char* pkg_name) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + svc_err = app_control_set_app_id(svc_h, pkg_name); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_MGR_DEBUG("app_control_set_app_id() was failed, [%d]", svc_err); +} + + +void sendServicelaunchRequest(app_control_h svc_h, app_control_reply_cb callback, void *user_data) +{ + int svc_err = APP_CONTROL_ERROR_NONE; + + svc_err = app_control_send_launch_request(svc_h, callback, user_data); + + if (svc_err != APP_CONTROL_ERROR_NONE) + MSG_MGR_DEBUG("app_control_send_launch_request() is failed : %d", svc_err); +} + + +void setNotiTextDomain(notification_h noti_h, const char *pkg_name, const char *loc_dir) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_text_domain(noti_h, pkg_name, loc_dir); + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_MGR_DEBUG("notification_set_text_domain() was failed. [%d]", noti_err); +} + + +void setNotiText(notification_h noti_h, notification_text_type_e type, const char *text, const char *key) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_text(noti_h, type, text, key, NOTIFICATION_VARIABLE_TYPE_NONE); + + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_MGR_DEBUG("notification_set_text() was failed. [%d]", noti_err); +} + + +void setNotiTimeToText(notification_h noti_h, notification_text_type_e type, time_t time) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_time_to_text(noti_h, type, time); + + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_MGR_DEBUG("notification_set_time_to_text() was failed. [%d]", noti_err); +} + + +void setNotiTime(notification_h noti_h, time_t time) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_time(noti_h, time); + + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_MGR_DEBUG("notification_set_time() was failed. [%d]", noti_err); +} + + + +void setNotiImage(notification_h noti_h, notification_image_type_e type, const char *image_path) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_image(noti_h, type, image_path); + + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_MGR_DEBUG("notification_set_image() was failed. [%d]", noti_err); +} + + +void setNotiSound(notification_h noti_h, notification_sound_type_e type, const char *path) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_sound(noti_h, type, path); + + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_MGR_DEBUG("notification_set_sound() was failed. [%d]", noti_err); +} + + +void setNotiVibration(notification_h noti_h, notification_vibration_type_e type, const char *path) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_vibration(noti_h, type, path); + + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_MGR_DEBUG("notification_set_vibration() was failed. [%d]", noti_err); +} + + +void setNotiEventHandler(notification_h noti_h, notification_event_type_e type, app_control_h event_handler) +{ + int noti_err = NOTIFICATION_ERROR_NONE; + + noti_err = notification_set_event_handler(noti_h, type, event_handler); + + if (noti_err != NOTIFICATION_ERROR_NONE) + MSG_MGR_DEBUG("notification_set_event_handler() was failed. [%d]", noti_err); +} + + +int MsgMgrInsertInstantMessage(msg_mgr_notification_type_t noti_type) +{ + MSG_MGR_BEGIN(); + + char *notiMsg = NULL; + + notification_h noti = notification_create(NOTIFICATION_TYPE_NOTI); + + switch (noti_type) { + case MSG_MGR_NOTI_TYPE_NORMAL: + case MSG_MGR_NOTI_TYPE_SIM: + case MSG_MGR_NOTI_TYPE_CB: { + MSG_MGR_NOTI_INFO_S noti_info; + memset(¬i_info, 0x00, sizeof(MSG_MGR_NOTI_INFO_S)); + + noti_info.type = noti_type; + int err = getLatestMsgInfo(¬i_info, true); + + if (err == 0) { + MSG_MGR_DEBUG("Unread count [%d]", noti_info.count); + if (noti_info.count == 1) { + MSG_MGR_SEC_DEBUG("noti_info.sender [%s]", noti_info.sender); + setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, noti_info.sender, NULL); + setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.text, NULL); + } else if (noti_info.count > 1) { + gchar *cnt_string = g_strdup_printf("%i", noti_info.count); + + notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, NEW_MESSAGE); + gchar *outString = g_strconcat(cnt_string, " ", notiMsg, NULL); + setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, outString, NULL); + setNotiText(noti, NOTIFICATION_TEXT_TYPE_CONTENT, noti_info.sender, NULL); + g_free(outString); + g_free(cnt_string); + } + + setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_NORMAL_ICON_PATH); + } + break; + } + case MSG_MGR_NOTI_TYPE_FAILED: { + notiMsg = get_translate_text(MSG_APP_PACKAGE_NAME, MSG_APP_LOCALEDIR, FAILED_TO_SEND_MESSAGE); + setNotiText(noti, NOTIFICATION_TEXT_TYPE_TITLE, notiMsg, NULL); + setNotiImage(noti, NOTIFICATION_IMAGE_TYPE_ICON, MSG_SMS_SENDING_FAILED_ICON_PATH); + break; + } + default: + MSG_MGR_DEBUG("No matching type for MsgNotiType%d]", noti_type); + goto _END_OF_INSTANT_NOTI; + break; + } + + if (notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_TICKER) != NOTIFICATION_ERROR_NONE) + MSG_MGR_DEBUG("Fail to notification_set_display_applist"); + + if (notification_post(noti) != NOTIFICATION_ERROR_NONE) + MSG_MGR_DEBUG("Fail to notification_post"); + +_END_OF_INSTANT_NOTI: + + if (notification_delete(noti) != NOTIFICATION_ERROR_NONE) + MSG_MGR_DEBUG("Fail to notification_delete"); + if (notiMsg) { + free(notiMsg); + notiMsg = NULL; + } + + if (noti) { + if (notification_free(noti) != NOTIFICATION_ERROR_NONE) + MSG_MGR_DEBUG("Fail to notification_free"); + noti = NULL; + } + + MSG_MGR_END(); + return 0; +} + + +int MsgMgrInsertBadge(unsigned int unreadMsgCnt) +{ + MSG_MGR_DEBUG("Start to set badge to [%d].", unreadMsgCnt); + + int err = BADGE_ERROR_NONE; + bool exist = false; + + err = badge_is_existing(MSG_DEFAULT_APP_ID, &exist); + + if (err != BADGE_ERROR_NONE) { + MSG_MGR_ERR("Fail to badge_is_existing : %d", err); + return -1; + } + + if (!exist) { + /* create badge */ + err = badge_add(MSG_DEFAULT_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); + + if (err != BADGE_ERROR_NONE) { + MSG_MGR_ERR("Fail to badge_set_count : %d", err); + return -1; + } + + return 0; +} + + +void MsgMgrNotiSoundRepeatAlarmCB(int alarmId) +{ + MSG_MGR_BEGIN(); + + MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_NORMAL, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE); + +#ifndef MSG_NOTI_INTEGRATION + MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_SIM, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE); + MsgMgrRefreshNotification(MSG_MGR_NOTI_TYPE_CB, true, MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE); +#endif + + MSG_MGR_END(); + return; +} + + +void MsgMgrSoundCreateRepeatAlarm(int RepeatTime) +{ + MSG_MGR_BEGIN(); + + int tmpAlarmId = 0; + time_t tmp_time; + struct tm repeat_tm; + + time(&tmp_time); + + tmp_time += (RepeatTime*60); + tzset(); + localtime_r(&tmp_time, &repeat_tm); + + if (MsgMgrAlarmRegistration(&repeat_tm, MsgMgrNotiSoundRepeatAlarmCB, &tmpAlarmId) != 0) { + MSG_MGR_DEBUG("MsgAlarmRegistration fail."); + return; + } + + g_alarmId = tmpAlarmId; + MSG_MGR_DEBUG("Set alarmId to [%d]", g_alarmId); + + MSG_MGR_END(); + + return; +} + + +void MsgMgrSoundSetRepeatAlarm() +{ + int nRepeatValue = 0; + long nRepeatTime = 0; + + if (vconf_get_int(MSG_ALERT_REP_TYPE, &nRepeatValue) != 0) { + MSG_MGR_INFO("vconf_get_int() is failed"); + } + + switch (nRepeatValue) { + case MSG_ALERT_TONE_ONCE: + nRepeatTime = 0; + break; + case MSG_ALERT_TONE_2MINS: + nRepeatTime = 2; + break; + case MSG_ALERT_TONE_5MINS: + nRepeatTime = 5; + break; + case MSG_ALERT_TONE_10MINS: + nRepeatTime = 10; + break; + default: + MSG_MGR_DEBUG("Invalid Repetition time"); + break; + } + + MSG_MGR_DEBUG("nRepeatTime = %d", nRepeatTime); + + if (nRepeatTime > 0) { + if (g_alarmId > 0) { + if (MsgMgrAlarmRemove(g_alarmId) != 0) { + MSG_MGR_FATAL("MsgAlarmRemove fail."); + } + g_alarmId = 0; + } + MsgMgrSoundCreateRepeatAlarm(nRepeatTime); + } + + return; +} + + +char *get_translate_text(const char *pkg_name, const char *locale_dir, const char *text) +{ + char *notiMsg = NULL; + char *lang = NULL; + + lang = vconf_get_str(VCONFKEY_LANGSET); + + setlocale(LC_MESSAGES, lang); + + bindtextdomain(pkg_name, locale_dir); + + notiMsg = dgettext(pkg_name, text); + + if (lang) { + free(lang); + lang = NULL; + } + + return g_strdup(notiMsg); +} diff --git a/manager/src/msg-manager-sound.cpp b/manager/src/msg-manager-sound.cpp new file mode 100644 index 0000000..e2fa7e6 --- /dev/null +++ b/manager/src/msg-manager-sound.cpp @@ -0,0 +1,620 @@ +/* + * 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. +*/ + +/*================================================================================================== + INCLUDE FILES +==================================================================================================*/ + +#include <stdlib.h> +#include <stdio.h> +#include <glib.h> +#include <sys/stat.h> +#include <unistd.h> + +#include <call-manager.h> +#include <player.h> +#include <sound_manager.h> +#include <feedback.h> +#include <feedback-internal.h> +#include <vconf.h> + +#include <msg-manager-contact.h> +#include <msg-manager-debug.h> +#include <msg-manager-notification.h> +#include <msg-manager-sound.h> + +/*================================================================================================== + DEFINES +==================================================================================================*/ + +#define DEFAULT_ALERT_FILE TZ_SYS_RO_APP_PATH "/" MSG_SETTING_APP_ID "shared/res/settings/Alerts/General notification_sdk.wav" + +#define MSG_MGR_SOUND_TIMEOUT 5500 + + +/*================================================================================================== + VARIABLES +==================================================================================================*/ +player_h g_PlayerHandle = NULL; +sound_stream_info_h g_stream_info = NULL; +char *defaultRingtonePath = NULL; +bool bFeedbackInit = false; +bool bPlaying = false; + +pthread_mutex_t muMmPlay = PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t muStream = PTHREAD_MUTEX_INITIALIZER; + +extern cm_client_h cm_handle; + +/*================================================================================================== + FUNCTION DEFINE +===================================================================================================*/ +int MsgMgrGetFileSize(const char *pFileName); +cm_call_status_e MsgMgrGetCallStatus(); + +int MsgMgrStreamStart(MSG_MGR_SOUND_TYPE_T soundType); +void MsgMgrStreamStop(); +void MsgMgrGetPlayStatus(bool bOnCall, bool bSound, bool bVibration, bool bMsgSound, bool bMsgVibration, bool *bPlaySound, bool *bPlayVibration); + +void MsgMgrSoundPlayMelody(char *pMsgToneFilePath); +void MsgMgrSoundPlayVibration(char *vibrationPath); + +/*================================================================================================== + FUNCTION IMPLEMENTATION +==================================================================================================*/ +int MsgMgrGetFileSize(const char *pFileName) +{ + struct stat file_stat; + + if (lstat(pFileName, &file_stat)) { + MSG_MGR_FATAL("error lstat: %s", g_strerror(errno)); + return -1; + } + + return (int)file_stat.st_size; +} + + +cm_call_status_e MsgMgrGetCallStatus() +{ + cm_call_status_e call_status = CM_CALL_STATUS_IDLE; + cm_get_call_status(cm_handle, &call_status); + + return call_status; +} + + +static void MsgMgrSoundPlayeErrorCallback(int error_code, void *user_data) +{ + MSG_MGR_DEBUG("MsgMgrSoundPlayeErrorCallback called [%d]", error_code); + MsgMgrStreamStop(); + MsgMgrSoundPlayStart(NULL, MSG_MGR_SOUND_PLAY_DEFAULT); +} + +static void MsgMgrSoundPlayeCompletedCallback(void *user_data) +{ + MSG_MGR_DEBUG("MsgMgrSoundPlayeCompletedCallback called"); + MsgMgrSoundPlayStop(); +} + +static void MsgMgrSoundPlayeInterruptedCallback(player_interrupted_code_e code, void *user_data) +{ + MSG_MGR_DEBUG("MsgMgrSoundPlayeInterruptedCallback called [%d]", code); + MsgMgrSoundPlayStop(); +} + +static void MsgStreamFocusCallback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data) +{ + MSG_MGR_DEBUG("MsgStreamFocusCallback called, reason_for_change [%d], additional_info [%s]", reason_for_change, additional_info); + + sound_stream_focus_state_e playback_focus_state = SOUND_STREAM_FOCUS_STATE_ACQUIRED; + + sound_manager_get_focus_state(stream_info, &playback_focus_state, NULL); + if (playback_focus_state == SOUND_STREAM_FOCUS_STATE_RELEASED) { + MSG_MGR_DEBUG("sound stream focus released"); + MsgMgrSoundPlayStop(); + } +} + + +void initMsgMgrSoundPlayer() +{ + bPlaying = false; + bFeedbackInit = false; + + defaultRingtonePath = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR); + + if (defaultRingtonePath == NULL || MsgMgrGetFileSize(defaultRingtonePath) < 1) { + defaultRingtonePath = (char *)DEFAULT_ALERT_FILE; + } + + MSG_MGR_DEBUG("defaultRingtonePath [%s]", defaultRingtonePath); +} + + +void MsgMgrGetRingtonePath(char *userRingtonePath, char **msg_tone_file_path_p) +{ + int tmpVal = 0; + if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) { + MSG_MGR_INFO("vcong_get_int() is failed"); + } + int ringtoneType = tmpVal; + + MSG_MGR_DEBUG("Ringtone type = [%d]", ringtoneType); + + if (ringtoneType == MSG_RINGTONE_TYPE_SILENT) { + *msg_tone_file_path_p = NULL; + return; + } + + char *tmpFilePath = NULL; + *msg_tone_file_path_p = new char[MSG_FILEPATH_LEN_MAX+1]; + + char *msg_tone_file_path = *msg_tone_file_path_p; + + bool bUserRingtone = userRingtonePath && userRingtonePath[0] != '\0'; + if (bUserRingtone) { + tmpFilePath = userRingtonePath; + } else { + if (ringtoneType == MSG_RINGTONE_TYPE_DEFAULT) { + tmpFilePath = vconf_get_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR); + } else { + tmpFilePath = vconf_get_str(MSG_SETTING_RINGTONE_PATH); + } + } + + memset(msg_tone_file_path, 0x00, sizeof(char)*(MSG_FILEPATH_LEN_MAX+1)); +#if MSG_MGR_DRM_SUPPORT + if ((tmpFilePath == NULL || MsgMgrGetFileSize(tmpFilePath) < 1) || /* wrong ringtone file path */ + (MsgDrmIsDrmFile(tmpFilePath) && !MsgDrmCheckRingtone(tmpFilePath))) { /* check DRM */ +#endif + if ((tmpFilePath == NULL || MsgMgrGetFileSize(tmpFilePath) < 1)) { /* wrong ringtone file path */ + if (tmpFilePath && (strcmp(tmpFilePath, "silent") == 0)) { + MSG_MGR_DEBUG("Set ringtone to NONE(Silent)"); + msg_tone_file_path = NULL; + } else { + MSG_MGR_DEBUG("Set ringtone to defaultRingtonePath."); + strncpy(msg_tone_file_path, defaultRingtonePath, MSG_FILEPATH_LEN_MAX); + } + } else { + MSG_MGR_DEBUG("Set ringtone to tmpFilePath."); + snprintf(msg_tone_file_path, MSG_FILEPATH_LEN_MAX, "%s", tmpFilePath); + } + + if (tmpFilePath && !bUserRingtone) { + free(tmpFilePath); + tmpFilePath = NULL; + } +} + +void MsgMgrGetPlayStatus(bool bVoiceMail, bool *bPlaySound, bool *bPlayVibration, bool *bOnCall) +{ + MSG_MGR_BEGIN(); + + if (!bPlaySound || !bPlayVibration) { + MSG_MGR_DEBUG("IN parameter is NULL."); + return; + } + + *bPlaySound = false; + *bPlayVibration = false; + + /* Global setting */ + int bSoundOn = 0; /* sound setting on notification panel */ + int bVibrationOn = 0; /* vibration setting on notification panel */ + + if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &bSoundOn) != 0) + MSG_MGR_INFO("vconf_get_bool() is failed"); + + if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &bVibrationOn) != 0) + MSG_MGR_INFO("vconf_get_bool() is failed"); + + /* Alert setting */ +#if 0 /* not used value */ + int bNotiVibrationOn = 0; /* alert vibration */ + if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATE_WHEN_NOTIFICATION_BOOL, &bNotiVibrationOn) != 0) + MSG_MGR_INFO("vconf_get_bool() is failed"); +#endif + + int bMsgSettingNoti = 1; /* Alert for message notification */ + int bMsgSettingVibration = 0; /* vibration for message notification */ + + int ringtoneType = MSG_RINGTONE_TYPE_DEFAULT; /*sound type for message notification */ + bool bMsgSettingSound = true; + + if (vconf_get_bool(MSG_SETTING_VIBRATION, &bMsgSettingVibration) != 0) + MSG_MGR_INFO("vconf_get_bool() is failed"); + + if (vconf_get_bool(MSG_SETTING_NOTIFICATION, &bMsgSettingNoti) != 0) + MSG_MGR_INFO("vconf_get_bool() is failed"); + + int tmpVal = 0; + if (vconf_get_int(MSG_SETTING_RINGTONE_TYPE, &tmpVal) != 0) { + MSG_MGR_INFO("vconf_get_int() is failed"); + } + ringtoneType = tmpVal; + if (ringtoneType == MSG_RINGTONE_TYPE_SILENT) + bMsgSettingSound = false; + + MSG_MGR_SEC_DEBUG("Sound status : Sound mode[%d], Manner mode[%d]", bSoundOn, bVibrationOn); + MSG_MGR_SEC_DEBUG("Msg Setting : Noti Alert[%d], vibration[%d], sound[%d], ringtoneType[%d]", bMsgSettingNoti, bMsgSettingVibration, bMsgSettingSound, ringtoneType); + + cm_call_status_e callStatus = CM_CALL_STATUS_IDLE; +/* int alertOnCall = 0; */ + + callStatus = MsgMgrGetCallStatus(); + MSG_MGR_DEBUG("Call Status [%d]", callStatus); + + /* Check call status */ + if (callStatus > CM_CALL_STATUS_IDLE && callStatus < CM_CALL_STATUS_MAX) { + /* 1. On Call */ + *bOnCall = true; /* set call status; */ + } else { + /* 2. Call is not active */ + MSG_MGR_DEBUG("Call is not active."); + int voiceRecording = 0; + if (vconf_get_int(VCONFKEY_RECORDER_STATE, &voiceRecording) != 0) { + MSG_MGR_INFO("vconf_get_int() is failed"); + } + + if (bVoiceMail) { /* 2-1. Voice message */ + if (bMsgSettingNoti) { + MsgMgrGetPlayStatus(false, bSoundOn, bVibrationOn, bMsgSettingSound, bMsgSettingVibration, bPlaySound, bPlayVibration); + + } else { + MSG_MGR_DEBUG("It doesn't play sound/vibration - voice message."); + } + } else { /* 2-1. Normal message */ + if (bMsgSettingNoti) { + if (voiceRecording != VCONFKEY_RECORDER_STATE_RECORDING) { + MsgMgrGetPlayStatus(false, bSoundOn, bVibrationOn, bMsgSettingSound, bMsgSettingVibration, bPlaySound, bPlayVibration); + } else { + MSG_MGR_DEBUG("It doesn't play sound/vibration."); + } + } else { + MSG_MGR_DEBUG("It doesn't play sound/vibration."); + } + } + } + + MSG_MGR_END(); +} + + +void MsgMgrGetPlayStatus(bool bOnCall, bool bSound, bool bVibration, bool bMsgSound, bool bMsgVibration, bool *bPlaySound, bool *bPlayVibration) +{ + MSG_MGR_BEGIN(); + + /* samsung basic concept : feedback should follow profile setting. + * And if notification setting exist in msg app, then apply it prior to profile when profile either sound or vibration. + * But, Play sound when profile is vibration during call, if device does not support haptic */ + if (bSound || bVibration) { + bool bHantic_device = false; +#ifdef FEATURE_HAPTIC_ENABLE + bHantic_device = true; +#endif + if (bHantic_device || (bOnCall == false)) { + if (bSound) { + if (bMsgSound) { + MSG_MGR_DEBUG("Play sound."); + *bPlaySound = true; + } + + if (bMsgVibration) { + MSG_MGR_DEBUG("Play vibration."); + *bPlayVibration = true; + } + } else { + if (bMsgVibration) { + MSG_MGR_DEBUG("Play vibration."); + *bPlayVibration = true; + } + } + } else { /* during call */ + if (bMsgSound || bMsgVibration) { + MSG_MGR_DEBUG("Play sound."); + *bPlaySound = true; + } + } + } + + MSG_MGR_END(); +} + + +void MsgMgrSoundPlayStart(const MSG_MGR_ADDRESS_INFO_S *pAddrInfo, MSG_MGR_SOUND_TYPE_T soundType) +{ + MSG_MGR_BEGIN(); + + MSG_MGR_DEBUG("soundType [%d]", soundType); + + /* check camera state */ + int cameraState = 0; /* camera recording state */ + if (vconf_get_int(VCONFKEY_CAMERA_STATE, &cameraState) != 0) { + MSG_MGR_INFO("vconf_get_int() is failed"); + } + MSG_MGR_SEC_DEBUG("Camera state [%d]", cameraState); + + if (cameraState == VCONFKEY_CAMERA_STATE_RECORDING) { + MSG_MGR_END(); + return; + } + + MSG_MGR_CONTACT_INFO_S contactInfo = {0,}; + if (pAddrInfo) { + if (MsgMgrGetContactInfo(pAddrInfo, &contactInfo) != 0) { + MSG_MGR_DEBUG("MsgGetContactInfo() fail."); + } + } + + /* get ringtone file path */ + char *msg_tone_file_path = NULL; + + if (soundType == MSG_MGR_SOUND_PLAY_EMERGENCY) { + msg_tone_file_path = new char[MSG_FILEPATH_LEN_MAX+1]; + memset(msg_tone_file_path, 0x00, sizeof(char)*(MSG_FILEPATH_LEN_MAX+1)); + } else if (soundType == MSG_MGR_SOUND_PLAY_DEFAULT) { + msg_tone_file_path = new char[MSG_FILEPATH_LEN_MAX+1]; + memset(msg_tone_file_path, 0x00, sizeof(char)*(MSG_FILEPATH_LEN_MAX+1)); + strncpy(msg_tone_file_path, DEFAULT_ALERT_FILE, MSG_FILEPATH_LEN_MAX); + } else { + MsgMgrGetRingtonePath(contactInfo.alerttonePath, &msg_tone_file_path); + } + MSG_MGR_SEC_DEBUG("soundType [%d], Sound File [%s]", soundType, msg_tone_file_path); + + /* get sound play status */ + bool bPlaySound = false; + bool bPlayVibration = false; + bool bVoiceMsg = (soundType == MSG_MGR_SOUND_PLAY_VOICEMAIL)?true:false; + bool bOnCall = false; + + MsgMgrGetPlayStatus(bVoiceMsg, &bPlaySound, &bPlayVibration, &bOnCall); + + MSG_MGR_SEC_DEBUG("sound=[%d], vibration=[%d], voice_msg?[%d], on_call?[%d]", + bPlaySound, bPlayVibration, bVoiceMsg, bOnCall); + + /* play sound */ + if (bPlaySound) { + int err = MsgMgrStreamStart(soundType); + + if (err != SOUND_MANAGER_ERROR_NONE) + MSG_MGR_DEBUG("MsgMgrStreamStart() Failed : %d", err); + else + MsgMgrSoundPlayMelody(msg_tone_file_path); + } + + if (bPlayVibration) + MsgMgrSoundPlayVibration(contactInfo.vibrationPath); + + if (msg_tone_file_path) + delete [] msg_tone_file_path; + + MSG_MGR_END(); +} + + +void MsgMgrSoundPlayStop() +{ + MSG_MGR_BEGIN(); + + int err = 0; + pthread_mutex_lock(&muMmPlay); + + if (bPlaying == true && g_PlayerHandle != NULL) { + MSG_MGR_DEBUG("stopping the player."); + /* Stop playing media contents */ + err = player_stop(g_PlayerHandle); + + if (err != PLAYER_ERROR_NONE) + MSG_MGR_DEBUG("stopping the player handle failed"); + } + + if (g_PlayerHandle != NULL) { + MSG_MGR_DEBUG("destroy the player."); + + player_unset_error_cb(g_PlayerHandle); + player_unset_completed_cb(g_PlayerHandle); + player_unset_interrupted_cb(g_PlayerHandle); + player_unprepare(g_PlayerHandle); + player_destroy(g_PlayerHandle); + } + + g_PlayerHandle = NULL; + bPlaying = false; + + pthread_mutex_unlock(&muMmPlay); + + MsgMgrStreamStop(); + + MSG_MGR_END(); +} + + +int MsgMgrStreamStart(MSG_MGR_SOUND_TYPE_T soundType) +{ + MSG_MGR_BEGIN(); + int err = 0; + + pthread_mutex_lock(&muStream); + + if (g_stream_info != NULL) { + err = sound_manager_destroy_stream_information(g_stream_info); + if (err != SOUND_MANAGER_ERROR_NONE) + MSG_MGR_DEBUG("sound_manager_destroy_stream_information() Failed : %d", err); + + g_stream_info = NULL; + } + + if (soundType == MSG_MGR_SOUND_PLAY_EMERGENCY) + err = sound_manager_create_stream_information(SOUND_STREAM_TYPE_EMERGENCY, MsgStreamFocusCallback, NULL, &g_stream_info); + else + err = sound_manager_create_stream_information(SOUND_STREAM_TYPE_NOTIFICATION, MsgStreamFocusCallback, NULL, &g_stream_info); + + if (err != SOUND_MANAGER_ERROR_NONE) { + MSG_MGR_DEBUG("sound_manager_create_stream_information() Failed : %d", err); + pthread_mutex_unlock(&muStream); + return err; + } + + err = sound_manager_acquire_focus(g_stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL); + pthread_mutex_unlock(&muStream); + + MSG_MGR_END(); + return err; +} + + +void MsgMgrStreamStop() +{ + MSG_MGR_BEGIN(); + pthread_mutex_lock(&muStream); + + if (g_stream_info != NULL) { + int err = sound_manager_release_focus(g_stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL); + if (err != SOUND_MANAGER_ERROR_NONE) + MSG_MGR_DEBUG("sound_manager_release_focus() Failed : %d", err); + + err = sound_manager_destroy_stream_information(g_stream_info); + if (err != SOUND_MANAGER_ERROR_NONE) + MSG_MGR_DEBUG("sound_manager_destroy_stream_information() Failed : %d", err); + + g_stream_info = NULL; + } + pthread_mutex_unlock(&muStream); + + MSG_MGR_END(); +} + + +void MsgMgrSoundPlayMelody(char *pMsgToneFilePath) +{ + int err = PLAYER_ERROR_NONE; + + if (!pMsgToneFilePath) { + MSG_MGR_DEBUG("Ringtone path is NULL"); + return; + } + + pthread_mutex_lock(&muMmPlay); + + if (g_stream_info == NULL) { + MSG_MGR_DEBUG("g_stream_info is NULL"); + pthread_mutex_unlock(&muMmPlay); + return; + } + + if (g_PlayerHandle) { + player_unset_error_cb(g_PlayerHandle); + player_unset_completed_cb(g_PlayerHandle); + player_unset_interrupted_cb(g_PlayerHandle); + player_unprepare(g_PlayerHandle); + player_destroy(g_PlayerHandle); + } + + err = player_create(&g_PlayerHandle); + + pthread_mutex_unlock(&muMmPlay); + + if (err != PLAYER_ERROR_NONE) { + MSG_MGR_DEBUG("creating the player handle failed"); + return; + } + + /* Setting the call back function msg_callback */ + player_set_error_cb(g_PlayerHandle, MsgMgrSoundPlayeErrorCallback, NULL); + player_set_completed_cb(g_PlayerHandle, MsgMgrSoundPlayeCompletedCallback, NULL); + player_set_interrupted_cb(g_PlayerHandle, MsgMgrSoundPlayeInterruptedCallback, NULL); + + player_set_audio_policy_info(g_PlayerHandle, g_stream_info); + + do { + err = player_set_uri(g_PlayerHandle, (const char *)pMsgToneFilePath); + if (err != PLAYER_ERROR_NONE) + MSG_MGR_DEBUG("player_set_uri() error : [%d]", err); + + err = player_prepare(g_PlayerHandle); + if (err != PLAYER_ERROR_NONE) { + MSG_MGR_DEBUG("player_prepare() error : [%d]", err); + if (pMsgToneFilePath != defaultRingtonePath) { + pMsgToneFilePath = defaultRingtonePath; + } else { + return; + } + } + } while (err != PLAYER_ERROR_NONE); + + + pthread_mutex_lock(&muMmPlay); + MSG_MGR_DEBUG("player_start with [%s]", pMsgToneFilePath); + err = player_start(g_PlayerHandle); + + if (err != PLAYER_ERROR_NONE) { + MSG_MGR_DEBUG("player_start, FAIL [%x]", err); + } else { + /* Add Timer to stop playing after 5 sec. */ + /* + int g_contact_timer = -1; + g_contact_timer = g_timeout_add(MSG_MGR_SOUND_TIMEOUT, (GSourceFunc)MsgSoundMelodyTimeout, NULL); + */ + + bPlaying = true; + } + pthread_mutex_unlock(&muMmPlay); +} + + +void MsgMgrSoundPlayVibration(char *vibrationPath) +{ + MSG_MGR_BEGIN(); + + int ret = 0; + + if (!bFeedbackInit) { + int ret = feedback_initialize(); + + if (ret != FEEDBACK_ERROR_NONE) { + MSG_MGR_DEBUG("Fail to feedback_initialize : [%d]", ret); + bFeedbackInit = false; + return; + } else { + MSG_MGR_DEBUG("Success to feedback_initialize."); + bFeedbackInit = true; + } + } + + if (vibrationPath && strlen(vibrationPath)) { + MSG_MGR_DEBUG("vibrationPath: [%s]", vibrationPath); + ret = feedback_set_resource_path(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE, vibrationPath); + if (ret != FEEDBACK_ERROR_NONE) + MSG_MGR_DEBUG("Fail to feedback_set_resource_path"); + ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE); + + if (ret != FEEDBACK_ERROR_NONE) + MSG_MGR_DEBUG("Fail to feedback_play_type"); + } else { + ret = feedback_set_resource_path(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE, NULL); + if (ret != FEEDBACK_ERROR_NONE) + MSG_MGR_DEBUG("Fail to feedback_set_resource_path"); + + ret = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_MESSAGE); + if (ret != FEEDBACK_ERROR_NONE) + MSG_MGR_DEBUG("Fail to feedback_play_type"); + } + + MSG_MGR_END(); +} + + diff --git a/manager/src/msg-manager.cpp b/manager/src/msg-manager.cpp index 17f896f..ad8aa81 100644 --- a/manager/src/msg-manager.cpp +++ b/manager/src/msg-manager.cpp @@ -1,8 +1,9 @@ +#include <stdio.h> #include <stdlib.h> #include <glib.h> -#include <msg.h> -#include <msg_storage.h> +extern "C" +{ #include <tizen.h> #include <service_app.h> #include <app_event.h> @@ -10,20 +11,50 @@ #include <notification_list.h> #include <notification_text_domain.h> #include <notification_internal.h> +#include <vconf.h> +#include <call-manager.h> +} + +#include "msg.h" +#include "msg_storage.h" -#include "msg-manager.h" #include "msg-manager-contact.h" #include "msg-manager-debug.h" +#include "msg-manager-notification.h" +#include "msg-manager-sound.h" /* below defines will be removed */ #define EVENT_KEY_OUT_MSG_TYPE "msg_type" #define EVENT_KEY_OUT_MSG_ID "msg_id" +msg_handle_t msg_handle = NULL; +cm_client_h cm_handle = NULL; bool service_app_create(void *data) { MSG_MGR_INFO("app_create"); + int msg_server_ready = 0; + for (int i = 0; i < 100; i++) { + vconf_get_bool(VCONFKEY_MSG_SERVER_READY, &msg_server_ready); + if (msg_server_ready == 1) { + int msg_err = msg_open_msg_handle(&msg_handle); + if (msg_err != MSG_SUCCESS) + MSG_MGR_DEBUG("msg_open_msg_handle() failed [%d]", msg_err); + else + MSG_MGR_DEBUG("msg_open_msg_handle() success"); + + break; + } else { + MSG_MGR_DEBUG("msg-server is not ready."); + sleep(1); + } + } + + MsgMgrInitNoti(); + initMsgMgrSoundPlayer(); + cm_init(&cm_handle); + return true; } @@ -31,7 +62,9 @@ void service_app_terminate(void *data) { MSG_MGR_INFO("app_terminate"); + cm_deinit(cm_handle); MsgMgrCloseContactSvc(); + msg_close_msg_handle(&msg_handle); return; } @@ -61,18 +94,11 @@ void _incoming_msg_func(app_control_h app_control) int msg_err = MSG_SUCCESS; msg_message_id_t msg_id = atoi(rcv_msg_id); - msg_handle_t msg_handle = NULL; msg_struct_t msg = NULL; msg_struct_t opt = NULL; contactInfo contact_info = {0,}; contact_info.msgId = msg_id; - msg_err = msg_open_msg_handle(&msg_handle); - if (msg_err != MSG_SUCCESS) { - MSG_MGR_ERR("msg_open_msg_handle() failed [%d]", msg_err); - return; - } - msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); opt = msg_create_struct(MSG_STRUCT_SENDOPT); msg_err = msg_get_message(msg_handle, msg_id, msg, opt); @@ -98,8 +124,6 @@ void _incoming_msg_func(app_control_h app_control) msg_release_struct(&msg); msg_release_struct(&opt); - msg_close_msg_handle(&msg_handle); - g_free(rcv_msg_id); g_free(rcv_msg_type); @@ -131,18 +155,11 @@ void _outgoing_msg_func(app_control_h app_control) int msg_err = MSG_SUCCESS; msg_message_id_t msg_id = atoi(sent_msg_id); - msg_handle_t msg_handle = NULL; msg_struct_t msg = NULL; msg_struct_t opt = NULL; contactInfo contact_info = {0,}; contact_info.msgId = msg_id; - msg_err = msg_open_msg_handle(&msg_handle); - if (msg_err != MSG_SUCCESS) { - MSG_MGR_ERR("msg_open_msg_handle() failed [%d]", msg_err); - return; - } - msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); opt = msg_create_struct(MSG_STRUCT_SENDOPT); msg_err = msg_get_message(msg_handle, msg_id, msg, opt); @@ -166,8 +183,6 @@ void _outgoing_msg_func(app_control_h app_control) msg_release_struct(&msg); msg_release_struct(&opt); - msg_close_msg_handle(&msg_handle); - g_free(sent_msg_id); g_free(sent_msg_type); @@ -176,7 +191,295 @@ void _outgoing_msg_func(app_control_h app_control) void _refresh_noti_func(app_control_h app_control) { + char *type = NULL; + char *feedback = NULL; + char *active_type = NULL; + msg_mgr_notification_type_t noti_type = MSG_MGR_NOTI_TYPE_NORMAL; + bool bFeedback = true; + msg_mgr_active_notification_type_t active_noti_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE; + + int ret = app_control_get_extra_data(app_control, "type", &type); + if (ret == APP_CONTROL_ERROR_NONE && type) { + MSG_MGR_DEBUG("type [%s]", type); + if (g_strcmp0(type, "normal") == 0) + noti_type = MSG_MGR_NOTI_TYPE_NORMAL; + + g_free(type); + } else { + MSG_MGR_ERR("app_control_get_extra_data failed"); + return; + } + + ret = app_control_get_extra_data(app_control, "feedback", &feedback); + if (ret == APP_CONTROL_ERROR_NONE && feedback) { + MSG_MGR_DEBUG("feedback [%s]", feedback); + if (g_strcmp0(feedback, "false") == 0) + bFeedback = false; + else if (g_strcmp0(feedback, "true") == 0) + bFeedback = true; + + g_free(feedback); + } + + ret = app_control_get_extra_data(app_control, "active_type", &active_type); + if (ret == APP_CONTROL_ERROR_NONE && active_type) { + MSG_MGR_DEBUG("active_type [%s]", active_type); + if (g_strcmp0(active_type, "none") == 0) + active_noti_type = MSG_MGR_ACTIVE_NOTI_TYPE_NONE; + else if (g_strcmp0(active_type, "active") == 0) + active_noti_type = MSG_MGR_ACTIVE_NOTI_TYPE_ACTIVE; + else if (g_strcmp0(active_type, "instant") == 0) + active_noti_type = MSG_MGR_ACTIVE_NOTI_TYPE_INSTANT; + + g_free(active_type); + } + MsgMgrRefreshNotification(noti_type, bFeedback, active_noti_type); +} + +void _add_noti_func(app_control_h app_control) +{ + char *type; + msg_mgr_notification_type_t noti_type = MSG_MGR_NOTI_TYPE_ALL; + + int ret = app_control_get_extra_data(app_control, "type", &type); + if (ret == APP_CONTROL_ERROR_NONE && type) { + if (g_strcmp0(type, "voice1") == 0) { + noti_type = MSG_MGR_NOTI_TYPE_VOICE_1; + } else if (g_strcmp0(type, "voice2") == 0) { + noti_type = MSG_MGR_NOTI_TYPE_VOICE_2; + } else if (g_strcmp0(type, "mwi") == 0) { + noti_type = MSG_MGR_NOTI_TYPE_MWI; + } else if (g_strcmp0(type, "class0") == 0) { + noti_type = MSG_MGR_NOTI_TYPE_CLASS0; + } + + g_free(type); + } else { + MSG_MGR_ERR("app_control_get_extra_data failed"); + return; + } + + char *msgId = NULL; + ret = app_control_get_extra_data(app_control, "msg_id", &msgId); + if (ret != APP_CONTROL_ERROR_NONE || msgId == NULL) { + MSG_MGR_ERR("app_control_get_extra_data failed"); + return; + } + + int msg_err = MSG_SUCCESS; + msg_message_id_t msg_id = atoi(msgId); + msg_struct_t msg = NULL; + msg_struct_t opt = NULL; + msg_list_handle_t addr_list = NULL; + MSG_MGR_MESSAGE_INFO_S msg_info = {0,}; + msg_info.msgId = msg_id; + + msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + opt = msg_create_struct(MSG_STRUCT_SENDOPT); + msg_err = msg_get_message(msg_handle, msg_id, msg, opt); + if (msg_err != MSG_SUCCESS) { + MSG_MGR_ERR("msg_get_message() failed [%d]", msg_err); + return; + } + + msg_get_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, &msg_info.sim_idx); + msg_get_int_value(msg, MSG_MESSAGE_DISPLAY_TIME_INT, (int *)&msg_info.displayTime); + msg_get_int_value(msg, MSG_MESSAGE_NETWORK_STATUS_INT, (int *)&msg_info.networkStatus); + msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addr_list); + + msg_struct_t addr_data = msg_list_nth_data(addr_list, 0); + msg_get_str_value(addr_data, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, msg_info.addressVal, MAX_ADDRESS_VAL_LEN); + msg_get_str_value(addr_data, MSG_ADDRESS_INFO_DISPLAYNAME_STR, msg_info.displayName, MAX_DISPLAY_NAME_LEN); + + if (noti_type == MSG_MGR_NOTI_TYPE_MWI || noti_type == MSG_MGR_NOTI_TYPE_CLASS0) { + int msg_size = 0; + msg_get_int_value(msg, MSG_MESSAGE_DATA_SIZE_INT, &msg_size); + if (msg_size > 0) + msg_get_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, msg_info.msgText, MAX_MSG_TEXT_LEN); + } + + msg_release_struct(&msg); + msg_release_struct(&opt); + + g_free(msgId); + + MsgMgrAddNotification(noti_type, &msg_info); +} + +void _add_report_noti_func(app_control_h app_control) +{ + char *type; + msg_mgr_notification_type_t noti_type = MSG_MGR_NOTI_TYPE_ALL; + + int ret = app_control_get_extra_data(app_control, "type", &type); + if (ret == APP_CONTROL_ERROR_NONE && type) { + if (g_strcmp0(type, "sms_delivery") == 0) { + noti_type = MSG_MGR_NOTI_TYPE_SMS_DELIVERY_REPORT; + } else if (g_strcmp0(type, "mms_delivery") == 0) { + noti_type = MSG_MGR_NOTI_TYPE_MMS_DELIVERY_REPORT; + } else if (g_strcmp0(type, "mms_read") == 0) { + noti_type = MSG_MGR_NOTI_TYPE_MMS_READ_REPORT; + } + + g_free(type); + } else { + MSG_MGR_ERR("app_control_get_extra_data failed"); + return; + } + + char *msgId = NULL; + ret = app_control_get_extra_data(app_control, "msg_id", &msgId); + if (ret != APP_CONTROL_ERROR_NONE || msgId == NULL) { + MSG_MGR_ERR("app_control_get_extra_data failed"); + return; + } + + int msg_err = MSG_SUCCESS; + msg_message_id_t msg_id = atoi(msgId); + msg_struct_t msg = NULL; + msg_struct_t opt = NULL; + msg_list_handle_t addr_list = NULL; + MSG_MGR_MESSAGE_INFO_S msg_info = {0,}; + msg_info.msgId = msg_id; + + msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + opt = msg_create_struct(MSG_STRUCT_SENDOPT); + msg_err = msg_get_message(msg_handle, msg_id, msg, opt); + if (msg_err != MSG_SUCCESS) { + MSG_MGR_ERR("msg_get_message() failed [%d]", msg_err); + return; + } + + msg_get_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, &msg_info.sim_idx); + msg_get_int_value(msg, MSG_MESSAGE_DISPLAY_TIME_INT, (int *)&msg_info.displayTime); + msg_get_int_value(msg, MSG_MESSAGE_NETWORK_STATUS_INT, (int *)&msg_info.networkStatus); + msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addr_list); + + msg_struct_t addr_data = msg_list_nth_data(addr_list, 0); + msg_get_str_value(addr_data, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, msg_info.addressVal, MAX_ADDRESS_VAL_LEN); + msg_get_str_value(addr_data, MSG_ADDRESS_INFO_DISPLAYNAME_STR, msg_info.displayName, MAX_DISPLAY_NAME_LEN); + + msg_release_struct(&msg); + msg_release_struct(&opt); + + g_free(msgId); + + MsgMgrAddReportNotification(noti_type, &msg_info); +} + +void _del_report_noti_func(app_control_h app_control) +{ + char *addr = NULL; + int ret = app_control_get_extra_data(app_control, "address", &addr); + if (ret != APP_CONTROL_ERROR_NONE || addr == NULL) { + MSG_MGR_ERR("app_control_get_extra_data failed"); + return; + } + + MsgMgrDeleteReportNotification(addr); + + g_free(addr); +} + +void _insert_only_active_noti_func(app_control_h app_control) +{ + char *type; + msg_mgr_notification_type_t noti_type = MSG_MGR_NOTI_TYPE_ALL; + + int ret = app_control_get_extra_data(app_control, "type", &type); + if (ret == APP_CONTROL_ERROR_NONE && type) { + if (g_strcmp0(type, "normal") == 0) { + noti_type = MSG_MGR_NOTI_TYPE_NORMAL; + } else if (g_strcmp0(type, "class0") == 0) { + noti_type = MSG_MGR_NOTI_TYPE_CLASS0; + } + + g_free(type); + } else { + MSG_MGR_ERR("app_control_get_extra_data failed"); + return; + } + + char *msgId = NULL; + ret = app_control_get_extra_data(app_control, "msg_id", &msgId); + if (ret != APP_CONTROL_ERROR_NONE || msgId == NULL) { + MSG_MGR_ERR("app_control_get_extra_data failed"); + return; + } + + int msg_err = MSG_SUCCESS; + msg_message_id_t msg_id = atoi(msgId); + msg_struct_t msg = NULL; + msg_struct_t opt = NULL; + msg_list_handle_t addr_list = NULL; + MSG_MGR_MESSAGE_INFO_S msg_info = {0,}; + msg_info.msgId = msg_id; + + msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + opt = msg_create_struct(MSG_STRUCT_SENDOPT); + msg_err = msg_get_message(msg_handle, msg_id, msg, opt); + if (msg_err != MSG_SUCCESS) { + MSG_MGR_ERR("msg_get_message() failed [%d]", msg_err); + return; + } + + msg_get_int_value(msg, MSG_MESSAGE_SIM_INDEX_INT, &msg_info.sim_idx); + + if (noti_type == MSG_MGR_NOTI_TYPE_CLASS0) { + msg_get_list_handle(msg, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addr_list); + + msg_struct_t addr_data = msg_list_nth_data(addr_list, 0); + msg_get_str_value(addr_data, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, msg_info.addressVal, MAX_ADDRESS_VAL_LEN); + msg_get_str_value(addr_data, MSG_ADDRESS_INFO_DISPLAYNAME_STR, msg_info.displayName, MAX_DISPLAY_NAME_LEN); + + int msg_size = 0; + msg_get_int_value(msg, MSG_MESSAGE_DATA_SIZE_INT, &msg_size); + if (msg_size > 0) + msg_get_str_value(msg, MSG_MESSAGE_SMS_DATA_STR, msg_info.msgText, MAX_MSG_TEXT_LEN); + } + + g_free(msgId); + + MsgMgrInsertOnlyActiveNotification(noti_type, &msg_info); +} + +void _sound_play_start_func(app_control_h app_control) +{ + char *type; + MSG_MGR_SOUND_TYPE_T sound_type = MSG_MGR_SOUND_PLAY_DEFAULT; + + int ret = app_control_get_extra_data(app_control, "type", &type); + if (ret == APP_CONTROL_ERROR_NONE && type) { + if (g_strcmp0(type, "default") == 0) { + sound_type = MSG_MGR_SOUND_PLAY_DEFAULT; + } else if (g_strcmp0(type, "user") == 0) { + sound_type = MSG_MGR_SOUND_PLAY_USER; + } else if (g_strcmp0(type, "emergency") == 0) { + sound_type = MSG_MGR_SOUND_PLAY_EMERGENCY; + } else if (g_strcmp0(type, "voicemail") == 0) { + sound_type = MSG_MGR_SOUND_PLAY_VOICEMAIL; + } + + g_free(type); + } else { + MSG_MGR_ERR("app_control_get_extra_data failed"); + return; + } + + char *addr = NULL; + ret = app_control_get_extra_data(app_control, "address", &addr); + + if (addr) { + MSG_MGR_ADDRESS_INFO_S addr_info = {0,}; + snprintf(addr_info.addressVal, MAX_ADDRESS_VAL_LEN, "%s", addr); + + MsgMgrSoundPlayStart(&addr_info, sound_type); + + g_free(addr); + } else { + MsgMgrSoundPlayStart(NULL, sound_type); + } } void service_app_control(app_control_h app_control, void *data) @@ -189,8 +492,6 @@ void service_app_control(app_control_h app_control, void *data) ret = app_control_get_operation(app_control, &operation); if (ret == APP_CONTROL_ERROR_NONE && operation) { - 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) { @@ -200,8 +501,18 @@ void service_app_control(app_control_h app_control, void *data) _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) { + } else if (g_strcmp0(cmd, "refresh_noti") == 0) { _refresh_noti_func(app_control); + } else if (g_strcmp0(cmd, "add_noti") == 0) { + _add_noti_func(app_control); + } else if (g_strcmp0(cmd, "add_report_noti") == 0) { + _add_report_noti_func(app_control); + } else if (g_strcmp0(cmd, "del_report_noti") == 0) { + _del_report_noti_func(app_control); + } else if (g_strcmp0(cmd, "insert_only_active_noti") == 0) { + _insert_only_active_noti_func(app_control); + } else if (g_strcmp0(cmd, "sound_play_start") == 0) { + _sound_play_start_func(app_control); } g_free(cmd); diff --git a/manager/tizen-manifest.xml b/manager/tizen-manifest.xml index 98a5607..2d1e37d 100644 --- a/manager/tizen-manifest.xml +++ b/manager/tizen-manifest.xml @@ -6,7 +6,13 @@ <icon>msg-manager.png</icon> </service-application> <privileges> + <privilege>http://tizen.org/privilege/alarm.set</privilege> <privilege>http://tizen.org/privilege/message.read</privilege> + <privilege>http://tizen.org/privilege/callhistory.read</privilege> <privilege>http://tizen.org/privilege/callhistory.write</privilege> + <privilege>http://tizen.org/privilege/notification</privilege> + <privilege>http://tizen.org/privilege/haptic</privilege> + <privilege>http://tizen.org/privilege/mediastorage</privilege> + <privilege>http://tizen.org/privilege/externalstorage</privilege> </privileges> </manifest> diff --git a/packaging/msg-service.spec b/packaging/msg-service.spec index e7ef5c1..ad2e69b 100755 --- a/packaging/msg-service.spec +++ b/packaging/msg-service.spec @@ -24,6 +24,7 @@ BuildRequires: pkgconfig(appcore-agent) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(badge) BuildRequires: pkgconfig(bundle) +BuildRequires: pkgconfig(callmgr_client) BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: pkgconfig(capi-appfw-package-manager) BuildRequires: pkgconfig(capi-content-media-content) @@ -59,6 +60,7 @@ BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(libwbxml2) BuildRequires: pkgconfig(motion) BuildRequires: pkgconfig(notification) +BuildRequires: pkgconfig(phonenumber-utils) BuildRequires: pkgconfig(security-server) BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(storage) diff --git a/plugin/sms_cdma_plugin/CMakeLists.txt b/plugin/sms_cdma_plugin/CMakeLists.txt index 2c63f6a..9c7e444 100755 --- a/plugin/sms_cdma_plugin/CMakeLists.txt +++ b/plugin/sms_cdma_plugin/CMakeLists.txt @@ -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 bundle eventsystem aul) +pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0 bundle eventsystem) FOREACH(flag ${sms_plugin_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp b/plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp index 257da87..2320e11 100755 --- a/plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp +++ b/plugin/sms_cdma_plugin/SmsCdmaPluginEventHandler.cpp @@ -19,7 +19,6 @@ #include <errno.h> #include <time.h> -#include <aul.h> #include <bundle.h> #include <eventsystem.h> @@ -475,10 +474,7 @@ void SmsPluginEventHandler::handleSentStatus(msg_network_status_t NetStatus) 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); - } + msg_launch_app(MSG_MGR_APP_ID, b); bundle_free(b); } } else { diff --git a/plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp b/plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp index dbb529f..036c0dd 100755 --- a/plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp +++ b/plugin/sms_cdma_plugin/SmsCdmaPluginSetting.cpp @@ -23,7 +23,6 @@ #include "MsgGconfWrapper.h" #include "MsgNotificationWrapper.h" -#include "MsgSoundPlayer.h" #include "MsgContact.h" #include "MsgUtilStorage.h" #include "MsgTextConvert.h" diff --git a/plugin/sms_plugin/CMakeLists.txt b/plugin/sms_plugin/CMakeLists.txt index d5e1a0d..1e317ce 100755 --- a/plugin/sms_plugin/CMakeLists.txt +++ b/plugin/sms_plugin/CMakeLists.txt @@ -34,7 +34,7 @@ SET(SMS-PLUGIN-SRCS ) INCLUDE_DIRECTORIES( - ${CMAKE_SOURCE_DIR}/include/mapi + ${CMAKE_SOURCE_DIR}/include/mapi ${CMAKE_SOURCE_DIR}/include/common ${CMAKE_SOURCE_DIR}/include/utils ${CMAKE_SOURCE_DIR}/include/externals @@ -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 bundle eventsystem aul) +pkg_check_modules(sms_plugin_pkgs REQUIRED glib-2.0 tapi libxml-2.0 libwbxml2 dlog vconf gio-2.0 capi-telephony bundle eventsystem) FOREACH(flag ${sms_plugin_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/plugin/sms_plugin/SmsPluginEventHandler.cpp b/plugin/sms_plugin/SmsPluginEventHandler.cpp index 91337fe..616d1b9 100755 --- a/plugin/sms_plugin/SmsPluginEventHandler.cpp +++ b/plugin/sms_plugin/SmsPluginEventHandler.cpp @@ -19,7 +19,6 @@ #include <stdlib.h> #include <errno.h> -#include <aul.h> #include <bundle.h> #include <eventsystem.h> @@ -113,10 +112,7 @@ void SmsPluginEventHandler::handleSentStatus(msg_network_status_t NetStatus) 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); - } + msg_launch_app(MSG_MGR_APP_ID, b); bundle_free(b); } } else { diff --git a/plugin/sms_plugin/SmsPluginSetting.cpp b/plugin/sms_plugin/SmsPluginSetting.cpp index a5261e9..4a6da6a 100755 --- a/plugin/sms_plugin/SmsPluginSetting.cpp +++ b/plugin/sms_plugin/SmsPluginSetting.cpp @@ -22,7 +22,6 @@ #include "MsgException.h" #include "MsgGconfWrapper.h" #include "MsgNotificationWrapper.h" -#include "MsgSoundPlayer.h" #include "MsgContact.h" #include "MsgUtilStorage.h" #include "MsgTextConvert.h" @@ -288,7 +287,7 @@ void SmsPluginSetting::initConfigData(TapiHandle *handle) memset(keyName, 0x00, sizeof(keyName)); snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_NUMBER, sim_idx); if (MsgSettingSetString(keyName, "") != MSG_SUCCESS) - MSG_DEBUG("MsgSettingSetInt is failed!!"); + MSG_DEBUG("MsgSettingSetString is failed!!"); memset(keyName, 0x00, sizeof(keyName)); snprintf(keyName, sizeof(keyName), "%s/%d", VOICEMAIL_COUNT, sim_idx); diff --git a/utils/MsgContact.cpp b/utils/MsgContact.cpp index 9e6a197..3548641 100755 --- a/utils/MsgContact.cpp +++ b/utils/MsgContact.cpp @@ -29,13 +29,6 @@ #if 0 __thread bool isContactSvcConnected = false; #endif -/* phonenumber minimum match digit. */ -#define PHONENUMBER_MIN_MATCH_DIGIT VCONFKEY_CONTACTS_SVC_PHONENUMBER_MIN_MATCH_DIGIT -#define DEFAULT_MIN_MATCH_DIGIT 8 - -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED -static int phonenumberMinMatchDigit = -1; -#endif /*================================================================================================== INTERNAL FUNCTION IMPLEMENTATION @@ -204,22 +197,6 @@ void normalizeNumber(const char *orig, char* dest, unsigned int destSize) /*================================================================================================== FUNCTION IMPLEMENTATION ==================================================================================================*/ -msg_error_t MsgInitContactSvc() -{ -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - if (MsgSettingGetInt(PHONENUMBER_MIN_MATCH_DIGIT, &phonenumberMinMatchDigit) != MSG_SUCCESS) { - MSG_INFO("MsgSettingGetInt() is failed"); - } - MSG_DEBUG("phonenumberMinMatchDigit [%d]", phonenumberMinMatchDigit); - - if (phonenumberMinMatchDigit < 1) { - phonenumberMinMatchDigit = DEFAULT_MIN_MATCH_DIGIT; - } -#endif /* MSG_CONTACTS_SERVICE_NOT_SUPPORTED */ - return MSG_SUCCESS; -} - - msg_error_t MsgGetContactInfo(const MSG_ADDRESS_INFO_S *pAddrInfo, MSG_CONTACT_INFO_S *pContactInfo) { MSG_BEGIN(); @@ -832,15 +809,6 @@ bool checkBlockingMode(char *address, bool *pisFavorites) #endif } -int MsgContactGetMinMatchDigit() -{ -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - return phonenumberMinMatchDigit; -#else - return DEFAULT_MIN_MATCH_DIGIT; -#endif -} - void MsgConvertNumber(const char* pSrcNum, char* pDestNum, int destSize) { diff --git a/utils/MsgUtilFunction.cpp b/utils/MsgUtilFunction.cpp index 056efa7..050c4a2 100755 --- a/utils/MsgUtilFunction.cpp +++ b/utils/MsgUtilFunction.cpp @@ -19,6 +19,7 @@ #include "MsgDebug.h" #include "MsgContact.h" +#include "MsgGconfWrapper.h" #include "MsgUtilFile.h" #include "MsgUtilFunction.h" @@ -27,8 +28,11 @@ #include <locale.h> #include <vconf.h> #include <ctype.h> +#include <aul.h> +#define DEFAULT_MIN_MATCH_DIGIT 8 + enum _FEATURE_INDEX_E { FEATURE_INDEX_SMS = 0, FEATURE_INDEX_MMS = 1, @@ -41,6 +45,9 @@ static bool b_feature_support[] = { }; int _dbus_owner_id = 0; +#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED +static int phonenumberMinMatchDigit = -1; +#endif /*================================================================================================== FUNCTION IMPLEMENTATION @@ -72,6 +79,27 @@ bool MsgCheckFeatureSupport(const char *feature_name) return result; } + +int MsgContactGetMinMatchDigit() +{ +#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED + if (phonenumberMinMatchDigit <= 0) { + if (MsgSettingGetInt(VCONFKEY_CONTACTS_SVC_PHONENUMBER_MIN_MATCH_DIGIT, &phonenumberMinMatchDigit) != MSG_SUCCESS) { + MSG_INFO("MsgSettingGetInt() is failed"); + } + MSG_DEBUG("phonenumberMinMatchDigit [%d]", phonenumberMinMatchDigit); + + if (phonenumberMinMatchDigit < 1) { + phonenumberMinMatchDigit = DEFAULT_MIN_MATCH_DIGIT; + } + } + + return phonenumberMinMatchDigit; +#else + return DEFAULT_MIN_MATCH_DIGIT; +#endif +} + /* Encoders */ int MsgEncodeCountInfo(MSG_COUNT_INFO_S *pCountInfo, char **ppDest) { @@ -1210,6 +1238,18 @@ uid_t msg_get_login_user() } +msg_error_t msg_launch_app(const char *app_id, bundle *bundle_data) +{ + int ret = aul_launch_app_for_uid(app_id, bundle_data, msg_get_login_user()); + if (ret <= 0) { + MSG_DEBUG("aul_launch_app_for_uid() is failed : %d", ret); + return MSG_ERR_UNKNOWN; + } + + return MSG_SUCCESS; +} + + void MsgDbusInit() { MSG_DEBUG(); diff --git a/utils/MsgUtilStorage.cpp b/utils/MsgUtilStorage.cpp index 4bdc18e..a7c7933 100755 --- a/utils/MsgUtilStorage.cpp +++ b/utils/MsgUtilStorage.cpp @@ -2891,9 +2891,11 @@ msg_error_t MsgStoDbSelectWithQuery(const char *szQuery, char ***db_res, int *ro if (err == MSG_ERR_DB_NORECORD) { dbHandle->freeTable(*db_res); err = MSG_SUCCESS; + *db_res = NULL; } else if (err != MSG_SUCCESS) { MSG_DEBUG("Fail to getTable()."); dbHandle->freeTable(*db_res); + *db_res = NULL; } return err; |