Fixed the invalid casting and remove the flash noti
[platform/core/messaging/email-service.git] / email-core / include / email-core-utils.h
1 /*
2 *  email-service
3 *
4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5 *
6 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
7
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */
21
22
23 /******************************************************************************
24  * File :  email-core-utils.h
25  * Desc :  Mail Utils Header
26  *
27  * Auth : 
28  *
29  * History : 
30  *    2006.08.16  :  created
31  *****************************************************************************/
32 #ifndef __EMAIL_CORE_UTILS_H__
33 #define __EMAIL_CORE_UTILS_H__
34
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif /* __cplusplus */
39
40 #include "email-types.h"
41 #include "email-internal-types.h"
42 #include "email-storage.h"
43 #include "email-core-global.h"
44 #include "email-core-mail.h"
45
46 /*  This is used for emcore_get_long_encoded_path */
47 #define EMAIL_CONNECT_FOR_SENDING       -1
48 #define ENCODED_PATH_SMTP       "UHDF_ENCODED_PATH_SMTP_EKJD"
49
50 typedef int (*email_get_unread_email_count_cb)(int unread, int *err_code);
51
52 /* parse the Full mailbox Path and get the Alias Name of the Mailbox */
53 char* emcore_get_alias_of_mailbox(const char *mailbox_path);
54
55 /* Parse the Mailbox Path and get the Account Email address */
56 INTERNAL_FUNC int   emcore_get_temp_file_name(char **filename, int *err_code);
57 int   emcore_get_long_encoded_path(char *multi_user_name, int account_id, char *path, int delimiter, char **long_enc_path, int *err_code);
58 int   emcore_get_encoded_mailbox_name(char *name, char **enc_name, int *err_code);
59 int   emcore_get_file_name(char *path, char **filename, int *err_code);
60 INTERNAL_FUNC int   emcore_get_file_size(char *path, int *size, int *err_code);
61 int   emcore_get_actual_mail_size(char *pBodyPlane, char *pBodyHtml, struct attachment_info *pAttachment, int *error_code);
62 int   emcore_calc_mail_size(char *multi_user_name, email_mail_data_t *mail_data_src, email_attachment_data_t *attachment_data_src, int attachment_count, int *error_code);
63 int   emcore_get_address_count(char *addr_str, int *to_num, int *err_code);
64 INTERNAL_FUNC int   emcore_is_storage_full();
65 int   emcore_get_long_encoded_path_with_account_info(char *multi_user_name, email_account_t *account, char *path, int delimiter, char **long_enc_path, int *err_code);
66 void  emcore_fill_address_information_of_mail_tbl(char *multi_user_name, emstorage_mail_tbl_t *mail_data);
67
68 INTERNAL_FUNC char* emcore_get_mail_field_name_by_attribute_type(email_mail_attribute_type input_attribute_type);
69 INTERNAL_FUNC int emcore_get_attribute_type_by_mail_field_name(char *input_mail_field_name, email_mail_attribute_type *output_mail_attribute_type);
70 INTERNAL_FUNC int emcore_get_mail_attribute_value_type(email_mail_attribute_type input_attribute_type, email_mail_attribute_value_type *output_value_type);
71 INTERNAL_FUNC int emcore_get_preview_text_from_file(char *multi_user_name, const char *input_plain_path, const char *input_html_path, int input_preview_buffer_length, char **output_preview_buffer);
72 #ifdef __FEATURE_BODY_SEARCH__
73 INTERNAL_FUNC int emcore_strip_mail_body_from_file(char *multi_user_name, emstorage_mail_tbl_t *mail, char **stripped_text, int *err_code);
74 #endif
75 INTERNAL_FUNC int emcore_get_first_address(const char *full_address, char **alias, char **address);
76
77
78 INTERNAL_FUNC int reg_replace (char *input_source_text, char *input_old_pattern_string, char *input_new_string);
79 INTERNAL_FUNC char *reg_replace_new (char *input_source_text, char *input_old_pattern_string, char *input_new_string);
80 int   emcore_strip_HTML_tag(const char *input_html_file_path, char *encoding_type, char *output_result_buffer, int input_result_buffer_legnth);
81 int   emcore_send_noti_for_new_mail(int account_id, char *mailbox_name, char *subject, char *from, char *uid, char *datetime);
82 int   emcore_make_attachment_file_name_with_extension(char *source_file_name, char *sub_type, char *result_file_name, int result_file_name_buffer_length, int *err_code);
83
84 /* Session Handling */
85 INTERNAL_FUNC int   emcore_get_empty_session(email_session_t **session);
86 INTERNAL_FUNC int   emcore_clear_session(email_session_t *session);
87 INTERNAL_FUNC int   emcore_get_current_session(email_session_t **session);
88
89 INTERNAL_FUNC int emcore_get_mail_count_by_query(char *multi_user_name, int account_id, int mailbox_type, int priority_sender, int *total_mail, int *unread_mail, int *err_code);
90
91 INTERNAL_FUNC int emcore_check_drm_file(char *path, int *err_code);
92 INTERNAL_FUNC int emcore_check_drm_is_ringtone(char *ringtone_path, int *err_code);
93
94 INTERNAL_FUNC void emcore_display_unread_in_badge(void *data);
95 INTERNAL_FUNC int emcore_display_badge_count(char *multi_user_name, int count);
96 INTERNAL_FUNC int emcore_set_network_error(int err_code);
97
98 INTERNAL_FUNC int emcore_calc_next_time_to_sync(char *multi_user_name, int input_account_id, time_t input_current_time, time_t *output_time);
99
100 /* Transaction Handling */
101 INTERNAL_FUNC int emcore_add_transaction_info(int mail_id , int handle  , int *err_code);
102 INTERNAL_FUNC int emcore_get_handle_by_mailId_from_transaction_info(int mail_id , int *pHandle);
103 INTERNAL_FUNC int emcore_delete_transaction_info_by_mailId(int mail_id);
104
105 /* For notification bar */
106 INTERNAL_FUNC int emcore_update_notification_for_unread_mail(int account_id);
107 INTERNAL_FUNC int emcore_clear_notifications(char *multi_user_name, int account_id);
108 //INTERNAL_FUNC int emcore_add_notification_for_unread_mail(emstorage_mail_tbl_t *input_mail_tbl_data);
109 INTERNAL_FUNC int emcore_add_notification(char *multi_user_name, int account_id, int mail_id, int unread_mail_count, int vip_unread_mail_count, int input_play_alert_tone, int sending_error, unsigned long display);
110 INTERNAL_FUNC int emcore_add_notification_for_send(char *multi_user_name, int account_id, int mail_id, email_action_t action, int sending_error, unsigned long display);
111 INTERNAL_FUNC void emcore_update_notification_for_send(int account_id, int mail_id, double progress);
112 INTERNAL_FUNC int emcore_delete_notification_for_read_mail(int mail_id);
113 INTERNAL_FUNC int emcore_delete_notification_by_account(char *multi_user_name, int account_id, int with_noti_tray);
114
115 INTERNAL_FUNC int emcore_show_user_message(char *multi_user_name, int id, email_action_t action, int error);
116
117 INTERNAL_FUNC int emcore_connect_contacts_service(char *multi_user_name);
118 INTERNAL_FUNC int emcore_disconnect_contacts_service(char *multi_user_name);
119
120 #ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
121
122 /**
123  * @fn emcore_convert_to_uid_range_set(email_id_set_t *id_set, int id_set_count, email_uid_range_set **uid_range_set, int range_len, int *err_code)
124  * Prepare a linked list of uid ranges with each node having a uid_range and lowest and highest uid in it.
125  *
126  *@author                                       h.gahlaut@samsung.com
127  * @param[in] id_set                    Specifies the array of mail_id and corresponding server_mail_id sorted by server_mail_ids in ascending order
128  * @param[in] id_set_count              Specifies the no. of cells in id_set array i.e. no. of sets of mail_ids and server_mail_ids
129  * @param[in] range_len         Specifies the maximum length of string of range allowed. 
130  * @param[out] uid_range_set    Returns the uid_ranges formed in the form of a linked list with head stored in uid_range_set pointer
131  * @param[out] err_code         Returns the error code.
132  * @remarks                                     An example of a uid_range formed is 2 : 6, 8, 10, 14 : 15, 89, 
133  *                                                      While using it the caller should remove the ending , (comma)                                    
134  * @return This function returns true on success or false on failure.
135  */
136  
137 INTERNAL_FUNC int emcore_convert_to_uid_range_set(email_id_set_t *id_set, int id_set_count, email_uid_range_set **uid_range_set, int range_len, int *err_code);
138
139 /**
140  * void emcore_free_uid_range_set(email_uid_range_set **uid_range_head)
141  * Frees the linked list of uid ranges 
142  *
143  * @author                                      h.gahlaut@samsung.com
144  * @param[in] uid_range_head    Head pointer of linked list of uid ranges               
145  * @remarks                                                                     
146  * @return This function does not return anything.
147  */
148 INTERNAL_FUNC void emcore_free_uid_range_set(email_uid_range_set **uid_range_set);
149
150 /**
151  * @fn emcore_append_subset_string_to_uid_range(char *subset_string, email_uid_range_set **uid_range_set, int range_len, unsigned long luid, unsigned long huid)
152  * Appends the subset_string to uid range if the uid range has not exceeded maximum length(range_len), otherwise creates a new node in linked list of uid range set 
153  * and stores the subset_string in its uid_range. Also sets the lowest and highest uids for the corresponsing uid_range
154  * 
155  * @author                                      h.gahlaut@samsung.com
156  * @param[in] subset_string             Specifies the subset string to be appended. A subset string can be like X : Y or X where X and Y are uids.
157  * @param[in] range_len         Specifies the maximum length of range string allowed. 
158  * @param[in] luid                              Specifies the lowest uid in subset string
159  * @param[in] huid                              Specifies the highest uid in subset string
160  * @param[out] uid_range_set    Returns the uid_ranges formed in the form of a linked list with head stored in uid_range_set pointer
161  * @param[out] err_code         Returns the error code.
162  * @remarks                                                                             
163  * @return This function returns true on success or false on failure.
164  */
165  
166 int emcore_append_subset_string_to_uid_range(char *subset_string, email_uid_range_set **current_node_adr, email_uid_range_set **uid_range_set, int range_len, unsigned long luid, unsigned long huid);
167
168 /**
169  * @fn emcore_form_comma_separated_strings(int numbers[], int num_count, int max_string_len, char ***strings, int *string_count, int *err_code)
170  * Forms comma separated strings of a give max_string_len from an array of numbers 
171  * 
172  * @author                                      h.gahlaut@samsung.com
173  * @param[in] numbers                   Specifies the array of numbers to be converted into comma separated strings.
174  * @param[in] num_count         Specifies the count of numbers in numbers array. 
175  * @param[in] max_string_len    Specifies the maximum length of comma separated strings that are to be formed.
176  * @param[out] strings                  Returns the base address of a double dimension array which stores the strings.
177  * @param[out] string_count             Returns the number of strings formed.
178  * @param[out] err_code         Returns the error code.
179  * @remarks                                     If Input to the function is five numbers like 2755 2754 2748 2749 2750 and a given max_string_len is 20.
180  *                                                      Then this function will form two comma separated strings as follows -
181  *                                                      "2755, 2754, 2748"
182  *                                                      "2749, 2750"
183  * @return This function returns true on success or false on failure.
184  */
185 INTERNAL_FUNC int emcore_form_comma_separated_strings(int numbers[], int num_count, int max_string_len, char ***strings, int *string_count, int *err_code);
186
187 /**
188  * @fn emcore_free_comma_separated_strings(char ***string_list, int *string_count)
189  * Frees the double dimensional array of strings. 
190  *
191  * @author                                      h.gahlaut@samsung.com
192  * @param[in] uid_range_head    Address of base address of double dimensional array of strings.
193  * @param[in] string_count              Address of variable holding the count of strings.
194  * @remarks                                                                     
195  * @return This function does not return anything.
196  */
197
198 INTERNAL_FUNC void emcore_free_comma_separated_strings(char ***string_list, int *string_count);
199
200 #endif
201
202 #ifdef __FEATURE_LOCAL_ACTIVITY__
203 /*  Added to get next activity id sequence */
204 INTERNAL_FUNC int emcore_get_next_activity_id(int *activity_id, int *err_code);
205 INTERNAL_FUNC int emcore_add_activity(emstorage_activity_tbl_t *new_activity, int *err_code);
206 INTERNAL_FUNC int emcore_delete_activity(emstorage_activity_tbl_t *activity, int *err_code);
207 #endif /* __FEATURE_LOCAL_ACTIVITY__ */
208
209 INTERNAL_FUNC void emcore_free_rule(email_rule_t* rule);
210 INTERNAL_FUNC void emcore_free_body_sparep(void **p);
211
212 INTERNAL_FUNC int emcore_search_string_from_file(char *file_path, char *search_string, char *new_string, int *result);
213
214 INTERNAL_FUNC int emcore_load_query_from_file(char *file_path, char ***query_array, int *array_len);
215
216 #ifdef __FEATURE_DRIVING_MODE__
217 INTERNAL_FUNC int emcore_start_driving_mode(char *multi_user_name, int mail_id);
218 #endif /* __FEATURE_DRIVING_MODE__ */
219
220 #ifdef __FEATURE_BLOCKING_MODE__
221 INTERNAL_FUNC bool emcore_init_blocking_mode_status();
222 INTERNAL_FUNC void emcore_set_blocking_mode_of_setting(int input_blocking_mode_of_setting);
223 INTERNAL_FUNC int emcore_get_blocking_mode_status();
224 INTERNAL_FUNC void emcore_set_blocking_mode_status(int blocking_mode);
225 INTERNAL_FUNC int emcore_check_blocking_mode(char *multi_user_name, char *sender_address, int *blocking_status);
226 INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *multi_user_name, char *sender_address, int *blocking_status);
227 #endif /* __FEATURE_BLOCKING_MODE__ */
228
229 INTERNAL_FUNC char *emcore_set_mime_entity(char *mime_path);
230 INTERNAL_FUNC int emcore_get_content_from_file(char *filename, char **contents, int *length);
231 INTERNAL_FUNC int emcore_set_content_to_file(const char *contents, char *dest_path, int length);
232
233 #ifdef __FEATURE_UPDATE_DB_TABLE_SCHEMA__
234 INTERNAL_FUNC int emcore_update_db_table_schema(char *multi_user_name);
235 #endif /* #ifdef __FEATURE_UPDATE_DB_TABLE_SCHEMA__ */
236 INTERNAL_FUNC int emcore_unescape_from_url(char *input_url, char **output_url);
237 INTERNAL_FUNC char *__em_get_month_in_string(int month);
238 INTERNAL_FUNC int emcore_make_date_string_for_search(time_t input_time, char *output_date_string);
239 INTERNAL_FUNC int emcore_make_uid_range_string(emcore_uid_list *uid_list, int total, char **output_uid_range_string);
240
241 #ifdef __cplusplus
242 }
243 #endif /* __cplusplus */
244
245 #endif /* __EMAIL_CORE_UTILS_H__ */