* @section CAPI_MESSAGING_MESSAGES_MODULE_FEATURE Related Features
* This API is related with the following features:\n
* - http://tizen.org/feature/network.telephony\n
+ * - http://tizen.org/feature/network.telephony.sms\n
* - http://tizen.org/feature/network.telephony.mms\n
*
* It is recommended to design feature related codes in your application for reliability.\n
* @section CAPI_MESSAGING_MESSAGES_MMS_MODULE_FEATURE Related Features
* This API is related with the following features:\n
* - http://tizen.org/feature/network.telephony\n
+ * - http://tizen.org/feature/network.telephony.sms\n
* - http://tizen.org/feature/network.telephony.mms\n
*
* It is recommended to design feature related codes in your application for reliability.\n
* @section CAPI_MESSAGING_MESSAGES_PUSH_MODULE_FEATURE Related Features
* This API is related with the following features:\n
* - http://tizen.org/feature/network.telephony\n
+ * - http://tizen.org/feature/network.telephony.sms\n
*
* It is recommended to design feature related codes in your application for reliability.\n
*
#ifndef __TIZEN_MESSAGING_PRIVATE_H__
#define __TIZEN_MESSAGING_PRIVATE_H__
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CAPI_MESSAGING"
+#define DBG_MODE (1)
+
#ifdef __cplusplus
extern "C"
{
#define MESSAGES_PRIVILEGE_READ "http://tizen.org/privilege/message.read"
#define MESSAGES_PRIVILEGE_WRITE "http://tizen.org/privilege/message.write"
-#define MESSAGES_TELEPHONY_FEATURE "http://tizen.org/feature/network.telephony"
+#define MESSAGES_TELEPHONY_SMS_FEATURE "http://tizen.org/feature/network.telephony.sms"
#define MESSAGES_TELEPHONY_MMS_FEATURE "http://tizen.org/feature/network.telephony.mms"
#define ERROR_CONVERT(err) _messages_error_converter(err, __FUNCTION__, __LINE__);
#include <stdbool.h>
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "CAPI_MESSAGING"
-#define DBG_MODE (1)
-
#ifdef __cplusplus
extern "C"
{
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
-%if "%{?tizen_profile_name}" == "wearable"
+%if "%{?profile}" == "tv"
ExcludeArch: %{arm} %ix86 x86_64
%endif
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;
CHECK_NULL(svc);
_svc = (messages_service_s*)calloc(1, sizeof(messages_service_s));
- if (NULL == svc)
+ if (NULL == _svc)
{
- LOGE("[%s] OUT_OF_MEMORY(0x%08x) fail to create a 'svc'."
+ LOGE("[%s] OUT_OF_MEMORY(0x%08x) fail to create a '_svc'."
, __FUNCTION__, MESSAGES_ERROR_OUT_OF_MEMORY);
return MESSAGES_ERROR_OUT_OF_MEMORY;
}
int messages_close_service(messages_service_h svc)
{
- CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE);
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE);
int ret;
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;
int messages_destroy_message(messages_message_h msg)
{
- CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE);
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE);
int ret;
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;
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;
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;
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] = {0, };
+ char _address[MAX_ADDRESS_VAL_LEN+1] = {0, };
int _type;
int count;
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;
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);
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;
else
{
countInfo = msg_create_struct(MSG_STRUCT_COUNT_INFO);
+ if (NULL == countInfo) {
+ LOGE("[%s:%d] OUT_OF_MEMORY(0x%08x) fail to create 'countInfo'."
+ , __FUNCTION__, __LINE__, MESSAGES_ERROR_OUT_OF_MEMORY);
+ return MESSAGES_ERROR_OUT_OF_MEMORY;
+ }
+
folderId = _messages_convert_mbox_to_fw(mbox);
ret = ERROR_CONVERT(msg_count_message(_svc->service_h, folderId, countInfo));
if (MESSAGES_ERROR_NONE != ret)
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;
// Set Condition
listCond = msg_create_struct(MSG_STRUCT_MSG_LIST_CONDITION);
+ if (NULL == listCond) {
+ LOGE("[%s:%d] OUT_OF_MEMORY(0x%08x) fail to create 'listCond'."
+ , __FUNCTION__, __LINE__, MESSAGES_ERROR_OUT_OF_MEMORY);
+ return MESSAGES_ERROR_OUT_OF_MEMORY;
+ }
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));
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);
+ msg_release_struct(&listCond);
if (MSG_SUCCESS != ret)
{
- msg_release_struct(&listCond);
+ msg_release_list_struct(&msg_list);
return ERROR_CONVERT(ret);
}
- msg_release_struct(&listCond);
// Result
_array = (messages_message_h*)calloc(msg_list.nCount + 1, sizeof(messages_message_h));
if (NULL == _array)
{
+ msg_release_list_struct(&msg_list);
LOGE("[%s:%d] OUT_OF_MEMORY(0x%08x) fail to create '_array'."
, __FUNCTION__, __LINE__, MESSAGES_ERROR_OUT_OF_MEMORY);
return MESSAGES_ERROR_OUT_OF_MEMORY;
{
LOGE("[%s:%d] OUT_OF_MEMORY(0x%08x) fail to create '_msg'."
, __FUNCTION__, __LINE__, MESSAGES_ERROR_OUT_OF_MEMORY);
+ for (; i > 0; i--) {
+ free(_array[i-1]);
+ }
free(_array);
+ msg_release_list_struct(&msg_list);
return MESSAGES_ERROR_OUT_OF_MEMORY;
}
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;
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);
int messages_set_message_incoming_cb(messages_service_h svc, messages_incoming_cb callback, void *user_data)
{
- CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE);
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE);
int ret;
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;
+ }
}
}
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;
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;
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;
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;
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];
+ char _text[MAX_MSG_TEXT_LEN+1] = {0,};
messages_message_type_e type;
messages_message_s *_msg = (messages_message_s*)msg;
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;
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;
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;
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;
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;
CHECK_NULL(msg);
new_msg_h = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
+ if (NULL == new_msg_h) {
+ LOGE("[%s:%d] OUT_OF_MEMORY(0x%08x) fail to create 'new_msg_h'."
+ , __FUNCTION__, __LINE__, MESSAGES_ERROR_OUT_OF_MEMORY);
+ return MESSAGES_ERROR_OUT_OF_MEMORY;
+ }
+
sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
+ if (NULL == sendOpt) {
+ msg_release_struct(&new_msg_h);
+ LOGE("[%s:%d] OUT_OF_MEMORY(0x%08x) fail to create 'sendOpt'."
+ , __FUNCTION__, __LINE__, MESSAGES_ERROR_OUT_OF_MEMORY);
+ return MESSAGES_ERROR_OUT_OF_MEMORY;
+ }
+
ret = msg_get_message(_svc->service_h, msg_id, new_msg_h, sendOpt);
if (MSG_SUCCESS != ret)
{
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;
CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_MMS_FEATURE);
int ret;
- char _subject[MAX_SUBJECT_LEN];
+ char _subject[MAX_SUBJECT_LEN+1] = {0,};
messages_message_type_e type;
messages_message_s *_msg = (messages_message_s*)msg;
msg_struct_t mms_media;
msg_struct_t mms_attach;
- messages_attachment_s *attach;
+ messages_attachment_s *attach = NULL;
CHECK_NULL(msg);
// Load MMS_MESSAGE_DATA_S
new_msg_h = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
+ if (new_msg_h == NULL) {
+ return MESSAGES_ERROR_OPERATION_FAILED;
+ }
+
sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
+ if (sendOpt == NULL) {
+ msg_release_struct(&new_msg_h);
+ return MESSAGES_ERROR_OPERATION_FAILED;
+ }
+
ret = msg_get_message(handle, msg_id, new_msg_h, sendOpt);
if (MSG_SUCCESS != ret)
{
continue;
}
- attach = (messages_attachment_s *)calloc(1, sizeof(messages_attachment_s));
- if (NULL == attach)
- {
- LOGW("[%s] OUT_OF_MEMORY(0x%08x) fail to create a 'attach'."
- , __FUNCTION__, MESSAGES_ERROR_OUT_OF_MEMORY);
- break;
- }
-
msg_get_int_value(mms_media, MSG_MMS_MEDIA_TYPE_INT, &media_type);
msg_get_str_value(mms_media, MSG_MMS_MEDIA_FILEPATH_STR, filepath, MSG_FILEPATH_LEN_MAX);
}
else
{
+ attach = (messages_attachment_s *)calloc(1, sizeof(messages_attachment_s));
+ if (NULL == attach)
+ {
+ LOGW("[%s] OUT_OF_MEMORY(0x%08x) fail to create a 'attach'."
+ , __FUNCTION__, MESSAGES_ERROR_OUT_OF_MEMORY);
+ break;
+ }
+
strncpy(attach->filepath, filepath, MSG_FILEPATH_LEN_MAX);
switch (media_type)
{
if (NULL == *text)
{
*text = (char*)calloc(1, st.st_size + 1);
+ if (*text == NULL) {
+ fclose(file);
+ return MESSAGES_ERROR_OPERATION_FAILED;
+ }
pos = *text;
}
else
{
len = strlen(*text);
*text = (char*)realloc(*text, len + st.st_size + 2);
+ if (*text == NULL) {
+ fclose(file);
+ return MESSAGES_ERROR_OPERATION_FAILED;
+ }
(*text)[len] = '\n';
pos = *text + len + 1;
}
-/*\r
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License. \r
- */\r
-\r
-#include <sys/stat.h>\r
-#include <unistd.h>\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <memory.h>\r
-\r
-#include <glib.h>\r
-\r
-#include <dlog.h>\r
-#include <msg.h>\r
-#include <msg_transport.h>\r
-#include <msg_storage.h>\r
-\r
-#include <app.h>\r
-\r
-#include <messages.h>\r
-#include <messages_types.h>\r
-#include <messages_private.h>\r
-\r
-#ifdef LOG_TAG\r
-#undef LOG_TAG\r
-#endif\r
-#define LOG_TAG "CAPI_MESSAGING"\r
-\r
-\r
-void _messages_push_incoming_mediator_cb(msg_handle_t handle, const char *push_header, const char *push_body, int push_body_len, void *user_param)\r
-{\r
- messages_push_incoming_callback_s *_cb = (messages_push_incoming_callback_s *)user_param;\r
- \r
- if (_cb && _cb->callback)\r
- {\r
- ((messages_push_incoming_cb)_cb->callback)(push_header, push_body, push_body_len, _cb->user_data);\r
- }\r
-}\r
-\r
-\r
-\r
-int messages_push_add_incoming_cb(messages_service_h service, const char *app_id, \r
- messages_push_incoming_cb callback, void *user_data)\r
-{\r
- CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE);\r
-\r
- int ret;\r
- messages_push_incoming_callback_s *_cb;\r
- \r
- messages_service_s *_svc = (messages_service_s *)service;\r
- \r
- CHECK_NULL(_svc);\r
- CHECK_NULL(_svc->service_h);\r
- CHECK_NULL(app_id);\r
- CHECK_NULL(callback);\r
- \r
- _cb = (messages_push_incoming_callback_s *)malloc(sizeof(messages_push_incoming_callback_s));\r
- if (NULL == _cb)\r
- {\r
- LOGE("[%s] OUT_OF_MEMORY(0x%08x) fail to create a '_cb'."\r
- , __FUNCTION__, MESSAGES_ERROR_OUT_OF_MEMORY);\r
- return MESSAGES_ERROR_OUT_OF_MEMORY; \r
- }\r
-\r
- _cb->app_id = strdup(app_id);\r
- _cb->callback = callback;\r
- _cb->user_data = user_data;\r
- \r
- ret = msg_reg_push_message_callback(_svc->service_h, _messages_push_incoming_mediator_cb, app_id, (void*)_cb);\r
- if (MSG_SUCCESS != ret)\r
- {\r
- if (_cb->app_id) {\r
- free(_cb->app_id);\r
- }\r
- free(_cb);\r
- return ERROR_CONVERT(ret);\r
- }\r
- \r
- _svc->push_incoming_cb_list = g_slist_append(_svc->push_incoming_cb_list, _cb);\r
- \r
- return MESSAGES_ERROR_NONE;\r
-}\r
-\r
-int messages_push_remove_incoming_cb(messages_service_h service, const char *app_id)\r
-{\r
- CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE);\r
-\r
- int i;\r
- messages_push_incoming_callback_s *_cb;\r
-\r
- messages_service_s *_svc = (messages_service_s *)service;\r
- \r
- CHECK_NULL(_svc);\r
- CHECK_NULL(_svc->service_h);\r
- CHECK_NULL(app_id);\r
- \r
- for (i=0; i < g_slist_length(_svc->push_incoming_cb_list); i++)\r
- {\r
- _cb = (messages_push_incoming_callback_s *)g_slist_nth_data(_svc->push_incoming_cb_list, i);\r
- if (NULL != _cb && NULL != _cb->app_id)\r
- {\r
- if (!strcmp(_cb->app_id, app_id)) { \r
- _cb->callback = NULL;\r
- }\r
- } \r
- }\r
- \r
- return MESSAGES_ERROR_NONE;\r
-}\r
-\r
-\r
-int messages_push_register(messages_service_h service, const char *content_type, const char *app_id)\r
-{\r
- CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE);\r
-\r
- int ret;\r
- \r
- msg_struct_t push_info;\r
- char *pkg_name;\r
- \r
- messages_service_s *_svc = (messages_service_s *)service;\r
-\r
- CHECK_NULL(_svc);\r
- CHECK_NULL(_svc->service_h);\r
- CHECK_NULL(content_type);\r
- CHECK_NULL(app_id);\r
- \r
- ret = app_get_id(&pkg_name);\r
- if (APP_ERROR_NONE != ret) {\r
- LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : app_get_id failed.",\r
- __FUNCTION__, __LINE__, MESSAGES_ERROR_OPERATION_FAILED);\r
- return MESSAGES_ERROR_OPERATION_FAILED; \r
- }\r
- \r
- push_info = msg_create_struct(MSG_STRUCT_PUSH_CONFIG_INFO);\r
- msg_set_str_value(push_info, MSG_PUSH_CONFIG_CONTENT_TYPE_STR, (char *)content_type, MAX_WAPPUSH_CONTENT_TYPE_LEN);\r
- msg_set_str_value(push_info, MSG_PUSH_CONFIG_APPLICATON_ID_STR, (char *)app_id, MAX_WAPPUSH_ID_LEN);\r
- msg_set_str_value(push_info, MSG_PUSH_CONFIG_PACKAGE_NAME_STR, pkg_name, MSG_FILEPATH_LEN_MAX);\r
- free(pkg_name);\r
- \r
- ret = msg_add_push_event(_svc->service_h, push_info); \r
- msg_release_struct(&push_info);\r
- if (MSG_SUCCESS != ret)\r
- {\r
- return ERROR_CONVERT(ret);\r
- }\r
- \r
- return MESSAGES_ERROR_NONE;\r
-}\r
-\r
-int messages_push_deregister(messages_service_h service, const char *content_type, const char *app_id)\r
-{\r
- CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE);\r
-\r
- int ret;\r
- \r
- msg_struct_t push_info;\r
- char *pkg_name;\r
- \r
- messages_service_s *_svc = (messages_service_s *)service;\r
- \r
- CHECK_NULL(_svc);\r
- CHECK_NULL(_svc->service_h);\r
- CHECK_NULL(content_type);\r
- CHECK_NULL(app_id);\r
- \r
- ret = app_get_id(&pkg_name);\r
- if (APP_ERROR_NONE != ret) {\r
- LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : app_get_id failed.",\r
- __FUNCTION__, __LINE__, MESSAGES_ERROR_OPERATION_FAILED);\r
- return MESSAGES_ERROR_OPERATION_FAILED; \r
- }\r
- \r
- push_info = msg_create_struct(MSG_STRUCT_PUSH_CONFIG_INFO);\r
- msg_set_str_value(push_info, MSG_PUSH_CONFIG_CONTENT_TYPE_STR, (char *)content_type, MAX_WAPPUSH_CONTENT_TYPE_LEN);\r
- msg_set_str_value(push_info, MSG_PUSH_CONFIG_APPLICATON_ID_STR, (char *)app_id, MAX_WAPPUSH_ID_LEN);\r
- msg_set_str_value(push_info, MSG_PUSH_CONFIG_PACKAGE_NAME_STR, pkg_name, MSG_FILEPATH_LEN_MAX);\r
- free(pkg_name);\r
- \r
- ret = msg_delete_push_event(_svc->service_h, push_info);\r
- msg_release_struct(&push_info);\r
- if (MSG_SUCCESS != ret)\r
- {\r
- return ERROR_CONVERT(ret);\r
- }\r
- \r
- return MESSAGES_ERROR_NONE;\r
-}\r
-\r
-int messages_push_reregister(messages_service_h service, const char *content_type, const char *app_id,\r
- const char *dst_content_type, const char *dst_app_id)\r
-{\r
- CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_FEATURE);\r
-\r
- int ret;\r
- \r
- msg_struct_t push_info;\r
- msg_struct_t dst_push_info;\r
- char *pkg_name;\r
- \r
- messages_service_s *_svc = (messages_service_s *)service;\r
- \r
- CHECK_NULL(_svc);\r
- CHECK_NULL(_svc->service_h);\r
- CHECK_NULL(content_type);\r
- CHECK_NULL(app_id);\r
- CHECK_NULL(dst_content_type);\r
- CHECK_NULL(dst_app_id);\r
- \r
- ret = app_get_id(&pkg_name);\r
- if (APP_ERROR_NONE != ret) {\r
- LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : app_get_id failed.",\r
- __FUNCTION__, __LINE__, MESSAGES_ERROR_OPERATION_FAILED);\r
- return MESSAGES_ERROR_OPERATION_FAILED; \r
- }\r
- \r
- push_info = msg_create_struct(MSG_STRUCT_PUSH_CONFIG_INFO);\r
- msg_set_str_value(push_info, MSG_PUSH_CONFIG_CONTENT_TYPE_STR, (char *)content_type, MAX_WAPPUSH_CONTENT_TYPE_LEN);\r
- msg_set_str_value(push_info, MSG_PUSH_CONFIG_APPLICATON_ID_STR, (char *)app_id, MAX_WAPPUSH_ID_LEN);\r
- msg_set_str_value(push_info, MSG_PUSH_CONFIG_PACKAGE_NAME_STR, pkg_name, MSG_FILEPATH_LEN_MAX);\r
- \r
- dst_push_info = msg_create_struct(MSG_STRUCT_PUSH_CONFIG_INFO);\r
- msg_set_str_value(dst_push_info, MSG_PUSH_CONFIG_CONTENT_TYPE_STR, (char *)dst_content_type, MAX_WAPPUSH_CONTENT_TYPE_LEN);\r
- msg_set_str_value(dst_push_info, MSG_PUSH_CONFIG_APPLICATON_ID_STR, (char *)dst_app_id, MAX_WAPPUSH_ID_LEN);\r
- msg_set_str_value(dst_push_info, MSG_PUSH_CONFIG_PACKAGE_NAME_STR, pkg_name, MSG_FILEPATH_LEN_MAX);\r
- free(pkg_name);\r
- \r
- ret = msg_update_push_event(_svc->service_h, push_info, dst_push_info);\r
- msg_release_struct(&push_info);\r
- msg_release_struct(&dst_push_info);\r
- if (MSG_SUCCESS != ret)\r
- {\r
- return ERROR_CONVERT(ret);\r
- }\r
- \r
- return MESSAGES_ERROR_NONE;\r
-}\r
-\r
-\r
-\r
+/*
+ * 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 <app.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_push_incoming_mediator_cb(msg_handle_t handle, const char *push_header, const char *push_body, int push_body_len, void *user_param)
+{
+ messages_push_incoming_callback_s *_cb = (messages_push_incoming_callback_s *)user_param;
+
+ if (_cb && _cb->callback)
+ {
+ ((messages_push_incoming_cb)_cb->callback)(push_header, push_body, push_body_len, _cb->user_data);
+ }
+}
+
+
+
+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_SMS_FEATURE);
+
+ int ret;
+ messages_push_incoming_callback_s *_cb;
+
+ messages_service_s *_svc = (messages_service_s *)service;
+
+ CHECK_NULL(_svc);
+ CHECK_NULL(_svc->service_h);
+ CHECK_NULL(app_id);
+ CHECK_NULL(callback);
+
+ _cb = (messages_push_incoming_callback_s *)malloc(sizeof(messages_push_incoming_callback_s));
+ if (NULL == _cb)
+ {
+ LOGE("[%s] OUT_OF_MEMORY(0x%08x) fail to create a '_cb'."
+ , __FUNCTION__, MESSAGES_ERROR_OUT_OF_MEMORY);
+ return MESSAGES_ERROR_OUT_OF_MEMORY;
+ }
+
+ _cb->app_id = strdup(app_id);
+ _cb->callback = callback;
+ _cb->user_data = user_data;
+
+ ret = msg_reg_push_message_callback(_svc->service_h, _messages_push_incoming_mediator_cb, app_id, (void*)_cb);
+ if (MSG_SUCCESS != ret)
+ {
+ if (_cb->app_id) {
+ free(_cb->app_id);
+ }
+ free(_cb);
+ return ERROR_CONVERT(ret);
+ }
+
+ _svc->push_incoming_cb_list = g_slist_append(_svc->push_incoming_cb_list, _cb);
+
+ return MESSAGES_ERROR_NONE;
+}
+
+int messages_push_remove_incoming_cb(messages_service_h service, const char *app_id)
+{
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE);
+
+ int i;
+ messages_push_incoming_callback_s *_cb;
+
+ messages_service_s *_svc = (messages_service_s *)service;
+
+ CHECK_NULL(_svc);
+ CHECK_NULL(_svc->service_h);
+ CHECK_NULL(app_id);
+
+ for (i=0; i < g_slist_length(_svc->push_incoming_cb_list); i++)
+ {
+ _cb = (messages_push_incoming_callback_s *)g_slist_nth_data(_svc->push_incoming_cb_list, i);
+ if (NULL != _cb && NULL != _cb->app_id)
+ {
+ if (!strcmp(_cb->app_id, app_id)) {
+ _cb->callback = NULL;
+ }
+ }
+ }
+
+ return MESSAGES_ERROR_NONE;
+}
+
+
+int messages_push_register(messages_service_h service, const char *content_type, const char *app_id)
+{
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE);
+
+ int ret;
+
+ msg_struct_t push_info;
+ char *pkg_name;
+
+ messages_service_s *_svc = (messages_service_s *)service;
+
+ CHECK_NULL(_svc);
+ CHECK_NULL(_svc->service_h);
+ CHECK_NULL(content_type);
+ CHECK_NULL(app_id);
+
+ ret = app_get_id(&pkg_name);
+ if (APP_ERROR_NONE != ret) {
+ LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : app_get_id failed.",
+ __FUNCTION__, __LINE__, MESSAGES_ERROR_OPERATION_FAILED);
+ return MESSAGES_ERROR_OPERATION_FAILED;
+ }
+
+ push_info = msg_create_struct(MSG_STRUCT_PUSH_CONFIG_INFO);
+ msg_set_str_value(push_info, MSG_PUSH_CONFIG_CONTENT_TYPE_STR, (char *)content_type, MAX_WAPPUSH_CONTENT_TYPE_LEN);
+ msg_set_str_value(push_info, MSG_PUSH_CONFIG_APPLICATON_ID_STR, (char *)app_id, MAX_WAPPUSH_ID_LEN);
+ msg_set_str_value(push_info, MSG_PUSH_CONFIG_PACKAGE_NAME_STR, pkg_name, MSG_FILEPATH_LEN_MAX);
+ free(pkg_name);
+
+ ret = msg_add_push_event(_svc->service_h, push_info);
+ msg_release_struct(&push_info);
+ if (MSG_SUCCESS != ret)
+ {
+ return ERROR_CONVERT(ret);
+ }
+
+ return MESSAGES_ERROR_NONE;
+}
+
+int messages_push_deregister(messages_service_h service, const char *content_type, const char *app_id)
+{
+ CHECK_MESSAGES_SUPPORTED(MESSAGES_TELEPHONY_SMS_FEATURE);
+
+ int ret;
+
+ msg_struct_t push_info;
+ char *pkg_name;
+
+ messages_service_s *_svc = (messages_service_s *)service;
+
+ CHECK_NULL(_svc);
+ CHECK_NULL(_svc->service_h);
+ CHECK_NULL(content_type);
+ CHECK_NULL(app_id);
+
+ ret = app_get_id(&pkg_name);
+ if (APP_ERROR_NONE != ret) {
+ LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : app_get_id failed.",
+ __FUNCTION__, __LINE__, MESSAGES_ERROR_OPERATION_FAILED);
+ return MESSAGES_ERROR_OPERATION_FAILED;
+ }
+
+ push_info = msg_create_struct(MSG_STRUCT_PUSH_CONFIG_INFO);
+ msg_set_str_value(push_info, MSG_PUSH_CONFIG_CONTENT_TYPE_STR, (char *)content_type, MAX_WAPPUSH_CONTENT_TYPE_LEN);
+ msg_set_str_value(push_info, MSG_PUSH_CONFIG_APPLICATON_ID_STR, (char *)app_id, MAX_WAPPUSH_ID_LEN);
+ msg_set_str_value(push_info, MSG_PUSH_CONFIG_PACKAGE_NAME_STR, pkg_name, MSG_FILEPATH_LEN_MAX);
+ free(pkg_name);
+
+ ret = msg_delete_push_event(_svc->service_h, push_info);
+ msg_release_struct(&push_info);
+ if (MSG_SUCCESS != ret)
+ {
+ return ERROR_CONVERT(ret);
+ }
+
+ return MESSAGES_ERROR_NONE;
+}
+
+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_SMS_FEATURE);
+
+ int ret;
+
+ msg_struct_t push_info;
+ msg_struct_t dst_push_info;
+ char *pkg_name;
+
+ messages_service_s *_svc = (messages_service_s *)service;
+
+ CHECK_NULL(_svc);
+ CHECK_NULL(_svc->service_h);
+ CHECK_NULL(content_type);
+ CHECK_NULL(app_id);
+ CHECK_NULL(dst_content_type);
+ CHECK_NULL(dst_app_id);
+
+ ret = app_get_id(&pkg_name);
+ if (APP_ERROR_NONE != ret) {
+ LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : app_get_id failed.",
+ __FUNCTION__, __LINE__, MESSAGES_ERROR_OPERATION_FAILED);
+ return MESSAGES_ERROR_OPERATION_FAILED;
+ }
+
+ push_info = msg_create_struct(MSG_STRUCT_PUSH_CONFIG_INFO);
+ msg_set_str_value(push_info, MSG_PUSH_CONFIG_CONTENT_TYPE_STR, (char *)content_type, MAX_WAPPUSH_CONTENT_TYPE_LEN);
+ msg_set_str_value(push_info, MSG_PUSH_CONFIG_APPLICATON_ID_STR, (char *)app_id, MAX_WAPPUSH_ID_LEN);
+ msg_set_str_value(push_info, MSG_PUSH_CONFIG_PACKAGE_NAME_STR, pkg_name, MSG_FILEPATH_LEN_MAX);
+
+ dst_push_info = msg_create_struct(MSG_STRUCT_PUSH_CONFIG_INFO);
+ msg_set_str_value(dst_push_info, MSG_PUSH_CONFIG_CONTENT_TYPE_STR, (char *)dst_content_type, MAX_WAPPUSH_CONTENT_TYPE_LEN);
+ msg_set_str_value(dst_push_info, MSG_PUSH_CONFIG_APPLICATON_ID_STR, (char *)dst_app_id, MAX_WAPPUSH_ID_LEN);
+ msg_set_str_value(dst_push_info, MSG_PUSH_CONFIG_PACKAGE_NAME_STR, pkg_name, MSG_FILEPATH_LEN_MAX);
+ free(pkg_name);
+
+ ret = msg_update_push_event(_svc->service_h, push_info, dst_push_info);
+ msg_release_struct(&push_info);
+ msg_release_struct(&dst_push_info);
+ if (MSG_SUCCESS != ret)
+ {
+ return ERROR_CONVERT(ret);
+ }
+
+ return MESSAGES_ERROR_NONE;
+}
#include <stdio.h>
#include <stdlib.h>
+#include <dlog.h>
#include <glib.h>
#define ERROR_CHECK(ret) \
if (MESSAGES_ERROR_NONE != ret) { \
- printf("%d: error, ret=%d \n", __LINE__, ret); \
- exit(1); \
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "%d: error, ret=%d \n", __LINE__, ret); \
+ return(0); \
}
static GMainLoop *mainloop;
int i, nAddr;
char *addr = NULL;
time_t time;
- struct tm *ptm;
+ struct tm ptm;
- printf("Incoming Message\n");
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Incoming Message\n");
messages_get_address_count(msg, &nAddr);
for (i=0; i < nAddr; i++) {
ret = messages_get_address(msg, i, &addr, NULL);
if (MESSAGES_ERROR_NONE == ret) {
- printf("Address[%d]: %s\n", i, addr);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Address[%d]: %s\n", i, addr);
free(addr);
}
}
ret = messages_get_text(msg, &text);
if (MESSAGES_ERROR_NONE == ret) {
- printf("Text: %s\n", text);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Text: %s\n", text);
free(text);
} else {
- printf("%d: error, ret=%d\n", __LINE__, ret);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "%d: error, ret=%d\n", __LINE__, ret);
}
messages_get_message_type(msg, &msgType);
switch(msgType) {
case MESSAGES_TYPE_SMS:
- printf("Type: SMS\n");
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Type: SMS\n");
break;
case MESSAGES_TYPE_MMS:
- printf("Type: MMS\n");
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Type: MMS\n");
break;
default:
- printf("Type: Unknown\n");
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Type: Unknown\n");
break;
}
messages_get_time(msg, &time);
- printf("Time: %d, %s", (int)time, ctime(&time));
-
- ptm = gmtime(&time);
- printf("gmtime test: %d.%d.%d %d:%d:%d \n",
- ptm->tm_year, ptm->tm_mon, ptm->tm_mday,
- ptm->tm_hour, ptm->tm_min, ptm->tm_sec
- );
-
-
+ char buf[50];
+ if (ctime_r(&time, buf))
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Time: %d, %s", (int)time, ctime_r(&time, buf));
+
+ gmtime_r(&time, &ptm);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "gmtime test: %d.%d.%d %d:%d:%d \n",
+ ptm.tm_year, ptm.tm_mon, ptm.tm_mday,
+ ptm.tm_hour, ptm.tm_min, ptm.tm_sec
+ );
}
int main(int argc, char *argv[])
#include <stdio.h>
#include <stdlib.h>
+#include <dlog.h>
#include <messages.h>
messages_get_message_type(msg, &msgType);
- printf("=[%d/%d]==================================\n", index + 1, result_count);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "=[%d/%d]==================================\n", index + 1, result_count);
messages_get_address_count(msg, &nAddr);
for (i=0; i < nAddr; i++) {
ret = messages_get_address(msg, i, &addr, NULL);
if (MESSAGES_ERROR_NONE == ret) {
- printf("Address[%d]: %s\n", i, addr);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Address[%d]: %s\n", i, addr);
free(addr);
}
}
ret = messages_get_text(msg, &text);
if (MESSAGES_ERROR_NONE == ret) {
- printf("Text: %s\n", text);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Text: %s\n", text);
free(text);
}
if (MESSAGES_TYPE_SMS == msgType) {
- printf("Type: SMS\n");
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Type: SMS\n");
} else if (MESSAGES_TYPE_MMS == msgType) {
- printf("Type: MMS\n");
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Type: MMS\n");
ret = messages_mms_get_subject(msg, &text);
if (MESSAGES_ERROR_NONE == ret) {
- printf("Subject: %s\n", text);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Subject: %s\n", text);
free(text);
}
ret = messages_mms_get_attachment_count(msg, &cnt);
if (MESSAGES_ERROR_NONE == ret) {
- printf("Attachments: %d\n", cnt);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Attachments: %d\n", cnt);
}
} else {
- printf("Type: Unknown");
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Type: Unknown");
}
ret = messages_get_time(msg, &time);
- printf("Time: %d, %s", (int)time, ctime(&time));
+ char buf[50];
+ if (ctime_r(&time, buf))
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Time: %d, %s", (int)time, ctime_r(&time, buf));
ret = messages_get_mbox_type(msg, &mbox);
- printf("MBOX: %d\n", mbox);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "MBOX: %d\n", mbox);
return true;
// open service
ret = messages_open_service(&svc);
if (MESSAGES_ERROR_NONE != ret) {
- printf("error: messages_open_service() = %d", ret);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "error: messages_open_service() = %d", ret);
return 1;
}
NULL, NULL,
0, 0, _search_cb, NULL);
if (MESSAGES_ERROR_NONE != ret) {
- printf("error: messages_foreach_message_from_db() = %d", ret);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "error: messages_foreach_message_from_db() = %d", ret);
return 1;
}
- printf("===============================================\n");
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "===============================================\n");
ret = messages_get_message_count(svc, MESSAGES_MBOX_INBOX, MESSAGES_TYPE_SMS, &count);
- printf("INBOX: %d messages\n", count);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "INBOX: %d messages\n", count);
ret = messages_get_message_count(svc, MESSAGES_MBOX_SENTBOX, MESSAGES_TYPE_SMS, &count);
- printf("SENTBOX: %d messages\n", count);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "SENTBOX: %d messages\n", count);
ret = messages_get_message_count(svc, MESSAGES_MBOX_OUTBOX, MESSAGES_TYPE_SMS, &count);
- printf("OUTBOX: %d sms messages\n", count);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "OUTBOX: %d sms messages\n", count);
ret = messages_get_message_count(svc, MESSAGES_MBOX_OUTBOX, MESSAGES_TYPE_MMS, &count);
- printf("OUTBOX: %d mms messages\n", count);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "OUTBOX: %d mms messages\n", count);
#include <stdio.h>
#include <stdlib.h>
+#include <dlog.h>
#include <glib.h>
void _sent_cb(messages_sending_result_e result, void *user_data)
{
- printf("sending result=%d\n", (int)result);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "sending result=%d\n", (int)result);
}
int main(int argc, char *argv[])
// open service
ret = messages_open_service(&svc);
if (MESSAGES_ERROR_NONE != ret) {
- printf("error: messages_open_service() = %d", ret);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "error: messages_open_service() = %d", ret);
return 1;
}
// create message
ret = messages_create_message(MESSAGES_TYPE_MMS, &msg);
if (MESSAGES_ERROR_NONE != ret) {
- printf("error: messages_create_message() = %d", ret);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "error: messages_create_message() = %d", ret);
return 1;
}
// messages_mms_add_attachment(msg, MESSAGES_MEDIA_IMAGE, "/opt/etc/msg-service/P091120_104633.jpg");
messages_mms_add_attachment(msg, MESSAGES_MEDIA_IMAGE, "/opt/media/Images/image2.jpg");
- printf("Before Sending\n");
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "Before Sending\n");
// send message
ret = messages_send_message(svc, msg, true, _sent_cb, NULL);
if (MESSAGES_ERROR_NONE != ret) {
- printf("error: messages_send_message() = %d", ret);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "error: messages_send_message() = %d", ret);
return 1;
}
#include <stdio.h>
#include <stdlib.h>
+#include <dlog.h>
#include <messages.h>
// open service
ret = messages_open_service(&svc);
if (MESSAGES_ERROR_NONE != ret) {
- printf("error: messages_open_service() = %d", ret);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "error: messages_open_service() = %d", ret);
return 1;
}
// create message
ret = messages_create_message(MESSAGES_TYPE_SMS, &msg);
if (MESSAGES_ERROR_NONE != ret) {
- printf("error: messages_create_message() = %d", ret);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "error: messages_create_message() = %d", ret);
return 1;
}
// send message
ret = messages_send_message(svc, msg, true, _sent_cb, NULL);
if (MESSAGES_ERROR_NONE != ret) {
- printf("error: messages_send_message() = %d", ret);
+ dlog_print(DLOG_DEBUG, "MESSAGE_TEST", "error: messages_send_message() = %d", ret);
return 1;
}