tizen 2.3.1 release
[framework/api/messages.git] / include / messages_private.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __TIZEN_MESSAGING_PRIVATE_H__
18 #define __TIZEN_MESSAGING_PRIVATE_H__
19
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24
25 #include <system_info.h>
26
27 typedef struct _messages_service_s {
28         msg_handle_t service_h;
29         void*        incoming_cb;
30         void*        incoming_cb_user_data;
31         bool         incoming_cb_enabled;
32         GSList*      sent_cb_list;
33         GSList*      push_incoming_cb_list;
34 } messages_service_s;
35
36 typedef struct _messages_message_s {
37         msg_struct_t msg_h;
38         char*        text;
39         GSList*      attachment_list;
40 } messages_message_s;
41
42 typedef struct _messages_attachment_s {
43     int          media_type;
44     char         filepath[MSG_FILEPATH_LEN_MAX +1];
45 } messages_attachment_s;
46
47 typedef struct _messages_sent_callback_s {
48         int          req_id;
49         void*        callback;
50         void*        user_data;
51 } messages_sent_callback_s;
52
53 typedef struct _messages_push_incoming_callback_s {
54         char*        app_id;
55         void*        callback;
56         void*        user_data;
57 } messages_push_incoming_callback_s;
58
59 #define MESSAGES_PRIVILEGE_READ                 "http://tizen.org/privilege/message.read"
60 #define MESSAGES_PRIVILEGE_WRITE                "http://tizen.org/privilege/message.write"
61
62 #define MESSAGES_TELEPHONY_FEATURE       "http://tizen.org/feature/network.telephony"
63 #define MESSAGES_TELEPHONY_MMS_FEATURE   "http://tizen.org/feature/network.telephony.mms"
64
65 #define ERROR_CONVERT(err) _messages_error_converter(err, __FUNCTION__, __LINE__);
66 #define CHECK_NULL(p) \
67         if (NULL == p) { \
68                 LOGE("[%s] INVALID_PARAMETER(0x%08x) %s is null.", \
69                         __FUNCTION__, MESSAGES_ERROR_INVALID_PARAMETER, #p); \
70                 return MESSAGES_ERROR_INVALID_PARAMETER; \
71         }
72
73 #define IS_SMS(x) ((x & MESSAGES_TYPE_SMS) == MESSAGES_TYPE_SMS)
74 #define IS_MMS(x) ((x & MESSAGES_TYPE_MMS) == MESSAGES_TYPE_MMS)
75
76 #define CHECK_MESSAGES_SUPPORTED(feature_name) \
77         do { \
78                 bool is_supported = false; \
79                 if (!system_info_get_platform_bool(feature_name, &is_supported)) { \
80                         if (is_supported == false) { \
81                                 LOGE("[%s] feature is disabled", feature_name); \
82                                 return MESSAGES_ERROR_NOT_SUPPORTED; \
83                         } \
84                 } else { \
85                         LOGE("Error - Feature getting from System Info"); \
86                         return MESSAGES_ERROR_OPERATION_FAILED; \
87                 } \
88         } while(0)
89
90 int _messages_convert_mbox_to_fw(messages_message_box_e mbox);
91 int _messages_convert_msgtype_to_fw(messages_message_type_e type);
92 int _messages_convert_recipient_to_fw(messages_recipient_type_e type);
93 int _messages_error_converter(int err, const char *func, int line);
94
95 #ifdef __cplusplus
96 }
97 #endif
98
99 #endif /* __TIZEN_MESSAGING_PRIVATE_H__ */