diff options
author | seunggi.hong <seunggi.hong@samsung.com> | 2015-04-06 14:44:23 +0900 |
---|---|---|
committer | seunggi.hong <seunggi.hong@samsung.com> | 2015-04-06 14:57:47 +0900 |
commit | cba29738bb6131fd42b22affb9d7e8cd41e3a914 (patch) | |
tree | 50a713b99701055542ee38bf93aa702159c74146 /src | |
parent | b6b53777347f754138642a64722ad239e3e2232a (diff) | |
download | messages-cba29738bb6131fd42b22affb9d7e8cd41e3a914.tar.gz messages-cba29738bb6131fd42b22affb9d7e8cd41e3a914.tar.bz2 messages-cba29738bb6131fd42b22affb9d7e8cd41e3a914.zip |
Sync with tizen 2.4submit/tizen_mobile/20150406.145510submit/tizen_mobile/20150406.143654submit/tizen_mobile/20150406.142950submit/tizen_mobile/20150406.141433submit/tizen_mobile/20150406.133152submit/tizen_mobile/20150406.102346submit/tizen/20150406.084653submit/tizen/20150406.061942
Change-Id: I824fb867536fdbc4bee0e529cd631df0374f8e2e
Signed-off-by: seunggi.hong <seunggi.hong@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/messages.c | 289 | ||||
-rw-r--r-- | src/messages_cb.c | 711 | ||||
-rw-r--r-- | src/messages_push.c | 22 |
3 files changed, 236 insertions, 786 deletions
diff --git a/src/messages.c b/src/messages.c index 061f528..7e392d2 100644 --- a/src/messages.c +++ b/src/messages.c @@ -23,7 +23,8 @@ #include <glib.h> -#include <dlog.h> +#include <privacy_checker_client.h> + #include <msg.h> #include <msg_transport.h> #include <msg_storage.h> @@ -32,13 +33,6 @@ #include <messages_types.h> #include <messages_private.h> -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "CAPI_MESSAGING" -#define DBG_MODE (1) - -#define MAX_MESSAGES_TEXT_LEN 1530 /* Private Utility Functions */ int _messages_get_media_type_from_filepath(const char *filepath); @@ -47,11 +41,12 @@ int _messages_load_mms_data(messages_message_s *msg, msg_handle_t handle); int _messages_save_textfile(const char *text, char **filepath); int _messages_load_textfile(const char *filepath, char **text); void _messages_sent_mediator_cb(msg_handle_t handle, msg_struct_t pStatus, void *user_param); - - +int _messages_check_feature(char *feature_name); int messages_open_service(messages_service_h *svc) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; messages_service_s *_svc; @@ -69,11 +64,6 @@ int messages_open_service(messages_service_h *svc) _svc->incoming_cb = NULL; _svc->incoming_cb_enabled = false; _svc->push_incoming_cb_list = NULL; - _svc->cbs_enabled_cb = false; - _svc->cbs_incoming_cb = NULL; - _svc->cbs_incoming_cb_save = false; - _svc->etws_incoming_cb = NULL; - _svc->cbs_settings_h = NULL; ret = msg_open_msg_handle(&_svc->service_h); if (MSG_SUCCESS != ret) { @@ -104,10 +94,11 @@ void _free_push_incoming_cb(messages_push_incoming_callback_s *cb) int messages_close_service(messages_service_h svc) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; messages_service_s *_svc = (messages_service_s *)svc; - messages_cb_settings_s *_settings; CHECK_NULL(_svc); ret = msg_close_msg_handle(&_svc->service_h); @@ -124,13 +115,6 @@ int messages_close_service(messages_service_h svc) _svc->push_incoming_cb_list = NULL; } - if (_svc->cbs_settings_h) { - _settings = (messages_cb_settings_s *)_svc->cbs_settings_h; - _messages_cb_clear_settings(_settings); - free(_settings); - _svc->cbs_settings_h = NULL; - } - free(svc); return ERROR_CONVERT(ret); @@ -138,6 +122,8 @@ int messages_close_service(messages_service_h svc) int messages_create_message(messages_message_type_e type, messages_message_h *msg) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; messages_message_s *_msg = NULL; @@ -175,6 +161,13 @@ int messages_create_message(messages_message_type_e type, messages_message_h *ms } else if (MESSAGES_TYPE_MMS == type) { + ret = _messages_check_feature(MESSAGES_TELEPHONY_MMS_FEATURE); + if (MESSAGES_ERROR_NONE != ret) { + msg_release_struct(&_msg->msg_h); + free(_msg); + return ret; + } + ret = ERROR_CONVERT(msg_set_int_value(_msg->msg_h, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS)); if (MESSAGES_ERROR_NONE != ret) { @@ -199,6 +192,8 @@ int messages_create_message(messages_message_type_e type, messages_message_h *ms int messages_destroy_message(messages_message_h msg) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; messages_message_s *_msg = (messages_message_s*)msg; @@ -221,6 +216,8 @@ int messages_destroy_message(messages_message_h msg) int messages_get_message_type(messages_message_h msg, messages_message_type_e *type) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int msgType; int ret; @@ -268,10 +265,11 @@ int messages_get_message_type(messages_message_h msg, messages_message_type_e *t int messages_add_address(messages_message_h msg, const char *address, messages_recipient_type_e type) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; messages_message_type_e msgType; - msg_struct_list_s *addr_list = NULL; msg_struct_t addr_info; messages_message_s *_msg = (messages_message_s*)msg; @@ -282,13 +280,11 @@ int messages_add_address(messages_message_h msg, const char *address, messages_r messages_get_message_type(msg, &msgType); - ret = msg_get_list_handle(_msg->msg_h, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addr_list); + ret = msg_list_add_item(_msg->msg_h, MSG_MESSAGE_ADDR_LIST_HND, &addr_info); if (MSG_SUCCESS != ret) { return ERROR_CONVERT(ret); } - addr_info = addr_list->msg_struct_info[addr_list->nCount]; - if (IS_SMS(msgType)) { msg_set_int_value(addr_info, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MSG_RECIPIENTS_TYPE_TO); @@ -317,15 +313,15 @@ int messages_add_address(messages_message_h msg, const char *address, messages_r return ERROR_CONVERT(ret); } - addr_list->nCount++; - return MESSAGES_ERROR_NONE; } int messages_get_address_count(messages_message_h msg, int *count) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; - msg_struct_list_s *addr_list = NULL; + msg_list_handle_t addr_list = NULL; messages_message_s *_msg = (messages_message_s*)msg; @@ -333,23 +329,26 @@ int messages_get_address_count(messages_message_h msg, int *count) CHECK_NULL(_msg->msg_h); CHECK_NULL(count); - ret = msg_get_list_handle(_msg->msg_h, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addr_list); + ret = msg_get_list_handle(_msg->msg_h, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addr_list); if (MSG_SUCCESS != ret) { return ERROR_CONVERT(ret); } - *count = addr_list->nCount; + *count = msg_list_length(addr_list); return MESSAGES_ERROR_NONE; } int messages_get_address(messages_message_h msg, int index, char **address, messages_recipient_type_e *type) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; char _address[MAX_ADDRESS_VAL_LEN] = {0, }; int _type; + int count; - msg_struct_list_s *addr_list = NULL; + msg_list_handle_t addr_list = NULL; msg_struct_t addr_info; messages_message_s *_msg = (messages_message_s*)msg; @@ -358,19 +357,20 @@ int messages_get_address(messages_message_h msg, int index, char **address, mess CHECK_NULL(_msg->msg_h); CHECK_NULL(address); - ret = msg_get_list_handle(_msg->msg_h, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addr_list); + ret = msg_get_list_handle(_msg->msg_h, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addr_list); if (MSG_SUCCESS != ret) { return ERROR_CONVERT(ret); } - if (index > addr_list->nCount) + count = msg_list_length(addr_list); + if (index > count) { LOGE("[%s] INVALID_PARAMETER(0x%08x) : index(%d) > addr_list->nCount(%d) " - , __FUNCTION__, MESSAGES_ERROR_INVALID_PARAMETER, index, addr_list->nCount); + , __FUNCTION__, MESSAGES_ERROR_INVALID_PARAMETER, index, count); return MESSAGES_ERROR_INVALID_PARAMETER; } - addr_info = addr_list->msg_struct_info[index]; + addr_info = (msg_struct_t)msg_list_nth_data(addr_list, index); ret = msg_get_str_value(addr_info, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, _address, MAX_ADDRESS_VAL_LEN); if (MSG_SUCCESS != ret) @@ -419,19 +419,15 @@ int messages_get_address(messages_message_h msg, int index, char **address, mess int messages_remove_all_addresses(messages_message_h msg) { - int ret; - msg_struct_list_s *addr_list = NULL; + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; messages_message_s *_msg = (messages_message_s*)msg; CHECK_NULL(_msg); CHECK_NULL(_msg->msg_h); - ret = msg_get_list_handle(_msg->msg_h, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addr_list); - if (MSG_SUCCESS == ret) - { - addr_list->nCount = 0; - } + ret = msg_list_clear(_msg->msg_h, MSG_MESSAGE_ADDR_LIST_HND); return ERROR_CONVERT(ret); } @@ -444,6 +440,14 @@ void _dump_message(messages_message_h msg) int messages_send_message(messages_service_h svc, messages_message_h msg, bool save_to_sentbox, messages_sent_cb callback, void *user_data) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + + /* Privacy check */ + int privacy_ret = privacy_checker_check_by_privilege(MESSAGES_PRIVILEGE_WRITE); + if (privacy_ret == PRIV_MGR_ERROR_USER_NOT_CONSENTED) { + return MESSAGES_ERROR_PERMISSION_DENIED; + } + int ret; int reqId; msg_struct_t req; @@ -481,6 +485,12 @@ int messages_send_message(messages_service_h svc, messages_message_h msg, bool s } else if (IS_MMS(msgType)) { + ret = _messages_check_feature(MESSAGES_TELEPHONY_MMS_FEATURE); + if (MESSAGES_ERROR_NONE != ret) { + msg_release_struct(&sendOpt); + return ret; + } + ret = _messages_save_mms_data(_msg); if (MESSAGES_ERROR_NONE == ret) { @@ -508,9 +518,9 @@ int messages_send_message(messages_service_h svc, messages_message_h msg, bool s else { LOGE("[%s] INVALID_PARAMETER(0x%08x) : Invalid Message Type.", - __FUNCTION__, TIZEN_ERROR_INVALID_PARAMETER); + __FUNCTION__, MESSAGES_ERROR_INVALID_PARAMETER); msg_release_struct(&sendOpt); - return TIZEN_ERROR_INVALID_PARAMETER; + return MESSAGES_ERROR_INVALID_PARAMETER; } msg_release_struct(&sendOpt); @@ -534,6 +544,8 @@ int messages_get_message_count(messages_service_h service, messages_message_box_e mbox, messages_message_type_e type, int *count) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; msg_folder_id_t folderId; msg_struct_t countInfo = NULL; @@ -604,11 +616,13 @@ int messages_search_message(messages_service_h service, int offset, int limit, messages_message_h **message_array, int *length, int *total) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int i; int ret; msg_struct_list_s msg_list; - msg_struct_t searchCon; + msg_struct_t listCond; messages_message_type_e _msgType; messages_service_s *_svc = (messages_service_s*)service; @@ -620,26 +634,31 @@ int messages_search_message(messages_service_h service, CHECK_NULL(message_array); // Set Condition - searchCon = msg_create_struct(MSG_STRUCT_SEARCH_CONDITION); - msg_set_int_value(searchCon, MSG_SEARCH_CONDITION_FOLDERID_INT, _messages_convert_mbox_to_fw(mbox)); - msg_set_int_value(searchCon, MSG_SEARCH_CONDITION_MSGTYPE_INT, _messages_convert_msgtype_to_fw(type)); + listCond = msg_create_struct(MSG_STRUCT_MSG_LIST_CONDITION); + + msg_set_int_value(listCond, MSG_LIST_CONDITION_FOLDER_ID_INT, _messages_convert_mbox_to_fw(mbox)); + msg_set_int_value(listCond, MSG_LIST_CONDITION_MSGTYPE_INT, _messages_convert_msgtype_to_fw(type)); + if (NULL != keyword) { - msg_set_str_value(searchCon, MSG_SEARCH_CONDITION_SEARCH_VALUE_STR, strdup(keyword), strlen(keyword)); + msg_set_str_value(listCond, MSG_LIST_CONDITION_TEXT_VALUE_STR, strdup(keyword), strlen(keyword)); } if (NULL != address) { - msg_set_str_value(searchCon, MSG_SEARCH_CONDITION_ADDRESS_VALUE_STR, strdup(address), strlen(address)); + msg_set_str_value(listCond, MSG_LIST_CONDITION_ADDRESS_VALUE_STR, strdup(address), strlen(address)); } // Search - ret = msg_search_message(_svc->service_h, searchCon, offset, limit, &msg_list); + msg_set_bool_value(listCond, MSG_LIST_CONDITION_AND_OPERATER_BOOL, true); + msg_set_int_value(listCond, MSG_LIST_CONDITION_OFFSET_INT, offset); + msg_set_int_value(listCond, MSG_LIST_CONDITION_LIMIT_INT, limit); + ret = msg_get_message_list2(_svc->service_h, listCond, &msg_list); if (MSG_SUCCESS != ret) { - msg_release_struct(&searchCon); + msg_release_struct(&listCond); return ERROR_CONVERT(ret); } - msg_release_struct(&searchCon); + msg_release_struct(&listCond); // Result _array = (messages_message_h*)calloc(msg_list.nCount + 1, sizeof(messages_message_h)); @@ -696,6 +715,8 @@ int messages_search_message(messages_service_h service, int messages_free_message_array(messages_message_h *message_array) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; int i=0; @@ -726,6 +747,14 @@ int messages_foreach_message(messages_service_h svc, int offset, int limit, messages_search_cb callback, void *user_data) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + + /* Privacy check */ + int privacy_ret = privacy_checker_check_by_privilege(MESSAGES_PRIVILEGE_READ); + if (privacy_ret == PRIV_MGR_ERROR_USER_NOT_CONSENTED) { + return MESSAGES_ERROR_PERMISSION_DENIED; + } + int i; int ret; bool ret_cb; @@ -819,17 +848,25 @@ void _messages_incoming_mediator_cb(msg_handle_t handle, msg_struct_t msg, void if (IS_MMS(msgType)) { + if (MESSAGES_ERROR_NONE != _messages_check_feature(MESSAGES_TELEPHONY_MMS_FEATURE)) { + free(_msg); + return; + } + _messages_load_mms_data(_msg, handle); } ((messages_incoming_cb)_svc->incoming_cb)((messages_message_h)_msg, _svc->incoming_cb_user_data); + messages_mms_remove_all_attachments((messages_message_h)_msg); free(_msg); } } int messages_set_message_incoming_cb(messages_service_h svc, messages_incoming_cb callback, void *user_data) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; messages_service_s *_svc = (messages_service_s*)svc; @@ -865,6 +902,8 @@ int messages_set_message_incoming_cb(messages_service_h svc, messages_incoming_c int messages_add_sms_listening_port(messages_service_h service, int port) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; messages_service_s *_svc = (messages_service_s*)service; CHECK_NULL(_svc); @@ -888,17 +927,23 @@ int messages_add_sms_listening_port(messages_service_h service, int port) int messages_unset_message_incoming_cb(messages_service_h svc) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + messages_service_s *_svc = (messages_service_s*)svc; CHECK_NULL(_svc); _svc->incoming_cb_enabled = false; + _svc->incoming_cb = NULL; + _svc->incoming_cb_user_data = NULL; return MESSAGES_ERROR_NONE; } int messages_get_message_port(messages_message_h msg, int *port) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; int _port; @@ -920,6 +965,8 @@ int messages_get_message_port(messages_message_h msg, int *port) int messages_set_text(messages_message_h msg, const char *text) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; int len; messages_message_type_e type; @@ -937,7 +984,7 @@ int messages_set_text(messages_message_h msg, const char *text) if (IS_SMS(type)) { len = strlen(text); - if (len > MAX_MESSAGES_TEXT_LEN) + if (len > MAX_MSG_TEXT_LEN) { LOGE("[%s] INVALID_PARAMETER(0x%08x) : the length of body exceeded the max, 1530 ." , __FUNCTION__, MESSAGES_ERROR_INVALID_PARAMETER); @@ -947,6 +994,8 @@ int messages_set_text(messages_message_h msg, const char *text) } else if (IS_MMS(type)) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_MMS_FEATURE); + if (NULL != _msg->text) { free(_msg->text); @@ -974,6 +1023,8 @@ int messages_set_text(messages_message_h msg, const char *text) int messages_get_text(messages_message_h msg, char **text) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; char _text[MAX_MSG_TEXT_LEN]; messages_message_type_e type; @@ -1037,6 +1088,8 @@ int messages_get_text(messages_message_h msg, char **text) int messages_get_time(messages_message_h msg, time_t *time) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; int _time; @@ -1058,6 +1111,8 @@ int messages_get_time(messages_message_h msg, time_t *time) int messages_get_message_id(messages_message_h msg, int *msg_id) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; int _id; @@ -1077,8 +1132,55 @@ int messages_get_message_id(messages_message_h msg, int *msg_id) return MESSAGES_ERROR_NONE; } + +int messages_set_sim_id(messages_message_h msg, int sim_id) +{ + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + + int ret; + + messages_message_s *_msg = (messages_message_s*)msg; + CHECK_NULL(_msg); + CHECK_NULL(_msg->msg_h); + + ret = msg_set_int_value(_msg->msg_h, MSG_MESSAGE_SIM_INDEX_INT, sim_id); + if (MSG_SUCCESS != ret) + { + return ERROR_CONVERT(ret); + } + + return MESSAGES_ERROR_NONE; +} + + +int messages_get_sim_id(messages_message_h msg, int *sim_id) +{ + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + + int ret; + int _id; + + messages_message_s *_msg = (messages_message_s*)msg; + CHECK_NULL(_msg); + CHECK_NULL(_msg->msg_h); + CHECK_NULL(sim_id); + + ret = msg_get_int_value(_msg->msg_h, MSG_MESSAGE_SIM_INDEX_INT, &_id); + if (MSG_SUCCESS != ret) + { + return ERROR_CONVERT(ret); + } + + *sim_id = _id; + + return MESSAGES_ERROR_NONE; +} + + int messages_search_message_by_id(messages_service_h service, int msg_id, messages_message_h *msg) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; msg_struct_t new_msg_h; messages_message_type_e _msgType; @@ -1119,6 +1221,13 @@ int messages_search_message_by_id(messages_service_h service, int msg_id, messag messages_get_message_type((messages_message_h)_msg, &_msgType); if (IS_MMS(_msgType)) { + ret = _messages_check_feature(MESSAGES_TELEPHONY_MMS_FEATURE); + if (MESSAGES_ERROR_NONE != ret) { + free(_msg); + msg_release_struct(&new_msg_h); + return ret; + } + ret = _messages_load_mms_data(_msg, _svc->service_h); if (MESSAGES_ERROR_NONE != ret) { free(_msg); @@ -1134,6 +1243,8 @@ int messages_search_message_by_id(messages_service_h service, int msg_id, messag int messages_get_mbox_type(messages_message_h msg, messages_message_box_e *mbox) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + int ret; int folder_id; @@ -1174,6 +1285,8 @@ int messages_get_mbox_type(messages_message_h msg, messages_message_box_e *mbox) int messages_mms_set_subject(messages_message_h msg, const char *subject) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_MMS_FEATURE); + int ret; messages_message_type_e type; @@ -1201,6 +1314,8 @@ int messages_mms_set_subject(messages_message_h msg, const char *subject) int messages_mms_get_subject(messages_message_h msg, char **subject) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_MMS_FEATURE); + int ret; char _subject[MAX_SUBJECT_LEN]; messages_message_type_e type; @@ -1244,10 +1359,13 @@ int messages_mms_get_subject(messages_message_h msg, char **subject) int messages_mms_add_attachment(messages_message_h msg, messages_media_type_e type, const char *path) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_MMS_FEATURE); + messages_message_type_e msg_type; messages_message_s *_msg = (messages_message_s*)msg; messages_attachment_s *attach; + int input_file_name_length; CHECK_NULL(_msg); CHECK_NULL(_msg->msg_h); @@ -1262,6 +1380,15 @@ int messages_mms_add_attachment(messages_message_h msg, messages_media_type_e ty return MESSAGES_ERROR_INVALID_PARAMETER; } + //CID 350148: Putting a check so that input buffer does not exceed max_size which will cause seg fault. + //CID 358513: Also putting this check before calloc of var attach to prevent memory leak in case of error. + input_file_name_length = strlen(path); + if(input_file_name_length > MSG_FILEPATH_LEN_MAX) { + LOGE("[%s] INVALID_PARAMETER(0x%08x) : maximum length of file_name_path can be %d" + , __FUNCTION__, MESSAGES_ERROR_INVALID_PARAMETER, MSG_FILEPATH_LEN_MAX); + return MESSAGES_ERROR_INVALID_PARAMETER; + } + // New Attach attach = (messages_attachment_s *)calloc(1, sizeof(messages_attachment_s)); if (NULL == attach) @@ -1272,7 +1399,8 @@ int messages_mms_add_attachment(messages_message_h msg, messages_media_type_e ty } attach->media_type = type; - strncpy(attach->filepath, path, strlen(path)); + + strncpy(attach->filepath, path, input_file_name_length); // Append _msg->attachment_list = g_slist_append(_msg->attachment_list, attach); @@ -1282,6 +1410,8 @@ int messages_mms_add_attachment(messages_message_h msg, messages_media_type_e ty int messages_mms_get_attachment_count(messages_message_h msg, int *count) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_MMS_FEATURE); + messages_message_type_e type; messages_message_s *_msg = (messages_message_s*)msg; @@ -1307,6 +1437,8 @@ int messages_mms_get_attachment_count(messages_message_h msg, int *count) int messages_mms_get_attachment(messages_message_h msg, int index, messages_media_type_e *type, char **path) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_MMS_FEATURE); + messages_attachment_s *_attach; messages_message_type_e msg_type; @@ -1348,6 +1480,8 @@ int messages_mms_get_attachment(messages_message_h msg, int index, messages_medi int messages_mms_remove_all_attachments(messages_message_h msg) { + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_MMS_FEATURE); + messages_message_s *_msg = (messages_message_s*)msg; CHECK_NULL(_msg); @@ -1363,6 +1497,7 @@ int messages_mms_remove_all_attachments(messages_message_h msg) return MESSAGES_ERROR_NONE; } + int _messages_save_mms_data(messages_message_s *msg) { int i; @@ -1430,7 +1565,7 @@ int _messages_save_mms_data(messages_message_s *msg) if (NULL == image) { - msg_mms_add_item(mms_data, MSG_STRUCT_MMS_REGION, ®ion); + msg_list_add_item(mms_data, MSG_STRUCT_MMS_REGION, ®ion); msg_set_str_value(region, MSG_MMS_REGION_ID_STR, (char *)"Text", 4); msg_set_int_value(region, MSG_MMS_REGION_LENGTH_LEFT_INT, 0); msg_set_int_value(region, MSG_MMS_REGION_LENGTH_TOP_INT, 0); @@ -1440,7 +1575,7 @@ int _messages_save_mms_data(messages_message_s *msg) } else if (NULL == msg->text) { - msg_mms_add_item(mms_data, MSG_STRUCT_MMS_REGION, ®ion); + msg_list_add_item(mms_data, MSG_STRUCT_MMS_REGION, ®ion); msg_set_str_value(region, MSG_MMS_REGION_ID_STR, (char *)"Image", 5); msg_set_int_value(region, MSG_MMS_REGION_LENGTH_LEFT_INT, 0); msg_set_int_value(region, MSG_MMS_REGION_LENGTH_TOP_INT, 0); @@ -1450,7 +1585,7 @@ int _messages_save_mms_data(messages_message_s *msg) } else { - msg_mms_add_item(mms_data, MSG_STRUCT_MMS_REGION, ®ion); + msg_list_add_item(mms_data, MSG_STRUCT_MMS_REGION, ®ion); msg_set_str_value(region, MSG_MMS_REGION_ID_STR, (char *)"Image", 5); msg_set_int_value(region, MSG_MMS_REGION_LENGTH_LEFT_INT, 0); msg_set_int_value(region, MSG_MMS_REGION_LENGTH_TOP_INT, 0); @@ -1458,7 +1593,7 @@ int _messages_save_mms_data(messages_message_s *msg) msg_set_int_value(region, MSG_MMS_REGION_LENGTH_HEIGHT_INT, 50); msg_set_int_value(region, MSG_MMS_REGION_BGCOLOR_INT, 0xffffff); - msg_mms_add_item(mms_data, MSG_STRUCT_MMS_REGION, ®ion); + msg_list_add_item(mms_data, MSG_STRUCT_MMS_REGION, ®ion); msg_set_str_value(region, MSG_MMS_REGION_ID_STR, (char *)"Text", 4); msg_set_int_value(region, MSG_MMS_REGION_LENGTH_LEFT_INT, 0); msg_set_int_value(region, MSG_MMS_REGION_LENGTH_TOP_INT, 50); @@ -1468,21 +1603,21 @@ int _messages_save_mms_data(messages_message_s *msg) } // Add Media - msg_mms_add_item(mms_data, MSG_STRUCT_MMS_PAGE, &page); + msg_list_add_item(mms_data, MSG_STRUCT_MMS_PAGE, &page); msg_set_int_value(page, MSG_MMS_PAGE_PAGE_DURATION_INT, 5440); if (NULL != image) { if (MESSAGES_MEDIA_IMAGE == image->media_type) { - msg_mms_add_item(page, MSG_STRUCT_MMS_MEDIA, &media); + msg_list_add_item(page, MSG_STRUCT_MMS_MEDIA, &media); msg_set_int_value(media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_IMG); msg_set_str_value(media, MSG_MMS_MEDIA_REGION_ID_STR, (char *)"Image", 5); msg_set_str_value(media, MSG_MMS_MEDIA_FILEPATH_STR, (char *)image->filepath, MSG_FILEPATH_LEN_MAX); } else if (MESSAGES_MEDIA_VIDEO == image->media_type) { - msg_mms_add_item(page, MSG_STRUCT_MMS_MEDIA, &media); + msg_list_add_item(page, MSG_STRUCT_MMS_MEDIA, &media); msg_set_int_value(media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_VIDEO); msg_set_str_value(media, MSG_MMS_MEDIA_REGION_ID_STR, (char *)"Image", 5); msg_set_str_value(media, MSG_MMS_MEDIA_FILEPATH_STR, (char *)image->filepath, MSG_FILEPATH_LEN_MAX); @@ -1491,7 +1626,7 @@ int _messages_save_mms_data(messages_message_s *msg) if (NULL != audio) { - msg_mms_add_item(page, MSG_STRUCT_MMS_MEDIA, &media); + msg_list_add_item(page, MSG_STRUCT_MMS_MEDIA, &media); msg_set_int_value(media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_AUDIO); msg_set_str_value(media, MSG_MMS_MEDIA_REGION_ID_STR, (char *)"Audio", 5); msg_set_str_value(media, MSG_MMS_MEDIA_FILEPATH_STR, (char *)audio->filepath, MSG_FILEPATH_LEN_MAX); @@ -1502,7 +1637,7 @@ int _messages_save_mms_data(messages_message_s *msg) ret = _messages_save_textfile(msg->text, &filepath); if (MESSAGES_ERROR_NONE == ret) { - msg_mms_add_item(page, MSG_STRUCT_MMS_MEDIA, &media); + msg_list_add_item(page, MSG_STRUCT_MMS_MEDIA, &media); msg_set_int_value(media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_TEXT); msg_set_str_value(media, MSG_MMS_MEDIA_REGION_ID_STR, (char *)"Text", 4); msg_set_str_value(media, MSG_MMS_MEDIA_FILEPATH_STR, (char *)filepath, MSG_FILEPATH_LEN_MAX); @@ -1525,7 +1660,7 @@ int _messages_save_mms_data(messages_message_s *msg) attach = g_slist_nth_data(msg->attachment_list, i); if (image != attach && audio != attach) { - msg_mms_add_item(mms_data, MSG_STRUCT_MMS_ATTACH, &mms_attach); + msg_list_add_item(mms_data, MSG_STRUCT_MMS_ATTACH, &mms_attach); msg_set_str_value(mms_attach, MSG_MMS_ATTACH_FILEPATH_STR, (char *)attach->filepath, MSG_FILEPATH_LEN_MAX); } } @@ -1757,7 +1892,7 @@ int _messages_load_textfile(const char *filepath, char **text) fclose(file); return MESSAGES_ERROR_OPERATION_FAILED; } - + if (NULL == *text) { @@ -1888,7 +2023,6 @@ int _messages_convert_recipient_to_fw(messages_recipient_type_e type) return ret; } - int _messages_error_converter(int err, const char *func, int line) { switch(err) @@ -1933,6 +2067,9 @@ int _messages_error_converter(int err, const char *func, int line) func, line, MESSAGES_ERROR_NO_DATA, err); return MESSAGES_ERROR_NO_DATA; + case MSG_ERR_PERMISSION_DENIED: + return MESSAGES_ERROR_PERMISSION_DENIED; + case MSG_SUCCESS: return MESSAGES_ERROR_NONE; @@ -1943,3 +2080,17 @@ int _messages_error_converter(int err, const char *func, int line) } } + +int _messages_check_feature(char *feature_name) { + bool is_supported = false; + if (!system_info_get_platform_bool(feature_name, &is_supported)) { + if (!is_supported) { + LOGE("[%s] feature is disabled", feature_name); + return MESSAGES_ERROR_NOT_SUPPORTED; + } + } else { + LOGE("Error - Feature getting from System Info"); + return MESSAGES_ERROR_OPERATION_FAILED; + } + return MESSAGES_ERROR_NONE; +} diff --git a/src/messages_cb.c b/src/messages_cb.c deleted file mode 100644 index 4a57ce5..0000000 --- a/src/messages_cb.c +++ /dev/null @@ -1,711 +0,0 @@ -/* - * Copyright (c) 2011 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 <sys/stat.h> -#include <unistd.h> - -#include <stdio.h> -#include <stdlib.h> -#include <memory.h> - -#include <glib.h> - -#include <dlog.h> -#include <msg.h> -#include <msg_transport.h> -#include <msg_storage.h> - -#include <messages.h> -#include <messages_types.h> -#include <messages_private.h> - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "CAPI_MESSAGING" - - - -void _messages_cb_incoming_mediator_cb(msg_handle_t handle, msg_struct_t msg, void *user_param) -{ - int cbType; - int etwsWarningType; - char etwsWarningInfo[MESSAGES_ETWS_WARNING_INFO_LEN]; - - messages_cb_message_s *_msg = NULL; - messages_service_s *_svc = (messages_service_s*)user_param; - - if (NULL == _svc) { - LOGW("[%s:%d] _svc is NULL.", __FUNCTION__, __LINE__); - return; - } - - if (NULL == msg) { - LOGW("[%s:%d] msg is NULL.", __FUNCTION__, __LINE__); - return; - } - - if (_svc->etws_incoming_cb || _svc->cbs_incoming_cb) - { - - _msg = (messages_cb_message_s *)calloc(1, sizeof(messages_message_s)); - if (NULL == _msg) - { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) fail to create '_msg'." - , __FUNCTION__, MESSAGES_ERROR_OUT_OF_MEMORY); - return; - } - - _msg->cb_msg_h = msg; - - msg_get_int_value(msg, MSG_CB_MSG_TYPE_INT, &cbType); - - if (MSG_TYPE_SMS_ETWS_PRIMARY == cbType) - { - if (_svc->etws_incoming_cb) - { - msg_get_int_value(msg, MSG_CB_MSG_ETWS_WARNING_TYPE_INT, &etwsWarningType); - msg_get_str_value(msg, MSG_CB_MSG_ETWS_WARNING_SECU_INFO_STR, etwsWarningInfo, MESSAGES_ETWS_WARNING_INFO_LEN); - - ((messages_cb_etws_primary_noti_cb)_svc->etws_incoming_cb)((messages_cb_message_h)_msg, etwsWarningType, etwsWarningInfo, _svc->etws_incoming_cb_user_data); - } - } - else { - if (_svc->cbs_incoming_cb) - { - ((messages_cb_incoming_cb)_svc->cbs_incoming_cb)((messages_cb_message_h)_msg, _svc->cbs_incoming_cb_user_data); - } - } - - free(_msg); - } -} - - -int messages_cb_get_message_id(messages_cb_message_h msg, int *msg_id) -{ - int ret; - - messages_cb_message_s *_msg = (messages_cb_message_s *)msg; - - CHECK_NULL(_msg); - CHECK_NULL(_msg->cb_msg_h); - CHECK_NULL(msg_id); - - ret = msg_get_int_value(_msg->cb_msg_h, MSG_CB_MSG_MSG_ID_INT, msg_id); - - return ERROR_CONVERT(ret); -} - -int messages_cb_get_serial_number(messages_cb_message_h msg, int *serial) -{ - int ret; - - messages_cb_message_s *_msg = (messages_cb_message_s *)msg; - - CHECK_NULL(_msg); - CHECK_NULL(_msg->cb_msg_h); - CHECK_NULL(serial); - - ret = msg_get_int_value(_msg->cb_msg_h, MSG_CB_MSG_SERIAL_NUM_INT, serial); - - return ERROR_CONVERT(ret); -} - -int messages_cb_get_dcs(messages_cb_message_h msg, int *dcs) -{ - int ret; - - messages_cb_message_s *_msg = (messages_cb_message_s *)msg; - - CHECK_NULL(_msg); - CHECK_NULL(_msg->cb_msg_h); - CHECK_NULL(dcs); - - ret = msg_get_int_value(_msg->cb_msg_h, MSG_CB_MSG_DCS_INT, dcs); - - return ERROR_CONVERT(ret); -} - -int messages_cb_get_message_type(messages_cb_message_h msg, messages_message_type_e *type) -{ - int ret; - int msgType; - - messages_cb_message_s *_msg = (messages_cb_message_s *)msg; - - CHECK_NULL(_msg); - CHECK_NULL(_msg->cb_msg_h); - CHECK_NULL(type); - - ret = msg_get_int_value(_msg->cb_msg_h, MSG_CB_MSG_TYPE_INT, &msgType); - if (MSG_SUCCESS != ret) - { - return ERROR_CONVERT(ret); - } - - switch (msgType) - { - case MSG_TYPE_SMS_ETWS_PRIMARY: - *type = MESSAGES_TYPE_SMS_ETWS_PRIMARY; - break; - case MSG_TYPE_SMS_ETWS_SECONDARY: - *type = MESSAGES_TYPE_SMS_ETWS_SECONDARY; - break; - default: - *type = MESSAGES_TYPE_SMS_CB; - break; - } - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_get_language_type(messages_cb_message_h msg, char **type) -{ - int ret; - int len; - char *_type; - - messages_cb_message_s *_msg = (messages_cb_message_s *)msg; - - CHECK_NULL(_msg); - CHECK_NULL(_msg->cb_msg_h); - CHECK_NULL(type); - - len = 15; - - _type = (char*)calloc(len + 1, sizeof(char)); // Maximum 15 bytes - if (NULL == _type) - { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) fail to create '_type'." - , __FUNCTION__, MESSAGES_ERROR_OUT_OF_MEMORY); - return MESSAGES_ERROR_OUT_OF_MEMORY; - } - ret = msg_get_str_value(_msg->cb_msg_h, MSG_CB_MSG_LANGUAGE_TYPE_STR, _type, len); - if (MSG_SUCCESS != ret) - { - free(_type); - return ERROR_CONVERT(ret); - } - - *type = _type; - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_get_text(messages_cb_message_h msg, char **text) -{ - int ret; - - int txtLen; - int msgType; - char *_text; - - messages_cb_message_s *_msg = (messages_cb_message_s *)msg; - - CHECK_NULL(_msg); - CHECK_NULL(_msg->cb_msg_h); - CHECK_NULL(text); - - ret = msg_get_int_value(_msg->cb_msg_h, MSG_CB_MSG_TYPE_INT, &msgType); - if (MSG_SUCCESS != ret) - { - return ERROR_CONVERT(ret); - } - - if (MSG_TYPE_SMS_ETWS_PRIMARY == msgType) - { - LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : The type of msg is ETWS_PRIMARY. This msg doesn't have 'text'.", - __FUNCTION__, __LINE__, MESSAGES_ERROR_OPERATION_FAILED); - return MESSAGES_ERROR_OPERATION_FAILED; - } - - ret = msg_get_int_value(_msg->cb_msg_h, MSG_CB_MSG_CB_TEXT_LEN_INT, &txtLen); - if (MSG_SUCCESS != ret) - { - return ERROR_CONVERT(ret); - } - - _text = (char *)calloc(txtLen + 1, sizeof(char)); - if (NULL == _text) - { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) fail to create '_text'." - , __FUNCTION__, MESSAGES_ERROR_OUT_OF_MEMORY); - return MESSAGES_ERROR_OUT_OF_MEMORY; - } - - ret = msg_get_str_value(_msg->cb_msg_h, MSG_CB_MSG_CB_TEXT_STR, _text, txtLen + 1); - if (MSG_SUCCESS != ret) - { - free(_text); - return ERROR_CONVERT(ret); - } - - *text = _text; - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_get_time(messages_cb_message_h msg, time_t *time) -{ - int ret; - int _time; - - messages_cb_message_s *_msg = (messages_cb_message_s *)msg; - - CHECK_NULL(_msg); - CHECK_NULL(_msg->cb_msg_h); - CHECK_NULL(time); - - ret = msg_get_int_value(_msg->cb_msg_h, MSG_CB_MSG_RECV_TIME_INT, &_time); - if (MSG_SUCCESS != ret) - { - return ERROR_CONVERT(ret); - } - - *time = (time_t)_time; - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_set_incoming_cb(messages_service_h service, bool save, - messages_cb_incoming_cb callback, void *user_data) -{ - int ret; - - messages_service_s *_svc = (messages_service_s *)service; - - CHECK_NULL(_svc); - CHECK_NULL(_svc->service_h); - CHECK_NULL(callback); - - if (!_svc->cbs_enabled_cb) - { - ret = msg_reg_cb_message_callback(_svc->service_h, _messages_cb_incoming_mediator_cb, save, (void*)_svc); - if (MSG_SUCCESS != ret) - { - return ERROR_CONVERT(ret); - } - _svc->cbs_enabled_cb = true; - } - - _svc->cbs_incoming_cb = (void*)callback; - _svc->cbs_incoming_cb_user_data = (void*)user_data; - _svc->cbs_incoming_cb_save = save; - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_unset_incoming_cb(messages_service_h service) -{ - messages_service_s *_svc = (messages_service_s *)service; - - CHECK_NULL(_svc); - - _svc->cbs_incoming_cb = NULL; - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_set_etws_primary_noti_cb(messages_service_h service, - messages_cb_etws_primary_noti_cb callback, void *user_data) -{ - int ret; - - messages_service_s *_svc = (messages_service_s *)service; - - CHECK_NULL(_svc); - CHECK_NULL(_svc->service_h); - CHECK_NULL(callback); - - if (!_svc->cbs_enabled_cb) - { - ret = msg_reg_cb_message_callback(_svc->service_h, _messages_cb_incoming_mediator_cb, _svc->cbs_incoming_cb_save, (void*)_svc); - if (MSG_SUCCESS != ret) - { - return ERROR_CONVERT(ret); - } - _svc->cbs_enabled_cb = true; - } - - _svc->etws_incoming_cb = (void*)callback; - _svc->etws_incoming_cb_user_data = (void*)user_data; - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_unset_etws_primary_noti_cb(messages_service_h service) -{ - messages_service_s *_svc = (messages_service_s *)service; - - CHECK_NULL(_svc); - - _svc->etws_incoming_cb = NULL; - - return MESSAGES_ERROR_NONE; -} - -int _messages_cb_clear_settings(messages_cb_settings_s *settings) -{ - CHECK_NULL(settings); - CHECK_NULL(settings->_struct); - - msg_release_struct(&settings->_struct); - - if (settings->channel_list) - { - g_slist_foreach(settings->channel_list, (GFunc)g_free, NULL); - g_slist_free(settings->channel_list); - settings->channel_list = NULL; - } - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_load_settings(messages_service_h service, messages_cb_settings_h *settings) -{ - int i; - int ret; - - messages_service_s *_svc = (messages_service_s *)service; - messages_cb_settings_s * _settings; - - msg_struct_list_s *channels = NULL; - - messages_cb_channel_s *_ch; - - CHECK_NULL(_svc); - CHECK_NULL(_svc->service_h); - CHECK_NULL(settings); - - // Allocate Settings - _settings = (messages_cb_settings_s *)calloc(1, sizeof(messages_cb_settings_s)); - if (NULL == _settings) - { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) fail to create a '_settings'." - , __FUNCTION__, MESSAGES_ERROR_OUT_OF_MEMORY); - return MESSAGES_ERROR_OUT_OF_MEMORY; - } - - // Load Settings - _settings->_struct = msg_create_struct(MSG_STRUCT_SETTING_CB_OPT); - ret = msg_get_cb_opt(_svc->service_h, _settings->_struct); - if (MSG_SUCCESS != ret) - { - msg_release_struct(&_settings->_struct); - free(_settings); - return ERROR_CONVERT(ret); - } - - // Load Channel List - msg_get_list_handle(_settings->_struct, MSG_CB_CHANNEL_LIST_STRUCT, (void **)&channels); - for (i=0; i < channels->nCount; i++) - { - _ch = (messages_cb_channel_s *)calloc(1, sizeof(messages_cb_channel_s)); - if (NULL == _ch) - { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) fail to create '_ch'." - , __FUNCTION__, MESSAGES_ERROR_OUT_OF_MEMORY); - _messages_cb_clear_settings(_settings); - free(_settings); - return MESSAGES_ERROR_OUT_OF_MEMORY; - } - - msg_get_bool_value(channels->msg_struct_info[i], MSG_CB_CHANNEL_ACTIVATE_BOOL, &_ch->activated); - msg_get_int_value(channels->msg_struct_info[i], MSG_CB_CHANNEL_ID_FROM_INT, &_ch->from_id); - msg_get_int_value(channels->msg_struct_info[i], MSG_CB_CHANNEL_ID_TO_INT, &_ch->to_id); - msg_get_str_value(channels->msg_struct_info[i], MSG_CB_CHANNEL_NAME_STR, _ch->name, CB_CHANNEL_NAME_MAX); - - _settings->channel_list = g_slist_append(_settings->channel_list, (messages_cb_channel_h)_ch); - } - - if (NULL != _svc->cbs_settings_h) - { - _messages_cb_clear_settings((messages_cb_settings_s*)_svc->cbs_settings_h); - free(_svc->cbs_settings_h); - } - _svc->cbs_settings_h = (messages_cb_settings_h)_settings; - - *settings = (messages_cb_settings_h)_settings; - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_save_settings(messages_service_h service, messages_cb_settings_h settings) -{ - int i; - int count; - int ret; - - messages_service_s *_svc = (messages_service_s *)service; - messages_cb_settings_s *_settings = (messages_cb_settings_s *)settings; - - messages_cb_channel_s *_ch; - msg_struct_list_s *channels = NULL; - - CHECK_NULL(_svc); - CHECK_NULL(_svc->service_h); - CHECK_NULL(_settings); - CHECK_NULL(_settings->_struct); - - msg_get_list_handle(_settings->_struct, MSG_CB_CHANNEL_LIST_STRUCT, (void **)&channels); - - count = g_slist_length(_settings->channel_list); - if (CB_CHANNEL_MAX < count) - { - count = CB_CHANNEL_MAX; - } - channels->nCount = count; - - for (i=0; i < channels->nCount; i++) - { - _ch = (messages_cb_channel_s *)g_slist_nth_data(_settings->channel_list, i); - - msg_set_bool_value(channels->msg_struct_info[i], MSG_CB_CHANNEL_ACTIVATE_BOOL, _ch->activated); - msg_set_int_value(channels->msg_struct_info[i], MSG_CB_CHANNEL_ID_FROM_INT, _ch->from_id); - msg_set_int_value(channels->msg_struct_info[i], MSG_CB_CHANNEL_ID_TO_INT, _ch->to_id); - msg_set_str_value(channels->msg_struct_info[i], MSG_CB_CHANNEL_NAME_STR, _ch->name, CB_CHANNEL_NAME_MAX); - } - - ret = msg_set_cb_opt(_svc->service_h, _settings->_struct); - - return ERROR_CONVERT(ret); -} - - -int messages_cb_settings_set_enabled(messages_cb_settings_h settings, bool enabled) -{ - int ret; - messages_cb_settings_s *_settings = (messages_cb_settings_s *)settings; - - CHECK_NULL(_settings); - CHECK_NULL(_settings->_struct); - - ret = msg_set_bool_value(_settings->_struct, MSG_CB_RECEIVE_BOOL, enabled); - if (MSG_SUCCESS != ret) - { - return ERROR_CONVERT(ret); - } - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_settings_is_enabled(messages_cb_settings_h settings, bool *enabled) -{ - int ret; - bool _enabled; - messages_cb_settings_s *_settings = (messages_cb_settings_s *)settings; - - CHECK_NULL(_settings); - CHECK_NULL(_settings->_struct); - CHECK_NULL(enabled); - - ret = msg_get_bool_value(_settings->_struct, MSG_CB_RECEIVE_BOOL, &_enabled); - if (MSG_SUCCESS != ret) - { - return ERROR_CONVERT(ret); - } - - *enabled = _enabled; - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_settings_add_channel(messages_cb_settings_h settings, messages_cb_channel_h channel) -{ - int count; - - messages_cb_settings_s *_settings = (messages_cb_settings_s *)settings; - - CHECK_NULL(_settings); - CHECK_NULL(channel); - - count = g_slist_length(_settings->channel_list); - if (CB_CHANNEL_MAX <= count) - { - LOGE("[%s] OUT_OF_RANGE(0x%08x) channel_list is full." - , __FUNCTION__, MESSAGES_ERROR_OUT_OF_MEMORY); - return MESSAGES_ERROR_OUT_OF_RANGE; - } - - _settings->channel_list = g_slist_append(_settings->channel_list, channel); - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_settings_remove_channel(messages_cb_settings_h settings, messages_cb_channel_h channel) -{ - messages_cb_settings_s *_settings = (messages_cb_settings_s *)settings; - - CHECK_NULL(_settings); - CHECK_NULL(channel); - - _settings->channel_list = g_slist_remove_all(_settings->channel_list, channel); - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_settings_get_channel(messages_cb_settings_h settings, int index, messages_cb_channel_h *channel) -{ - messages_cb_channel_h ch; - messages_cb_settings_s *_settings = (messages_cb_settings_s *)settings; - - CHECK_NULL(_settings); - CHECK_NULL(channel); - - ch = (messages_cb_channel_h)g_slist_nth_data(_settings->channel_list, index); - if (NULL == ch) - { - LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : No channel data in the channel list.", - __FUNCTION__, __LINE__, MESSAGES_ERROR_OPERATION_FAILED); - return MESSAGES_ERROR_OPERATION_FAILED; - } - - *channel = ch; - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_settings_get_channel_count(messages_cb_settings_h settings, int *count) -{ - messages_cb_settings_s *_settings = (messages_cb_settings_s *)settings; - - CHECK_NULL(_settings); - CHECK_NULL(count); - - *count = g_slist_length(_settings->channel_list); - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_create_channel(messages_cb_channel_h *channel) -{ - messages_cb_channel_s *_channel; - - CHECK_NULL(channel); - - _channel = (messages_cb_channel_s *)calloc(1, sizeof(messages_cb_channel_s)); - if (NULL == _channel) - { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) fail to create '_channel'." - , __FUNCTION__, MESSAGES_ERROR_OUT_OF_MEMORY); - return MESSAGES_ERROR_OUT_OF_MEMORY; - } - - *channel = (messages_cb_channel_h)_channel; - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_destroy_channel(messages_cb_channel_h channel) -{ - messages_cb_channel_s *_channel = (messages_cb_channel_s *)channel; - - CHECK_NULL(_channel); - - free(channel); - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_channel_set_id(messages_cb_channel_h channel, int from_id, int to_id) -{ - messages_cb_channel_s *_channel = (messages_cb_channel_s *)channel; - - CHECK_NULL(_channel); - - _channel->from_id = from_id; - _channel->to_id = to_id; - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_channel_get_id(messages_cb_channel_h channel, int *from_id, int *to_id) -{ - messages_cb_channel_s *_channel = (messages_cb_channel_s *)channel; - - CHECK_NULL(_channel); - CHECK_NULL(from_id); - CHECK_NULL(to_id); - - *from_id = _channel->from_id; - *to_id = _channel->to_id; - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_channel_set_name(messages_cb_channel_h channel, const char *name) -{ - int size; - - messages_cb_channel_s *_channel = (messages_cb_channel_s *)channel; - - CHECK_NULL(_channel); - CHECK_NULL(name); - - size = strlen(name); - - if (CB_CHANNEL_NAME_MAX < size) - { - LOGE("[%s] OUT_OF_RANGE(0x%08x) channel name > %d" - , __FUNCTION__, MESSAGES_ERROR_OUT_OF_MEMORY, CB_CHANNEL_NAME_MAX); - return MESSAGES_ERROR_OUT_OF_RANGE; - } - - strncpy(_channel->name, name, CB_CHANNEL_NAME_MAX); - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_channel_get_name(messages_cb_channel_h channel, char **name) -{ - messages_cb_channel_s *_channel = (messages_cb_channel_s *)channel; - - CHECK_NULL(_channel); - CHECK_NULL(name); - - *name = strdup(_channel->name); - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_channel_set_activated(messages_cb_channel_h channel, bool activated) -{ - messages_cb_channel_s *_channel = (messages_cb_channel_s *)channel; - - CHECK_NULL(_channel); - - _channel->activated = activated; - - return MESSAGES_ERROR_NONE; -} - -int messages_cb_channel_is_activated(messages_cb_channel_h channel, bool *activated) -{ - messages_cb_channel_s *_channel = (messages_cb_channel_s *)channel; - - CHECK_NULL(_channel); - CHECK_NULL(activated); - - *activated = _channel->activated; - - return MESSAGES_ERROR_NONE; -} - - - - - diff --git a/src/messages_push.c b/src/messages_push.c index a6f0bd3..fce67f6 100644 --- a/src/messages_push.c +++ b/src/messages_push.c @@ -55,6 +55,8 @@ void _messages_push_incoming_mediator_cb(msg_handle_t handle, const char *push_h int messages_push_add_incoming_cb(messages_service_h service, const char *app_id,
messages_push_incoming_cb callback, void *user_data)
{
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE);
+
int ret;
messages_push_incoming_callback_s *_cb;
@@ -94,6 +96,8 @@ int messages_push_add_incoming_cb(messages_service_h service, const char *app_id int messages_push_remove_incoming_cb(messages_service_h service, const char *app_id)
{
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE);
+
int i;
messages_push_incoming_callback_s *_cb;
@@ -120,6 +124,8 @@ int messages_push_remove_incoming_cb(messages_service_h service, const char *app int messages_push_register(messages_service_h service, const char *content_type, const char *app_id)
{
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE);
+
int ret;
msg_struct_t push_info;
@@ -132,9 +138,9 @@ int messages_push_register(messages_service_h service, const char *content_type, CHECK_NULL(content_type);
CHECK_NULL(app_id);
- ret = app_get_package(&pkg_name);
+ ret = app_get_id(&pkg_name);
if (APP_ERROR_NONE != ret) {
- LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : app_get_package failed.",
+ LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : app_get_id failed.",
__FUNCTION__, __LINE__, MESSAGES_ERROR_OPERATION_FAILED);
return MESSAGES_ERROR_OPERATION_FAILED;
}
@@ -157,6 +163,8 @@ int messages_push_register(messages_service_h service, const char *content_type, int messages_push_deregister(messages_service_h service, const char *content_type, const char *app_id)
{
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE);
+
int ret;
msg_struct_t push_info;
@@ -169,9 +177,9 @@ int messages_push_deregister(messages_service_h service, const char *content_typ CHECK_NULL(content_type);
CHECK_NULL(app_id);
- ret = app_get_package(&pkg_name);
+ ret = app_get_id(&pkg_name);
if (APP_ERROR_NONE != ret) {
- LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : app_get_package failed.",
+ LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : app_get_id failed.",
__FUNCTION__, __LINE__, MESSAGES_ERROR_OPERATION_FAILED);
return MESSAGES_ERROR_OPERATION_FAILED;
}
@@ -195,6 +203,8 @@ int messages_push_deregister(messages_service_h service, const char *content_typ int messages_push_reregister(messages_service_h service, const char *content_type, const char *app_id,
const char *dst_content_type, const char *dst_app_id)
{
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE);
+
int ret;
msg_struct_t push_info;
@@ -210,9 +220,9 @@ int messages_push_reregister(messages_service_h service, const char *content_typ CHECK_NULL(dst_content_type);
CHECK_NULL(dst_app_id);
- ret = app_get_package(&pkg_name);
+ ret = app_get_id(&pkg_name);
if (APP_ERROR_NONE != ret) {
- LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : app_get_package failed.",
+ LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : app_get_id failed.",
__FUNCTION__, __LINE__, MESSAGES_ERROR_OPERATION_FAILED);
return MESSAGES_ERROR_OPERATION_FAILED;
}
|