4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 /******************************************************************************
24 * File : email-core-utils.h
25 * Desc : Mail Utils Header
30 * 2006.08.16 : created
31 *****************************************************************************/
32 #ifndef __EMAIL_CORE_UTILS_H__
33 #define __EMAIL_CORE_UTILS_H__
38 #endif /* __cplusplus */
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"
46 /* This is used for emcore_get_long_encoded_path */
47 #define ENCODED_PATH_SMTP "UHDF_ENCODED_PATH_SMTP_EKJD"
49 typedef int (*emf_get_unread_email_count_cb)(int unread, int *err_code);
51 /* parse the Full mailbox Path and get the Alias Name of the Mailbox */
52 char* emcore_get_alias_of_mailbox(const char *mailbox_path);
54 /* Parse the Mailbox Path and get the Account Email address */
55 int emcore_get_temp_file_name(char **filename, int *err_code);
56 int emcore_get_long_encoded_path(int account_id, char *path, int delimiter, char **long_enc_path, int *err_code);
57 int emcore_get_encoded_mailbox_name(char *name, char **enc_name, int *err_code);
58 int emcore_get_file_name(char *path, char **filename, int *err_code);
59 int emcore_get_file_size(char *path, int *size, int *err_code);
60 int emcore_get_actual_mail_size(char *pBodyPlane, char *pBodyHtml, struct attachment_info *pAttachment, int *error_code);
61 int emcore_calc_mail_size(emf_mail_data_t *mail_data_src, emf_attachment_data_t *attachment_data_src, int attachment_count, int *error_code);
62 int emcore_get_address_count(char *addr_str, int *to_num, int *err_code);
63 int emcore_is_storage_full(int *error);
64 int emcore_show_popup(int id, emf_action_t action, int error);
65 int emcore_get_long_encoded_path_with_account_info(emf_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);
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 emcore_strip_HTML(char *source_string);
71 int emcore_send_noti_for_new_mail(int account_id, char *mailbox_name, char *subject, char *from, char *uid, char *datetime);
72 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 /* Session Handling */
75 int emcore_get_empty_session(emf_session_t **session);
76 int emcore_clear_session(emf_session_t *session);
77 int emcore_get_current_session(emf_session_t **session);
79 INTERNAL_FUNC emf_option_t *emcore_get_option(int *err_code);
80 INTERNAL_FUNC int emcore_set_option(emf_option_t *opt, int *err_code);
82 INTERNAL_FUNC int emcore_check_unread_mail();
83 INTERNAL_FUNC int emcore_set_network_error(int err_code);
85 /* Transaction Handling */
86 INTERNAL_FUNC int emcore_add_transaction_info(int mail_id , int handle , int *err_code);
87 INTERNAL_FUNC int emcore_get_handle_by_mailId_from_transaction_info(int mail_id , int *pHandle);
88 INTERNAL_FUNC int emcore_delete_transaction_info_by_mailId(int mail_id);
90 /* For notification bar */
91 INTERNAL_FUNC int emcore_update_notification_for_unread_mail(int account_id);
92 INTERNAL_FUNC int emcore_clear_all_notifications();
93 INTERNAL_FUNC int emcore_add_notification_for_unread_mail(emstorage_mail_tbl_t *input_mail_tbl_data);
94 INTERNAL_FUNC int emcore_delete_notification_for_read_mail(int mail_id);
95 INTERNAL_FUNC int emcore_delete_notification_by_account(int account_id);
96 INTERNAL_FUNC int emcore_finalize_sync(int account_id, int *error);
100 #ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
103 * @fn emcore_convert_to_uid_range_set(emf_id_set_t *id_set, int id_set_count, emf_uid_range_set **uid_range_set, int range_len, int *err_code)
104 * Prepare a linked list of uid ranges with each node having a uid_range and lowest and highest uid in it.
106 *@author h.gahlaut@samsung.com
107 * @param[in] id_set Specifies the array of mail_id and corresponding server_mail_id sorted by server_mail_ids in ascending order
108 * @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
109 * @param[in] range_len Specifies the maximum length of string of range allowed.
110 * @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
111 * @param[out] err_code Returns the error code.
112 * @remarks An example of a uid_range formed is 2 : 6, 8, 10, 14 : 15, 89,
113 * While using it the caller should remove the ending , (comma)
114 * @return This function returns true on success or false on failure.
117 INTERNAL_FUNC int emcore_convert_to_uid_range_set(emf_id_set_t *id_set, int id_set_count, emf_uid_range_set **uid_range_set, int range_len, int *err_code);
120 * void emcore_free_uid_range_set(emf_uid_range_set **uid_range_head)
121 * Frees the linked list of uid ranges
123 * @author h.gahlaut@samsung.com
124 * @param[in] uid_range_head Head pointer of linked list of uid ranges
126 * @return This function does not return anything.
128 INTERNAL_FUNC void emcore_free_uid_range_set(emf_uid_range_set **uid_range_set);
131 * @fn emcore_append_subset_string_to_uid_range(char *subset_string, emf_uid_range_set **uid_range_set, int range_len, unsigned long luid, unsigned long huid)
132 * 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
133 * and stores the subset_string in its uid_range. Also sets the lowest and highest uids for the corresponsing uid_range
135 * @author h.gahlaut@samsung.com
136 * @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.
137 * @param[in] range_len Specifies the maximum length of range string allowed.
138 * @param[in] luid Specifies the lowest uid in subset string
139 * @param[in] huid Specifies the highest uid in subset string
140 * @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
141 * @param[out] err_code Returns the error code.
143 * @return This function returns true on success or false on failure.
146 int emcore_append_subset_string_to_uid_range(char *subset_string, emf_uid_range_set **current_node_adr, emf_uid_range_set **uid_range_set, int range_len, unsigned long luid, unsigned long huid);
149 * @fn emcore_form_comma_separated_strings(int numbers[], int num_count, int max_string_len, char ***strings, int *string_count, int *err_code)
150 * Forms comma separated strings of a give max_string_len from an array of numbers
152 * @author h.gahlaut@samsung.com
153 * @param[in] numbers Specifies the array of numbers to be converted into comma separated strings.
154 * @param[in] num_count Specifies the count of numbers in numbers array.
155 * @param[in] max_string_len Specifies the maximum length of comma separated strings that are to be formed.
156 * @param[out] strings Returns the base address of a double dimension array which stores the strings.
157 * @param[out] string_count Returns the number of strings formed.
158 * @param[out] err_code Returns the error code.
159 * @remarks If Input to the function is five numbers like 2755 2754 2748 2749 2750 and a given max_string_len is 20.
160 * Then this function will form two comma separated strings as follows -
163 * @return This function returns true on success or false on failure.
165 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);
168 * @fn emcore_free_comma_separated_strings(char ***string_list, int *string_count)
169 * Frees the double dimensional array of strings.
171 * @author h.gahlaut@samsung.com
172 * @param[in] uid_range_head Address of base address of double dimensional array of strings.
173 * @param[in] string_count Address of variable holding the count of strings.
175 * @return This function does not return anything.
178 INTERNAL_FUNC void emcore_free_comma_separated_strings(char ***string_list, int *string_count);
182 #ifdef __FEATURE_LOCAL_ACTIVITY__
183 /* Added to get next activity id sequence */
184 INTERNAL_FUNC int emcore_get_next_activity_id(int *activity_id, int *err_code);
185 INTERNAL_FUNC int emcore_add_activity(emstorage_activity_tbl_t *new_activity, int *err_code);
186 INTERNAL_FUNC int emcore_delete_activity(emstorage_activity_tbl_t *activity, int *err_code);
187 #endif /* __FEATURE_LOCAL_ACTIVITY__ */
191 #endif /* __cplusplus */
193 #endif /* __EMAIL_CORE_UTILS_H__ */