6fa8d2ad98a7b0a6014a640894e69b67ab02a714
[apps/core/preloaded/email.git] / composer / include / email-composer-type.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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 __DEF_email_composer_type_H_
18 #define __DEF_email_composer_type_H_
19
20 #include <stdio.h>
21 #include <string.h>
22 #include <stdbool.h>
23 #include <glib-object.h>
24 #include <Elementary.h>
25 #include <Evas.h>
26 #include <Edje.h>
27 #include <Eina.h>
28 #include <E_DBus.h>
29 #include <Efreet_Mime.h>
30 #include <Ecore_IMF.h>
31 #include <Ecore_File.h>
32 #include <vconf.h>
33 #include <email-api.h>
34
35 #include "email-debug.h"
36
37 #define MYFILE_IMGE_PATH "/usr/apps/org.tizen.myfile/res/images"
38 #define UG_MYFILE_PATH DIR_DEFAULT_MEDIA_PHONE
39 #define COMPOSER_EDJ_NAME EDJDIR"/email-composer-view.edj"
40
41 #define EMAIL_TMP_FOLDER DIR_TMP_PREFIX"/email"
42 #define EMAIL_TMP_FOLDER_PERMISSION 0755
43 #define SAVE_HTML_FILE_NAME "mail.html"
44 #define SAVE_URI EMAIL_TMP_FOLDER"/mail.txt"
45 #define THUMBNAIL_SIZE 80
46
47 #define COMPOSER_ORINGIN_HTML_STR N_("Original mail.htm")
48
49 #define MAX_STR_LEN                             1024
50
51 #define MAX_ACCOUNT                             10
52 #define MAX_ACCOUNT_NAME_LEN            64
53
54 #define MAX_RECIPIENT_ADDRESS_LEN       234
55 #define MAX_RECIPIENT_COUNT             100
56 #define MAX_RECIPIENT_ADDRESSES_LEN     (MAX_RECIPIENT_ADDRESS_LEN * MAX_RECIPIENT_COUNT)
57 #define MAX_SUBJECT_LEN                 1024
58
59 #define MAX_BODY_SIZE                           32763
60 #define MAX_ATTACHMENT_ITEM             100
61 #define MAX_ATTACHMENT_SIZE             50 * 1024 * 1024
62 #define MAX_ATTACHMENT_FILE_LEN 1024
63
64 #define CONV_THUMB_WIDTH        250
65 #define CONV_THUMB_HEIGHT 170
66
67 #define ATTACHMENT_MEDIA_FOLDER_NAME    "media"
68 #define ATTACHMENT_MMC_FOLDER_NAME      "storage"
69
70 #define ATTACHMENT_MEDIA_IMAGE          "image"
71 #define ATTACHMENT_MEDIA_VIDEO          "video"
72 #define ATTACHMENT_MEDIA_AUDIO          "audio"
73 #define ATTACHMENT_MEDIA_VCARD          "vcf"
74 #define ATTACHMENT_MEDIA_VCALENDAR      "vcs"
75
76 #define ATTACHMENT_IMAGE_FILE_PATH              IMGDIR"/composer_attachment_image.png"
77 #define ATTACHMENT_AUDIO_FILE_PATH              IMGDIR"/composer_attachment_sound.png"
78 #define ATTACHMENT_VIDEO_FILE_PATH              IMGDIR"/composer_attachment_video.png"
79 #define ATTACHMENT_ETC_FILE_PATH                IMGDIR"/composer_attachment_etc.png"
80 #define ATTACHMENT_VCARD_FILE_PATH              IMGDIR"/composer_attachment_vcard.png"
81 #define ATTACHMENT_VCALENDAR_FILE_PATH          IMGDIR"/composer_attachment_vcalender.png"
82
83 #define EMAIL_THEME_TIZEN_BLACK         "tizen-black"
84 #define EMAIL_THEME_TIZEN_BLACK_HD              "tizen-black-hd"
85 #define EMAIL_THEME_TIZEN_WHITE         "tizen"
86 #define EMAIL_THEME_TIZEN_WHITE_HD              "tizen-hd"
87
88 typedef struct {
89         gchar email_addr[MAX_RECIPIENT_ADDRESS_LEN];    /* Specific email address of recipient */
90         int email_type;
91 } EmailList;
92
93 typedef struct {
94         int selected_email_idx;
95         int email_cnt;
96         bool is_contact_info;
97         bool is_always_bcc;
98         bool is_from_addr;
99         gchar *display_name;    /* Specific display name of recipient */
100         EmailList email_list[MAX_RECIPIENT_COUNT];
101 } EmailRecpInfo;
102
103 typedef enum {
104         EMAIL_THEME_BLACK,
105         EMAIL_THEME_WHITE,
106         EMAIL_THEME_MAX
107 } EmailThemeType;
108
109 typedef enum {
110         EMAIL_COMPOSER_LAUNCH_INLINE_IMAGE,
111         EMAIL_COMPOSER_LAUNCH_GALLERY,
112         EMAIL_COMPOSER_LAUNCH_TAKE_PHOTO,
113         EMAIL_COMPOSER_LAUNCH_RECORD_VIDEO,
114         EMAIL_COMPOSER_LAUNCH_VOICE_RECORDER,
115         EMAIL_COMPOSER_LAUNCH_FILE,
116         EMAIL_COMPOSER_LAUNCH_NAMECARD,
117         EMAIL_COMPOSER_LAUNCH_CALENDAR,
118         EMAIL_COMPOSER_LAUNCH_MEMO,
119         EMAIL_COMPOSER_LAUNCH_MESSAGE_COMPOSER,
120         EMAIL_COMPOSER_LAUNCH_MAX,
121 } EmailComposerLaunchType;
122
123 typedef enum {
124         COMPOSER_ATTACHMENT_ITEM_IMAGE,
125         COMPOSER_ATTACHMENT_ITEM_SOUND,
126         COMPOSER_ATTACHMENT_ITEM_VIDEO,
127         COMPOSER_ATTACHMENT_ITEM_ETC,
128 } EmailComposerAttachmentType;
129
130 typedef enum {
131         COMPOSER_ERROR_NONE = 0,
132
133         COMPOSER_ERROR_FAIL = -1,
134         COMPOSER_ERROR_SEND_FAIL = -2,
135         COMPOSER_ERROR_NULL_POINTER = -3,
136         COMPOSER_ERROR_INVALID_ARG = -4,
137         COMPOSER_ERROR_SERVICE_INIT_FAIL = -5,
138
139         COMPOSER_ERROR_NO_DEFAULT_ACCOUNT = -6,
140         COMPOSER_ERROR_NO_ACCOUNT = -7,
141         COMPOSER_ERROR_NO_ACCOUNT_LIST = -8,
142         COMPOSER_ERROR_INVALID_FILE = -9,
143         COMPOSER_ERROR_INVALID_FILE_SIZE = -10,
144         COMPOSER_ERROR_ETHUMB_FAIL = -11,
145
146         COMPOSER_ERROR_GET_DATA_FAIL = -12,
147         COMPOSER_ERROR_MAKE_MAIL_FAIL= -13,
148         COMPOSER_ERROR_UNKOWN_TYPE = -14,
149         COMPOSER_ERROR_DBUS_FAIL = -15,
150         COMPOSER_ERROR_RECIPIENT_DUPLICATED = -16,
151         COMPOSER_ERROR_ENGINE_INIT_FAILED = -17,
152         COMPOSER_ERROR_STORAGE_FULL = -18,
153 } COMPOSER_ERROR_TYPE_E;
154
155 typedef enum {
156         COMPOSER_FOCUS_STATUS_NONE = 1 << 0,
157         COMPOSER_FOCUS_STATUS_SELECTED = 1 << 1,
158         COMPOSER_FOCUS_STATUS_ON_PAUSE = 1 << 2,
159         COMPOSER_FOCUS_STATUS_MAX = 1 << 3,
160 } COMPOSER_FOCUS_STATUS_TYPE;
161
162 typedef struct _EmailComposerAccount EmailComposerAccount;
163 typedef struct _EmailComposerMailbox EmailComposerMailbox;
164 typedef struct _EmailComposerMail EmailComposerMail;
165
166 struct _EmailComposerAccount {
167         int account_id;
168         int account_count;
169         int account_type;
170         char *account_name;
171         Evas_Object *account_rdg;
172         Evas_Object *account_rd[MAX_ACCOUNT];
173         email_account_t *account_list;
174         email_account_t *account;
175 };
176
177 struct _EmailComposerMailbox {
178         int mailbox_id;
179         email_mailbox_t *mail_box;
180 };
181
182 struct _EmailComposerMail {
183         email_mail_data_t *mail_data;
184         email_attachment_data_t *attachment_list;
185 };
186
187 typedef struct {
188         int storage_type;       /* the storage_type */
189         int contact_index;      /* the contact_index */
190         int phone_index;        /* the phone_index */
191         char name[256];         /* the name */
192         char phone_number[41];  /* the phone_number */
193         char email[129];        /* the default_email */
194 } contactui_info_t;
195
196 #undef STR_VALID
197 #define STR_VALID(str) \
198                 ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
199
200 #undef STR_INVALID
201 #define STR_INVALID(str) \
202                 ((str == NULL || strlen(str) == 0) ? TRUE : FALSE)
203
204 #undef STR_LEN
205 #define STR_LEN(str)    ({ char *s = str; (s) ? strlen(s) : 0; })
206
207 #undef STR_CMP
208 #define STR_CMP(s1, s2) \
209                 (((s1) == NULL || (s2) == NULL) ? FALSE : (g_ascii_strcasecmp(s1, s2) == 0 ? TRUE : FALSE))
210
211 #undef STR_CMP0
212 #define STR_CMP0(s1, s2) \
213                 (g_strcmp0(s1, s2) == 0 ? TRUE : FALSE)
214
215 #undef STR_NCMP
216 #define STR_NCMP(s1, s2, n) \
217                 (g_ascii_strncasecmp(s1, s2, (gsize)n) == 0 ? TRUE : FALSE)
218
219 #undef STR_CPY
220 #define STR_CPY(dest, src) \
221                 g_stpcpy(dest, src)
222
223 #undef STR_NCPY
224 #define STR_NCPY(dest, src, n) \
225                 strncpy(dest, src, n)
226
227 #undef STR_LCPY
228 #define STR_LCPY(dest, src, n) \
229                 g_strlcpy(dest, src, n)
230
231 #undef STR_CAT
232 #define STR_CAT(dest, src) \
233                 strcat(dest, src)
234
235 #undef STR_NCAT
236 #define STR_NCAT(dest, src, n) \
237                 strncat(dest, src, n)
238
239 #undef STR_LCAT
240 #define STR_LCAT(dest, src, n) \
241                 g_strlcat(dest, src, n)
242
243 #endif                          /* __DEF_email_composer_type_H__ */