Apply sip back key concept in composer
[apps/home/message-app.git] / composer / src / ui-composer / msg-ui-composer-main.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 /* includes*/
18 #include <Ecore_X.h>
19 #include <tapi_common.h>
20 #include <TapiUtility.h>
21 #include <utilX.h>
22
23 #include "msg-ui-composer-main.h"
24 #include "msg-ui-composer-recipient.h"
25 #include "msg-ui-composer-popup.h"
26 #include "msg-ui-composer-predictsearch.h"
27 #include "msg-ui-composer-subject.h"
28 #include "msg-ui-composer-body.h"
29 #include "msg-ui-composer-pageduration.h"
30 #include "msg-ui-composer-message.h"
31 #include "msg-ui-composer-common.h"
32 #include "msg-ui-composer-external.h"
33 #include "msg-ui-composer-bubble.h"
34 #include "msg-ui-composer-main.h"       /*for page duration, it should be removed if more option concept is changed*/
35
36 #include "msg-ui-common-utility.h"
37
38 #define COMPOSER_BUNDLE_ATTACH_TOKEN "\n"
39 #define COMPOSER_BUNDLE_RECP_TOKEN ","
40
41 /*==================================================================================================
42 *                                                               FUNCTION IMPLEMENTATIONS
43 *==================================================================================================*/
44 static COMPOSER_EDIT_STATE_E __msg_ui_composer_edit_check(MSG_COMPOSER_VIEW_DATA_S *cd)
45 {
46         D_ENTER;
47         D_MSG_RETVM_IF(cd == NULL, COMPOSER_EDIT_NONE, "Composer Data == NULL");
48
49         bool isvalid_address = false;
50         bool iscontent_edited = false;
51
52         if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
53                 int recipient_count = msg_ui_composer_recipient_count_get(cd->recipient);
54                 if (recipient_count > 0) {
55                         isvalid_address = true;
56                 }
57
58                 const char *entry_str = msg_ui_composer_recipient_entry_text_get(cd->recipient);
59                 if (entry_str && strlen(entry_str)) {
60                         if (msg_ui_composer_recipient_vaild_check(entry_str) == EINA_TRUE)
61                                 isvalid_address = true;
62                 }
63         } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
64                 isvalid_address = true;
65         }
66
67         /* valid address & there is body content */
68         if (msg_ui_composer_common_is_send_possible(cd) == true)
69                 iscontent_edited = true;
70
71         if (isvalid_address && iscontent_edited)
72                 return COMPOSER_EDIT_RECIPIENT_AND_BODY;
73         else if (isvalid_address)
74                 return COMPOSER_EDIT_RECIPIENT;
75         else if (iscontent_edited)
76                 return COMPOSER_EDIT_BODY;
77         else
78                 return COMPOSER_EDIT_NONE;
79 }
80
81 static void __msgc_vconf_changed_cb(keynode_t *key, void *data)
82 {
83         D_ENTER;
84
85         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
86         D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
87         D_MSG_RETM_IF(key == NULL, "key is NULL");
88
89         int index = 0;
90         int font_size = 0;
91         int converted_size = 0;
92         char *key_name = NULL;
93
94         key_name = vconf_keynode_get_name(key);
95         if (!key_name) {
96                 D_EMSG("key_name is NULL");
97                 return;
98         }
99
100         if (!strcmp(key_name, VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE)) {
101                 index = vconf_keynode_get_int(key);
102                 font_size = msg_common_get_font_size_from_index(index);
103                 converted_size = (MSGC_BODY_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
104
105                 cd->font_size = converted_size;
106
107                 /* sync current font size as accessibility font index */
108                 if (msg_common_set_font_size(index) == FALSE)
109                         D_EMSG("msg_common_set_font_size(index = %d) is failed !!", index);
110
111                 /* sync msg accessibility font size with accessibility font index */
112                 if (msg_common_set_access_font_size(index) == FALSE)
113                         D_EMSG("vconf_set_int(VCONFKEY_MSG_APP_ACCESS_FONT_SIZE) is failed !!, [%d]", index);
114         } else if (!strcmp(key_name, VCONFKEY_MSG_APP_FONT_SIZE)) {
115                 index = vconf_keynode_get_int(key);
116                 font_size = msg_common_get_font_size_from_index(index);
117                 converted_size = (MSGC_BODY_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
118
119                 cd->font_size = converted_size;
120         } else {
121                 D_EMSG("key did not match.");
122         }
123
124         D_MSG("font size = %d", font_size);
125         D_MSG("converted font size = %d", converted_size);
126
127         D_LEAVE;
128 }
129
130 static void __msgc_init_font_size(MSG_COMPOSER_VIEW_DATA_S *cd)
131 {
132         D_ENTER;
133         D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
134
135         int index = 0;
136         int access_font_index = 0;
137         int msg_access_font_index = 0;
138         int font_size = 0;
139         int converted_size = 0;
140
141         /* get msg accessibility font index */
142         if (msg_common_get_access_font_size(&msg_access_font_index) == FALSE) {
143                 D_EMSG("msg_common_get_access_font_size is failed !!");
144                 msg_access_font_index = MSG_APP_FONT_SIZE_INDEX_NORMAL; /* 1 */
145         }
146
147         /* get accessibility font index */
148         if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &access_font_index) < 0) {
149                 D_EMSG("vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE) is failed !!");
150                 access_font_index = MSG_SYS_FONT_SIZE_INDEX_NORMAL;     /* 1 */
151         }
152
153         if (msg_common_get_font_size(&index) == FALSE) {
154                 D_EMSG("msg_common_get_font_size() is failed");
155                 cd->font_size = MSGC_BODY_FONT_SIZE;
156                 return;
157         } else {
158                 D_MSG("selected font_size index = %d", index);
159         }
160
161         D_MSG("VCONFKEY_MSG_APP_ACCESS_FONT_SIZE = %d", msg_access_font_index);
162         D_MSG("VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE = %d", access_font_index);
163
164         if (msg_access_font_index != access_font_index) {
165                 font_size = msg_common_get_font_size_from_index(access_font_index);
166
167                 /* sync current font size as accessibility font index */
168                 if (msg_common_set_font_size(access_font_index) == FALSE)
169                         D_EMSG("msg_common_set_font_size(index = %d) is failed !!", access_font_index);
170
171                 /* sync msg accessibility font size with accessibility font index */
172                 if (msg_common_set_access_font_size(access_font_index) == FALSE)
173                         D_EMSG("vconf_set_int(VCONFKEY_MSG_APP_ACCESS_FONT_SIZE) is failed !!, [%d]", access_font_index);
174         } else {
175                 font_size = msg_common_get_font_size_from_index(index);
176         }
177
178         converted_size = (MSGC_BODY_FONT_SIZE * font_size) / MSG_APP_FONT_SIZE_NORMAL;
179
180         cd->font_size = converted_size;
181         D_MSG("font size = %d, converted_size = %d", font_size, converted_size);
182
183         D_LEAVE;
184 }
185
186 static void __msgc_parse_recipient_list(MSG_COMPOSER_VIEW_DATA_S *cd, const char *address)
187 {
188         D_ENTER;
189         D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
190         D_MSG_RETM_IF(address == NULL, "address is NULL");
191
192         bool bMaxCount = false;
193         bool bInvalidNum = false;
194         bool bDup = false;
195
196         Eina_List *recipient_list = make_tokenize_list(address, ",");
197
198         if (recipient_list) {
199                 Eina_List *l = NULL;
200                 char *recipient;
201                 EINA_LIST_FOREACH(recipient_list, l, recipient) {
202                         if (recipient) {
203                                 D_MSG("TO = %s", recipient);
204                                 if (msg_ui_composer_recipient_count_get(cd->recipient) >= COMPOSER_RECIPIENT_COUNT_MAX) {
205                                         bMaxCount = true;
206                                         g_free(recipient);
207                                         break;
208                                 }
209
210                                 if (msg_ui_composer_recipient_duplicate_check(cd->recipient, recipient) == COMPOSER_RETURN_RECIPIENT_DUPLICATE) {
211                                         bDup = true;
212                                         g_free(recipient);
213                                         continue;
214                                 }
215
216                                 if (msg_ui_composer_recipient_vaild_check(recipient) == EINA_FALSE) {
217                                         bInvalidNum = true;
218                                 } else {
219                                         msg_ui_composer_recipient_append(cd->recipient, recipient, 0);
220                                 }
221
222                                 g_free(recipient);
223                         }
224                 }
225
226                 D_MSG("bMaxCount = %d, bInvalidNum = %d, bDup = %d", bMaxCount, bInvalidNum, bDup);
227                 if (bMaxCount) {
228                         msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_COUNT_MAX);
229                 } else if (bInvalidNum) {
230                         msg_ui_composer_status_btn_popup_show(cd, MSGC_STR_NOTI_RECIPIENT_INVALID, 0, MSGC_STR_BUTTON_OK);
231                 } else if (bDup) {
232                         msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_DUP_RECP);
233                 }
234         }
235
236         D_LEAVE;
237 }
238
239 static void __msgc_ui_parse_mmsto_uri(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle, const char *uri)
240 {
241         D_ENTER;
242         D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
243         D_MSG_RETM_IF(svc_handle == NULL, "svc_handle is NULL");
244         D_MSG_RETM_IF(uri == NULL, "uri is NULL");
245
246         char *content = NULL;
247         char *recipient = NULL;
248         char *body_text = NULL;
249         char *subject = NULL;
250         char *attachment = NULL;
251         char *cc = NULL;
252         char *scheme = g_strdup(uri);
253
254         if (scheme) {
255                 strtok_r(scheme, ":", &content);
256
257                 if (content) {
258                         if (g_ascii_isdigit(content[0]) || (content[0] == '+' && g_ascii_isdigit(content[1]))) {
259                                 recipient = strtok_r(NULL, "?", &content);
260                                 cc = strtok_r(NULL, "&", &content);
261                                 if (cc)
262                                         strtok_r(NULL, "=", &cc);
263
264                                 D_MSG("RECIPIENT = [%s]", recipient);
265                                 if (recipient)
266                                         __msgc_parse_recipient_list(cd, (const char *)recipient);
267                         }
268                 }
269                 g_free(scheme);
270         } else {
271                 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TO, &recipient) == SERVICE_ERROR_NONE) && recipient) {
272                         __msgc_parse_recipient_list(cd, (const char *)recipient);
273                 }
274         }
275
276         if ((service_get_extra_data(svc_handle, SERVICE_DATA_TEXT, &body_text) == SERVICE_ERROR_NONE) && body_text)
277                 msg_ui_composer_body_set_loaded_text(cd, (const char *)body_text, 0);
278
279         if ((service_get_extra_data(svc_handle, SERVICE_DATA_SUBJECT, &subject) == SERVICE_ERROR_NONE) && subject)
280                 msg_ui_composer_subject_set_loaded_data(cd, (const char *)subject);
281
282         if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_ATTACHFILE, &attachment) == SERVICE_ERROR_NONE) && attachment) {
283                 cd->attachlist = make_tokenize_list((const char *)attachment, COMPOSER_BUNDLE_ATTACH_TOKEN);
284                 if (cd->attachlist)
285                         msg_ui_composer_body_items_add(cd);
286         }
287
288         D_LEAVE;
289 }
290
291 static void __msgc_ui_parse_file_uri(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle, const char *uri)
292 {
293         D_ENTER;
294         D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
295         D_MSG_RETM_IF(uri == NULL, "uri is NULL");
296
297         char *content = NULL;
298         char attachment[DEF_IMG_PATH_LEN + 1] = {0, };
299         int i = 0;
300         int len = 0;
301         char *scheme = g_strdup(uri);
302
303         if (scheme) {
304                 strtok_r(scheme, ":", &content);
305                 D_MSG("content = [%s]", content);
306
307                 if (content) {
308                         len = strlen(content) - 2;
309                         if (len <= 0) {
310                                 D_EMSG("len is less than 0 !!");
311                                 g_free(scheme);
312                                 return;
313                         }
314
315                         /* Remove '//' from content string */
316                         for (i = 0; i < len; i++) {
317                                 attachment[i] = content[i+2];
318                         }
319
320                         if (attachment[0] != '\0') {
321                                 D_MSG("APPSVC ATTACHMENT = [%s]", attachment);
322                                 cd->attachlist = make_tokenize_list((const char *)attachment, COMPOSER_BUNDLE_ATTACH_TOKEN);
323                                 if (cd->attachlist)
324                                         msg_ui_composer_body_items_add(cd);
325                         }
326                 }
327                 g_free(scheme);
328         } else {
329                 D_EMSG("scheme is NULL!!");
330         }
331
332         D_LEAVE;
333 }
334
335 static void __msg_ui_parse_sms_uri(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle, const char *uri)
336 {
337         D_ENTER;
338         D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
339         D_MSG_RETM_IF(svc_handle == NULL, "svc_handle is NULL");
340         D_MSG_RETM_IF(uri == NULL, "uri is NULL");
341
342         char *content = NULL;
343         char *recipient = NULL;
344         char *body_text = NULL;
345         char *scheme = g_strdup(uri);
346
347         if (scheme) {
348                 strtok_r(scheme, ":", &content);
349
350                 if (content) {
351                         if (g_ascii_isdigit(content[0]) || (content[0] == '+' && g_ascii_isdigit(content[1]))) {
352                                 recipient = strtok_r(NULL, "?", &content);
353                                 D_MSG("RECIPIENT = [%s]", recipient);
354
355                                 if (recipient)
356                                         __msgc_parse_recipient_list(cd, (const char *)recipient);
357                         }
358                 }
359                 g_free(scheme);
360         } else {
361                 if ((service_get_extra_data(svc_handle, SERVICE_DATA_TO, &recipient) == SERVICE_ERROR_NONE) && recipient)
362                         __msgc_parse_recipient_list(cd, (const char *)recipient);
363         }
364
365         if ((service_get_extra_data(svc_handle, SERVICE_DATA_TEXT, &body_text) == SERVICE_ERROR_NONE) && body_text)
366                 msg_ui_composer_body_set_loaded_text(cd, (const char *)body_text, 0);
367
368         D_LEAVE;
369 }
370
371 static void __msgc_get_service_app_svc_op(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle, char *operation)
372 {
373         D_ENTER;
374         D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
375         D_MSG_RETM_IF(svc_handle == NULL, "svc_handle is NULL");
376         D_MSG_RETM_IF(operation == NULL, "operation is NULL");
377
378         char *uri = NULL;
379         char *recipient = NULL;
380         char *body_text = NULL;
381         char *attachment = NULL;
382         char *subject = NULL;
383
384         if (g_strcmp0(operation, SERVICE_OPERATION_SEND) == 0) {
385                 if (service_get_uri(svc_handle, &uri) == SERVICE_ERROR_NONE)
386                         D_MSG("URI = [%s]", uri);
387
388                 if (uri) {
389                         if (g_str_has_prefix(uri, MSG_BUNDLE_VALUE_MMSTO_URI)) { /* MMS URI : mmsto */
390                                  __msgc_ui_parse_mmsto_uri(cd, svc_handle, (const char *)uri);
391                         } else if (g_str_has_prefix(uri, MSG_BUNDLE_VALUE_FILE_URI)) { /* URI : file */
392                                  __msgc_ui_parse_file_uri(cd, svc_handle, (const char *)uri);
393                         } else if (g_str_has_prefix(uri, "/")) {
394                                 cd->attachlist = make_tokenize_list((const char *)uri, COMPOSER_BUNDLE_ATTACH_TOKEN);
395                                 if (cd->attachlist)
396                                         msg_ui_composer_body_items_add(cd);
397                         } else {
398                                 D_EMSG("Not supported URI type");
399                                 return;
400                         }
401                 } else {
402                         if ((service_get_extra_data(svc_handle, SERVICE_DATA_TO, &recipient) == SERVICE_ERROR_NONE) && recipient)
403                                 __msgc_parse_recipient_list(cd, (const char *)recipient);
404
405                         if ((service_get_extra_data(svc_handle, SERVICE_DATA_TEXT, &body_text) == SERVICE_ERROR_NONE) && body_text)
406                                 msg_ui_composer_body_set_loaded_text(cd, (const char *)body_text, 0);
407
408                         if ((service_get_extra_data(svc_handle, SERVICE_DATA_SUBJECT, &subject) == SERVICE_ERROR_NONE) && subject)
409                                 msg_ui_composer_subject_set_loaded_data(cd, (const char *)subject);
410
411                         if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_ATTACHFILE, &attachment) == SERVICE_ERROR_NONE) && attachment) {
412                                 cd->attachlist = make_tokenize_list((const char *)attachment, COMPOSER_BUNDLE_ATTACH_TOKEN);
413                                 if (cd->attachlist)
414                                         msg_ui_composer_body_items_add(cd);
415                         }
416                 }
417         } else if (g_strcmp0(operation, SERVICE_OPERATION_SEND_TEXT) == 0) {
418                 if (service_get_uri(svc_handle, &uri) == SERVICE_ERROR_NONE)
419                         D_MSG("URI = [%s]", uri);
420
421                 if (uri) {
422                         if (g_str_has_prefix(uri, MSG_BUNDLE_VALUE_SMS_URI)) {  /* SMS URI : sms */
423                                 __msg_ui_parse_sms_uri(cd, svc_handle, (const char *)uri);
424                         } else {
425                                 D_EMSG("Not supported mime type");
426                                 return;
427                         }
428                 } else {
429                         if ((service_get_extra_data(svc_handle, SERVICE_DATA_TO, &recipient) == SERVICE_ERROR_NONE) && recipient)
430                                 __msgc_parse_recipient_list(cd, (const char *)recipient);
431
432                         if ((service_get_extra_data(svc_handle, SERVICE_DATA_TEXT, &body_text) == SERVICE_ERROR_NONE) && body_text)
433                                 msg_ui_composer_body_set_loaded_text(cd, (const char *)body_text, 0);
434                 }
435         } else {
436                 D_EMSG("Invalid operation type !!");
437         }
438
439         D_LEAVE;
440 }
441
442 /* function definitions*/
443 static void __msg_ui_composer_bundle_data_process(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle)
444 {
445         D_ENTER;
446         D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
447         D_MSG_RETM_IF(svc_handle == NULL, "Bundle Data is NULL");
448
449         char *bundle_txt = NULL;
450
451         if (cd->isAppControl) { /* composer launching from appcontrol */
452                 char *operation = NULL;
453
454                 service_get_operation(svc_handle, &operation);
455                 __msgc_get_service_app_svc_op(cd, svc_handle, operation);
456         } else {
457                 if (cd->composer_mode == MSG_COMPOSER_MODE_EDIT || cd->composer_mode == MSG_COMPOSER_MODE_FORWARD) {
458                         if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_MSG_ID, &bundle_txt) == SERVICE_ERROR_NONE) && bundle_txt) {
459                                 bool set_recipient = false;
460                                 int msg_id = atoi(bundle_txt);
461
462                                 if (cd->composer_mode == MSG_COMPOSER_MODE_EDIT) {
463                                         cd->msg_id = msg_id;
464                                         set_recipient = true;
465                                 }
466
467                                 msg_ui_composer_message_init();
468                                 msg_ui_composer_message_load_message(cd->msg_handle, msg_id);
469                                 if (msg_ui_composer_message_set_loaded_data(cd, set_recipient) != COMPOSER_RETURN_CREATION_WARINING_MODE_FAIL)
470                                         msg_ui_composer_message_destroy();
471
472                         } else {
473                                 D_EMSG("there is no msgid");
474                         }
475                 } else {
476                         if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_TO, &bundle_txt) == SERVICE_ERROR_NONE) && bundle_txt) {
477                                 __msgc_parse_recipient_list(cd, bundle_txt);
478                         } else {
479                                 if ((service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_NUMBER_INDEX, &bundle_txt)== SERVICE_ERROR_NONE) && bundle_txt) {
480                                         char *recipient = NULL;
481                                         char *index  = NULL;
482                                         char *save_p = NULL;
483                                         int idx = 0;
484
485                                         char *copy_string = MSG_STRDUP(bundle_txt);
486                                         if (copy_string) {
487
488                                                 recipient = strtok_r(copy_string, "/", &save_p);
489                                                 if (recipient) {
490                                                         index = strtok_r(NULL, "/", &save_p);
491                                                         if (index) {
492                                                                 D_MSG("NUMBER_INDEX = %s[%s]", recipient, index);
493                                                                 idx = atoi(index);
494                                                         } else {
495                                                                 idx = 0;
496                                                         }
497
498                                                         if (msg_ui_composer_recipient_count_get(cd->recipient) >= COMPOSER_RECIPIENT_COUNT_MAX) {
499                                                                 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_COUNT_MAX);
500                                                         } else {
501                                                                 if (msg_ui_composer_recipient_duplicate_check(cd->recipient, recipient) == COMPOSER_RETURN_RECIPIENT_DUPLICATE) {
502                                                                         msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_DUP_RECP);
503                                                                 } else {
504                                                                         if (msg_ui_composer_recipient_vaild_check(recipient) == EINA_FALSE) {
505                                                                                 msg_ui_composer_status_btn_popup_show(cd, MSGC_STR_NOTI_RECIPIENT_INVALID, 0, MSGC_STR_BUTTON_OK);
506                                                                         } else {
507                                                                                 msg_ui_composer_recipient_append(cd->recipient, recipient, idx);
508                                                                         }
509                                                                 }
510                                                         }
511                                                 }
512
513                                                 g_free(copy_string);
514                                         }
515                                 }
516                         }
517
518                         if (SERVICE_ERROR_NONE == service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_SUBJECT, &bundle_txt))
519                                 msg_ui_composer_subject_set_loaded_data(cd, bundle_txt);
520
521                         if (SERVICE_ERROR_NONE == service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_BODY, &bundle_txt))
522                                 msg_ui_composer_body_set_loaded_text(cd, bundle_txt, 0);
523
524                         if (SERVICE_ERROR_NONE == service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_ATTACHFILE, &bundle_txt)) {
525                                 cd->attachlist = make_tokenize_list(bundle_txt, COMPOSER_BUNDLE_ATTACH_TOKEN);
526                                 if (cd->attachlist)
527                                         msg_ui_composer_body_items_add(cd);
528                         }
529                 }
530         }
531
532         D_LEAVE;
533 }
534
535 static void __msg_ui_composer_sent_status_cb(msg_handle_t Handle, msg_struct_t pStatus, void *pUserParam)
536 {
537         D_ENTER;
538         D_LEAVE;
539
540         return;
541 }
542
543 static void __end_popup_ok_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
544 {
545         D_ENTER;
546         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
547         D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
548
549         MSGC_EVAS_OBJECT_DEL(cd->popup_end);
550
551         ug_destroy_me(cd->ug);
552 }
553
554 static void __end_popup_cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
555 {
556         D_ENTER;
557         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
558         D_MSG_RETM_IF(cd == NULL, "composer data is NULL");
559
560         MSGC_EVAS_OBJECT_DEL(cd->popup_end);
561
562         cd->isclosed = false;
563
564         msg_ui_composer_last_focus_load(cd);
565         D_LEAVE;
566 }
567
568 static void  __msg_ui_composer_end_popup(MSG_COMPOSER_VIEW_DATA_S *cd)
569 {
570         D_ENTER;
571
572         MSGC_EVAS_OBJECT_DEL(cd->popup_end);
573
574         Evas_Object *popup = msg_ui_composer_status_popup_show(cd->main_window, cd, MSGC_STR_POP_DISCARD_Q, 0);
575         Evas_Object *btn1 = elm_button_add(popup);
576         elm_object_style_set(btn1, "popup_button/default");
577         elm_object_text_set(btn1, MSGC_STR_BUTTON_OK);
578         elm_object_part_content_set(popup, "button1", btn1);
579         evas_object_smart_callback_add(btn1, "clicked", __end_popup_ok_btn_clicked_cb, cd);
580         Evas_Object *btn2 = elm_button_add(popup);
581         elm_object_style_set(btn2, "popup_button/default");
582         elm_object_text_set(btn2, MSGC_STR_BUTTON_CANCEL);
583         elm_object_part_content_set(popup, "button2", btn2);
584         evas_object_smart_callback_add(btn2, "clicked", __end_popup_cancel_btn_clicked_cb, cd);
585         elm_object_focus_allow_set(popup, EINA_TRUE);
586         elm_object_focus_set(popup, EINA_TRUE);
587         evas_object_show(popup);
588
589         cd->popup_end = popup;
590
591         D_LEAVE;
592         return;
593 }
594
595 static void __naviframe_back_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
596 {
597         D_ENTER;
598         D_MSG_RETM_IF(data == NULL, "Data == NULL");
599         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
600
601         if (cd->is_keypad_show) {
602                 D_MSG("Hide keypad or clipboard");
603                 cd->hide_keypad_op = true;
604                 return;
605         }
606
607         COMPOSER_EDIT_STATE_E edit_state = __msg_ui_composer_edit_check(cd);
608         D_MSG("edit_state = %d", edit_state);
609
610         if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
611                 if (cd->isclosed) {
612                         D_EMSG("back btn is already called");
613                         return;
614                 }
615
616                 /* isclosed is set to prevent showing invalid popup*/
617                 cd->isclosed = true;
618
619                 if (edit_state == COMPOSER_EDIT_RECIPIENT || edit_state == COMPOSER_EDIT_BODY) {
620                         __msg_ui_composer_end_popup(cd);
621                         return;
622                 }
623         } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
624                 if (edit_state == COMPOSER_EDIT_RECIPIENT) {
625
626                         PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
627
628                         if (bubble_data->title_menu_opened)
629                                 msg_ui_bubble_close_title_menu_genlist(bubble_data);
630
631                         if (bubble_data->bubble_count == 0) {
632                                 int err = MSG_SUCCESS;
633
634                                 if (bubble_data->isDraft == true)
635                                         err = msg_delete_thread_message_list(bubble_data->msgHandle, bubble_data->threadId, false);
636
637                                 if (err == MSG_SUCCESS) {
638                                         service_h svc_handle;
639                                         char buf[DEF_BUF_LEN_S] = {0,};
640
641                                         if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
642                                                 D_EMSG("service_create() is failed !!");
643                                         } else {
644                                                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_RESULT, MSG_BUNDLE_VALUE_DEL_ALL);
645                                                 snprintf(buf, sizeof(buf), "%d", bubble_data->threadId);
646                                                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ID, buf);
647                                                 ug_send_result(cd->ug, svc_handle);
648
649                                                 service_destroy(svc_handle);
650                                         }
651                                 } else {
652                                         D_MSG("msg_delete_thread_message_list failed");
653                                 }
654                         }
655                 }
656         }
657
658         ug_destroy_me(cd->ug);
659
660         D_LEAVE;
661 }
662
663 static void __preview_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
664 {
665         D_ENTER;
666         MSG_COMPOSER_VIEW_DATA_S *cd = data;
667         D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
668         D_MSG_RETM_IF(cd->navi_it == NULL, "Naviitem is NULL");
669
670         msg_struct_t msgInfo = NULL;
671         msg_ui_composer_message_init();
672         msg_ui_composer_read_preview_message(cd);
673
674         /* make preview message data */
675         msgInfo = msg_ui_composer_message_make_preview(cd->msg_handle);
676
677         if (msgInfo)
678                 msg_ui_composer_external_call(cd, COMPOSER_EXT_TYPE_MSGVIEWER, msgInfo);
679
680         msg_ui_composer_message_destroy();
681
682         if (cd->ctx_popup) {
683                 evas_object_del(cd->ctx_popup);
684                 cd->ctx_popup = NULL;
685         }
686
687         D_LEAVE;
688 }
689
690 static void __pageduration_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
691 {
692         D_ENTER;
693         MSG_COMPOSER_VIEW_DATA_S *cd = data;
694         D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
695         D_MSG_RETM_IF(cd->navi_it == NULL, "Naviitem is NULL");
696
697         msg_ui_composer_pageduration_popup_create(cd);
698
699         if (cd->ctx_popup) {
700                 evas_object_del(cd->ctx_popup);
701                 cd->ctx_popup = NULL;
702         }
703
704         D_LEAVE;
705 }
706
707 static void __msg_ui_composer_ctxpopup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
708 {
709         MSG_UI_ENTER();
710         MSG_COMPOSER_VIEW_DATA_S *cd = data;
711
712         if (cd->ctx_popup) {
713                 evas_object_del(cd->ctx_popup);
714                 cd->ctx_popup = NULL;
715         }
716
717         MSG_UI_LEAVE();
718 }
719
720 static void msg_composer_naviframe_more_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
721 {
722         MSG_UI_ENTER();
723         MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !data || !obj);
724
725         MSG_COMPOSER_VIEW_DATA_S *cd = data;
726         PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
727         Evas_Object *ctx_popup = NULL;
728
729         if (cd->popup_end) {
730                 evas_object_del(cd->popup_end);
731                 cd->popup_end = NULL;
732         }
733
734         if (bubble_data) {
735                 if (bubble_data->popup) {
736                         evas_object_del(bubble_data->popup);
737                         bubble_data->popup = NULL;
738                 }
739
740                 if (bubble_data->title_menu_opened)
741                         msg_ui_bubble_close_title_menu_genlist(bubble_data);
742         }
743
744         /* fix ctx_popup flashing issue because of focus */
745         ctx_popup = elm_ctxpopup_add(cd->main_window);
746         elm_ctxpopup_direction_priority_set(ctx_popup, ELM_CTXPOPUP_DIRECTION_DOWN,
747                                                  ELM_CTXPOPUP_DIRECTION_UNKNOWN,
748                                                  ELM_CTXPOPUP_DIRECTION_UNKNOWN,
749                                                  ELM_CTXPOPUP_DIRECTION_UNKNOWN);
750
751         evas_object_smart_callback_add(ctx_popup, "dismissed", __msg_ui_composer_ctxpopup_dismissed_cb, cd);
752
753         if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
754                 elm_ctxpopup_item_append(ctx_popup, dgettext("sys_string", "IDS_COM_SK_DELETE"), NULL, msg_ui_bubble_more_delete_clicked_cb, cd);
755
756         if (cd->msg_type == COMPOSER_MSG_TYPE_MMS) {
757                 /* preview */
758                 if (msg_ui_composer_body_has_media(cd))
759                         elm_ctxpopup_item_append(ctx_popup, MSGC_STR_PREVIEW, NULL, __preview_btn_clicked_cb, cd);
760
761                 /* page duration */
762                 char buf[DEF_BUF_LEN_S + 1] = {0,};
763                 char duration[DEF_BUF_LEN_D + 1] = {0,};
764                 const char *str = _MSGSTR("IDS_MSGC_OPT2_DURATION_HPS_SEC_ABB");
765                 int pageduration = msg_ui_composer_pageduration_value_get(cd);
766
767                 snprintf(duration, sizeof(duration)-1, "%d", pageduration);
768                 snprintf(buf, sizeof(buf)-1, str, duration);
769                 elm_ctxpopup_item_append(ctx_popup, buf, NULL, __pageduration_btn_clicked_cb, cd);
770         }
771
772         if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
773                 elm_ctxpopup_item_append(ctx_popup, dgettext(MESSAGE_PKGNAME, "IDS_MSG_HEADER_BACKUP"), NULL, msg_ui_bubble_backup_clicked_cb, cd);
774
775         Evas_Coord x = 0;
776         Evas_Coord y = 0;
777         Evas_Coord w = 0;
778         Evas_Coord h = 0;
779         evas_object_geometry_get(cd->more_btn, &x, &y, &w, &h);
780         evas_object_move(ctx_popup, (x+(w/2)) , y+h);
781         evas_object_show(ctx_popup);
782
783         cd->ctx_popup = ctx_popup;
784
785         MSG_UI_LEAVE();
786 }
787
788 static void __naviframe_compose_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
789 {
790         D_ENTER;
791         MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !data || !obj);
792
793         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
794
795         if (cd->bubble_data->popup) {
796                 evas_object_del(cd->bubble_data->popup);
797                 cd->bubble_data->popup = NULL;
798         }
799
800         service_h svc_handle;
801
802         if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
803                 D_EMSG("service_create() is failed !!");
804         } else {
805                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_MODE, MSG_BUNDLE_VALUE_EDIT);
806                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_FROM, MSG_BUNDLE_VALUE_INTERNAL);
807                 msg_ui_composer_launch_composer_create(cd, svc_handle);
808                 service_destroy(svc_handle);
809         }
810         D_LEAVE;
811 }
812
813 static Evas_Object *__naviframe_back_btn_create(Evas_Object *parent, void *data, bool title)
814 {
815         D_ENTER;
816         D_MSG_RETVM_IF(parent == NULL, NULL, "parent == NULL");
817         D_MSG_RETVM_IF(data == NULL, NULL, "data == NULL");
818         D_MSG("Title type = %d", title);
819
820         Evas_Object *btn = NULL;
821         btn = elm_button_add(parent);
822         if (btn == NULL)
823                 return NULL;
824
825         if (title == true) {
826                 elm_object_style_set(btn, "naviframe/back_btn/default");
827         } else {
828                 elm_object_style_set(btn, "naviframe/back_btn/default");
829         }
830         evas_object_smart_callback_add(btn, "clicked", __naviframe_back_btn_clicked_cb, data);
831         evas_object_show(btn);
832         D_LEAVE;
833         return btn;
834 }
835
836 static Evas_Object *__naviframe_more_btn_create(Evas_Object *parent, void *data)
837 {
838         D_ENTER;
839         D_MSG_RETVM_IF(parent == NULL, NULL, "parent == NULL");
840         D_MSG_RETVM_IF(data == NULL, NULL, "data == NULL");
841
842         Evas_Object *btn = elm_button_add(parent);
843         if (!btn)
844                 return NULL;
845
846         elm_object_style_set(btn, "naviframe/more/default");
847
848         evas_object_smart_callback_add(btn, "clicked", msg_composer_naviframe_more_btn_clicked_cb, data);
849         evas_object_show(btn);
850         D_LEAVE;
851         return btn;
852 }
853
854 static Evas_Object *__naviframe_compose_btn_create(Evas_Object *parent, void *data)
855 {
856         D_ENTER;
857         D_MSG_RETVM_IF(parent == NULL, NULL, "parent == NULL");
858         D_MSG_RETVM_IF(data == NULL, NULL, "data == NULL");
859
860         Evas_Object *btn = elm_button_add(parent);
861         if (!btn)
862                 return NULL;
863         elm_object_style_set(btn, "naviframe/title_icon");
864
865         Evas_Object *icon = elm_icon_add(btn);
866         elm_image_file_set(icon, MSG_IMAGES_EDJ, MSG_UI_THREAD_LIST_TITLE_ICON_COMPOSE);
867         elm_image_resizable_set(icon, 1, 1);
868         evas_object_image_smooth_scale_set(icon, 0);
869         elm_object_content_set(btn, icon);
870         evas_object_smart_callback_add(btn, "clicked", __naviframe_compose_btn_clicked_cb, data);
871         D_LEAVE;
872
873         return btn;
874 }
875
876 void msg_ui_composer_reset_request(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle)
877 {
878         D_ENTER;
879
880         if (!cd)
881                 return;
882
883         COMPOSER_EDIT_STATE_E edit_state = __msg_ui_composer_edit_check(cd);
884         D_MSG("edit_state = %d", edit_state);
885         D_MSG("composer mode = %d, msg_ug_mode = %d", cd->composer_mode, cd->msg_ug_mode);
886
887         if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
888                 if (edit_state == COMPOSER_EDIT_RECIPIENT_AND_BODY) {
889                         /* auto saving */
890                         msg_ui_composer_message_init();
891
892                         if (msg_ui_composer_get_message_data(cd) == COMPOSER_RETURN_SUCCESS) {
893                                 /* delete draft message */
894                                 msg_thread_id_t tid = 0;
895
896                                 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
897                                         PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
898                                         tid = bubble_data->threadId;
899                                 } else {
900                                         GSList *address_list = msg_ui_composer_message_get_address();
901                                         msg_ui_composer_get_thread_id_by_address(cd->msg_handle, address_list, &tid);
902                                 }
903
904                                 D_MSG("tid = %d", tid);
905                                 if (tid > 0)
906                                         msg_ui_composer_delete_draft_message(cd->msg_handle, tid);
907
908                                 D_MSG("save draft message");
909                                 msg_ui_composer_save_message(cd->msg_handle, 0);
910                         }
911
912                         msg_ui_composer_message_destroy();
913                 }
914         } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
915                 if (edit_state == COMPOSER_EDIT_RECIPIENT) {
916                         PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
917
918                         if (bubble_data->title_menu_opened)
919                                 msg_ui_bubble_close_title_menu_genlist(bubble_data);
920
921                         if (bubble_data->bubble_count == 0) {
922                                 int err = MSG_SUCCESS;
923
924                                 if (bubble_data->isDraft == true)
925                                         err = msg_delete_thread_message_list(bubble_data->msgHandle, bubble_data->threadId, false);
926
927                                 if (err == MSG_SUCCESS) {
928                                         service_h svc_handle;
929                                         if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
930                                                 D_EMSG("service_create() is failed !!");
931                                         } else {
932                                                 char buf[DEF_BUF_LEN_S] = {0,};
933                                                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_RESULT, MSG_BUNDLE_VALUE_DEL_ALL);
934                                                 snprintf(buf, sizeof(buf), "%d", bubble_data->threadId);
935                                                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ID, buf);
936
937                                                 ug_send_result(cd->ug, svc_handle);
938
939                                                 service_destroy(svc_handle);
940                                         }
941                                 } else {
942                                         D_MSG("msg_delete_thread_message_list failed");
943                                 }
944                         } else {
945                                 /* delete draft message */
946                                 msg_struct_list_s msg_list = {0,};
947
948                                 if (msg_get_message_list(cd->msg_handle, MSG_DRAFT_ID, bubble_data->threadId, 0, 0, &msg_list) == COMPOSER_RETURN_SUCCESS) {
949                                         int i = 0;
950                                         int msgid = 0;
951
952                                         for (i = 0; i < msg_list.nCount; i++) {
953                                                 msg_get_int_value(msg_list.msg_struct_info[i], MSG_MESSAGE_ID_INT, &msgid);
954                                                 D_MSG("draft msg_id is %d", msgid);
955                                                 if (msg_delete_message(cd->msg_handle, msgid) != COMPOSER_RETURN_SUCCESS)
956                                                         D_EMSG("msg_ui_comp_core_delete_message is failed = %d", msgid);
957                                         }
958                                 }
959
960                                 msg_release_list_struct(&msg_list);
961                         }
962                 } else if (edit_state == COMPOSER_EDIT_RECIPIENT_AND_BODY) {
963                         /* auto saving */
964                         msg_ui_composer_message_init();
965
966                         if (msg_ui_composer_get_message_data(cd) == COMPOSER_RETURN_SUCCESS) {
967                                 /* delete draft message */
968                                 msg_thread_id_t tid = 0;
969
970                                 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
971                                         PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
972                                         tid = bubble_data->threadId;
973                                 } else {
974                                         GSList *address_list = msg_ui_composer_message_get_address();
975                                         msg_ui_composer_get_thread_id_by_address(cd->msg_handle, address_list, &tid);
976                                 }
977
978                                 D_MSG("tid = %d", tid);
979                                 if (tid > 0)
980                                         msg_ui_composer_delete_draft_message(cd->msg_handle, tid);
981
982                                 D_MSG("save draft message");
983                                 msg_ui_composer_save_message(cd->msg_handle, 0);
984                         }
985
986                         msg_ui_composer_message_destroy();
987                 }
988
989                 /* clear recipient_list of bubble composer */
990                 msg_ui_composer_recipient_clear_recipient_list(cd);
991         }
992
993         /*process reset*/
994         msg_ui_composer_reset(cd, svc_handle);
995
996         D_LEAVE;
997 }
998
999 /*
1000  *      1. clear all composer editing obj
1001  *      2. make composer using bundle val
1002 */
1003 COMPOSER_RETURN_TYPE_E msg_ui_composer_reset(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle)
1004 {
1005         D_ENTER;
1006         if (!cd)
1007                 return COMPOSER_RETURN_FAIL;
1008
1009         if (cd->working_path) {
1010                 ecore_file_recursive_rm(cd->working_path);
1011                 g_free(cd->working_path);
1012         }
1013
1014         cd->working_path = msg_composer_create_working_dir();
1015
1016         if (cd->working_path == NULL) {
1017                 D_EMSG("Fail of make working dir!!!");
1018                 return COMPOSER_RETURN_FAIL;
1019         }
1020
1021         if (svc_handle) {
1022                 msg_ui_composer_clear(cd);
1023
1024                 char *thread_id = NULL;
1025                 char *msg_id = NULL;
1026                 char *composer_mode = NULL;
1027                 char *from = NULL;
1028
1029                 service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ID, &thread_id);
1030                 service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_MSG_ID, &msg_id);
1031                 service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_MODE, &composer_mode);
1032                 service_get_extra_data(svc_handle, MSG_BUNDLE_KEY_FROM, &from);
1033
1034                 if (composer_mode) {
1035                         if (g_strcmp0(composer_mode, MSG_BUNDLE_VALUE_EDIT) == 0)
1036                                 cd->composer_mode = MSG_COMPOSER_MODE_EDIT;
1037                         else if (g_strcmp0(composer_mode, MSG_BUNDLE_VALUE_FORWARD) == 0)
1038                                 cd->composer_mode = MSG_COMPOSER_MODE_FORWARD;
1039                         else
1040                                 cd->composer_mode = MSG_COMPOSER_MODE_NORMAL;
1041                 } else {
1042                         cd->composer_mode = MSG_COMPOSER_MODE_NORMAL;
1043                 }
1044
1045                 if (from && g_strcmp0(from, MSG_BUNDLE_VALUE_INTERNAL) == 0)
1046                         cd->isMsgInternal = true;
1047                 else
1048                         cd->isMsgInternal = false;
1049
1050                 /*Change to Bubble view*/
1051                 if ((thread_id || msg_id) && cd->composer_mode == MSG_COMPOSER_MODE_NORMAL) {
1052                         D_MSG("bubble view composer mode = %d, msg_ug_mode = %d", cd->composer_mode, cd->msg_ug_mode);
1053
1054                         if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER) {
1055                                 D_MSG("change bubble view");
1056                                 msg_ui_composer_change_bubble_view(cd);
1057                                 msg_ui_bubble_parse_bubble_data(cd->bubble_data, svc_handle);
1058                                 msg_ui_bubble_start_view(cd->bubble_data);
1059                                 msg_ui_composer_navi_title_set((void *)cd);
1060
1061                                 /* set recipient list for bubble composer */
1062                                 msg_ui_composer_recipient_set_recipient_list(cd, cd->bubble_data->threadId);
1063                         } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1064                                 D_MSG("reload bubble view");
1065                                 msg_ui_bubble_parse_bubble_data(cd->bubble_data, svc_handle);
1066                                 msg_ui_bubble_list_load(cd->bubble_data, true);
1067                                 msg_ui_composer_navi_title_set((void *)cd);
1068
1069                                 /* set recipient list for bubble composer */
1070                                 msg_ui_composer_recipient_set_recipient_list(cd, cd->bubble_data->threadId);
1071                         } else {
1072                                 D_EMSG("Invalid type");
1073                         }
1074
1075                         cd->msg_ug_mode = MSG_UG_MODE_BUBBLE_COMPOSER;
1076                 } else {
1077                         D_MSG("normal composer composer mode = %d, msg_ug_mode = %d", cd->composer_mode, cd->msg_ug_mode);
1078
1079                         if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1080                                 D_MSG("change composer view");
1081                                 if (cd->bubble_data) {
1082                                         cd->bubble_data->ug_state = BUBBLE_UG_DESTROY;
1083                                         msg_ui_bubble_deinit_bubble_data(cd->bubble_data);
1084                                         cd->bubble_data = NULL;
1085                                 }
1086
1087                                 msg_ui_composer_change_composer_view(cd);
1088                         }
1089
1090                         if (cd->isMsgInternal == true)
1091                                 cd->msg_ug_mode = MSG_UG_MODE_FULL_COMPOSER;
1092                         else
1093                                 cd->msg_ug_mode = MSG_UG_MODE_ONLY_COMPOSER;
1094
1095                         __msg_ui_composer_bundle_data_process(cd, svc_handle);
1096                 }
1097         }
1098
1099         D_LEAVE;
1100         return COMPOSER_RETURN_SUCCESS;
1101 }
1102
1103 COMPOSER_RETURN_TYPE_E msg_ui_composer_start(MSG_COMPOSER_VIEW_DATA_S *cd, service_h svc_handle)
1104 {
1105         D_ENTER;
1106         D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer Data is NULL");
1107
1108         COMPOSER_RETURN_TYPE_E ret = COMPOSER_RETURN_SUCCESS;
1109         cd->state = COMPOSER_STATE_TYPE_RUNNING;
1110
1111         /* bundle data parsing */
1112         if (svc_handle) {
1113                 if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1114                         cd->isLoad = true;
1115                         __msg_ui_composer_bundle_data_process(cd, svc_handle);
1116
1117                         if (cd->attachlist == NULL)
1118                                 cd->isLoad = false;
1119
1120                 } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1121                         D_MSG("START BUBBLE COMPOSER");
1122                         PMSG_BUBBLE_DATA bubble_data = (PMSG_BUBBLE_DATA)cd->bubble_data;
1123                         msg_ui_bubble_parse_bubble_data(bubble_data, svc_handle);
1124                         msg_ui_bubble_start_view(bubble_data);
1125                         msg_ui_composer_navi_title_set((void *)cd);
1126
1127                         /* set recipient list for bubble composer */
1128                         msg_ui_composer_recipient_set_recipient_list(cd, cd->bubble_data->threadId);
1129                 }
1130         }
1131
1132         /* set first focus*/
1133         if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1134                 if (!msg_ui_composer_popup_exist(cd)) {
1135
1136                         int recipient_count = msg_ui_composer_recipient_count_get(cd->recipient);
1137
1138                         if (recipient_count > 0) {
1139                                 msg_ui_composer_body_focus_set(cd, 0);
1140                                 msg_ui_composer_recipient_expanded_set(cd->recipient, EINA_FALSE);
1141                         } else {
1142                                 msg_ui_composer_recipient_focus_set(cd->recipient);
1143                         }
1144                 }
1145         }
1146
1147         D_LEAVE;
1148         return ret;
1149 }
1150
1151 static void __msg_composer_auto_save_and_delete_msg(MSG_COMPOSER_VIEW_DATA_S *cd)
1152 {
1153         D_ENTER;
1154         D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
1155
1156         /* save and delete msg */
1157         if (!cd->disable_auto_save_mode) {
1158                 COMPOSER_EDIT_STATE_E edit_state = __msg_ui_composer_edit_check(cd);
1159                 if (edit_state == COMPOSER_EDIT_RECIPIENT_AND_BODY) {
1160
1161                         /* auto save composer data */
1162                         msg_ui_composer_message_init();
1163                         if (msg_ui_composer_get_message_data(cd) == COMPOSER_RETURN_SUCCESS) {
1164                                 /* delete draft message */
1165                                 msg_thread_id_t tid = 0;
1166
1167                                 if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1168                                         PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
1169                                         tid = bubble_data->threadId;
1170                                 } else {
1171                                         GSList *address_list = msg_ui_composer_message_get_address();
1172                                         msg_ui_composer_get_thread_id_by_address(cd->msg_handle, address_list, &tid);
1173                                 }
1174
1175                                 D_MSG("tid = %d", tid);
1176                                 if (tid > 0)
1177                                         msg_ui_composer_delete_draft_message(cd->msg_handle, tid);
1178
1179                                 D_MSG("save draft message");
1180                                 msg_ui_composer_save_message(cd->msg_handle, 0);
1181                                 /* show saved ticker popup */
1182                                 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_AUTO_SAVED);
1183                         }
1184
1185                         msg_ui_composer_message_destroy();
1186                 } else if (edit_state == COMPOSER_EDIT_RECIPIENT) {
1187                         if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1188                                 /* delete draft message */
1189                                 MSG_BUBBLE_DATA *bubble_data = cd->bubble_data;
1190
1191                                 if (bubble_data) {
1192                                         msg_ui_composer_delete_draft_message(cd->msg_handle, bubble_data->threadId);
1193                                 }
1194                         }
1195                 }
1196         }
1197
1198         D_LEAVE;
1199 }
1200
1201 COMPOSER_RETURN_TYPE_E msg_ui_composer_destroy(MSG_COMPOSER_VIEW_DATA_S *cd)
1202 {
1203         D_ENTER;
1204         COMPOSER_RETURN_TYPE_E ret = COMPOSER_RETURN_SUCCESS;
1205
1206         msg_ui_composer_decrease_ref_count();
1207
1208         if (!cd)
1209                 return COMPOSER_RETURN_FAIL;
1210
1211         D_PRINT("===== Composer UG Destroy Start =====");
1212
1213         __msg_composer_auto_save_and_delete_msg(cd);
1214
1215         /* discoonect volume key handler */
1216         msg_ui_composer_disconnect_handler(cd);
1217
1218         contacts_disconnect2();
1219
1220         D_PRINT("----- Unregister vconf callback -----");
1221         if (vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, __msgc_vconf_changed_cb) < 0) {
1222                 D_EMSG("Fail to unregister vconf CB with [%s]", VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE);
1223         }
1224         if (vconf_ignore_key_changed(VCONFKEY_MSG_APP_FONT_SIZE, __msgc_vconf_changed_cb) < 0) {
1225                 D_EMSG("Fail to unregister vconf CB with [%s]", VCONFKEY_MSG_APP_FONT_SIZE);
1226         }
1227
1228         if (cd->tapi_handle) {
1229                 if (tel_deinit(cd->tapi_handle) != TAPI_API_SUCCESS)
1230                         D_EMSG("tel_deinit is failed");
1231                 cd->tapi_handle = NULL;
1232         }
1233
1234         if(cd->job_thread_end) {
1235                 D_PRINT("----- Job Delete -----");
1236                 ecore_job_del(cd->job_thread_end);
1237                 cd->job_thread_end = NULL;
1238         }
1239
1240         if(cd->attach_thread) {
1241                 D_PRINT("----- Thread Delete -----");
1242                 ecore_thread_cancel(cd->attach_thread);
1243                 cd->attach_thread = NULL;
1244         }
1245
1246         if (cd->last_focus_idler) {
1247                 D_PRINT("----- idler Delete -----");
1248                 ecore_idler_del(cd->last_focus_idler);
1249                 cd->last_focus_idler = NULL;
1250         }
1251
1252         if (cd->flight_mode_timer) {
1253                 ecore_timer_del(cd->flight_mode_timer);
1254                 cd->flight_mode_timer = NULL;
1255         }
1256
1257         if (cd->recipient) {
1258                 D_PRINT("----- Recipient Delete -----");
1259                 msg_ui_composer_recipient_delete(cd->recipient);
1260                 cd->recipient = NULL;
1261         }
1262
1263         D_PRINT("----- Recipient list Clear -----");
1264         msg_ui_composer_recipient_clear_recipient_list(cd);
1265
1266         D_PRINT("----- Predict Search Delete -----");
1267         msg_ui_composer_predictsearch_list_delete(cd);
1268
1269         D_PRINT("----- Body Delete -----");
1270         msg_ui_composer_body_delete(cd);
1271
1272         D_PRINT("----- Close Msg Handle -----");
1273         msg_close_msg_handle(&cd->msg_handle);
1274
1275         D_PRINT("----- Delete Popup  -----");
1276         msg_ui_composer_popup_delete_all(cd);
1277
1278         if (cd->working_path) {
1279                 ecore_file_recursive_rm(cd->working_path);
1280                 g_free(cd->working_path);
1281                 cd->working_path = NULL;
1282         }
1283
1284         if (cd->th) {
1285                 elm_theme_extension_del(cd->th, MSG_CUSTOM_WINSET_EDJ);
1286                 elm_theme_free(cd->th);
1287                 cd->th = NULL;
1288         }
1289
1290         /* rollback indicator mode to previous mode */
1291         if (msg_ui_composer_get_ref_count() <= 0)
1292                 elm_win_indicator_mode_set(cd->main_window, cd->indicator_mode);
1293
1294         D_PRINT("===== Composer UG Destroy End =====");
1295
1296         D_LEAVE;
1297         return ret;
1298 }
1299
1300 void msg_ui_composer_change_language(MSG_COMPOSER_VIEW_DATA_S *cd)
1301 {
1302         D_ENTER;
1303         D_MSG_RETM_IF(cd == NULL, "cd is NULL");
1304
1305         if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1306                 /* destroy popup */
1307                 msg_ui_composer_popup_delete_all(cd);
1308
1309                 if (cd->ctx_popup) {
1310                         evas_object_del(cd->ctx_popup);
1311                         cd->ctx_popup = NULL;
1312                 }
1313
1314                 /* title */
1315                 msg_ui_composer_navi_title_set(cd);
1316
1317                 /* recipient */
1318                 if (cd->recipient) {
1319                         Evas_Object *mbe = cd->recipient->mbe;
1320
1321                         /* set mbe label */
1322                         char label_txt[TO_FIELD_LABEL_SIZE_MAX] = { 0, };
1323                         gsize len = 0;
1324
1325                         len = snprintf(label_txt, (gsize)sizeof(label_txt), "%s:", MSGC_STR_TO);
1326                         if (len == -1) {
1327                                 D_EMSG("len = %d", len);
1328                         } else if (len > 0) {
1329                                 label_txt[len] = '\0';
1330                                 elm_object_text_set(mbe, label_txt);
1331                         } else {
1332                                 D_EMSG("len = %d", len);
1333                         }
1334
1335                         /* set guide text */
1336                         elm_object_part_text_set(mbe, "guide", MSGC_STR_ADD_RECIPIENT);
1337                 }
1338
1339                 /* subject */
1340                 if (cd->sub_data.entry)
1341                         edje_object_part_text_set(_EDJ(cd->sub_data.layout), "subject.guidetxt", MSGC_STR_SUBJECT);
1342
1343                 /* attachment */
1344                 if (cd->ly_attach_main) {
1345                         char buf[DEF_BUF_LEN_S + 1] = {0,};
1346                         const char *str = _MSGSTR("IDS_MSGC_BODY_PD_ATTACHMENTS");
1347
1348                         snprintf(buf, sizeof(buf), str, cd->attach_data.attachment_Cnt);
1349                         edje_object_part_text_set(_EDJ(cd->ly_attach_main), "text.filename", buf);
1350                 }
1351
1352                 /* mms size */
1353                 if (cd->msg_type == COMPOSER_MSG_TYPE_MMS)
1354                         msg_ui_composer_body_info_area_update(cd);
1355         }
1356
1357         cd->isclosed = false;
1358
1359         D_LEAVE;
1360 }
1361
1362 COMPOSER_RETURN_TYPE_E msg_ui_composer_rotate(MSG_COMPOSER_VIEW_DATA_S *cd, COMPOSER_ROTATE_TYPE_E rotate)
1363 {
1364         D_ENTER;
1365         D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "cd is NULL");
1366
1367         cd->rotate = rotate;
1368         D_MSG("rotate val [%d]", rotate);
1369
1370         if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1371
1372                 RECIPIENT_S *r = cd->recipient;
1373                 if (!r) return COMPOSER_RETURN_FAIL;
1374
1375                 if (rotate == COMPOSER_ROTATE_PORTRAIT || rotate == COMPOSER_ROTATE_PORTRAIT_UPSIDEDOWN) {
1376                         elm_layout_theme_set(cd->base, "layout", "application", "default");
1377
1378                         if (!cd->loaded_ug)
1379                                 elm_win_indicator_mode_set(cd->main_window, ELM_WIN_INDICATOR_SHOW);
1380
1381                         elm_box_horizontal_set(r->bx_main, EINA_FALSE);
1382                         elm_scroller_content_min_limit(r->sc, EINA_FALSE, EINA_TRUE);
1383                         evas_object_size_hint_max_set(r->sc, 9999, COMPOSER_RECIPIENT_PORTRAIT_HEIGHT_MAX);
1384                 } else if (rotate == COMPOSER_ROTATE_LANDSCAPE || rotate == COMPOSER_ROTATE_LANDSCAPE_UPSIDEDOWN) {
1385                         elm_layout_theme_set(cd->base, "layout", "application", "noindicator");/*hide indicator in Landscape*/
1386
1387                         if (!cd->loaded_ug) {
1388                                 elm_win_indicator_mode_set(cd->main_window, ELM_WIN_INDICATOR_HIDE);
1389                                 D_MSG("hide indicator");
1390                         }
1391
1392                         elm_box_horizontal_set(r->bx_main, EINA_TRUE);
1393                         elm_scroller_content_min_limit(r->sc, EINA_FALSE, EINA_FALSE);
1394                         evas_object_size_hint_max_set(r->sc, 9999, -1);
1395                 }
1396
1397                 /* change body scroller size */
1398                 msg_ui_composer_change_body_scroll_size(cd, 0);
1399
1400         } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER) {
1401                 if (rotate == COMPOSER_ROTATE_PORTRAIT || rotate == COMPOSER_ROTATE_PORTRAIT_UPSIDEDOWN) {
1402                         if (cd->bubble_data)
1403                                 cd->bubble_data->isRotate = false;
1404
1405                         if (cd->compose_btn) {
1406                                 evas_object_hide(cd->compose_btn);
1407                                 elm_object_part_content_unset(cd->navi_title_layout, "compose_btn");
1408                         }
1409                 } else if (rotate == COMPOSER_ROTATE_LANDSCAPE || rotate == COMPOSER_ROTATE_LANDSCAPE_UPSIDEDOWN) {
1410                         if (cd->bubble_data) {
1411                                 cd->bubble_data->isRotate = true;
1412
1413                                 if (cd->compose_btn && cd->bubble_data->viewmode == BUBBLE_NORMAL_VIEW) {
1414                                         evas_object_show(cd->compose_btn);
1415                                         elm_object_part_content_set(cd->navi_title_layout, "compose_btn", cd->compose_btn);
1416                                 }
1417                         }
1418                 }
1419
1420                 elm_win_indicator_mode_set(cd->main_window, ELM_WIN_INDICATOR_SHOW);
1421
1422                 /* change body scroller size */
1423                 msg_ui_composer_change_body_scroll_size(cd, 0);
1424
1425         } else {
1426                 D_EMSG("Unknown Composer Mode");
1427                 return COMPOSER_RETURN_FAIL;
1428         }
1429
1430         D_LEAVE;
1431         return COMPOSER_RETURN_SUCCESS;
1432 }
1433
1434 COMPOSER_RETURN_TYPE_E msg_ui_composer_init(MSG_COMPOSER_VIEW_DATA_S *cd)
1435 {
1436         D_ENTER;
1437
1438         if (cd == NULL) {
1439                 D_EMSG("[ASSERT] pcmop_data is NULL");
1440                 return COMPOSER_RETURN_FAIL;
1441         }
1442
1443         /* create message handle */
1444         if (msg_open_msg_handle(&cd->msg_handle) != MSG_SUCCESS) {
1445                 D_EMSG("[ASSERT] msg-server doesn't response !!!");
1446                 return COMPOSER_RETURN_FAIL;
1447         }
1448
1449         /* set message sent status callback */
1450         if (msg_reg_sent_status_callback(cd->msg_handle, &__msg_ui_composer_sent_status_cb, cd) != MSG_SUCCESS) {
1451                 D_EMSG("[ASSERT] sent status callback register error!!!");
1452                 return COMPOSER_RETURN_FAIL;
1453         }
1454
1455         /* connect contacts svc*/
1456         if (contacts_connect2() != 0) {
1457                 D_EMSG("[ASSERT] Fail of contacts_connect2 !!!");
1458                 return COMPOSER_RETURN_FAIL;
1459         }
1460
1461         cd->working_path = msg_composer_create_working_dir();
1462         if (cd->working_path == NULL) {
1463                 D_EMSG("[ASSERT] Fail of make working dir!!!");
1464                 return COMPOSER_RETURN_FAIL;
1465         }
1466
1467         /* set default message type is SMS */
1468         cd->msg_type = COMPOSER_MSG_TYPE_SMS;
1469
1470         /* get sms setting */
1471         msg_struct_t sms_sent_opt = msg_create_struct(MSG_STRUCT_SETTING_SMS_SEND_OPT);
1472
1473         if (msg_get_sms_send_opt(cd->msg_handle, sms_sent_opt) != MSG_SUCCESS) {
1474                 D_EMSG("Getting SMS_SEND_OP ERROR");
1475         } else {
1476                 msg_get_int_value(sms_sent_opt, MSG_SMS_SENDOPT_ENCODE_TYPE_INT, &cd->encode_mode);
1477                 D_MSG("SMS Encode mode is %d", cd->encode_mode);
1478         }
1479
1480         msg_release_struct(&sms_sent_opt);
1481
1482         if (cd->cms_max_page == 0) {
1483                 // TODO: get cms max page from msgfw when it is supported by msgfw.
1484                 cd->cms_max_page = COMPOSER_CMS_MAX_PAGE;
1485         }
1486
1487         /* get mms max size */
1488         if (cd->mms_max_size == 0) {
1489                 msg_struct_t setting = msg_create_struct(MSG_STRUCT_SETTING_MSGSIZE_OPT);
1490
1491                 if (msg_get_msgsize_opt(cd->msg_handle, setting) != MSG_SUCCESS) {
1492                         D_EMSG("Getting MMS MAX SIZE ERROR");
1493                 } else {
1494                         if (setting)
1495                                 msg_get_int_value(setting, MSG_MESSAGE_SIZE_INT, &cd->mms_max_size);
1496
1497                         D_MSG("msg max size = [%d KB] !!!", cd->mms_max_size);
1498                         cd->mms_max_size = cd->mms_max_size * 1024;
1499                 }
1500                 msg_release_struct(&setting);
1501         }
1502
1503         /* set default font size*/
1504         __msgc_init_font_size(cd);
1505
1506         /* coonect volume key handler */
1507         msg_ui_composer_connect_handler(cd);
1508
1509         /* register vconf callback function */
1510         if (vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, __msgc_vconf_changed_cb, cd) < 0) {
1511                 D_EMSG("Fail to register vconf CB with [%s]", VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE);
1512         }
1513         if (vconf_notify_key_changed(VCONFKEY_MSG_APP_FONT_SIZE, __msgc_vconf_changed_cb, cd) < 0) {
1514                 D_EMSG("Fail to register vconf CB with [%s]", VCONFKEY_MSG_APP_FONT_SIZE);
1515         }
1516
1517         cd->th = elm_theme_new();
1518         elm_theme_ref_set(cd->th, NULL);
1519         elm_theme_extension_add(cd->th, MSG_CUSTOM_WINSET_EDJ);
1520
1521         return COMPOSER_RETURN_SUCCESS;
1522 }
1523
1524 /*
1525  * Create Composer First View
1526  */
1527 COMPOSER_RETURN_TYPE_E msg_ui_composer_create(MSG_COMPOSER_VIEW_DATA_S *cd)
1528 {
1529         D_ENTER;
1530         D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer data is NULL");
1531         D_MSG_RETVM_IF(cd->main_window == NULL, COMPOSER_RETURN_FAIL, "main_window is NULL");
1532         D_MSG_RETVM_IF(cd->base == NULL, COMPOSER_RETURN_FAIL, "base layout is NULL");
1533
1534         Evas_Object *navi_frame = NULL;
1535         Evas_Object *more_button = NULL;
1536         Evas_Object *compose_button = NULL;
1537         Evas_Object *content_layout = NULL;
1538         Elm_Object_Item *navi_it = NULL;
1539         Evas_Object *back_btn = NULL;
1540
1541         /* State Set */
1542         cd->state = COMPOSER_STATE_TYPE_CREATE;
1543
1544         /* Create naviframe */
1545         navi_frame = elm_naviframe_add(cd->base);
1546         if (!navi_frame) {
1547                 D_EMSG("naviframe add fail");
1548                 goto error_return;
1549         }
1550
1551         evas_object_show(navi_frame);
1552         cd->navi_bar = navi_frame;
1553
1554         /* Create content layout */
1555         content_layout = elm_layout_add(navi_frame);
1556         if (!content_layout) {
1557                 D_EMSG("layout add fail");
1558                 goto error_return;
1559         }
1560
1561         if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1562                 elm_layout_file_set(content_layout, MSGC_UI_DEFAULT_EDJ, MSGC_EDJ_GRP_CONTENT_LAYOUT);
1563         } else if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER){
1564                 elm_layout_file_set(content_layout, MSGC_UI_DEFAULT_EDJ, MSGC_EDJ_GRP_CONTENT_LAYOUT);
1565                 edje_object_signal_emit(_EDJ(content_layout), "change.bubble", "*");
1566         } else {
1567                 D_EMSG("UG mode Unknown");
1568                 goto error_return;
1569         }
1570
1571         evas_object_size_hint_weight_set(content_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1572         evas_object_size_hint_align_set(content_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1573         edje_object_signal_emit(_EDJ(content_layout), "hide.predictsearch", "*");
1574         evas_object_show(content_layout);
1575
1576         cd->content_layout = content_layout;
1577
1578         /*Create content*/
1579         if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1580                 cd->recipient = msg_ui_composer_recipient_create(content_layout, 1, cd);
1581                 if (cd->recipient == NULL)
1582                         goto error_return;
1583
1584                 elm_object_part_content_set(content_layout, "swl.recipient", cd->recipient->bx_main);
1585
1586                 Evas_Object *predict_search_layout = msg_ui_composer_predictsearch_list_create(content_layout, cd);
1587                 elm_object_part_content_set(content_layout, "swl.predictsearch", predict_search_layout);
1588
1589         } else {
1590                 PMSG_BUBBLE_DATA bubble_data = msg_ui_bubble_init_bubble_data(cd->msg_handle, cd);
1591                 if (!bubble_data) {
1592                         goto error_return;
1593                 }
1594
1595                 cd->bubble_data = bubble_data;
1596
1597                 Evas_Object *bubble_layout = msg_ui_bubble_create_view(content_layout, cd->bubble_data);
1598                 if (!bubble_layout) {
1599                         goto error_return;
1600                 }
1601                 elm_object_part_content_set(content_layout, "swl.bubble.content", bubble_layout);
1602         }
1603
1604         Evas_Object *body_layout = msg_ui_composer_body_create(cd, content_layout);
1605         if (!body_layout) {
1606                 goto error_return;
1607         }
1608
1609         elm_object_part_content_set(content_layout, "swl.composer.body", body_layout);
1610
1611         cd->ly_body = body_layout;
1612
1613         /*Push content to navi frame*/
1614         if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1615                 if (cd->isMsgInternal)
1616                         back_btn = __naviframe_back_btn_create(navi_frame, (void *)cd, false);
1617                 else
1618                         back_btn = __naviframe_back_btn_create(navi_frame, (void *)cd, true);
1619         } else {
1620                 back_btn = __naviframe_back_btn_create(navi_frame, (void *)cd, false);
1621         }
1622
1623         evas_object_event_callback_add(navi_frame, EVAS_CALLBACK_CHANGED_SIZE_HINTS, msg_ui_composer_naviframe_size_hints_changed, cd);
1624
1625         navi_it = elm_naviframe_item_push(navi_frame, NULL, NULL, NULL, content_layout, "empty");
1626
1627         cd->navi_it = navi_it;
1628         cd->back_btn = back_btn;
1629
1630         /* create navi title layout */
1631         cd->navi_title_layout = msg_ui_composer_create_navi_title_bar(cd);
1632         msg_ui_composer_navi_title_set(cd);
1633         elm_object_item_part_content_set(cd->navi_it, "title", cd->navi_title_layout);
1634
1635         /*Create more button*/
1636         more_button = __naviframe_more_btn_create(navi_frame, cd);
1637
1638         elm_object_part_content_set(cd->navi_title_layout, "more_btn", more_button);
1639         elm_object_part_content_set(cd->navi_title_layout, "prev_btn", back_btn);
1640
1641         cd->more_btn = more_button;
1642
1643         if (cd->msg_type == COMPOSER_MSG_TYPE_SMS && cd->msg_ug_mode != MSG_UG_MODE_BUBBLE_COMPOSER)
1644                 elm_object_disabled_set(cd->more_btn, EINA_TRUE);
1645
1646         /*Create compose button*/
1647         compose_button = __naviframe_compose_btn_create(navi_frame, cd);
1648
1649         if (cd->bubble_data != NULL && cd->bubble_data->isRotate == true) {
1650                 evas_object_show(compose_button);
1651                 elm_object_part_content_set(cd->navi_title_layout, "compose_btn", compose_button);
1652         } else {
1653                 evas_object_hide(compose_button);
1654                 elm_object_part_content_unset(cd->navi_title_layout, "compose_btn");
1655         }
1656
1657         cd->compose_btn = compose_button;
1658
1659         /* set navibar to main layout (base) */
1660         elm_object_part_content_set(cd->base, "elm.swallow.content", navi_frame);
1661
1662         D_LEAVE;
1663         return COMPOSER_RETURN_SUCCESS;
1664
1665 error_return:
1666         return COMPOSER_RETURN_FAIL;
1667 }
1668
1669 COMPOSER_RETURN_TYPE_E msg_ui_composer_bubble_data_set(MSG_COMPOSER_VIEW_DATA_S *cd, int thread_id)
1670 {
1671         D_ENTER;
1672         D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer data is NULL");
1673         D_MSG_RETVM_IF(cd->msg_ug_mode != MSG_UG_MODE_BUBBLE_COMPOSER, COMPOSER_RETURN_FAIL, "msg_ug_mode is NOT BUBBLE TYPE");
1674         D_MSG_RETVM_IF(thread_id <=  0, COMPOSER_RETURN_FAIL, "Composer mode is Not Full");
1675         D_MSG_RETVM_IF(cd->bubble_data == NULL, COMPOSER_RETURN_FAIL, "bubble data is NULL");
1676
1677         PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
1678         msg_struct_t threadInfo = NULL;
1679         int err;
1680
1681         /*Create bubble list*/
1682         bubble_data->threadId = thread_id;
1683         D_MSG("Thread ID = %d", bubble_data->threadId);
1684
1685         msg_struct_list_s addrList;
1686         int i = 0;
1687         memset(&addrList, 0x00, sizeof(msg_struct_list_s));
1688
1689         err = msg_get_address_list(bubble_data->msgHandle, bubble_data->threadId, &addrList);
1690
1691         if (err == MSG_SUCCESS) {
1692                 bubble_data->addr_list.addr_cnt = addrList.nCount;
1693
1694                 for (i = 0; i<addrList.nCount; i++) {
1695                         int contact_id = 0;
1696                         msg_get_int_value(addrList.msg_struct_info[i], MSG_ADDRESS_INFO_CONTACT_ID_INT, &contact_id);
1697                         /** addresss */
1698                         msg_get_str_value(addrList.msg_struct_info[i], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, bubble_data->addr_list.addr_info[i].address, DEF_THREAD_ADDR_LEN);
1699
1700                         /** contact ID & display name */
1701                         if (contact_id > 0) {
1702                                 bubble_data->addr_list.addr_info[i].contact_id = contact_id;
1703                                 msg_get_str_value(addrList.msg_struct_info[i], MSG_ADDRESS_INFO_DISPLAYNAME_STR, bubble_data->addr_list.addr_info[i].name, DEF_THREAD_NAME_LEN);
1704                         } else {
1705                                 bubble_data->addr_list.addr_info[i].contact_id = 0;
1706                         }
1707                 }
1708
1709                 msg_release_list_struct(&addrList);
1710         } else {
1711                 D_MSG("[ERROR] msg_get_address_list returns error [%d]", err);
1712         }
1713
1714         threadInfo = msg_create_struct(MSG_STRUCT_THREAD_INFO);
1715         err = msg_get_thread(bubble_data->msgHandle, bubble_data->threadId, threadInfo);
1716
1717         if (err == MSG_SUCCESS)
1718                 msg_get_str_value(threadInfo, MSG_THREAD_NAME_STR, bubble_data->threadName, DEF_THREAD_NAME_LEN);
1719         else
1720                 D_MSG("[ERROR] msg_get_trhead returns error [%d", err);
1721
1722         msg_release_struct(&threadInfo);
1723
1724         return COMPOSER_RETURN_SUCCESS;
1725 }
1726
1727 COMPOSER_RETURN_TYPE_E msg_ui_composer_change_composer_view(MSG_COMPOSER_VIEW_DATA_S *cd)
1728 {
1729         D_ENTER;
1730         D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer data is NULL");
1731         D_MSG_RETVM_IF(cd->msg_ug_mode != MSG_UG_MODE_BUBBLE_COMPOSER, COMPOSER_RETURN_FAIL, "Composer mode is Not Full");
1732
1733         /*Change Mode */
1734         cd->msg_ug_mode = MSG_UG_MODE_ONLY_COMPOSER;
1735
1736         /*Change content layout to composer layout*/
1737         edje_object_signal_emit(_EDJ(cd->content_layout), "change.composer", "*");
1738
1739         elm_scroller_content_min_limit(cd->body_scroll, 0, 0);
1740
1741         cd->recipient = msg_ui_composer_recipient_create(cd->content_layout, 1, cd);
1742         elm_object_part_content_set(cd->content_layout, "swl.recipient", cd->recipient->bx_main);
1743
1744         Evas_Object *predict_search_layout = msg_ui_composer_predictsearch_list_create(cd->content_layout, cd);
1745         elm_object_part_content_set(cd->content_layout, "swl.predictsearch", predict_search_layout);
1746
1747         MSGC_EVAS_OBJECT_DEL(cd->back_btn);
1748         Evas_Object *back_btn = __naviframe_back_btn_create(cd->navi_bar, (void *)cd, true);
1749         elm_object_part_content_set(cd->navi_title_layout, "prev_btn", back_btn);
1750         cd->back_btn = back_btn;
1751
1752         msg_ui_composer_navi_title_set(cd);
1753
1754         D_LEAVE;
1755         return COMPOSER_RETURN_SUCCESS;
1756 }
1757
1758 COMPOSER_RETURN_TYPE_E msg_ui_composer_change_bubble_view(MSG_COMPOSER_VIEW_DATA_S *cd)
1759 {
1760         D_ENTER;
1761         D_MSG_RETVM_IF(cd == NULL, COMPOSER_RETURN_FAIL, "Composer data is NULL");
1762         D_MSG_RETVM_IF(cd->msg_ug_mode != MSG_UG_MODE_FULL_COMPOSER, COMPOSER_RETURN_FAIL, "Composer mode is Not Full");
1763
1764         /*Change Mode */
1765         cd->msg_ug_mode = MSG_UG_MODE_BUBBLE_COMPOSER;
1766
1767         /*Change content layout to bubble layout*/
1768         edje_object_signal_emit(_EDJ(cd->content_layout), "hide.predictsearch", "*");
1769         edje_object_signal_emit(_EDJ(cd->content_layout), "change.bubble", "*");
1770
1771         elm_scroller_content_min_limit(cd->body_scroll, 0, 1);
1772         evas_object_size_hint_max_set(cd->body_scroll, 9999, 250);
1773
1774         /*Init bubble data*/
1775         PMSG_BUBBLE_DATA bubble_data = msg_ui_bubble_init_bubble_data(cd->msg_handle, cd);
1776         if (!bubble_data)
1777                 return COMPOSER_RETURN_FAIL;
1778
1779         cd->bubble_data = (void *)bubble_data;
1780
1781         /*Change naviframe layout for bubble*/
1782         Evas_Object *cancel_btn = __naviframe_back_btn_create(cd->navi_bar, (void *)cd, false);
1783         elm_object_part_content_set(cd->navi_title_layout, "prev_btn", cancel_btn);
1784         cd->back_btn = cancel_btn;
1785
1786         Evas_Object *layout = msg_ui_bubble_create_view(cd->content_layout, cd->bubble_data); // First parameter should be 'content_layout'.
1787         elm_object_part_content_set(cd->content_layout, "swl.bubble.content", layout);
1788
1789         /*remove unused layout*/
1790         MSGC_EVAS_OBJECT_DEL(cd->ly_recipient);
1791         msg_ui_composer_recipient_delete(cd->recipient);
1792         cd->recipient = NULL;
1793
1794         msg_ui_composer_predictsearch_list_delete(cd);
1795
1796         return COMPOSER_RETURN_SUCCESS;
1797 }
1798
1799 /*
1800  * msg_ui_composer_editable_set
1801  * editable == FALSE : hide body content & disable more button & close option header
1802  * editable == TRUE : show body content layout
1803  * */
1804 void msg_ui_composer_editable_set(MSG_COMPOSER_VIEW_DATA_S *cd, Eina_Bool editable)
1805 {
1806         D_ENTER;
1807         D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
1808
1809         if (editable == EINA_FALSE){
1810                 Evas_Object *body_layout = elm_object_part_content_unset(cd->content_layout, "swl.composer.body");
1811                 evas_object_hide(body_layout);
1812
1813                 if (cd->more_btn)
1814                         elm_object_disabled_set(cd->more_btn, EINA_TRUE);
1815         } else {
1816                 elm_object_part_content_set(cd->content_layout, "swl.composer.body", cd->ly_body);
1817                 evas_object_show(cd->ly_body);
1818
1819                 if (cd->more_btn)
1820                         elm_object_disabled_set(cd->more_btn, EINA_FALSE);
1821
1822         }
1823
1824         D_LEAVE;
1825 }
1826
1827 void msg_ui_composer_bubble_del_all(void *data, service_h svc_handle)
1828 {
1829         D_ENTER;
1830
1831         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1832         D_MSG_RETM_IF(cd == NULL, "Composer data is NULL");
1833
1834         ug_send_result(cd->ug, svc_handle);
1835 }
1836
1837 Evas_Object *msg_ui_composer_create_navi_title_bar(void *data)
1838 {
1839         D_ENTER;
1840
1841         if (!data) {
1842                 D_EMSG("[ERROR] data is NULL");
1843                 return NULL;
1844         }
1845
1846         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1847
1848         Evas_Object *title_layout = elm_layout_add(cd->navi_bar);
1849         elm_layout_file_set(title_layout, MSG_COMMON_EDJ, "title");
1850         evas_object_size_hint_weight_set(title_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1851         evas_object_size_hint_align_set(title_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1852         evas_object_show(title_layout);
1853
1854         return title_layout;
1855 }
1856
1857 void msg_ui_composer_navi_title_set(void *data)
1858 {
1859         D_ENTER;
1860
1861         if (!data) {
1862                 D_EMSG("data is NULL");
1863                 return;
1864         }
1865
1866         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1867         PMSG_BUBBLE_DATA bubble_data = cd->bubble_data;
1868
1869         if (cd->msg_ug_mode == MSG_UG_MODE_FULL_COMPOSER || cd->msg_ug_mode == MSG_UG_MODE_ONLY_COMPOSER) {
1870                 elm_object_part_text_set(cd->navi_title_layout, "title_text", MSGC_STR_NEW_MESSAGE);
1871         } else if (cd->msg_ug_mode ==  MSG_UG_MODE_BUBBLE_COMPOSER) {
1872                 Evas_Object *title_button = NULL;
1873
1874                 elm_object_part_text_set(cd->navi_title_layout, "title_text", ""); // text part clear first
1875
1876                 title_button = elm_button_add(cd->navi_bar);
1877
1878                 elm_object_theme_set(title_button, cd->th);
1879                 elm_object_style_set(title_button, "title_button");
1880
1881                 evas_object_size_hint_weight_set(title_button, 0.0, 0.0);
1882                 evas_object_size_hint_align_set(title_button, EVAS_HINT_FILL, EVAS_HINT_FILL);
1883
1884                 if (bubble_data->addr_list.addr_cnt == 1) {
1885                         if (bubble_data->addr_list.addr_info[0].contact_id > 0 && bubble_data->addr_list.addr_info[0].name[0] != '\0')
1886                                 elm_object_text_set(title_button, bubble_data->addr_list.addr_info[0].name);
1887                         else if (bubble_data->addr_list.addr_info[0].address[0] != '\0')
1888                                 elm_object_text_set(title_button, bubble_data->addr_list.addr_info[0].address);
1889                         else
1890                                 elm_object_text_set(title_button, dgettext("sys_string", "IDS_COM_BODY_UNKNOWN"));
1891                 } else if (bubble_data->addr_list.addr_cnt > 1) {
1892                         char title_text[DEF_BUF_LEN+1] = {0,};
1893
1894                         if (bubble_data->addr_list.addr_info[0].contact_id > 0 && bubble_data->addr_list.addr_info[0].name[0] != '\0')
1895                                 snprintf(title_text, sizeof(title_text), "%s +%d", bubble_data->addr_list.addr_info[0].name, bubble_data->addr_list.addr_cnt-1);
1896                         else if (bubble_data->addr_list.addr_info[0].address[0] != '\0')
1897                                 snprintf(title_text, sizeof(title_text), "%s +%d", bubble_data->addr_list.addr_info[0].address, bubble_data->addr_list.addr_cnt-1);
1898                         else
1899                                 snprintf(title_text, sizeof(title_text), "%s +%d", dgettext("sys_string", "IDS_COM_BODY_UNKNOWN"), bubble_data->addr_list.addr_cnt-1);
1900
1901                         elm_object_text_set(title_button, title_text);
1902                 } else {
1903                         elm_object_text_set(title_button, dgettext("sys_string", "IDS_COM_BODY_UNKNOWN"));
1904                 }
1905
1906                 evas_object_show(title_button);
1907                 elm_object_part_content_set(cd->navi_title_layout, "title_btn", title_button);
1908                 evas_object_smart_callback_add(title_button, "clicked", msg_ui_bubble_title_button_clicked_cb, cd);
1909
1910                 bubble_data->title_button = title_button;
1911         } else {
1912                 D_EMSG("Invalid msg_ui_mode [%d]", cd->msg_ug_mode);
1913                 return;
1914         }
1915 }
1916
1917 static Eina_Bool __msgc_up_key_long_press_cb(void *data)
1918 {
1919         D_ENTER;
1920         D_MSG_RETVM_IF(data == NULL, EINA_FALSE, "cd is NULL");
1921         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1922
1923         if (!msg_common_increase_font_size()) {
1924                 cd->vol_up_key_longpress = NULL;
1925                 return EINA_FALSE;
1926         }
1927
1928         /* apply font size */
1929         if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
1930                 msg_common_apply_font_size("bubble", cd->content_layout);
1931
1932         msg_ui_composer_apply_font_size(cd, false);
1933
1934         return EINA_TRUE;
1935 }
1936
1937 static Eina_Bool __msgc_down_key_long_press_cb(void *data)
1938 {
1939         D_ENTER;
1940         D_MSG_RETVM_IF(data == NULL, EINA_FALSE, "cd is NULL");
1941         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1942
1943         if (!msg_common_decrease_font_size()) {
1944                 cd->vol_down_key_longpress = NULL;
1945                 return EINA_FALSE;
1946         }
1947
1948         /* apply font size */
1949         if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
1950                 msg_common_apply_font_size("bubble", cd->content_layout);
1951
1952         msg_ui_composer_apply_font_size(cd, false);
1953
1954         return EINA_TRUE;
1955 }
1956
1957 Eina_Bool msg_ui_composer_key_release_cb(void *data, int type, void *event)
1958 {
1959         D_ENTER;
1960         D_MSG_RETVM_IF(data == NULL, EINA_FALSE, "cd is NULL");
1961         D_MSG_RETVM_IF(event == NULL, EINA_FALSE, "event is NULL");
1962         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1963         Ecore_Event_Key *ev = (Ecore_Event_Key *)event;
1964         int use_volume_key = false;
1965
1966         vconf_get_bool(VCONFKEY_MSG_APP_USE_VOLUME_KEY, &use_volume_key);
1967
1968         if (use_volume_key) {
1969                 if (!g_strcmp0(ev->keyname, KEY_VOLUMEUP)) {    /* KEY_VOLUMEUP */
1970                         D_MSG("KEY_VOLUMEUP is released");
1971
1972                         if (cd->vol_up_key_longpress) {
1973                                 ecore_timer_del(cd->vol_up_key_longpress);
1974                                 cd->vol_up_key_longpress = NULL;
1975                         }
1976                 } else if (!g_strcmp0(ev->keyname, KEY_VOLUMEDOWN)) {   /* KEY_VOLUMEDOWN */
1977                         D_MSG("KEY_VOLUMEDOWN is released");
1978
1979                         if (cd->vol_down_key_longpress) {
1980                                 ecore_timer_del(cd->vol_down_key_longpress);
1981                                 cd->vol_down_key_longpress = NULL;
1982                         }
1983                 } else {
1984                         D_MSG("key_name is not applicable!");
1985                 }
1986         } else {
1987                 D_MSG("Use volume key setting is not activated. Do volume key action");
1988         }
1989
1990         return EINA_TRUE;
1991 }
1992
1993 Eina_Bool msg_ui_composer_key_press_cb(void *data, int type, void *event)
1994 {
1995         D_ENTER;
1996         D_MSG_RETVM_IF(data == NULL, EINA_FALSE, "cd is NULL");
1997         D_MSG_RETVM_IF(event == NULL, EINA_FALSE, "event is NULL");
1998         MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
1999         Ecore_Event_Key *ev = (Ecore_Event_Key *)event;
2000         int use_volume_key = false;
2001
2002         vconf_get_bool(VCONFKEY_MSG_APP_USE_VOLUME_KEY, &use_volume_key);
2003
2004         if (use_volume_key) {
2005                 if (!g_strcmp0(ev->keyname, KEY_VOLUMEUP)) {    /* KEY_VOLUMEUP */
2006                         D_MSG("KEY_VOLUMEUP is pressed");
2007
2008                         msg_common_increase_font_size();
2009
2010                         /* apply font size */
2011                         if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
2012                                 msg_common_apply_font_size("bubble", cd->content_layout);
2013
2014                         msg_ui_composer_apply_font_size(cd, false);
2015
2016                         cd->vol_up_key_longpress = ecore_timer_add(0.1, (Ecore_Task_Cb) __msgc_up_key_long_press_cb, (void *)cd);
2017                 } else if (!g_strcmp0(ev->keyname, KEY_VOLUMEDOWN)) {   /* KEY_VOLUMEDOWN */
2018                         D_MSG("KEY_VOLUMEDOWN is pressed");
2019
2020                         msg_common_decrease_font_size();
2021
2022                         /* apply font size */
2023                         if (cd->msg_ug_mode == MSG_UG_MODE_BUBBLE_COMPOSER)
2024                                 msg_common_apply_font_size("bubble", cd->content_layout);
2025
2026                         msg_ui_composer_apply_font_size(cd, false);
2027
2028                         cd->vol_down_key_longpress = ecore_timer_add(0.1, (Ecore_Task_Cb) __msgc_down_key_long_press_cb, (void *)cd);
2029                 } else {
2030                         D_MSG("key_name is not applicable!");
2031                 }
2032         } else {
2033                 D_MSG("Use volume key setting is not activated. Do volume key action");
2034         }
2035
2036         return EINA_TRUE;
2037 }
2038
2039 void msg_ui_composer_connect_handler(MSG_COMPOSER_VIEW_DATA_S *cd)
2040 {
2041         D_ENTER;
2042         D_MSG_RETM_IF(cd == NULL, "cd is NULL");
2043
2044         int use_volume_key = 0;
2045         vconf_get_bool(VCONFKEY_MSG_APP_USE_VOLUME_KEY, &use_volume_key);
2046
2047         if (use_volume_key) {
2048                 msg_ui_composer_grab_key_setting(cd->xdisplay, cd->main_window);
2049                 /* connect key handler for volume up/down */
2050                 if (!cd->volkey_press_handler)
2051                         cd->volkey_press_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, msg_ui_composer_key_press_cb, (void *)cd);
2052
2053                 if (!cd->volkey_release_handler)
2054                         cd->volkey_release_handler = ecore_event_handler_add(ECORE_EVENT_KEY_UP, msg_ui_composer_key_release_cb, (void *)cd);
2055         }
2056         D_MSG("use_volume_key = %d", use_volume_key);
2057
2058         D_LEAVE;
2059 }
2060
2061 void msg_ui_composer_disconnect_handler(MSG_COMPOSER_VIEW_DATA_S *cd)
2062 {
2063         D_ENTER;
2064         D_MSG_RETM_IF(cd == NULL, "cd is NULL");
2065
2066         if (cd->volkey_press_handler) {
2067                 ecore_event_handler_del(cd->volkey_press_handler);
2068                 cd->volkey_press_handler = NULL;
2069         }
2070
2071         if (cd->vol_down_key_longpress) {
2072                 ecore_timer_del(cd->vol_down_key_longpress);
2073                 cd->vol_down_key_longpress = NULL;
2074         }
2075
2076         if (cd->volkey_release_handler) {
2077                 ecore_event_handler_del(cd->volkey_release_handler);
2078                 cd->volkey_release_handler = NULL;
2079         }
2080
2081         if (cd->vol_up_key_longpress) {
2082                 ecore_timer_del(cd->vol_up_key_longpress);
2083                 cd->vol_up_key_longpress = NULL;
2084         }
2085
2086         msg_ui_composer_ungrab_key_setting(cd->xdisplay, cd->main_window);
2087
2088         D_LEAVE;
2089 }