2.0_alpha release commit
[framework/messaging/email-service.git] / email-core / include / email-core-utils.h
1 /*
2 *  email-service
3 *
4 * Copyright (c) 2000 - 2011 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 int   emcore_get_temp_file_name(char **filename, int *err_code);
57 int   emcore_get_long_encoded_path(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 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(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 int   emcore_is_storage_full(int *error);
65 int   emcore_get_long_encoded_path_with_account_info(email_account_t *account, char *path, int delimiter, char **long_enc_path, int *err_code);
66 void  emcore_fill_address_information_of_mail_tbl(emstorage_mail_tbl_t *mail_data);
67
68
69 int   emcore_get_preview_text_from_file(const char *input_plain_path, const char *input_html_path, int input_preview_buffer_length, char **output_preview_buffer);
70 int   reg_replace (char *input_source_text, char *input_old_pattern_string, char *input_new_string);
71 int   emcore_strip_HTML(char *source_string);
72 int   emcore_send_noti_for_new_mail(int account_id, char *mailbox_name, char *subject, char *from, char *uid, char *datetime);
73 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);
74
75 /* Session Handling */
76 int   emcore_get_empty_session(email_session_t **session);
77 int   emcore_clear_session(email_session_t *session);
78 int   emcore_get_current_session(email_session_t **session);
79
80 INTERNAL_FUNC email_option_t *emcore_get_option(int *err_code);
81 INTERNAL_FUNC int emcore_set_option(email_option_t *opt, int *err_code);
82
83 INTERNAL_FUNC int emcore_check_unread_mail();
84 INTERNAL_FUNC int emcore_set_network_error(int err_code);
85
86 /* Transaction Handling */
87 INTERNAL_FUNC int emcore_add_transaction_info(int mail_id , int handle  , int *err_code);
88 INTERNAL_FUNC int emcore_get_handle_by_mailId_from_transaction_info(int mail_id , int *pHandle);
89 INTERNAL_FUNC int emcore_delete_transaction_info_by_mailId(int mail_id);
90
91 /* For notification bar */
92 INTERNAL_FUNC int emcore_update_notification_for_unread_mail(int account_id);
93 INTERNAL_FUNC int emcore_clear_all_notifications();
94 INTERNAL_FUNC int emcore_add_notification_for_unread_mail(emstorage_mail_tbl_t *input_mail_tbl_data);
95 INTERNAL_FUNC int emcore_delete_notification_for_read_mail(int mail_id);
96 INTERNAL_FUNC int emcore_delete_notification_by_account(int account_id);
97 INTERNAL_FUNC int emcore_finalize_sync(int account_id, int *error);
98
99 INTERNAL_FUNC int emcore_show_user_message(int id, email_action_t action, int error);
100
101 #ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
102
103 /**
104  * @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)
105  * Prepare a linked list of uid ranges with each node having a uid_range and lowest and highest uid in it.
106  *
107  *@author                                       h.gahlaut@samsung.com
108  * @param[in] id_set                    Specifies the array of mail_id and corresponding server_mail_id sorted by server_mail_ids in ascending order
109  * @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
110  * @param[in] range_len         Specifies the maximum length of string of range allowed. 
111  * @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
112  * @param[out] err_code         Returns the error code.
113  * @remarks                                     An example of a uid_range formed is 2 : 6, 8, 10, 14 : 15, 89, 
114  *                                                      While using it the caller should remove the ending , (comma)                                    
115  * @return This function returns true on success or false on failure.
116  */
117  
118 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);
119
120 /**
121  * void emcore_free_uid_range_set(email_uid_range_set **uid_range_head)
122  * Frees the linked list of uid ranges 
123  *
124  * @author                                      h.gahlaut@samsung.com
125  * @param[in] uid_range_head    Head pointer of linked list of uid ranges               
126  * @remarks                                                                     
127  * @return This function does not return anything.
128  */
129 INTERNAL_FUNC void emcore_free_uid_range_set(email_uid_range_set **uid_range_set);
130
131 /**
132  * @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)
133  * 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 
134  * and stores the subset_string in its uid_range. Also sets the lowest and highest uids for the corresponsing uid_range
135  * 
136  * @author                                      h.gahlaut@samsung.com
137  * @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.
138  * @param[in] range_len         Specifies the maximum length of range string allowed. 
139  * @param[in] luid                              Specifies the lowest uid in subset string
140  * @param[in] huid                              Specifies the highest uid in subset string
141  * @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
142  * @param[out] err_code         Returns the error code.
143  * @remarks                                                                             
144  * @return This function returns true on success or false on failure.
145  */
146  
147 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);
148
149 /**
150  * @fn emcore_form_comma_separated_strings(int numbers[], int num_count, int max_string_len, char ***strings, int *string_count, int *err_code)
151  * Forms comma separated strings of a give max_string_len from an array of numbers 
152  * 
153  * @author                                      h.gahlaut@samsung.com
154  * @param[in] numbers                   Specifies the array of numbers to be converted into comma separated strings.
155  * @param[in] num_count         Specifies the count of numbers in numbers array. 
156  * @param[in] max_string_len    Specifies the maximum length of comma separated strings that are to be formed.
157  * @param[out] strings                  Returns the base address of a double dimension array which stores the strings.
158  * @param[out] string_count             Returns the number of strings formed.
159  * @param[out] err_code         Returns the error code.
160  * @remarks                                     If Input to the function is five numbers like 2755 2754 2748 2749 2750 and a given max_string_len is 20.
161  *                                                      Then this function will form two comma separated strings as follows -
162  *                                                      "2755, 2754, 2748"
163  *                                                      "2749, 2750"
164  * @return This function returns true on success or false on failure.
165  */
166 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);
167
168 /**
169  * @fn emcore_free_comma_separated_strings(char ***string_list, int *string_count)
170  * Frees the double dimensional array of strings. 
171  *
172  * @author                                      h.gahlaut@samsung.com
173  * @param[in] uid_range_head    Address of base address of double dimensional array of strings.
174  * @param[in] string_count              Address of variable holding the count of strings.
175  * @remarks                                                                     
176  * @return This function does not return anything.
177  */
178
179 INTERNAL_FUNC void emcore_free_comma_separated_strings(char ***string_list, int *string_count);
180
181 #endif
182
183 #ifdef __FEATURE_LOCAL_ACTIVITY__
184 /*  Added to get next activity id sequence */
185 INTERNAL_FUNC int emcore_get_next_activity_id(int *activity_id, int *err_code);
186 INTERNAL_FUNC int emcore_add_activity(emstorage_activity_tbl_t *new_activity, int *err_code);
187 INTERNAL_FUNC int emcore_delete_activity(emstorage_activity_tbl_t *activity, int *err_code);
188 #endif /* __FEATURE_LOCAL_ACTIVITY__ */
189
190 INTERNAL_FUNC void emcore_free_rule(email_rule_t* rule);
191
192
193 #ifdef __cplusplus
194 }
195 #endif /* __cplusplus */
196
197 #endif /* __EMAIL_CORE_UTILS_H__ */