diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/messages.c | 124 | ||||
-rw-r--r-- | src/messages_push.c | 10 |
2 files changed, 63 insertions, 71 deletions
diff --git a/src/messages.c b/src/messages.c index 2b62a85..3f263f5 100755 --- a/src/messages.c +++ b/src/messages.c @@ -22,7 +22,9 @@ #include <memory.h> #include <glib.h> -#include <dlog.h> + +#include <privacy_checker_client.h> + #include <msg.h> #include <msg_transport.h> #include <msg_storage.h> @@ -31,15 +33,6 @@ #include <messages_types.h> #include <messages_private.h> -#include <privacy_checker_client.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); @@ -52,7 +45,7 @@ int _messages_check_feature(char *feature_name); int messages_open_service(messages_service_h *svc) { - CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; messages_service_s *_svc; @@ -73,20 +66,20 @@ int messages_open_service(messages_service_h *svc) _svc->push_incoming_cb_list = NULL; ret = msg_open_msg_handle(&_svc->service_h); - if (MSG_SUCCESS != ret) { - free(_svc); - return ERROR_CONVERT(ret); - } + if (MSG_SUCCESS != ret) + goto ERR_RET; ret = msg_reg_sent_status_callback(_svc->service_h, &_messages_sent_mediator_cb, (void*)_svc); - if (MSG_SUCCESS != ret) { - free(_svc); - return ERROR_CONVERT(ret); - } + if (MSG_SUCCESS != ret) + goto ERR_RET; *svc = (messages_service_h)_svc; return MESSAGES_ERROR_NONE; + +ERR_RET: + free(_svc); + return ERROR_CONVERT(ret); } void _free_push_incoming_cb(messages_push_incoming_callback_s *cb) @@ -101,7 +94,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; @@ -129,7 +122,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; messages_message_s *_msg = NULL; @@ -160,28 +153,17 @@ int messages_create_message(messages_message_type_e type, messages_message_h *ms { ret = ERROR_CONVERT(msg_set_int_value(_msg->msg_h, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS)); if (MESSAGES_ERROR_NONE != ret) - { - msg_release_struct(&_msg->msg_h); - free(_msg); - return ret; - } + goto ERR_RET; } 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; - } + if (MESSAGES_ERROR_NONE != ret) + goto ERR_RET; ret = ERROR_CONVERT(msg_set_int_value(_msg->msg_h, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS)); if (MESSAGES_ERROR_NONE != ret) - { - msg_release_struct(&_msg->msg_h); - free(_msg); - return ret; - } + goto ERR_RET; } else { @@ -195,11 +177,16 @@ int messages_create_message(messages_message_type_e type, messages_message_h *ms *msg = (messages_message_h)_msg; return MESSAGES_ERROR_NONE; + +ERR_RET: + msg_release_struct(&_msg->msg_h); + free(_msg); + return ret; } int messages_destroy_message(messages_message_h msg) { - CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; @@ -223,7 +210,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int msgType; int ret; @@ -272,7 +259,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; @@ -325,7 +312,7 @@ int messages_add_address(messages_message_h msg, const char *address, messages_r int messages_get_address_count(messages_message_h msg, int *count) { - CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; msg_list_handle_t addr_list = NULL; @@ -348,7 +335,7 @@ int messages_get_address_count(messages_message_h msg, int *count) int messages_get_address(messages_message_h msg, int index, char **address, messages_recipient_type_e *type) { - CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; char _address[MAX_ADDRESS_VAL_LEN+1] = {0, }; @@ -426,7 +413,7 @@ int messages_get_address(messages_message_h msg, int index, char **address, mess int messages_remove_all_addresses(messages_message_h msg) { - CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; messages_message_s *_msg = (messages_message_s*)msg; @@ -447,7 +434,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); /* Privacy check */ int privacy_ret = privacy_checker_check_by_privilege(MESSAGES_PRIVILEGE_WRITE); @@ -551,7 +538,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; msg_folder_id_t folderId; @@ -629,7 +616,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int i; int ret; @@ -738,7 +725,7 @@ int messages_search_message(messages_service_h service, int messages_free_message_array(messages_message_h *message_array) { - CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; int i=0; @@ -770,7 +757,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); /* Privacy check */ int privacy_ret = privacy_checker_check_by_privilege(MESSAGES_PRIVILEGE_READ); @@ -888,7 +875,7 @@ void _messages_incoming_mediator_cb(msg_handle_t handle, msg_struct_t msg, void int messages_set_message_incoming_cb(messages_service_h svc, messages_incoming_cb callback, void *user_data) { - CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_MMS_FEATURE); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; @@ -907,12 +894,14 @@ int messages_set_message_incoming_cb(messages_service_h svc, messages_incoming_c return ret; } - ret = ERROR_CONVERT( - msg_reg_mms_conf_message_callback(_svc->service_h, &_messages_incoming_mediator_cb, NULL, (void*)_svc) - ); - if (MESSAGES_ERROR_NONE != ret) - { - return ret; + if (MESSAGES_ERROR_NONE == _messages_check_feature(MESSAGES_TELEPHONY_MMS_FEATURE)) { + ret = ERROR_CONVERT( + msg_reg_mms_conf_message_callback(_svc->service_h, &_messages_incoming_mediator_cb, NULL, (void*)_svc) + ); + if (MESSAGES_ERROR_NONE != ret) + { + return ret; + } } } @@ -925,7 +914,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; messages_service_s *_svc = (messages_service_s*)service; @@ -950,20 +939,22 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; int _port; @@ -986,7 +977,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; int len; @@ -1005,7 +996,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); @@ -1044,7 +1035,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; char _text[MAX_MSG_TEXT_LEN+1] = {0,}; @@ -1109,7 +1100,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; int _time; @@ -1132,7 +1123,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; int _id; @@ -1156,7 +1147,7 @@ int messages_get_message_id(messages_message_h msg, int *msg_id) int messages_set_sim_id(messages_message_h msg, int sim_id) { - CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; @@ -1176,7 +1167,7 @@ int messages_set_sim_id(messages_message_h msg, int sim_id) int messages_get_sim_id(messages_message_h msg, int *sim_id) { - CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; int _id; @@ -1200,7 +1191,7 @@ int messages_get_sim_id(messages_message_h msg, int *sim_id) int messages_search_message_by_id(messages_service_h service, int msg_id, messages_message_h *msg) { - CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; msg_struct_t new_msg_h; @@ -1277,7 +1268,7 @@ 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); + CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE); int ret; int folder_id; @@ -1531,6 +1522,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; diff --git a/src/messages_push.c b/src/messages_push.c index fce67f6..70b50a8 100644 --- a/src/messages_push.c +++ b/src/messages_push.c @@ -55,7 +55,7 @@ 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);
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE);
int ret;
messages_push_incoming_callback_s *_cb;
@@ -96,7 +96,7 @@ 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);
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE);
int i;
messages_push_incoming_callback_s *_cb;
@@ -124,7 +124,7 @@ 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);
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE);
int ret;
@@ -163,7 +163,7 @@ 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);
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE);
int ret;
@@ -203,7 +203,7 @@ 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);
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE);
int ret;
|