modify msg-service to support dpm feature
[platform/core/messaging/msg-service.git] / include / utils / MsgUtilFunction.h
1 /*
2  * Copyright (c) 2014 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 MSG_UTIL_FUNCTION_H
18 #define MSG_UTIL_FUNCTION_H
19
20 #define MSG_UTIL_CH_EMAIL_AT    '@'
21
22 /*==================================================================================================
23                                                                                         INCLUDE FILES
24 ==================================================================================================*/
25 #include "MsgStorageTypes.h"
26 #include "MsgSettingTypes.h"
27 #include "MsgFilterTypes.h"
28 #include "MsgInternalTypes.h"
29 #include "MsgCmdTypes.h"
30
31 #include <bundle.h>
32
33 /*==================================================================================================
34                                                                                         DEFINES
35 ==================================================================================================*/
36
37 #define MSG_TYPE_CHECK(a, b) \
38         do {\
39                 if (a != (b & 0xff00)) {\
40                         return MSG_ERR_INVALID_PARAMETER; \
41                 } \
42         } while (0)
43
44 /*==================================================================================================
45                                                                         FUNCTION PROTOTYPES
46 ==================================================================================================*/
47
48 bool MsgCheckFeatureSupport(const char *feature_name);
49
50 int MsgContactGetMinMatchDigit();
51
52 /* Encoders */
53 int MsgEncodeCountInfo(MSG_COUNT_INFO_S *pCountInfo, char **ppDest);
54
55 int MsgEncodeCountByMsgType(int MsgCount, char **ppDest);
56
57 int MsgEncodeRecipientList(MSG_RECIPIENTS_LIST_S *pRecipientList, char **ppDest);
58
59 int MsgEncodeMsgId(msg_message_id_t *pMsgId, char **ppDest);
60
61 int MsgEncodeMsgInfo(const MSG_MESSAGE_INFO_S *pMsgInfo, char **ppDest);
62
63 int MsgEncodeMsgInfo(MSG_MESSAGE_INFO_S *pMsgInfo,  MSG_SENDINGOPT_INFO_S* pSendOptInfo, char **ppDest);
64
65 int MsgEncodeFolderViewList(msg_struct_list_s *pFolderViewList, char **ppDest);
66
67 int MsgEncodeFolderList(msg_struct_list_s *pFolderList, char **ppDest);
68
69 int MsgEncodeSetting(MSG_SETTING_S *pSetting, char **ppDest);
70
71 int MsgEncodeFilterList(msg_struct_list_s *pFilterList, char **ppDest);
72
73 int MsgEncodeFilterFlag(bool *pSetFlag, char **ppDest);
74
75 int MsgEncodeThreadViewList(msg_struct_list_s *pThreadViewList, char **ppDest);
76
77 int MsgEncodeConversationViewList(msg_struct_list_s *pConvViewList, char **ppDest);
78
79 int MsgEncodeMsgGetContactCount(MSG_THREAD_COUNT_INFO_S *threadCountInfo, char **ppDest);
80
81 int MsgEncodeMemSize(unsigned int *memsize, char **ppDest);
82
83 int MsgEncodeSyncMLOperationData(int msgId, int extId, char **ppDest);
84
85 int MsgEncodeStorageChangeData(const msg_storage_change_type_t storageChangeType, const msg_id_list_s *pMsgIdList, char **ppDest);
86
87 int MsgEncodeReportMsgData(const msg_report_type_t msgReportType, const MSG_MESSAGE_INFO_S *pMsgInfo, char **ppDest);
88
89 int MsgEncodeReportStatus(MSG_REPORT_STATUS_INFO_S* pReportStatus, int count, char **ppDest);
90
91 int MsgEncodeThreadId(msg_thread_id_t *pThreadId, char **ppDest);
92
93 int MsgEncodeThreadInfo(MSG_THREAD_VIEW_S *pThreadInfo, char **ppDest);
94
95
96 /* Decoders */
97 void MsgDecodeMsgId(char *pSrc, msg_message_id_t *pMsgId);
98
99 void MsgDecodeCountInfo(char *pSrc, MSG_COUNT_INFO_S *pCountInfo);
100
101 void MsgDecodeMsgInfo(char *pSrc, MSG_MESSAGE_INFO_S *pMsgInfo);
102
103 void MsgDecodeMsgInfo(char *pSrc, MSG_MESSAGE_INFO_S *pMsgInfo,  MSG_SENDINGOPT_INFO_S* pSendOptInfo);
104
105 void MsgDecodeFolderViewList(char *pSrc, msg_struct_list_s *pFolderViewList);
106
107 void MsgDecodeRecipientList(char *pSrc, MSG_RECIPIENTS_LIST_S *pRecipientList);
108
109 void MsgDecodeFolderList(char *pSrc, msg_struct_list_s *pFolderList);
110
111 void MsgDecodeSetting(char *pSrc, MSG_SETTING_S *pSetting);
112
113 void MsgDecodeFilterList(char *pSrc, msg_struct_list_s *pFilterList);
114
115 void MsgDecodeFilterFlag(char *pSrc, bool *pSetFlag);
116
117 void MsgDecodeMsgType(char *pSrc, MSG_MESSAGE_TYPE_S* pMsgType);
118
119 void MsgDecodeContactCount(char *pSrc,  MSG_THREAD_COUNT_INFO_S *pMsgThreadCountList);
120
121 void MsgDecodeMemSize(char *pSrc, unsigned int *memsize);
122
123 void MsgDecodeReportStatus(char *pSrc,  msg_struct_list_s *report_list);
124
125 void MsgDecodeThreadId(char *pSrc, msg_thread_id_t *pThreadId);
126
127 void MsgDecodeThreadInfo(char *pSrc, MSG_THREAD_VIEW_S *pThreadInfo);
128
129
130 /* Event Encoder */
131 int MsgMakeEvent(const void *pData, int DataSize, MSG_EVENT_TYPE_T MsgEvent, msg_error_t MsgError, void **ppEvent);
132
133
134 /* Util functions */
135 int msg_verify_number(const char *raw, char *trimmed);
136
137 int msg_verify_email(const char *raw);
138
139 char* msg_clean_country_code(char *src);
140
141 char* msg_normalize_number(char *src);
142
143 char *getTranslateText(const char *pkg_name, const char *locale_dir, const char *text);
144
145 msg_error_t MsgMakeSortRule(const MSG_SORT_RULE_S *pSortRule, char *pSqlSort);
146
147 bool msg_is_valid_email(char *pAddress);
148
149 msg_error_t msg_write_text_to_msg_info(MSG_MESSAGE_INFO_S *pMsgInfo, char *text);
150
151 void msg_replace_available_file_name(char *fileName);
152
153 void msg_replace_space_char(char *pszText);
154
155 gchar * msg_replace_non_ascii_char(const gchar *pszText, gunichar replacementChar);
156
157 uid_t msg_get_login_user();
158
159 msg_error_t msg_launch_app(const char *app_id, bundle *bundle_data);
160
161 msg_error_t msg_aul_svc_set_operation(bundle *bundle_data, const char *operation);
162
163 msg_error_t msg_aul_svc_set_uri(bundle *bundle_data, char *uri);
164
165 void msg_init_dpm_policy();
166
167 void msg_deinit_dpm_policy();
168
169 bool msg_check_dpm_policy(int type);
170
171 #endif /* MSG_UTIL_FUNCTION_H */