Delete draft messages before saving draft message
[apps/home/message-app.git] / composer / src / message / msg-ui-composer-message.c
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://floralicense.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
18 /* includes*/
19 #include "msg-ui-composer-subject.h"
20 #include "msg-ui-composer-util.h"
21 #include "msg-ui-composer-body.h"
22 #include "msg-ui-composer-message.h"
23 #include "msg-ui-composer-message-data.h"
24 #include "msg-ui-composer-attachment.h"
25 #include "msg-ui-composer-common.h"
26 #include "msg-ui-composer-recipient.h"
27 #include "msg-ui-composer-popup.h"
28
29 #include <glib-object.h>
30 #include <glib.h>
31
32 /* defines */
33 #define MSG_DATA_TEMPPATH       DATADIR "/"
34
35 #define MSG_COMPOSER_SMIL_SCREEN_WIDTH  480
36 #define MSG_COMPOSER_SMIL_SCREEN_HEIGHT 800
37
38 #define MSG_COMPOSER_SMIL_POS_TOP               1
39 #define MSG_COMPOSER_SMIL_POS_BOTTOM    50
40 #define MSG_COMPOSER_SMIL_POS_LEFT              0
41
42 #define MSG_COMPOSER_SMIL_REGION_WIDTH  100
43 #define MSG_COMPOSER_SMIL_REGION_HEIGHT 50
44
45 #define MSG_COMPOSER_SMIL_DEFAULT_BGCOLOR 0xFFFFFF
46 #define MSG_COMPOSER_SMIL_DEFAULT_FONT_COLOR 0x000000
47 #define MSG_COMPOSER_SMIL_DEFAULT_FONT_SIZE 30
48 #define MSG_COMPOSER_SMIL_DEFAULT_BOLD false
49 #define MSG_COMPOSER_SMIL_DEFAULT_UNDERLINE false
50
51
52
53 /* globals */
54 static MSG_COMP_MSG_DATA_S *msg_data = NULL;
55
56 /* function defines*/
57
58 /****************************************************
59  *
60  *      UI HANDLING
61  *
62  *****************************************************/
63
64 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_init()
65 {
66         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
67
68         if (msg_data != NULL) {
69                 free(msg_data);
70                 msg_data = NULL;
71         }
72
73         msg_data = (MSG_COMP_MSG_DATA_S *)calloc(1, sizeof(MSG_COMP_MSG_DATA_S));
74
75         if (msg_data == NULL) {
76                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] msg_data calloc error");
77                 return COMPOSER_RETURN_FAIL;
78         }
79
80         memset(msg_data, 0x00, sizeof(MSG_COMP_MSG_DATA_S));
81
82         return COMPOSER_RETURN_SUCCESS;
83 }
84
85 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_destroy()
86 {
87         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
88
89         if (msg_data == NULL) {
90                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] msg_data is already NULL");
91                 return COMPOSER_RETURN_FAIL;
92         }
93         /* free recipient data */
94         if (msg_data->recp_list != NULL) {
95                 g_slist_foreach(msg_data->recp_list, (GFunc) free, NULL);
96                 g_slist_free(msg_data->recp_list);
97                 msg_data->recp_list = NULL;
98         }
99         /* free sms data. */
100         if (msg_data->sms_data.body_text != NULL) {
101                 free(msg_data->sms_data.body_text);
102                 msg_data->sms_data.body_text = NULL;
103         }
104
105         free(msg_data);
106         msg_data = NULL;
107
108         return COMPOSER_RETURN_SUCCESS;
109 }
110
111 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_add_address(char *number)
112 {
113         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
114
115         if (number == NULL) {
116                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] argument [number] is NULL !!");
117                 return COMPOSER_RETURN_FAIL;
118         }
119
120         char *address = strdup(number);
121         msg_data->recp_list = g_slist_append(msg_data->recp_list, (void *)address);
122
123         return COMPOSER_RETURN_SUCCESS;
124 }
125
126 GSList *msg_ui_composer_message_get_address(void)
127 {
128         D_ENTER;
129         D_MSG_RETVM_IF(msg_data == NULL, NULL, "msg_data is NULL. need to init");
130
131         return msg_data->recp_list;
132 }
133
134 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_set_msg_type(COMPOSER_MSG_TYPE_E msg_type)
135 {
136         if (!msg_data) {
137                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] msg_data is NULL. need to init");
138                 return COMPOSER_RETURN_NULL_POINTER;
139         }
140
141         msg_data->msg_type = msg_type;
142
143         return COMPOSER_RETURN_SUCCESS;
144 }
145
146 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_set_sms_body(char *body_text)
147 {
148         if (body_text == NULL) {
149                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] argument [body_text] is NULL !!");
150                 return COMPOSER_RETURN_FAIL;
151         }
152
153         msg_data->sms_data.body_text = strdup(body_text);
154         msg_data->sms_data.body_length = strlen(body_text);
155
156         return COMPOSER_RETURN_SUCCESS;
157 }
158
159 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_set_subject(char *subject, int length)
160 {
161         D_ENTER;
162         if (msg_data == NULL || subject == NULL) {
163                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] message data is NULL or no subject");
164                 return COMPOSER_RETURN_FAIL;
165         }
166
167         if (subject && length > 0)
168                 msg_data->mms_data.isSubject = true;
169
170         if (length <= sizeof(msg_data->mms_data.subject))
171                 strncpy(msg_data->mms_data.subject, subject, length);
172         else
173                 strncpy(msg_data->mms_data.subject, subject, sizeof(msg_data->mms_data.subject)-1);
174
175         D_LEAVE;
176         return COMPOSER_RETURN_SUCCESS;
177 }
178
179 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_set_attach_count(int attach_count)
180 {
181         D_ENTER;
182
183         if (!msg_data) {
184                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] msg_data is NULL");
185                 return COMPOSER_RETURN_NULL_POINTER;
186         }
187
188         MSG_COMP_MMS_DATA_S *mms_data = &msg_data->mms_data;
189
190         mms_data->attach_count = attach_count;
191
192         D_LEAVE;
193         return COMPOSER_RETURN_SUCCESS;
194 }
195
196 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_add_attachments(const char *filepath, int filetype)
197 {
198         D_ENTER;
199         D_MSG_RETVM_IF(ecore_file_exists(filepath) == EINA_FALSE, COMPOSER_RETURN_FAIL,"File is NOT exist");
200
201         if (!msg_data) {
202                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] msg_data is NULL");
203                 return COMPOSER_RETURN_NULL_POINTER;
204         }
205
206         MSG_COMP_MMS_DATA_S *mms_data = &msg_data->mms_data;
207         int attach_count = mms_data->attach_count;
208
209         int i = 0;
210         for (i = 0; i < attach_count; i++) {
211                 if (strlen(mms_data->attachlist[i].filepath) <= 0) {
212                         mms_data->attachlist[i].filetype = filetype;
213
214                         strncpy(mms_data->attachlist[i].filepath, filepath, strlen(filepath));
215                         MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] attachment file path : [%s]", mms_data->attachlist[i].filepath);
216                         break;
217                 }
218         }
219
220         D_LEAVE;
221         return COMPOSER_RETURN_SUCCESS;
222 }
223
224 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_set_page_count(int page_count)
225 {
226         D_ENTER;
227
228         if (!msg_data) {
229                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] message data is not exist");
230                 return COMPOSER_RETURN_NULL_POINTER;
231         }
232
233         msg_data->mms_data.page_count = page_count;
234
235         D_LEAVE;
236         return COMPOSER_RETURN_SUCCESS;
237 }
238
239 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_set_is_text_top(bool isTextTop)
240 {
241         D_ENTER;
242
243         if (!msg_data) {
244                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] message data is not exist");
245                 return COMPOSER_RETURN_NULL_POINTER;
246         }
247
248         msg_data->mms_data.isTextTop = isTextTop;
249
250         D_LEAVE;
251         return COMPOSER_RETURN_SUCCESS;
252 }
253
254 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_mms_set_text(const char *text, int nPage)
255 {
256         D_ENTER;
257
258         if (!msg_data) {
259                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] message data is not exist !!");
260                 return COMPOSER_RETURN_NULL_POINTER;
261         }
262
263         MSG_COMP_MMS_DATA_S *mms_data = &msg_data->mms_data;
264         int text_len = 0;
265
266         if (text)
267                 text_len = strlen(text);
268
269         if (text && text_len > 0) {
270                 mms_data->pagelist[nPage].isText = true;
271
272                 if (text_len <= COMPOSER_MMS_TEXT_MAX_BYTE)
273                         strncpy(mms_data->pagelist[nPage].body_text, text, text_len);
274                 else
275                         strncpy(mms_data->pagelist[nPage].body_text, text, COMPOSER_MMS_TEXT_MAX_BYTE);
276         } else {
277                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] no text");
278                 mms_data->pagelist[nPage].isText = false;
279                 return COMPOSER_RETURN_FAIL;
280         }
281
282         D_LEAVE;
283         return COMPOSER_RETURN_SUCCESS;
284 }
285
286 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_mms_set_page_duration(int nPage, int duration)
287 {
288         D_ENTER;
289
290         if (!msg_data) {
291                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] message data is NOT exist");
292                 return COMPOSER_RETURN_NULL_POINTER;
293         }
294
295         if (nPage >= COMPOSER_MMS_MAX_PAGE) {
296                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] Invalid nPage index");
297                 return COMPOSER_RETURN_FAIL;
298         }
299
300         MSG_COMP_MMS_DATA_S *mms_data = &msg_data->mms_data;
301
302         if (duration > COMPOSER_PAGE_DEFAULT_DURATION)
303                 mms_data->pagelist[nPage].page_duration = duration;
304
305
306         D_LEAVE;
307         return COMPOSER_RETURN_SUCCESS;
308 }
309
310 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_mms_set_media(const char *file_path, COMPOSER_MEDIA_TYPE_E media_type, int nPage)
311 {
312         D_ENTER;
313         D_MSG_RETVM_IF(ecore_file_exists(file_path) == EINA_FALSE, COMPOSER_RETURN_FAIL, "File is NOT exist");
314
315         if (!msg_data) {
316                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] message data is NOT exist");
317                 return COMPOSER_RETURN_NULL_POINTER;
318         }
319
320         MSG_COMP_MMS_DATA_S *mms_data = &msg_data->mms_data;
321
322         if (!file_path) {
323                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] No file path");
324                 return COMPOSER_RETURN_FAIL;
325         }
326
327         switch (media_type) {
328         case COMPOSER_MEDIA_TYPE_IMAGE:
329                 mms_data->pagelist[nPage].isImage = true;
330                 strncpy(mms_data->pagelist[nPage].image_file_path, file_path, strlen(file_path));
331                 break;
332
333         case COMPOSER_MEDIA_TYPE_VIDEO:
334                 mms_data->pagelist[nPage].isVideo = true;
335                 strncpy(mms_data->pagelist[nPage].image_file_path, file_path, strlen(file_path));
336                 break;
337
338         case COMPOSER_MEDIA_TYPE_AUDIO:
339                 mms_data->pagelist[nPage].isSound = true;
340                 strncpy(mms_data->pagelist[nPage].sound_file_path, file_path, strlen(file_path));
341                 break;
342
343         default:
344                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] invalid media type");
345                 return COMPOSER_RETURN_INVALID_MEDIA_TYPE;
346         }
347
348         D_LEAVE;
349         return COMPOSER_RETURN_SUCCESS;
350 }
351
352 /*****************************************************
353  *
354  *       Framework message Handling
355  *
356  *******************************************************/
357
358 static COMPOSER_RETURN_TYPE_E __msg_ui_composer_set_recipient()
359 {
360         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
361
362         if (msg_data == NULL || msg_data->msgInfo == NULL) {
363                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] msgInfo is NULL !!");
364                 return COMPOSER_RETURN_FAIL;
365         }
366
367         int count = g_slist_length(msg_data->recp_list);
368         int i = 0;
369         msg_struct_list_s *addr_list = NULL;
370
371         msg_get_list_handle(msg_data->msgInfo, MSG_MESSAGE_ADDR_LIST_STRUCT, (void**)&addr_list);
372
373         addr_list->nCount = count;
374         for (i = 0; i < count; i++) {
375                 char *address = (char *)g_slist_nth_data(msg_data->recp_list, i);
376                 if (address == NULL) {
377                         MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] address is value NULL, skip");
378                         continue;
379                 }
380
381                 int addr_type = get_address_type((const char*)address);
382                 if (addr_type == COMPOSER_UTIL_ADDRTYPE_NUMBER)
383                         msg_set_int_value(addr_list->msg_struct_info[i], MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MSG_ADDRESS_TYPE_PLMN);
384                 else if (addr_type == COMPOSER_UTIL_ADDRTYPE_EMAIL)
385                         msg_set_int_value(addr_list->msg_struct_info[i], MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MSG_ADDRESS_TYPE_EMAIL);
386                 msg_set_int_value(addr_list->msg_struct_info[i], MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MSG_RECIPIENTS_TYPE_TO);
387                 msg_set_str_value(addr_list->msg_struct_info[i], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, address, strlen(address));
388         }
389
390         return COMPOSER_RETURN_SUCCESS;
391 }
392
393 COMPOSER_RETURN_TYPE_E msg_ui_composer_create_new_message()
394 {
395         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
396
397         if (msg_data->msgInfo != NULL) {
398                 msg_release_struct(&msg_data->msgInfo);
399                 msg_data->msgInfo = NULL;
400         }
401
402         msg_data->msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
403
404         if (msg_data->msgInfo == NULL) {
405                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] msg_create_struct failed");
406                 return COMPOSER_RETURN_FAIL;
407         }
408
409         return COMPOSER_RETURN_SUCCESS;
410 }
411
412 COMPOSER_RETURN_TYPE_E msg_ui_composer_release_message()
413 {
414         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
415
416         if (msg_data->msgInfo == NULL) {
417                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] msgInfo is already destroyed !!");
418                 return COMPOSER_RETURN_FAIL;
419         }
420
421         if (msg_release_struct(&msg_data->msgInfo) != MSG_SUCCESS) {
422                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] msgInfo is already destroyed !!");
423                 return COMPOSER_RETURN_FAIL;
424         }
425
426         return COMPOSER_RETURN_SUCCESS;
427 }
428
429 static COMPOSER_RETURN_TYPE_E __msg_ui_composer_make_sms_message(msg_handle_t msg_handle, int msg_id)
430 {
431         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
432
433         if (msg_data == NULL || msg_data->msgInfo == NULL) {
434                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] msgInfo is NULL !!");
435                 return COMPOSER_RETURN_FAIL;
436         }
437
438         int err = MSG_SUCCESS;
439
440         /* set msgid */
441         if (msg_id) {
442                 D_MSG("msg_id = %d", msg_id);
443                 if (msg_set_int_value(msg_data->msgInfo, MSG_MESSAGE_ID_INT, msg_id) != MSG_SUCCESS) {
444                         MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] set msgId error");
445                 }
446         }
447
448         /* set message type to SMS */
449         if (msg_set_int_value(msg_data->msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS) != MSG_SUCCESS) {
450                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT]msg_ui_comp_core_set_message_type error !!");
451                 return COMPOSER_RETURN_FAIL;
452         }
453         /* set message body text */
454         if (msg_data->sms_data.body_text)
455                 err = msg_set_str_value(msg_data->msgInfo, MSG_MESSAGE_SMS_DATA_STR, msg_data->sms_data.body_text, strlen(msg_data->sms_data.body_text));
456         else
457                 err = msg_set_str_value(msg_data->msgInfo, MSG_MESSAGE_SMS_DATA_STR, NULL, 0);
458
459         if (err != MSG_SUCCESS) {
460                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT]msg_ui_comp_core_set_sms_body error !!");
461                 return COMPOSER_RETURN_FAIL;
462         }
463         /* set recipient */
464         if (__msg_ui_composer_set_recipient(msg_data) != COMPOSER_RETURN_SUCCESS) {
465                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT]__msg_ui_composer_set_recipient error !!");
466                 return COMPOSER_RETURN_FAIL;
467         }
468
469         return COMPOSER_RETURN_SUCCESS;
470 }
471
472 static COMPOSER_RETURN_TYPE_E __msg_ui_composer_make_smil_header(msg_handle_t msg_handle, msg_struct_t mms_data, bool isTextTop)
473 {
474         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
475
476         if (!mms_data) {
477                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] msg_data is NULL");
478                 return COMPOSER_RETURN_FAIL;
479         }
480
481         msg_struct_t text_region = NULL;
482         msg_struct_t image_region = NULL;
483
484         /************  make rootlayout ***************/
485         msg_set_int_value(mms_data, MSG_MMS_ROOTLAYOUT_WIDTH_INT, MSG_COMPOSER_SMIL_SCREEN_WIDTH);
486         msg_set_int_value(mms_data, MSG_MMS_ROOTLAYOUT_HEIGHT_INT, MSG_COMPOSER_SMIL_SCREEN_HEIGHT);
487         msg_set_int_value(mms_data, MSG_MMS_ROOTLAYOUT_BGCOLOR_INT, MSG_COMPOSER_SMIL_DEFAULT_BGCOLOR);
488
489         /************ make region ********************/
490         /* 1. add text region */
491         msg_mms_add_item(mms_data, MSG_STRUCT_MMS_REGION, &text_region);
492         msg_set_str_value(text_region, MSG_MMS_REGION_ID_STR, "Text", strlen("Text"));
493         msg_set_int_value(text_region, MSG_MMS_REGION_LENGTH_LEFT_INT, MSG_COMPOSER_SMIL_POS_LEFT);
494
495         if (isTextTop)
496                 msg_set_int_value(text_region, MSG_MMS_REGION_LENGTH_TOP_INT, MSG_COMPOSER_SMIL_POS_TOP);
497         else
498                 msg_set_int_value(text_region, MSG_MMS_REGION_LENGTH_TOP_INT, MSG_COMPOSER_SMIL_POS_BOTTOM);
499
500         msg_set_int_value(text_region, MSG_MMS_REGION_LENGTH_WIDTH_INT, MSG_COMPOSER_SMIL_REGION_WIDTH);
501         msg_set_int_value(text_region, MSG_MMS_REGION_LENGTH_HEIGHT_INT, MSG_COMPOSER_SMIL_REGION_HEIGHT);
502         msg_set_int_value(text_region, MSG_MMS_REGION_BGCOLOR_INT, MSG_COMPOSER_SMIL_DEFAULT_BGCOLOR);
503
504         /* 2. image(video) region */
505         msg_mms_add_item(mms_data, MSG_STRUCT_MMS_REGION, &image_region);
506         msg_set_str_value(image_region, MSG_MMS_REGION_ID_STR, "Image", strlen("Image"));
507         msg_set_int_value(image_region, MSG_MMS_REGION_LENGTH_LEFT_INT, MSG_COMPOSER_SMIL_POS_LEFT);
508
509         if (isTextTop)
510                 msg_set_int_value(image_region, MSG_MMS_REGION_LENGTH_TOP_INT, MSG_COMPOSER_SMIL_POS_BOTTOM);
511         else
512                 msg_set_int_value(image_region, MSG_MMS_REGION_LENGTH_TOP_INT, MSG_COMPOSER_SMIL_POS_TOP);
513
514         msg_set_int_value(image_region, MSG_MMS_REGION_LENGTH_WIDTH_INT, MSG_COMPOSER_SMIL_REGION_WIDTH);
515         msg_set_int_value(image_region, MSG_MMS_REGION_LENGTH_HEIGHT_INT, MSG_COMPOSER_SMIL_REGION_HEIGHT);
516         msg_set_int_value(image_region, MSG_MMS_REGION_BGCOLOR_INT, MSG_COMPOSER_SMIL_DEFAULT_BGCOLOR);
517
518         MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
519         return COMPOSER_RETURN_SUCCESS;
520 }
521
522 static COMPOSER_RETURN_TYPE_E __msg_ui_composer_make_mms_body(msg_handle_t msg_handle, msg_struct_t fw_mms_data)
523 {
524         D_ENTER;
525
526         if (!msg_data || !fw_mms_data) {
527                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] message data or FW mms data pointer is NULL");
528                 return COMPOSER_RETURN_NULL_POINTER;
529         }
530
531         MSG_COMP_MMS_DATA_S *ui_mms_data = &msg_data->mms_data;
532         int page_count = ui_mms_data->page_count;
533         int i = 0;
534
535         for (i = 0; i < page_count; i++) {
536                 msg_struct_t page_info = NULL;
537                 int page_duration = 0;
538
539                 /* verify page duration */
540                 if (COMPOSER_PAGE_DEFAULT_DURATION < ui_mms_data->pagelist[i].page_duration)
541                         page_duration = ui_mms_data->pagelist[i].page_duration;
542                 else
543                         page_duration = COMPOSER_PAGE_DEFAULT_DURATION;
544
545                 D_MSG("%dth page's page duration = %d", i + 1, page_duration);
546                 page_duration = page_duration * 1000;
547
548                 /* 1. make page */
549                 if (msg_mms_add_item(fw_mms_data, MSG_STRUCT_MMS_PAGE, &page_info) != MSG_SUCCESS) {
550                         MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] create mms page error");
551                         return COMPOSER_RETURN_FAIL;
552                 }
553
554                 msg_set_int_value(page_info, MSG_MMS_PAGE_PAGE_DURATION_INT, page_duration);
555
556                 /* 2. add media */
557                 /* 1) text */
558                 if (ui_mms_data->pagelist[i].isText) {
559                         FILE *fp;
560                         char szFilePath[DEF_BUF_LEN_L] = { 0x00, };
561                         char szFileName[DEF_BUF_LEN_L] = { 0x00, };
562                         char strMsg[COMPOSER_MMS_TEXT_MAX_BYTE + 1] = { 0x00, };
563
564                         msg_struct_t added_media = NULL;
565                         msg_struct_t text_style = NULL;
566
567                         /* create txt file */
568                         snprintf(szFilePath, sizeof(szFilePath), "%sMMS_Temp_%d.txt", MSG_DATA_TEMPPATH, i + 1);
569                         snprintf(szFileName, sizeof(szFileName), "MMS_Temp_%d.txt", i + 1);
570
571                         fp = fopen(szFilePath, "wb");
572                         if (!fp) {
573                                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "fopen error");
574                                 return COMPOSER_RETURN_FAIL;
575                         }
576
577                         strncpy(strMsg, ui_mms_data->pagelist[i].body_text, sizeof(strMsg) - 1);
578                         fwrite(strMsg, strlen(strMsg), 1, fp);
579                         fclose(fp);
580
581                         msg_mms_add_item(page_info, MSG_STRUCT_MMS_MEDIA, &added_media);
582                         msg_set_int_value(added_media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_TEXT);
583                         msg_set_str_value(added_media, MSG_MMS_MEDIA_REGION_ID_STR, "Text", strlen("Text"));
584                         msg_set_str_value(added_media, MSG_MMS_MEDIA_FILEPATH_STR, szFilePath, strlen(szFilePath));
585
586                         /** set font style */
587                         text_style = msg_create_struct(MSG_STRUCT_MMS_SMIL_TEXT);
588                         msg_set_int_value(text_style, MSG_MMS_SMIL_TEXT_COLOR_INT, MSG_COMPOSER_SMIL_DEFAULT_FONT_COLOR);
589                         msg_set_int_value(text_style, MSG_MMS_SMIL_TEXT_SIZE_INT, MSG_COMPOSER_SMIL_DEFAULT_FONT_SIZE);
590                         msg_set_int_value(text_style, MSG_MMS_SMIL_TEXT_BOLD_BOOL, MSG_COMPOSER_SMIL_DEFAULT_BOLD);
591                         msg_set_int_value(text_style, MSG_MMS_SMIL_TEXT_BOLD_BOOL, MSG_COMPOSER_SMIL_DEFAULT_UNDERLINE);
592
593                         msg_set_struct_handle(added_media, MSG_MMS_MEDIA_SMIL_TEXT_HND, text_style);
594                         msg_release_struct(&text_style);
595                 }
596
597                 /* 2) image / video */
598                 if (ui_mms_data->pagelist[i].isImage) {
599                         MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] image file added");
600                         msg_struct_t added_media = NULL;
601                         char *filepath = ui_mms_data->pagelist[i].image_file_path;
602
603                         msg_mms_add_item(page_info, MSG_STRUCT_MMS_MEDIA, &added_media);
604                         msg_set_int_value(added_media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_IMG);
605                         msg_set_str_value(added_media, MSG_MMS_MEDIA_REGION_ID_STR, "Image", strlen("Image"));
606                         msg_set_str_value(added_media, MSG_MMS_MEDIA_FILEPATH_STR, filepath, strlen(filepath));
607                 } else if (ui_mms_data->pagelist[i].isVideo) {
608                         MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] video file added");
609                         msg_struct_t added_media = NULL;
610                         char *filepath = ui_mms_data->pagelist[i].image_file_path;
611
612                         msg_mms_add_item(page_info, MSG_STRUCT_MMS_MEDIA, &added_media);
613                         msg_set_int_value(added_media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_VIDEO);
614                         msg_set_str_value(added_media, MSG_MMS_MEDIA_REGION_ID_STR, "Image", strlen("Image"));
615                         msg_set_str_value(added_media, MSG_MMS_MEDIA_FILEPATH_STR, filepath, strlen(filepath));
616                 }
617                 /* 3) sound */
618                 if (ui_mms_data->pagelist[i].isSound) {
619                         MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] sound file added");
620                         msg_struct_t added_media = NULL;
621                         char *filepath = ui_mms_data->pagelist[i].sound_file_path;
622
623                         msg_mms_add_item(page_info, MSG_STRUCT_MMS_MEDIA, &added_media);
624                         msg_set_int_value(added_media, MSG_MMS_MEDIA_TYPE_INT, MMS_SMIL_MEDIA_AUDIO);
625                         msg_set_str_value(added_media, MSG_MMS_MEDIA_FILEPATH_STR, filepath, strlen(filepath));
626                 }
627         }
628
629         D_LEAVE;
630         return COMPOSER_RETURN_SUCCESS;
631 }
632
633 static COMPOSER_RETURN_TYPE_E __msg_ui_composer_make_mms_message(msg_handle_t msg_handle, int msg_id)
634 {
635         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
636
637         msg_struct_t fw_mms_data = NULL;
638         MSG_COMP_MMS_DATA_S ui_mms_data = { 0, };
639
640         if (msg_data == NULL || msg_data->msgInfo == NULL) {
641                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] msg_data is NULL !! ");
642                 return COMPOSER_RETURN_FAIL;
643         }
644
645         ui_mms_data = msg_data->mms_data;
646
647         /* set msgid */
648         if (msg_id) {
649                 D_MSG("msg_id = %d", msg_id);
650                 if (msg_set_int_value(msg_data->msgInfo, MSG_MESSAGE_ID_INT, msg_id) != MSG_SUCCESS) {
651                         MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] set msgId error");
652                 }
653         }
654
655         /* set msg type to MMS */
656         if (msg_set_int_value(msg_data->msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS) != MSG_SUCCESS) {
657                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] set message type[MMS] error");
658                 return COMPOSER_RETURN_FAIL;
659         }
660         /* create mms data */
661         fw_mms_data = msg_create_struct(MSG_STRUCT_MMS);
662         if (fw_mms_data == NULL) {
663                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] create mms message error!!");
664                 return COMPOSER_RETURN_FAIL;
665         }
666
667         /* create smil header <rootlayout> <region> */
668         if (__msg_ui_composer_make_smil_header(msg_handle, fw_mms_data, ui_mms_data.isTextTop) != COMPOSER_RETURN_SUCCESS) {
669                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] smil header create error");
670                 msg_release_struct(&fw_mms_data);
671                 return COMPOSER_RETURN_FAIL;
672         }
673         /* set subject */
674         int subject_len = strlen(ui_mms_data.subject);
675         if (ui_mms_data.isSubject == true || subject_len > 0) {
676                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] Set subject ");
677                 if (msg_set_str_value(msg_data->msgInfo, MSG_MESSAGE_SUBJECT_STR, ui_mms_data.subject, subject_len) != MSG_SUCCESS)
678                         MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] mms set subject error ");
679         }
680         /* set attachment */
681         if (ui_mms_data.attach_count > 0) {
682                 int i = 0;
683                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "ui_mms_data.attach_count = %d", ui_mms_data.attach_count);
684
685                 if (ui_mms_data.attach_count > COMPOSER_MMS_MAX_ATTACH_COUNT) {
686                         MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] attachment count error, max count change");
687                         ui_mms_data.attach_count = COMPOSER_MMS_MAX_ATTACH_COUNT;
688                 }
689
690                 for (i = 0; i < ui_mms_data.attach_count; i++) {
691                         MSG_COMP_ATTACH_DATA_S *attach_data = &ui_mms_data.attachlist[i];
692                         if (attach_data == NULL) {
693                                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] attachment data is NULL");
694                                 break;
695                         }
696                         msg_struct_t attachment = NULL;
697                         msg_mms_add_item(fw_mms_data, MSG_STRUCT_MMS_ATTACH, &attachment);
698                         msg_set_str_value(attachment, MSG_MMS_ATTACH_FILEPATH_STR, attach_data->filepath, strlen(attach_data->filepath));
699                 }
700         }
701         /* make body */
702         /* 1) make page */
703         __msg_ui_composer_make_mms_body(msg_handle, fw_mms_data);
704
705         /* 2) set MMS body */
706         msg_set_mms_struct(msg_data->msgInfo, fw_mms_data);
707         msg_release_struct(&fw_mms_data);
708
709         /* set recipient */
710         if (__msg_ui_composer_set_recipient() != COMPOSER_RETURN_SUCCESS) {
711                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT]__msg_ui_composer_set_recipient error !!");
712                 return COMPOSER_RETURN_FAIL;
713         }
714
715         return COMPOSER_RETURN_SUCCESS;
716 }
717
718 static COMPOSER_RETURN_TYPE_E __msg_ui_composer_send(msg_handle_t msg_handle)
719 {
720         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
721
722         if (msg_data == NULL || msg_data->msgInfo == NULL) {
723                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] message is not initialized");
724                 return COMPOSER_RETURN_FAIL;
725         }
726
727         msg_struct_t req = msg_create_struct(MSG_STRUCT_REQUEST_INFO);
728         int msg_type = MSG_TYPE_INVALID;
729         int err;
730
731         msg_struct_t sendOpt = NULL;
732         msg_get_struct_handle(req, MSG_REQUEST_SENDOPT_HND, &sendOpt);
733         msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false);
734
735         msg_set_struct_handle(req, MSG_REQUEST_MESSAGE_HND, msg_data->msgInfo);
736         msg_get_int_value(msg_data->msgInfo, MSG_MESSAGE_TYPE_INT, &msg_type);
737
738         if (msg_is_sms(msg_type)) {
739                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] try to send sms");
740                 err = msg_sms_send_message(msg_handle, req);
741         } else if (msg_is_mms(msg_type)) {
742                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] try to send mms");
743                 err = msg_mms_send_message(msg_handle, req);
744         } else {
745                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] error message type");
746                 msg_release_struct(&req);
747                 return COMPOSER_RETURN_FAIL;
748         }
749
750         msg_release_struct(&req);
751
752         if (err == MSG_SUCCESS) {
753                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] sending success");
754                 return COMPOSER_RETURN_SUCCESS;
755         } else if (err == MSG_ERR_INVALID_PARAMETER) {
756                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] sending failed error code [%d] : INVALID_PARAM ", err);
757                 return COMPOSER_RETURN_NULL_POINTER;
758         } else if (err == MSG_ERR_NO_SIM) {
759                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] sending failed error code [%d] : NO SIM", err);
760                 return COMPOSER_RETURN_NO_SIM;
761         } else {
762                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] sending failed error code [%d]", err);
763                 return COMPOSER_RETURN_FAIL;
764         }
765 }
766
767 msg_struct_t msg_ui_composer_message_make_preview(msg_handle_t msg_handle)
768 {
769         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
770
771         if (msg_data == NULL) {
772                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] can not send message,,, msg_data is NULL");
773                 return NULL;
774         }
775
776         if (msg_ui_composer_create_new_message() != COMPOSER_RETURN_SUCCESS) {
777                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] create new message error !!!");
778                 return NULL;
779         }
780
781         if (__msg_ui_composer_make_mms_message(msg_handle, 0)
782             != COMPOSER_RETURN_SUCCESS) {
783                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] make mms message error !!!");
784                 return NULL;
785         }
786
787         MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
788         return msg_data->msgInfo;
789 }
790
791 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_make_and_send(msg_handle_t msg_handle, int msg_id, msg_thread_id_t *tid)
792 {
793         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
794
795         if (msg_data == NULL) {
796                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] can not send message,,, msg_data is NULL");
797                 return COMPOSER_RETURN_FAIL;
798         }
799
800         COMPOSER_RETURN_TYPE_E ret = COMPOSER_RETURN_SUCCESS;
801
802         /* 1. create a new message (create msg_struct_t) */
803         if (msg_ui_composer_create_new_message() != COMPOSER_RETURN_SUCCESS) {
804                 return COMPOSER_RETURN_FAIL;
805         }
806
807         /* 2. make message */
808         if (msg_data->msg_type == COMPOSER_MSG_TYPE_SMS) {
809                 if (__msg_ui_composer_make_sms_message(msg_handle, msg_id) != COMPOSER_RETURN_SUCCESS)
810                         ret =  COMPOSER_RETURN_FAIL;
811         } else if (msg_data->msg_type == COMPOSER_MSG_TYPE_MMS) {
812                 if (__msg_ui_composer_make_mms_message(msg_handle, msg_id) != COMPOSER_RETURN_SUCCESS)
813                         ret = COMPOSER_RETURN_FAIL;
814         } else {
815                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] invalid message type");
816                 ret = COMPOSER_RETURN_FAIL;
817         }
818
819         /*3. send message */
820         if (ret != COMPOSER_RETURN_FAIL) {
821                 ret = __msg_ui_composer_send(msg_handle);
822
823                 if (ret == COMPOSER_RETURN_SUCCESS || ret == COMPOSER_RETURN_NO_SIM) {
824                         msg_struct_list_s *addr_list = NULL;
825
826                         msg_get_list_handle(msg_data->msgInfo, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addr_list);
827                         msg_get_thread_id_by_address(msg_handle, addr_list, tid);
828                 }
829         }
830
831         /*4. release message */
832         msg_release_struct(&msg_data->msgInfo);
833         msg_data->msgInfo = NULL;
834
835         return ret;
836 }
837
838 COMPOSER_RETURN_TYPE_E msg_ui_composer_get_thread_id_by_address(msg_handle_t msg_handle, GSList *address_list, msg_thread_id_t *tid)
839 {
840         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
841
842         if (address_list == NULL || tid == NULL) {
843                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "param is NULL");
844                 return COMPOSER_RETURN_FAIL;
845         }
846
847         COMPOSER_RETURN_TYPE_E ret = COMPOSER_RETURN_SUCCESS;
848         int count = g_slist_length(address_list);
849         int i = 0;
850         msg_struct_list_s *addr_list = NULL;
851         msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
852
853         if (msgInfo) {
854                 msg_get_list_handle(msgInfo, MSG_MESSAGE_ADDR_LIST_STRUCT, (void**)&addr_list);
855
856                 addr_list->nCount = count;
857                 for (i = 0; i < count; i++) {
858                         char *address = (char *)g_slist_nth_data(address_list, i);
859                         if (address == NULL) {
860                                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "address is NULL, skip");
861                                 continue;
862                         }
863
864                         int addr_type = get_address_type((const char*)address);
865                         if (addr_type == COMPOSER_UTIL_ADDRTYPE_NUMBER)
866                                 msg_set_int_value(addr_list->msg_struct_info[i], MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MSG_ADDRESS_TYPE_PLMN);
867                         else if (addr_type == COMPOSER_UTIL_ADDRTYPE_EMAIL)
868                                 msg_set_int_value(addr_list->msg_struct_info[i], MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MSG_ADDRESS_TYPE_EMAIL);
869                         msg_set_int_value(addr_list->msg_struct_info[i], MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MSG_RECIPIENTS_TYPE_TO);
870                         msg_set_str_value(addr_list->msg_struct_info[i], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, address, strlen(address));
871                 }
872
873                 msg_get_thread_id_by_address(msg_handle, addr_list, tid);
874
875                 msg_release_struct(&msgInfo);
876         } else {
877                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "msgInfo is NULL");
878                 ret = COMPOSER_RETURN_FAIL;
879         }
880
881         return ret;
882 }
883
884 COMPOSER_RETURN_TYPE_E msg_ui_composer_delete_draft_message(msg_handle_t msg_handle, msg_thread_id_t tid)
885 {
886         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
887
888         COMPOSER_RETURN_TYPE_E ret = COMPOSER_RETURN_SUCCESS;
889         msg_struct_list_s msg_list = {0,};
890
891         if (msg_get_message_list(msg_handle, MSG_DRAFT_ID, tid, 0, 0, &msg_list) == MSG_SUCCESS) {
892                 int i = 0;
893                 int msgid = 0;
894
895                 if (msg_list.nCount)
896                         D_MSG("delete draft message");
897
898                 for (i = 0; i < msg_list.nCount; i++) {
899                         msg_get_int_value(msg_list.msg_struct_info[i], MSG_MESSAGE_ID_INT, &msgid);
900                         D_MSG("draft msg_id is %d", msgid);
901                         if (msg_delete_message(msg_handle, msgid) != COMPOSER_RETURN_SUCCESS)
902                                 D_EMSG("msg_delete_message is failed, msgid = %d", msgid);
903                 }
904         }
905         msg_release_list_struct(&msg_list);
906
907         return ret;
908 }
909
910 COMPOSER_RETURN_TYPE_E msg_ui_composer_save_message(msg_handle_t msg_handle, int msg_id)
911 {
912         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
913
914         if (msg_data == NULL) {
915                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] can not save message,,, msg_data is NULL");
916                 return COMPOSER_RETURN_FAIL;
917         }
918
919         COMPOSER_RETURN_TYPE_E ret = COMPOSER_RETURN_SUCCESS;
920
921         /* 1. create a new message (create msg_struct_t) */
922         if (msg_ui_composer_create_new_message() != COMPOSER_RETURN_SUCCESS) {
923                 return COMPOSER_RETURN_FAIL;
924         }
925
926         /* 2. make message */
927         if (msg_data->msg_type == COMPOSER_MSG_TYPE_SMS) {
928                 if (__msg_ui_composer_make_sms_message(msg_handle, msg_id) != COMPOSER_RETURN_SUCCESS)
929                         ret =  COMPOSER_RETURN_FAIL;
930         } else if (msg_data->msg_type == COMPOSER_MSG_TYPE_MMS) {
931                 if (__msg_ui_composer_make_mms_message(msg_handle, msg_id) != COMPOSER_RETURN_SUCCESS)
932                         ret = COMPOSER_RETURN_FAIL;
933         } else {
934                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] invalid message type");
935                 ret = COMPOSER_RETURN_FAIL;
936         }
937
938         /*3. save message */
939         if (ret != COMPOSER_RETURN_FAIL) {
940                 msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
941                 msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false);
942
943                 if (!msg_id)
944                         ret = msg_add_message(msg_handle, msg_data->msgInfo, sendOpt);
945                 else
946                         ret = msg_update_message(msg_handle, msg_data->msgInfo, sendOpt);
947
948                 msg_release_struct(&sendOpt);
949         }
950
951         /*4. release message */
952         msg_release_struct(&msg_data->msgInfo);
953         msg_data->msgInfo = NULL;
954
955         return ret;
956 }
957
958 COMPOSER_RETURN_TYPE_E msg_ui_composer_get_message_data(MSG_COMPOSER_VIEW_DATA_S *cd)
959 {
960         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
961
962         if (msg_data == NULL) {
963                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] can not save message,,, msg_data is NULL");
964                 return COMPOSER_RETURN_FAIL;
965         }
966
967         MSG_UI_RETV_IF(MSG_UI_LEVEL_ERR, cd == NULL, COMPOSER_RETURN_FAIL);
968
969         if (msg_ui_composer_recipient_read_data(cd) != COMPOSER_RETURN_SUCCESS) {
970                 D_EMSG("Make recipient data Error");
971                 return COMPOSER_RETURN_FAIL;
972         }
973
974         if (__msg_ui_composer_body_read_data(cd) != COMPOSER_RETURN_SUCCESS) {
975                 D_EMSG("Make body data Error");
976                 return COMPOSER_RETURN_FAIL;
977         }
978
979         MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
980
981         return COMPOSER_RETURN_SUCCESS;
982 }
983
984 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_load_message(msg_handle_t msg_handle, int msgID)
985 {
986         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
987
988         if (!msg_handle) {
989                 MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] msg_handle is NULL");
990                 return COMPOSER_RETURN_NULL_POINTER;
991         }
992
993         msg_struct_t load_msg = NULL;
994         msg_struct_t sendOpt = NULL;
995         msg_struct_t mmsBody = NULL;
996
997         /* create new message */
998         load_msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
999         if (load_msg == NULL) {
1000                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] message create message failed.");
1001                 return COMPOSER_RETURN_FAIL;
1002         }
1003         sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
1004         if (sendOpt == NULL) {
1005                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] message create sendopt failed.");
1006                 msg_release_struct(&load_msg);
1007                 return COMPOSER_RETURN_FAIL;
1008         }
1009         /* load message */
1010         if (msg_get_message(msg_handle,(msg_message_id_t)msgID, load_msg, sendOpt) != MSG_SUCCESS) {
1011                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] msg_get_message failed");
1012                 msg_release_struct(&load_msg);
1013                 msg_release_struct(&sendOpt);
1014                 return COMPOSER_RETURN_FAIL;
1015         }
1016
1017         /* load "FROM" address */
1018         msg_struct_list_s *addr_list = NULL;
1019         msg_get_list_handle(load_msg, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addr_list);
1020
1021         if (addr_list) {
1022                 int addr_count = addr_list->nCount;
1023                 int i = 0;
1024                 char number_str[MAX_ADDRESS_VAL_LEN + 1] = {0,};
1025
1026                 for (i = 0; i < addr_count; i++) {
1027                         memset(number_str, 0, sizeof(number_str));
1028
1029                         msg_get_str_value(addr_list->msg_struct_info[i], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, number_str, MAX_ADDRESS_VAL_LEN);
1030
1031                         if (strlen(number_str))
1032                                 msg_ui_composer_message_add_address(number_str);
1033                 }
1034         }
1035
1036         /* load message type */
1037         int msgType;
1038         msg_get_int_value(load_msg, MSG_MESSAGE_TYPE_INT, &msgType);
1039
1040         if (msgType == MSG_TYPE_SMS) {
1041                 char *body_text = NULL;
1042                 int body_size = 0;
1043
1044                 msg_data->msg_type = COMPOSER_MSG_TYPE_SMS;
1045
1046                 msg_get_int_value(load_msg, MSG_MESSAGE_DATA_SIZE_INT, &body_size);
1047
1048                 if (body_size > 0)
1049                         body_text = (char *)calloc(1, body_size+1);
1050
1051                 if (body_text)
1052                         msg_get_str_value(load_msg, MSG_MESSAGE_SMS_DATA_STR, body_text, body_size);
1053
1054                 if (body_text && strlen(body_text) > 0) {
1055                         msg_data->sms_data.body_text = strdup(body_text);
1056                         msg_data->sms_data.body_length = strlen(body_text);
1057                 }
1058
1059                 if (body_text)
1060                         free(body_text);
1061
1062         } else if (msgType == MSG_TYPE_MMS) {
1063                 char subject[MAX_SUBJECT_LEN+1] = {0,};
1064                 msg_data->msg_type = COMPOSER_MSG_TYPE_MMS;
1065
1066                 /* load mms body */
1067                 mmsBody = msg_create_struct(MSG_STRUCT_MMS);
1068                 if (mmsBody == NULL) {
1069                         msg_release_struct(&load_msg);
1070                         msg_release_struct(&sendOpt);
1071                         return COMPOSER_RETURN_FAIL;
1072                 }
1073                 msg_get_mms_struct(load_msg, mmsBody);
1074                 /* load subject */
1075                 if (msg_get_str_value(load_msg, MSG_MESSAGE_SUBJECT_STR, subject, MAX_SUBJECT_LEN) != MSG_SUCCESS) {
1076                         MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] No subject data");
1077                         msg_data->mms_data.isSubject = false;
1078                 } else {
1079                         MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] loaded subject : [%s]", subject);
1080                         msg_data->mms_data.isSubject = true;
1081                         strncpy(msg_data->mms_data.subject, subject, COMPOSER_SUBJECT_MAX_BYTE);
1082                 }
1083
1084                 /* load region */
1085                 msg_list_handle_t region_list = NULL;
1086                 msg_get_list_handle(mmsBody, MSG_MMS_REGION_LIST_HND, (void **)&region_list);
1087
1088                 int region_count = msg_list_length(region_list);
1089                 if (region_count >= 2) {
1090                         msg_struct_t region_info_0 = NULL;
1091                         msg_struct_t region_info_1 = NULL;
1092                         bool is_text_top = false;
1093
1094                         region_info_0 = (msg_struct_t)msg_list_nth_data(region_list, 0);
1095                         region_info_1 = (msg_struct_t)msg_list_nth_data(region_list, 1);
1096
1097                         if (msg_ui_composer_check_is_text_top(region_info_0, region_info_1, &is_text_top) == COMPOSER_RETURN_SUCCESS)
1098                                 msg_data->mms_data.isTextTop = is_text_top;
1099                 } else {
1100                         D_EMSG("there is no region info region_count = %d", region_count);
1101                 }
1102
1103                 /* load attachment */
1104                 msg_list_handle_t attach_list = NULL;
1105                 msg_get_list_handle(mmsBody, MSG_MMS_ATTACH_LIST_HND, (void **)&attach_list);
1106                 msg_data->mms_data.attach_count = msg_list_length(attach_list);
1107
1108                 if (msg_data->mms_data.attach_count > 0) {
1109                         int i = 0;
1110
1111                         for (i = 0; i < msg_data->mms_data.attach_count ; i++) {
1112                                 msg_struct_t attach_info = (msg_struct_t)msg_list_nth_data(attach_list, i);
1113
1114                                 if (attach_info == NULL) {
1115                                         MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] attachment [%d]th item loading error ", i);
1116                                         continue;
1117                                 }
1118
1119                                 msg_get_int_value(attach_info, MSG_MMS_ATTACH_MIME_TYPE_INT, &msg_data->mms_data.attachlist[i].filetype);
1120                                 msg_get_str_value(attach_info, MSG_MMS_ATTACH_FILEPATH_STR, msg_data->mms_data.attachlist[i].filepath, sizeof(msg_data->mms_data.attachlist[i].filepath));
1121                                 msg_get_str_value(attach_info, MSG_MMS_ATTACH_FILENAME_STR, msg_data->mms_data.attachlist[i].filename, sizeof(msg_data->mms_data.attachlist[i].filename));
1122                         }
1123                 }
1124
1125                 /* load body (page and text, media) */
1126                 msg_list_handle_t page_list = NULL;
1127                 msg_get_list_handle(mmsBody, MSG_MMS_PAGE_LIST_HND, (void **)&page_list);
1128
1129                 msg_data->mms_data.page_count = msg_list_length(page_list);
1130
1131                 if (msg_data->mms_data.page_count > 0) {
1132                         int i = 0;
1133
1134                         for (i = 0; i < msg_data->mms_data.page_count; i++) {
1135                                 msg_struct_t pageInfo = msg_list_nth_data(page_list, i);
1136                                 msg_list_handle_t media_list = NULL;
1137                                 int media_count = 0;
1138
1139                                 if (pageInfo == NULL) {
1140                                         MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] MMS PAGE [%d]th page loading error ", i);
1141                                         continue;
1142                                 }
1143
1144                                 /* get page duration */
1145                                 int page_duration = 0;
1146                                 msg_get_int_value(pageInfo, MSG_MMS_PAGE_PAGE_DURATION_INT, &page_duration);
1147                                 if (page_duration % 1000)
1148                                         page_duration = page_duration / 1000 + 1;
1149                                 else
1150                                         page_duration = page_duration / 1000;
1151
1152                                 msg_data->mms_data.pagelist[i].page_duration = page_duration;
1153
1154                                 msg_get_list_handle(pageInfo, MSG_MMS_PAGE_MEDIA_LIST_HND, (void **)&media_list);
1155                                 media_count = msg_list_length(media_list);
1156
1157                                 if (media_count > 0) {
1158                                         int j = 0;
1159
1160                                         for (j = 0; j < media_count; j++) {
1161                                                 msg_struct_t mediaInfo = (msg_struct_t)msg_list_nth_data(media_list, j);
1162                                                 int mediatype;
1163
1164                                                 if (mediaInfo == NULL) {
1165                                                         MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] MMS PAGE [%d]th page loading error ", j);
1166                                                         continue;
1167                                                 }
1168
1169                                                 msg_get_int_value(mediaInfo, MSG_MMS_MEDIA_TYPE_INT, &mediatype);
1170                                                 /* if media type image or video */
1171                                                 if (mediatype == MMS_SMIL_MEDIA_IMG) {
1172                                                         msg_data->mms_data.pagelist[i].isImage = true;
1173                                                         msg_get_str_value(mediaInfo, MSG_MMS_MEDIA_FILEPATH_STR, msg_data->mms_data.pagelist[i].image_file_path, sizeof(msg_data->mms_data.pagelist[i].image_file_path));
1174                                                 } else if (mediatype == MMS_SMIL_MEDIA_VIDEO || mediatype == MMS_SMIL_MEDIA_IMG_OR_VIDEO) {
1175                                                         msg_data->mms_data.pagelist[i].isVideo = true;
1176                                                         msg_get_str_value(mediaInfo, MSG_MMS_MEDIA_FILEPATH_STR, msg_data->mms_data.pagelist[i].image_file_path, sizeof(msg_data->mms_data.pagelist[i].image_file_path));
1177                                                 } else if (mediatype == MMS_SMIL_MEDIA_AUDIO) {
1178                                                         msg_data->mms_data.pagelist[i].isSound = true;
1179                                                         msg_get_str_value(mediaInfo, MSG_MMS_MEDIA_FILEPATH_STR, msg_data->mms_data.pagelist[i].sound_file_path, sizeof(msg_data->mms_data.pagelist[i].sound_file_path));
1180                                                 } else if (mediatype == MMS_SMIL_MEDIA_TEXT) {
1181                                                         FILE *fp = NULL;
1182                                                         char filepath[DEF_BUF_LEN_L] = {0,};
1183                                                         msg_get_str_value(mediaInfo, MSG_MMS_MEDIA_FILEPATH_STR, filepath, sizeof(filepath));
1184
1185                                                         if (access(filepath, R_OK) == 0) {
1186                                                                 if (!(fp = fopen(filepath, "r"))) {
1187                                                                         MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR]File Open Error");
1188                                                                         msg_data->mms_data.pagelist[i].isText = false;
1189                                                                         continue;
1190                                                                 }
1191
1192                                                                 struct stat stat_buf;
1193                                                                 if (stat(filepath, &stat_buf) != 0) {
1194                                                                         MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR]Getting file information Error");
1195                                                                         msg_data->mms_data.pagelist[i].isText = false;
1196                                                                         fclose(fp);
1197                                                                         continue;
1198                                                                 }
1199
1200                                                                 if (stat_buf.st_size <= 0) {
1201                                                                         MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR]Getting file size is ZERO");
1202                                                                         msg_data->mms_data.pagelist[i].isText = false;
1203                                                                         fclose(fp);
1204                                                                         continue;
1205                                                                 }
1206
1207                                                                 msg_data->mms_data.pagelist[i].isText = true;
1208
1209                                                                 int result = fread(msg_data->mms_data.pagelist[i].body_text, sizeof(char), stat_buf.st_size, fp);
1210                                                                 if (result != stat_buf.st_size)
1211                                                                         D_EMSG("fread result is different!! result = %d, stat_buf.st_size = %d", result, stat_buf.st_size);
1212
1213                                                                 fclose(fp);
1214                                                         } else {
1215                                                                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] file access failed");
1216                                                                 msg_data->mms_data.pagelist[i].isText = false;
1217                                                         }
1218
1219                                                 } else {
1220                                                         msg_release_struct(&mmsBody);
1221                                                         msg_release_struct(&load_msg);
1222                                                         msg_release_struct(&sendOpt);
1223                                                         return COMPOSER_RETURN_INVALID_MEDIA_TYPE;
1224                                                 }
1225                                         }
1226                                 }
1227                         }
1228                 }
1229         } else {
1230                 msg_data->msg_type = COMPOSER_MSG_TYPE_INVALID;
1231                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] invalid message type");
1232                 msg_release_struct(&load_msg);
1233                 msg_release_struct(&sendOpt);
1234                 return COMPOSER_RETURN_INVALID_MSG_TYPE;
1235         }
1236
1237         if (msgType == MSG_TYPE_MMS)
1238                 msg_release_struct(&mmsBody);
1239
1240         msg_release_struct(&load_msg);
1241         msg_release_struct(&sendOpt);
1242         MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
1243         return COMPOSER_RETURN_SUCCESS;
1244 }
1245
1246 static void __msgc_warning_popup_ok_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1247 {
1248         D_ENTER;
1249         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1250         D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
1251         int page = (int)evas_object_data_get(cd->popup_end, "page_index");
1252
1253         MSGC_EVAS_OBJECT_DEL(cd->popup_end);
1254
1255         cd->body_data.creation_allowed = COMPOSER_CONTENT_CREATION_ALLOWED;
1256
1257         msg_ui_composer_message_set_page_data(cd, page);
1258
1259         cd->body_data.creation_allowed = COMPOSER_CONTENT_CREATION_NONE;
1260
1261         msg_ui_composer_message_destroy();
1262
1263         D_LEAVE;
1264 }
1265
1266 static void __msgc_warning_popup_cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1267 {
1268         D_ENTER;
1269         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1270         D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
1271
1272         int page = (int)evas_object_data_get(cd->popup_end, "page_index");
1273
1274         MSGC_EVAS_OBJECT_DEL(cd->popup_end);
1275
1276         cd->body_data.creation_allowed = COMPOSER_CONTENT_CREATION_NOT_ALLOWED;
1277
1278         msg_ui_composer_message_set_page_data(cd, page);
1279
1280         cd->body_data.creation_allowed = COMPOSER_CONTENT_CREATION_NONE;
1281
1282         msg_ui_composer_message_destroy();
1283
1284         D_LEAVE;
1285 }
1286
1287 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_set_page_data(void *composer_data, int page)
1288 {
1289         D_ENTER;
1290         D_MSG_RETVM_IF(composer_data == NULL, COMPOSER_RETURN_FAIL, "composer data is NULL");
1291         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)composer_data;
1292         int ret = COMPOSER_RETURN_SUCCESS;
1293         static bool is_drm = false;
1294         static bool is_restricted_mode = false;
1295
1296         D_MSG("MMS PAGE COUNT [%d], page = %d", msg_data->mms_data.page_count, page);
1297
1298         if (page > msg_data->mms_data.page_count)
1299                 return COMPOSER_RETURN_FAIL;
1300
1301         for (; page < msg_data->mms_data.page_count; page++) {
1302                 if (msg_data->mms_data.pagelist[page].isImage) {
1303                         ret = msg_ui_composer_body_set_loaded_media(cd, msg_data->mms_data.pagelist[page].image_file_path, COMPOSER_MEDIA_TYPE_IMAGE, page);
1304                 } else if (msg_data->mms_data.pagelist[page].isVideo) {
1305                         ret = msg_ui_composer_body_set_loaded_media(cd, msg_data->mms_data.pagelist[page].image_file_path, COMPOSER_MEDIA_TYPE_VIDEO, page);
1306                 }
1307
1308                 if (msg_data->mms_data.pagelist[page].isSound) {
1309                         ret = msg_ui_composer_body_set_loaded_media(cd, msg_data->mms_data.pagelist[page].sound_file_path, COMPOSER_MEDIA_TYPE_AUDIO, page);
1310                 }
1311
1312                 if (ret == COMPOSER_RETURN_DRM_FORWARDLOCK) {
1313                         D_MSG("ret COMPOSER_RETURN_DRM_FORWARDLOCK");
1314                         is_drm = true;
1315                 } else if (ret == COMPOSER_RETURN_CREATION_RESTRICTED_MODE_FAIL) {
1316                         D_MSG("ret COMPOSER_RETURN_CREATION_RESTRICTED_MODE_FAIL");
1317                         is_restricted_mode = true;
1318                 } else if (ret == COMPOSER_RETURN_CREATION_WARINING_MODE_FAIL) {
1319                         D_MSG("ret COMPOSER_RETURN_CREATION_WARINING_MODE_FAIL");
1320                         MSGC_EVAS_OBJECT_DEL(cd->popup_end);
1321                         /* show warning mode popup */
1322                         Evas_Object *popup = msg_ui_composer_status_popup_show(cd->navi_bar, cd, _MSGSTR("IDS_MSGF_POP_RESTRICTED_CONTENT_TYPE_ATTACH_ANYWAY_Q"), 0);
1323                         Evas_Object *btn1 = elm_button_add(popup);
1324                         elm_object_style_set(btn1, "popup_button/default");
1325                         elm_object_text_set(btn1, MSGC_STR_BUTTON_OK);
1326                         elm_object_part_content_set(popup, "button1", btn1);
1327                         evas_object_smart_callback_add(btn1, "clicked", __msgc_warning_popup_ok_btn_clicked_cb, cd);
1328
1329                         Evas_Object *btn2 = elm_button_add(popup);
1330                         elm_object_style_set(btn2, "popup_button/default");
1331                         elm_object_text_set(btn2, MSGC_STR_BUTTON_CANCEL);
1332                         elm_object_part_content_set(popup, "button2", btn2);
1333                         evas_object_smart_callback_add(btn2, "clicked", __msgc_warning_popup_cancel_btn_clicked_cb, cd);
1334                         cd->popup_end = popup;
1335
1336                         evas_object_data_set(popup, "page_index", (void *)page);
1337
1338                         return ret;
1339                 }
1340
1341                 if (msg_data->mms_data.pagelist[page].isText) {
1342                         msg_ui_composer_body_set_loaded_text(cd, msg_data->mms_data.pagelist[page].body_text, page);
1343                 }
1344
1345                 /* set page duration */
1346                 msg_ui_composer_body_set_loaded_page_duration(cd, msg_data->mms_data.pagelist[page].page_duration, page);
1347         }
1348
1349         if (is_drm) {
1350                 /* show drm forwardlock popup */
1351                 Evas_Object *popup = msg_ui_composer_status_popup_show(cd->navi_bar, cd, MSGC_STR_POP_FILE_IS_FORWARD_LOCK, 0);
1352                 Evas_Object *btn1 = elm_button_add(popup);
1353                 elm_object_style_set(btn1, "popup_button/default");
1354                 elm_object_text_set(btn1, MSGC_STR_BUTTON_CLOSE);
1355                 elm_object_part_content_set(popup, "button1", btn1);
1356                 evas_object_smart_callback_add(btn1, "clicked", msg_ui_composer_status_popup_response_cb, popup);
1357         } else if (is_restricted_mode) {
1358                 /* show restricted mode popup */
1359                 Evas_Object *popup = msg_ui_composer_status_popup_show(cd->navi_bar, cd, _MSGSTR("Unsupported media type"), 0);
1360                 Evas_Object *btn1 = elm_button_add(popup);
1361                 elm_object_style_set(btn1, "popup_button/default");
1362                 elm_object_text_set(btn1, MSGC_STR_BUTTON_CLOSE);
1363                 elm_object_part_content_set(popup, "button1", btn1);
1364                 evas_object_smart_callback_add(btn1, "clicked", msg_ui_composer_status_popup_response_cb, popup);
1365         }
1366
1367         is_drm = false;
1368         is_restricted_mode = false;
1369
1370         D_LEAVE;
1371         return COMPOSER_RETURN_SUCCESS;
1372 }
1373
1374 COMPOSER_RETURN_TYPE_E msg_ui_composer_message_set_loaded_data(void *composer_data, bool set_recipient)
1375 {
1376         D_ENTER;
1377         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)composer_data;
1378         int i = 0;
1379         int ret = COMPOSER_RETURN_SUCCESS;
1380
1381         /* recipient */
1382         if (set_recipient) {
1383                 if (msg_data->recp_list) {
1384
1385                         int count = g_slist_length(msg_data->recp_list);
1386                         char *address = NULL;
1387
1388                         for (i = 0; i < count; i++) {
1389                                 address = (char *)g_slist_nth_data(msg_data->recp_list, i);
1390
1391                                 if (address)
1392                                         msg_ui_composer_recipient_set_loaded_data(cd, address, 0);
1393                         }
1394                 }
1395         }
1396
1397         if (msg_data->msg_type == COMPOSER_MSG_TYPE_SMS) {
1398                 msg_ui_composer_body_set_loaded_text(cd, msg_data->sms_data.body_text, 0);
1399                 return COMPOSER_RETURN_SUCCESS;
1400         }
1401
1402         /* subject */
1403         if (msg_data->mms_data.isSubject)
1404                 msg_ui_composer_subject_set_loaded_data(cd, msg_data->mms_data.subject);
1405
1406         /* region */
1407         if (msg_data->mms_data.isTextTop)
1408                 cd->body_data.region_order = COMPOSER_REGION_ORDER_TEXT_TOP;
1409         else
1410                 cd->body_data.region_order = COMPOSER_REGION_ORDER_IMAGE_TOP;
1411
1412         /* attachment */
1413         for (i = 0; i < msg_data->mms_data.attach_count; i++) {
1414                 char *filepath = msg_data->mms_data.attachlist[i].filepath;
1415                 int filetype = msg_data->mms_data.attachlist[i].filetype;
1416
1417                 msg_ui_composer_attachment_set_loaded_data(cd, filepath, filetype);
1418         }
1419
1420         /* body page data*/
1421         ret = msg_ui_composer_message_set_page_data(cd, 0);
1422
1423         if (ret == COMPOSER_RETURN_CREATION_WARINING_MODE_FAIL)
1424                 return ret;
1425
1426         D_LEAVE;
1427         return COMPOSER_RETURN_SUCCESS;
1428 }