Update org.tizen.message.spec.
[apps/core/preloaded/message-app.git] / main / message.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *    http://floralicense.org/license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "message.h"
18 #include <Ecore_X.h>
19 #include <ui-gadget.h>
20 #include <ui-gadget-module.h>
21 #include <sound_manager.h>
22 #include <system_info.h>
23
24 #include "msg-ui-thread-main.h"
25 #include "msg-ui-common-utility.h"
26
27 static void __rotate(app_device_orientation_e orientation, void *data);
28 static void __msg_ui_popup_warning(Evas_Object *parent, const char *msg);
29 static service_h __msg_ui_parse_sms_uri(service_h service, const char *uri);
30 static service_h __msg_ui_parse_mmsto_uri(service_h service, const char *uri);
31 static service_h __msg_ui_parse_file_uri(service_h service, const char *uri);
32 static service_h __get_service_with_new_msg(struct appdata *ad);
33 static service_h __get_service_with_msg_id(struct appdata *ad, service_h service);
34
35 void layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv);
36 void result_cb(ui_gadget_h ug, service_h result, void *priv);
37 void destroy_cb(ui_gadget_h ug, void *priv);
38
39 struct appdata *gAppData = NULL;
40
41 static void win_del(void *data, Evas_Object *obj, void *event)
42 {
43         elm_exit();
44 }
45
46 static void main_quit_cb(void *data, Evas_Object *obj, void *event_info)
47 {
48         elm_exit();
49 }
50
51 static void lang_changed(void *data)
52 {
53         D_ENTER;
54         struct appdata *ad = data;
55
56         ug_send_event(UG_EVENT_LANG_CHANGE);
57
58         msg_ui_thread_lang_changed(ad->thread_data);
59 }
60
61 static void low_battery_cb(void *data)
62 {
63         D_ENTER;
64
65         ug_send_event(UG_EVENT_LOW_BATTERY);
66 }
67
68 static void region_changed_cb(void *data)
69 {
70         D_ENTER;
71
72         ug_send_event(UG_EVENT_REGION_CHANGE);
73 }
74
75 static void device_orientation(app_device_orientation_e orientation, void *data)
76 {
77         D_ENTER;
78
79         struct appdata *ad = data;
80         if (ad == NULL || ad->win_main == NULL)
81                 return;
82
83         __rotate(orientation, data);
84 }
85
86 static void __rotate(app_device_orientation_e orientation, void *data)
87 {
88         struct appdata *ad = data;
89         int ret = 0;
90         int rot = THREAD_ROTATE_ANGLE_UNKNOWN;
91
92         switch (orientation) {
93                 case APP_DEVICE_ORIENTATION_0:
94                         rot = THREAD_ROTATE_ANGLE_PORTRAIT;
95                         ret = ug_send_event(UG_EVENT_ROTATE_PORTRAIT);
96                         break;
97                 case APP_DEVICE_ORIENTATION_180:
98                         rot = THREAD_ROTATE_ANGLE_PORTRAIT_UPSIDEDOWN;
99                         ret = ug_send_event(UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN);
100                         break;
101                 case APP_DEVICE_ORIENTATION_270:
102                         rot = THREAD_ROTATE_ANGLE_LANDSCAPE;
103                         ret = ug_send_event(UG_EVENT_ROTATE_LANDSCAPE);
104                         break;
105                 case APP_DEVICE_ORIENTATION_90:
106                         rot = THREAD_ROTATE_ANGLE_LANDSCAPE_UPSIDEDOWN;
107                         ret = ug_send_event(UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN);
108                         break;
109                 default:
110                         rot = THREAD_ROTATE_ANGLE_UNKNOWN;
111                         break;
112         }
113
114         if (rot >= 0) {
115                 msg_ui_thread_rotation_set(ad->thread_data, rot);
116                 elm_win_rotation_with_resize_set(ad->win_main, rot);
117         }
118 }
119
120 static void _block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
121 {
122         evas_object_del(obj);
123         elm_exit();
124 }
125
126 static void __msg_ui_popup_warning(Evas_Object *parent, const char *msg)
127 {
128         D_ENTER;
129
130         MSG_UI_RET_IF(MSG_UI_LEVEL_ASSERT, parent == NULL || msg == NULL);
131
132         Evas_Object *layout, *pu;
133
134         evas_object_show(parent);
135
136         layout = elm_layout_add(parent);
137         elm_layout_theme_set(layout, "layout", "application", "default");
138         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
139         elm_win_resize_object_add(parent, layout);
140         evas_object_show(layout);
141
142         pu = elm_popup_add(layout);
143         MSG_UI_RETM_IF(MSG_UI_LEVEL_ASSERT, pu == NULL, "Cannot add popup object\n");
144         evas_object_size_hint_weight_set(pu, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
145         evas_object_smart_callback_add(pu , "block,clicked", _block_clicked_cb, NULL);
146
147         elm_object_text_set(pu, msg);
148         elm_popup_timeout_set(pu, 2);
149         evas_object_smart_callback_add(pu, "timeout", main_quit_cb, NULL);
150         evas_object_show(pu);
151
152         D_LEAVE;
153 }
154
155 static service_h __msg_ui_parse_sms_uri(service_h service, const char *uri)
156 {
157         D_ENTER;
158
159         char *content = NULL;
160         char *recipient = NULL;
161         char *body_text = NULL;
162
163         service_h svc_handle = NULL;
164
165         if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
166                 D_EMSG("service_create() is failed !!");
167                 return NULL;
168         }
169
170         char *scheme = g_strdup(uri);
171
172         if (scheme) {
173                 strtok_r(scheme, ":", &content);
174
175                 if (content) {
176                         if (g_ascii_isdigit(content[0]) || (content[0] == '+' && g_ascii_isdigit(content[1]))) {
177                                 recipient = strtok_r(NULL, "?", &content);
178                                 D_MSG("APPSVC RECIPIENT = [%s]", recipient);
179
180                                 if (recipient)
181                                         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_TO, recipient);
182                         }
183                 }
184                 g_free(scheme);
185         } else {
186                 service_get_extra_data(service, SERVICE_DATA_TO, &recipient);
187                 D_MSG("APPSVC RECIPIENT = [%s]", recipient);
188                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_TO, recipient);
189         }
190
191         /* Add body text */
192         service_get_extra_data(service, SERVICE_DATA_TEXT, &body_text);
193         if (body_text) {
194                 D_MSG("APPSVC BODY_TEXT = [%s]", body_text);
195                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_BODY, body_text);
196         }
197
198         D_LEAVE;
199         return svc_handle;
200 }
201
202 static service_h __msg_ui_parse_mmsto_uri(service_h service, const char *uri)
203 {
204         D_ENTER;
205
206         char *content = NULL;
207         char *recipient = NULL;
208         char *body_text = NULL;
209         char *subject = NULL;
210         char *attachment = NULL;
211         char *cc = NULL;
212
213         service_h svc_handle = NULL;
214
215         if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
216                 D_EMSG("service_create() is failed !!");
217                 return NULL;
218         }
219
220         char *scheme = g_strdup(uri);
221
222         if (scheme) {
223                 strtok_r(scheme, ":", &content);
224
225                 if (content) {
226                         if (g_ascii_isdigit(content[0]) || (content[0] == '+' && g_ascii_isdigit(content[1]))) {
227                                 recipient = strtok_r(NULL, "?", &content);
228                                 cc = strtok_r(NULL, "&", &content);
229                                 if (cc)
230                                         strtok_r(NULL, "=", &cc);
231
232                                 D_MSG("APPSVC RECIPIENT = [%s]", recipient);
233                                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_TO, recipient);
234                         }
235                 }
236                 g_free(scheme);
237         } else {
238                 service_get_extra_data(service, SERVICE_DATA_TO, &recipient);
239                 D_MSG("APPSVC RECIPIENT = [%s]", recipient);
240                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_TO, recipient);
241         }
242
243         /* Add body text */
244         service_get_extra_data(service, SERVICE_DATA_TEXT, &body_text);
245         if (body_text) {
246                 D_MSG("APPSVC BODY_TEXT = [%s]", body_text);
247                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_BODY, body_text);
248         }
249
250         /* Add subject */
251         service_get_extra_data(service, SERVICE_DATA_SUBJECT, &subject);
252         if (subject) {
253                 D_MSG("APPSVC SUBJECT = [%s]", subject);
254                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_SUBJECT, subject);
255         }
256
257         /* Add attachment */
258         service_get_extra_data(service, MSG_BUNDLE_KEY_ATTACHFILE, &attachment);
259         if (attachment) {
260                 D_MSG("APPSVC ATTACHMENT = [%s]", attachment);
261                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_ATTACHFILE, attachment);
262         }
263
264         D_LEAVE;
265
266         return svc_handle;
267 }
268
269 static service_h __msg_ui_parse_file_uri(service_h service, const char *uri)
270 {
271         D_ENTER;
272
273         char *content = NULL;
274         char attachment[DEF_IMG_PATH_LEN] = {0, };
275         int i = 0;
276         int len = 0;
277
278         service_h svc_handle = NULL;
279
280         if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
281                 D_EMSG("service_create() is failed !!");
282                 return NULL;
283         }
284
285         char *scheme = g_strdup(uri);
286
287         if (scheme) {
288                 strtok_r(scheme, ":", &content);
289                 D_MSG("content = [%s]", content);
290
291                 if (content) {
292                         len = strlen(content) - 2;
293                         if (len <= 0) {
294                                 D_EMSG("len is less than 0 !!");
295                                 service_destroy(svc_handle);
296                                 g_free(scheme);
297                                 return NULL;
298                         }
299
300                         /* Remove '//' from content string */
301                         for (i = 0; i < len; i++) {
302                                 attachment[i] = content[i+2];
303                         }
304
305                         if (attachment[0] != '\0') {
306                                 D_MSG("APPSVC ATTACHMENT = [%s]", attachment);
307                                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_ATTACHFILE, attachment);
308                         }
309                 }
310                 g_free(scheme);
311         } else {
312                 D_EMSG("scheme is NULL!!");
313                 service_destroy(svc_handle);
314                 return NULL;
315         }
316
317         D_LEAVE;
318
319         return svc_handle;
320 }
321
322 static service_h __get_service_app_svc_op(const char *operation, service_h service)
323 {
324         D_ENTER;
325
326         if (service == NULL || operation == NULL)
327                 return NULL;
328
329         char *uri = NULL;
330         char *recipient = NULL;
331         char *body_text = NULL;
332         char *attachment = NULL;
333         char *subject = NULL;
334
335         service_h svc_handle = NULL;
336
337         if (g_strcmp0(operation, SERVICE_OPERATION_SEND) == 0) {
338                 service_get_uri(service, &uri);
339                 D_MSG("APPSVC URI = [%s]", uri);
340
341                 if (uri) {
342                         if (g_str_has_prefix(uri, MSG_BUNDLE_VALUE_MMSTO_URI)) {  /* MMS URI */
343                                 svc_handle = __msg_ui_parse_mmsto_uri(service, uri);
344                         } else if (g_str_has_prefix(uri, MSG_BUNDLE_VALUE_FILE_URI)) {
345                                 /* file URI */
346                                 svc_handle = __msg_ui_parse_file_uri(service, uri);
347                                 if (svc_handle == NULL) {
348                                         D_MSG("cb is NULL");
349                                         return NULL;
350                                 }
351                         } else if (g_str_has_prefix(uri, "/")) {
352                                 if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
353                                         D_EMSG("service_create() is failed !!");
354                                         return NULL;
355                                 }
356
357                                 D_MSG("APPSVC ATTACHMENT = [%s]", uri);
358                                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_ATTACHFILE, uri);
359                         } else {
360                                 D_MSG("Not supported URI type");
361                                 return NULL;
362                         }
363                 } else {
364                         if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
365                                 D_EMSG("service_create() is failed !!");
366                                 return NULL;
367                         }
368
369                         /* Add recipient number */
370                         service_get_extra_data(service, SERVICE_DATA_TO, &recipient);
371                         if (recipient) {
372                                 D_MSG("APPSVC RECIPIENT = [%s]", recipient);
373                                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_TO, recipient);
374                         }
375
376                         /* Add body text */
377                         service_get_extra_data(service, SERVICE_DATA_TEXT, &body_text);
378                         if (body_text) {
379                                 D_MSG("APPSVC BODY_TEXT = [%s]", body_text);
380                                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_BODY, body_text);
381                         }
382
383                         /* Add subject */
384                         service_get_extra_data(service, SERVICE_DATA_SUBJECT, &subject);
385                         if (subject) {
386                                 D_MSG("APPSVC SUBJECT = [%s]", subject);
387                                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_SUBJECT, subject);
388                         }
389
390                         /* Add attachment */
391                         service_get_extra_data(service, MSG_BUNDLE_KEY_ATTACHFILE, &attachment);
392                         if (attachment) {
393                                 D_MSG("APPSVC ATTACHMENT = [%s]", attachment);
394                                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_ATTACHFILE, attachment);
395                         }
396                 }
397
398                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_TYPE, MSG_BUNDLE_VALUE_COMPOSE);
399
400         } else if (g_strcmp0(operation, SERVICE_OPERATION_SEND_TEXT) == 0) {
401                 service_get_uri(service, &uri);
402                 D_MSG("APPSVC URI = [%s]", uri);
403
404                 if (uri) {
405                         if (g_str_has_prefix(uri, MSG_BUNDLE_VALUE_SMS_URI)) {  /* SMS URI */
406                                 svc_handle = __msg_ui_parse_sms_uri(service, uri);
407                         } else {
408                                 D_MSG("Not supported mime type");
409                                 return NULL;
410                         }
411                 } else {
412                         if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
413                                 D_EMSG("service_create() is failed !!");
414                                 return NULL;
415                         }
416
417                         /* Add body text */
418                         service_get_extra_data(service, SERVICE_DATA_TEXT, &body_text);
419                         if (body_text) {
420                                 D_MSG("APPSVC BODY_TEXT = [%s]", body_text);
421                                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_BODY, body_text);
422                         }
423
424                         /* Add recipient number */
425                         service_get_extra_data(service, SERVICE_DATA_TO, &recipient);
426                         if (recipient) {
427                                 D_MSG("APPSVC RECIPIENT = [%s]", recipient);
428                                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_TO, recipient);
429                         }
430                 }
431
432                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_TYPE, MSG_BUNDLE_VALUE_COMPOSE);
433         } else if (g_strcmp0(operation, SERVICE_OPERATION_DEFAULT) == 0) {
434                 char *key_type = NULL;
435
436                 service_get_extra_data(service, MSG_BUNDLE_KEY_TYPE, &key_type);
437                 if (g_strcmp0(key_type, MSG_BUNDLE_VALUE_MSG_ID) == 0) {
438                         msg_error_t err = MSG_SUCCESS;
439                         msg_struct_t count_info = msg_create_struct(MSG_STRUCT_COUNT_INFO);
440                         int unread_cnt = 0;
441
442                         err = msg_count_message(gAppData->msgHandle, MSG_INBOX_ID, count_info);
443                         if (err != MSG_SUCCESS) {
444                                 msg_release_struct(&count_info);
445                                 return NULL;
446                         }
447
448                         msg_get_int_value(count_info, MSG_COUNT_INFO_UNREAD_INT, &unread_cnt);
449                         if (unread_cnt == 1)
450                                 svc_handle = __get_service_with_msg_id(gAppData, service);
451
452                         msg_release_struct(&count_info);
453                 }
454         }
455
456         D_LEAVE;
457
458         return svc_handle;
459 }
460
461 static service_h __get_service_with_new_msg(struct appdata *ad)
462 {
463         D_ENTER;
464
465         msg_error_t err = MSG_SUCCESS;
466         msg_struct_list_s peerList;
467         msg_struct_t sort_rule_t = msg_create_struct(MSG_STRUCT_SORT_RULE);
468         service_h svc_handle = NULL;
469
470         int i = 0;
471         int new_sms_cnt = 0;
472         int new_mms_cnt = 0;
473         int unreadCnt = 0;
474         char buf[DEF_BUF_LEN_L] = {'0',};
475         char buf_contact[DEF_BUF_LEN] = {'0',};
476
477         msg_set_int_value(sort_rule_t, MSG_SORT_RULE_SORT_TYPE_INT, MSG_SORT_BY_THREAD_DATE);
478         msg_set_bool_value(sort_rule_t, MSG_SORT_RULE_ACSCEND_BOOL, false);
479
480         vconf_get_int(VCONFKEY_MESSAGE_RECV_SMS_STATE, &new_sms_cnt);
481         vconf_get_int(VCONFKEY_MESSAGE_RECV_MMS_STATE, &new_mms_cnt);
482
483         err = msg_get_thread_view_list(ad->msgHandle, sort_rule_t, &peerList);
484         if (err != MSG_SUCCESS) {
485                 msg_release_struct(&sort_rule_t);
486                 return NULL;
487         }
488
489         if (peerList.nCount <= 0) {
490                 msg_release_list_struct(&peerList);
491                 msg_release_struct(&sort_rule_t);
492                 return NULL;
493         }
494
495         for (i=0; i<peerList.nCount; i++){
496                 msg_get_int_value(peerList.msg_struct_info[i], MSG_THREAD_UNREAD_COUNT_INT, &unreadCnt);
497                 if (unreadCnt > 0)
498                         break;
499         }
500
501         if(i >= peerList.nCount) {
502                 msg_release_list_struct(&peerList);
503                 msg_release_struct(&sort_rule_t);
504                 return NULL;
505         }
506
507         msg_get_int_value(peerList.msg_struct_info[i], MSG_THREAD_UNREAD_COUNT_INT, &unreadCnt);
508         if(unreadCnt == new_sms_cnt+new_mms_cnt){
509                 if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
510                         D_EMSG("service_create() is failed !!");
511                         msg_release_list_struct(&peerList);
512                         msg_release_struct(&sort_rule_t);
513                         return NULL;
514                 }
515
516                 msg_struct_list_s *addrList = NULL;
517                 int thread_id = 0;
518                 int contact_id = 0;
519                 char strName[DEF_THREAD_NAME_LEN+1] = {0,};
520                 char strNumber[DEF_THREAD_ADDR_LEN+1] = {0,};
521
522                 msg_get_int_value(peerList.msg_struct_info[i], MSG_THREAD_ID_INT, &thread_id);
523                 msg_get_list_handle(peerList.msg_struct_info[i], MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addrList);
524
525                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_TYPE, MSG_BUNDLE_VALUE_NEW_MSG);
526                 snprintf(buf, DEF_BUF_LEN_L, "%d", thread_id);
527                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ID, buf);
528                 msg_get_str_value(peerList.msg_struct_info[i], MSG_THREAD_NAME_STR, strName, DEF_THREAD_NAME_LEN);
529                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_NAME, strName);
530
531                 msg_get_str_value(addrList->msg_struct_info[0], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, strNumber, DEF_THREAD_ADDR_LEN);
532                 msg_get_int_value(addrList->msg_struct_info[0], MSG_ADDRESS_INFO_CONTACT_ID_INT, &contact_id);
533
534                 snprintf(buf_contact, DEF_BUF_LEN, "%d", contact_id);
535                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ADDRESS, strNumber);
536                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_CONTACT_ID, buf_contact);
537         }
538
539         msg_release_struct(&sort_rule_t);
540         msg_release_list_struct(&peerList);
541
542         D_LEAVE;
543
544         return svc_handle;
545 }
546
547 static service_h __get_service_with_msg_id(struct appdata *ad, service_h service)
548 {
549         D_ENTER;
550
551         service_h svc_handle = NULL;
552
553         if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
554                 D_EMSG("service_create() is failed !!");
555                 return NULL;
556         }
557
558         int msg_id = 0;
559         char *msg_id_str = NULL;
560         service_get_extra_data(service, MSG_BUNDLE_KEY_MSG_ID, &msg_id_str);
561
562         if (!msg_id_str) {
563                 service_destroy(svc_handle);
564                 return NULL;
565         }
566
567         msg_id = atoi(msg_id_str);
568
569         if (msg_id <= 0) {
570                 service_destroy(svc_handle);
571                 return NULL;
572         }
573
574         msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
575         msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
576         msg_error_t err = MSG_SUCCESS;
577
578         int thread_id = 0;
579         int contact_id = 0;
580         char buf_thread[DEF_BUF_LEN_S] = {0,};
581         char buf_contact[DEF_BUF_LEN_S] = {0,};
582
583         msg_struct_list_s *addr_list = NULL;
584         char strNumber[DEF_THREAD_ADDR_LEN + 1] = {0,};
585         char strName[DEF_THREAD_NAME_LEN + 1] = {0,};
586
587         err = msg_get_message(ad->msgHandle, (msg_message_id_t)msg_id, msgInfo, sendOpt);
588
589         if (err != MSG_SUCCESS) {
590                 service_destroy(svc_handle);
591                 msg_release_struct(&msgInfo);
592                 msg_release_struct(&sendOpt);
593                 return NULL;
594         }
595
596         msg_get_int_value(msgInfo, MSG_MESSAGE_THREAD_ID_INT, &thread_id);
597         snprintf(buf_thread, sizeof(buf_thread), "%d", thread_id);
598
599         msg_get_list_handle(msgInfo, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addr_list);
600
601         msg_get_str_value(addr_list->msg_struct_info[0], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, strNumber, DEF_THREAD_ADDR_LEN);
602         msg_get_str_value(addr_list->msg_struct_info[0], MSG_ADDRESS_INFO_DISPLAYNAME_STR, strName, DEF_THREAD_NAME_LEN);
603         msg_get_int_value(addr_list->msg_struct_info[0], MSG_ADDRESS_INFO_CONTACT_ID_INT, &contact_id);
604         snprintf(buf_contact, sizeof(buf_contact), "%d", contact_id);
605
606         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ID, buf_thread);
607         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_NAME, strName);
608         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ADDRESS, strNumber);
609         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_CONTACT_ID, buf_contact);
610
611         msg_release_struct(&msgInfo);
612         msg_release_struct(&sendOpt);
613
614         D_LEAVE;
615         return svc_handle;
616 }
617
618 static Evas_Object* create_win(const char *name)
619 {
620         D_ENTER;
621
622         Evas_Object *eo;
623         int w, h;
624
625         eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
626         if (eo) {
627                 elm_win_title_set(eo, name);
628                 evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
629                 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
630                 evas_object_resize(eo, w, h);
631                 elm_win_conformant_set(eo, EINA_TRUE);
632         }
633
634         D_LEAVE;
635         return eo;
636 }
637
638 void layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
639 {
640         D_ENTER;
641
642         struct appdata *ad;
643         Evas_Object *base, *win;
644
645         if (!ug || !priv)
646                 return;
647
648         ad = priv;
649
650         base = ug_get_layout(ug);
651
652         if (!base){
653                 ug_destroy(ug);
654                 return;
655         }
656
657         win = ug_get_window();
658
659         switch (mode) {
660                 case UG_MODE_FULLVIEW:
661                         evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
662                         elm_win_resize_object_add(win, base);
663                         evas_object_show(base);
664                         break;
665                 case UG_MODE_FRAMEVIEW:
666                 default:
667                         break;
668         }
669
670         D_LEAVE;
671 }
672
673 void result_cb(ui_gadget_h ug, service_h result, void *priv)
674 {
675         D_ENTER;
676
677         MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !ug || !priv);
678
679         struct appdata *ad = priv;
680
681         PMSG_THREAD_DATA pData = (PMSG_THREAD_DATA)ad->thread_data;
682         PMSG_THREAD_LIST_DATA pListData = NULL;
683         char *buf = NULL;
684         char *str_result = NULL;
685
686         service_get_extra_data(result, MSG_BUNDLE_KEY_RESULT, &str_result);
687         if (pData == NULL) {
688                 if (!g_strcmp0(str_result, MSG_BUNDLE_VALUE_DEL_ALL))
689                         ug_destroy(ug);
690
691                 elm_exit();
692                 return;
693         }
694
695         pListData = msg_ui_thread_get_current_list();
696
697         if (!g_strcmp0(str_result, MSG_BUNDLE_VALUE_DEL_ALL)) {
698                 ug_destroy(ug);
699
700                 if (pListData) {
701                         int del_id = 0;
702
703                         if (pListData->app_data_type == THREAD_LIST_APP_DATA_MSG) {
704                                 service_get_extra_data(result, MSG_BUNDLE_KEY_MSG_ID, &buf);
705                                 if (buf) {
706                                         del_id = atoi(buf);
707                                         msg_ui_thread_list_msg_item_delete(pListData, del_id);
708                                 }
709                         } else {
710                                 service_get_extra_data(result, MSG_BUNDLE_KEY_THREAD_ID, &buf);
711                                 if (buf) {
712                                         del_id = atoi(buf);
713                                         msg_ui_thread_list_item_delete(pListData, del_id);
714                                 }
715                         }
716
717                         if (pData->isRotate == true) {
718                                 if (!pData->split_data) {
719                                         msg_ui_thread_create_split_data();
720                                         msg_ui_thread_splitview_launch(pData, pData->split_data);
721                                 }
722                         } else {
723                                 elm_object_part_content_set(pData->panes, "left", pData->layout_main);
724                                 elm_object_part_content_unset(pData->panes, "right");
725                                 elm_panes_content_left_size_set(pData->panes, 1.0);
726                         }
727
728                         pListData->sel_gen_item = NULL;
729                         pListData->sel_thread_id = 0;
730                         pListData->sel_msg_id = 0;
731                         ad->composer_ug = NULL;
732                         ad->ug_type = MSG_COMPOSER_UG_TYPE_NONE;
733                 }
734         } else {
735                 int update_id = 0;
736
737                 if (pListData->app_data_type == THREAD_LIST_APP_DATA_MSG) {
738                         service_get_extra_data(result, MSG_BUNDLE_KEY_MSG_ID, &buf);
739                         if (buf) {
740                                 update_id = atoi(buf);
741                                 msg_ui_thread_list_msg_item_update(pListData, update_id);
742                         }
743                 } else {
744                         service_get_extra_data(result, MSG_BUNDLE_KEY_THREAD_ID, &buf);
745                         if (buf) {
746                                 update_id = atoi(buf);
747                                 msg_ui_thread_list_item_update(pListData, update_id);
748                                 pListData->sel_thread_id = update_id;
749                         }
750                 }
751         }
752
753         D_LEAVE;
754 }
755
756 void destroy_cb(ui_gadget_h ug, void *priv)
757 {
758         D_ENTER;
759
760         MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !ug || !priv);
761
762         struct appdata *ad = (struct appdata *)priv;
763         int ug_type = ad->ug_type;
764
765         if (ug == ad->composer_ug) {
766                 ug_destroy(ug);
767                 ad->composer_ug = NULL;
768                 ad->ug_type = MSG_COMPOSER_UG_TYPE_NONE;
769         }
770
771         if (ad->layout_main) {
772                 PMSG_THREAD_DATA pData = (PMSG_THREAD_DATA)ad->thread_data;
773                 PMSG_THREAD_LIST_DATA pListData = NULL;
774
775                 pListData = msg_ui_thread_get_current_list();
776                 if (pListData == NULL) {
777                         elm_exit();
778                         return;
779                 }
780
781                 if (pData) {
782                         if (pData->isRotate == true) {
783                                 if (!pData->split_data) {
784                                         msg_ui_thread_create_split_data();
785                                         msg_ui_thread_splitview_launch(pData, pData->split_data);
786                                 }
787                                 if (ug_type == MSG_COMPOSER_UG_TYPE_VIEWER) {
788                                         msg_ui_thread_cancel_search_mode(pListData);
789                                         elm_win_lower(pData->win_main);
790                                 }
791                         } else {
792                                 elm_object_part_content_set(pData->panes, "left", pData->layout_main);
793                                 elm_object_part_content_unset(pData->panes, "right");
794                                 elm_panes_content_left_size_set(pData->panes, 1.0);
795                         }
796                 }
797
798                 if (pListData->sel_thread_id > 0)
799                         msg_ui_thread_list_item_update(pListData, pListData->sel_thread_id);
800
801                 if (pListData->sel_msg_id > 0)
802                         msg_ui_thread_list_msg_item_update(pListData, pListData->sel_msg_id);
803
804                 pListData->sel_gen_item = NULL;
805                 pListData->sel_thread_id = 0;
806                 pListData->sel_msg_id = 0;
807
808                 pListData->view_mode = THREAD_NORMAL_VIEW;
809         } else {
810                 elm_exit();
811         }
812 }
813
814 int msg_ui_load_composer_ug(service_h svc_handle, MessageComposerUgType ug_type)
815 {
816         D_ENTER;
817
818         if (!gAppData)
819                 return MSG_UI_RET_ERR;
820
821         if (gAppData->composer_ug) {
822                 if (ug_type == MSG_COMPOSER_UG_TYPE_COMPOSER && gAppData->ug_type == MSG_COMPOSER_UG_TYPE_VIEWER) {
823                         ug_destroy(gAppData->composer_ug);
824                         gAppData->composer_ug = NULL;
825                         gAppData->ug_type = MSG_COMPOSER_UG_TYPE_NONE;
826
827                         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_FROM, MSG_BUNDLE_VALUE_INTERNAL);
828                         if (ug_type == MSG_COMPOSER_UG_TYPE_COMPOSER)
829                                 gAppData->composer_ug = ug_create(NULL, MSG_COMPOSER_UG_NAME, UG_MODE_FULLVIEW, svc_handle, &gAppData->cbs);
830                         else
831                                 gAppData->composer_ug = ug_create(NULL, MSG_COMPOSER_UG_NAME, UG_MODE_FRAMEVIEW, svc_handle, &gAppData->cbs);
832                 } else {
833                         ug_send_message(gAppData->composer_ug, svc_handle);
834                 }
835         } else {
836                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_FROM, MSG_BUNDLE_VALUE_INTERNAL);
837                 if (ug_type == MSG_COMPOSER_UG_TYPE_COMPOSER)
838                         gAppData->composer_ug = ug_create(NULL, MSG_COMPOSER_UG_NAME, UG_MODE_FULLVIEW, svc_handle, &gAppData->cbs);
839                 else
840                         gAppData->composer_ug = ug_create(NULL, MSG_COMPOSER_UG_NAME, UG_MODE_FRAMEVIEW, svc_handle, &gAppData->cbs);
841         }
842
843         if (!gAppData->composer_ug)
844                 return MSG_UI_RET_ERR;
845
846         gAppData->ug_type = ug_type;
847
848         if (ug_type == MSG_COMPOSER_UG_TYPE_VIEWER) {
849                 PMSG_THREAD_DATA pData = (PMSG_THREAD_DATA)gAppData->thread_data;
850                 Evas_Object * layout = (Evas_Object *)ug_get_layout(gAppData->composer_ug);
851                 elm_object_part_content_set(pData->panes, "right", layout);
852                 msg_ui_thread_destroy_split_data(pData->split_data);
853
854                 if (pData->isRotate == false) {
855                         elm_object_part_content_unset(pData->panes, "left");
856                         elm_panes_content_left_size_set(pData->panes, 0.0);
857                         evas_object_hide(pData->layout_main);
858                 }
859         }
860         D_LEAVE;
861         return MSG_UI_RET_SUCCESS;
862 }
863
864 Evas_Object *msg_ui_get_composer_ug_viewer_layout(void)
865 {
866         D_ENTER;
867
868         if (!gAppData || !gAppData->composer_ug)
869                 return NULL;
870
871         if (gAppData->ug_type != MSG_COMPOSER_UG_TYPE_VIEWER)
872                 return NULL;
873
874         Evas_Object * layout = (Evas_Object *)ug_get_layout(gAppData->composer_ug);
875
876         D_LEAVE;
877
878         return layout;
879 }
880
881 void msg_ui_destroy_composer_ug(void)
882 {
883         if (!gAppData || !gAppData->composer_ug)
884                 return;
885
886         ug_destroy(gAppData->composer_ug);
887
888         PMSG_THREAD_DATA pData = (PMSG_THREAD_DATA)gAppData->thread_data;
889         PMSG_THREAD_LIST_DATA pListData = msg_ui_thread_get_current_list();
890
891         if (pListData) {
892                 if (pData->isRotate == true) {
893                         if (!pData->split_data) {
894                                 msg_ui_thread_create_split_data();
895                                 msg_ui_thread_splitview_launch(pData, pData->split_data);
896                         }
897                 }
898
899                 pListData->sel_gen_item = NULL;
900                 pListData->sel_thread_id = 0;
901                 pListData->sel_msg_id = 0;
902                 gAppData->composer_ug = NULL;
903                 gAppData->ug_type = MSG_COMPOSER_UG_TYPE_NONE;
904         }
905 }
906
907 static bool app_create(void *data)
908 {
909         /* return TRUE : success, return FALSE : not to run main loop */
910
911         D_ENTER;
912
913         MSG_UI_RETV_IF(MSG_UI_LEVEL_ERR, !data, MSG_UI_RET_ERR);
914
915         struct appdata *ad = data;
916         Evas_Object *win;
917         sound_manager_error_e err = SOUND_MANAGER_ERROR_NONE;
918
919         /* create window */
920         win = create_win(MESSAGE_PKGNAME);
921         if (win == NULL)
922                 return FALSE;
923
924         ad->win_main = win;
925
926         ad->bg = elm_bg_add(ad->win_main);
927         evas_object_size_hint_weight_set(ad->bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
928         elm_win_resize_object_add(ad->win_main, ad->bg);
929
930         ad->conform = elm_conformant_add(win);
931         if (ad->conform == NULL)
932                 return FALSE;
933
934         evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
935         elm_win_resize_object_add(win, ad->conform);
936         evas_object_show(ad->conform);
937
938         err = sound_manager_set_session_type(SOUND_SESSION_TYPE_SHARE);
939         if (err != SOUND_MANAGER_ERROR_NONE)
940                 D_MSG("sound_manager_set_session_type is failed, ret = [%d]", err);
941
942         UG_INIT_EFL(ad->win_main, UG_OPT_INDICATOR_ENABLE);
943         elm_win_indicator_mode_set(ad->win_main, ELM_WIN_INDICATOR_SHOW);
944         __rotate(app_get_device_orientation(), ad);
945
946         ad->cbs.layout_cb = layout_cb;
947         ad->cbs.result_cb = result_cb;
948         ad->cbs.destroy_cb = destroy_cb;
949         ad->cbs.priv = (void *)ad;
950
951         gAppData = ad; // Set global app data pointer;
952
953         D_LEAVE;
954         return TRUE;
955 }
956
957 static void app_terminate(void *data)
958 {
959         D_ENTER;
960
961         MSG_UI_RETM_IF(MSG_UI_LEVEL_ERR, !data, "data is null");
962
963         struct appdata *ad = data;
964         msg_error_t     err;
965
966         ug_destroy_all();
967
968         if (ad->thread_data)
969                 msg_ui_thread_deinit_thread_data(ad->thread_data);
970
971         if (ad->msgHandle) {
972                 err = msg_close_msg_handle(&ad->msgHandle);
973                 D_MSG("msg_close_msg_handle, ret = [%d]", err);
974         }
975
976         D_LEAVE;
977 }
978
979 static void app_pause(void *data)
980 {
981         D_ENTER;
982
983         msg_ui_thread_set_app_state(MSG_UI_STATE_PAUSE);
984         ug_pause();
985
986         D_LEAVE;
987 }
988
989 static void app_resume(void *data)
990 {
991         D_ENTER;
992         msg_ui_thread_set_app_state(MSG_UI_STATE_RUNNING);
993
994         ug_resume();
995
996         D_LEAVE;
997 }
998
999 static void app_service(service_h service, void *data)
1000 {
1001         D_ENTER;
1002         MSG_UI_RETM_IF(MSG_UI_LEVEL_ERR, !data, "data is NULL");
1003
1004         struct appdata *ad = data;
1005         service_h svc_handle = NULL;
1006         msg_error_t err = MSG_SUCCESS;
1007         msg_handle_t msgHandle = NULL;
1008         bool isDefaultView = false;
1009
1010         char *operation = NULL;
1011         char *cvalue = NULL;
1012         int ret = SYSTEM_INFO_ERROR_NONE;
1013
1014         ret = system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &cvalue);
1015         if (ret == SYSTEM_INFO_ERROR_NONE && cvalue != NULL) {
1016                 if (g_strcmp0(cvalue, "Emulator") == 0) {
1017                         D_MSG("Not support in Emulator !!");
1018                         g_free(cvalue);
1019                         cvalue = NULL;
1020
1021                         service_h reply;
1022
1023                         int ret = service_create(&reply);
1024                         if (ret != SERVICE_ERROR_NONE) {
1025                                 D_EMSG("service_create() is failed : ret = %d", ret);
1026                         } else {
1027                                 service_reply_to_launch_request(reply, service, SERVICE_RESULT_CANCELED);
1028                                 service_destroy(reply);
1029                         }
1030
1031                         /* Exit application because it is not supported in Emulator. */
1032                         elm_exit();
1033                         return;
1034                 }
1035         }
1036
1037         if (cvalue) {
1038                 g_free(cvalue);
1039                 cvalue = NULL;
1040         }
1041
1042         ug_resume();
1043
1044         if (!ad->msgHandle) {
1045                 err = msg_open_msg_handle(&msgHandle);
1046                 if (err != MSG_SUCCESS) {
1047                         MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "msg_open_msg_handle failed, Error=[%d]\n", err);
1048                         __msg_ui_popup_warning(ad->win_main,  dgettext("sys_string", "IDS_COM_POP_SERVICE_UNAVAILABLE"));
1049                         return;
1050                 }
1051                 ad->msgHandle = msgHandle;
1052         }
1053
1054         if (service) {
1055                 service_get_operation(service, &operation);
1056                 if (operation) {
1057                         svc_handle = __get_service_app_svc_op(operation, service);
1058                 } else {
1059                         char *key_type = NULL;
1060
1061                         service_get_extra_data(service, MSG_BUNDLE_KEY_TYPE, &key_type);
1062                         if (g_strcmp0(key_type, MSG_BUNDLE_VALUE_COMPOSE) == 0) {
1063                                 service_clone(&svc_handle, service);
1064                         } else if (g_strcmp0(key_type, MSG_BUNDLE_VALUE_NEW_MSG) == 0) {
1065                                 svc_handle = __get_service_with_new_msg(ad);
1066                         } else if (g_strcmp0(key_type, MSG_BUNDLE_VALUE_MSG_ID) == 0) {
1067                                 svc_handle = __get_service_with_msg_id(ad, service);
1068                         } else {
1069                                 char *mime_type = NULL;
1070
1071                                 service_get_extra_data(service, AUL_K_MIME_TYPE, &mime_type);
1072                                 if (g_strcmp0(mime_type, MSG_BUNDLE_VALUE_SMS_URI) == 0)
1073                                         svc_handle = __msg_ui_parse_sms_uri(service, NULL);
1074                                 else if (g_strcmp0(mime_type, MSG_BUNDLE_VALUE_MMSTO_URI) == 0)
1075                                         svc_handle = __msg_ui_parse_mmsto_uri(service, NULL);
1076                                 else
1077                                         isDefaultView = true;
1078                         }
1079                 }
1080
1081                 if (!svc_handle)
1082                         isDefaultView = true;
1083         } else {
1084                 isDefaultView = true;
1085         }
1086
1087         if (isDefaultView) {
1088                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "show DefaultView");
1089                 if (ad->composer_ug) {
1090                         ug_destroy(ad->composer_ug);
1091                         ad->composer_ug = NULL;
1092                         ad->ug_type = MSG_COMPOSER_UG_TYPE_NONE;
1093                 }
1094
1095                 if (!ad->thread_data)
1096                         ad->thread_data = msg_ui_thread_init_thread_data(ad);
1097
1098                 if (!ad->layout_main) {
1099                         ad->layout_main = msg_ui_thread_create_layout_main(ad->thread_data);
1100                         evas_object_size_hint_weight_set(ad->layout_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1101                         elm_object_content_set(ad->conform, ad->layout_main);
1102
1103                         msg_ui_thread_load_thread_view(ad->thread_data, service);
1104                 } else {
1105                         msg_ui_thread_reset_thread_view(ad->thread_data, service);
1106                 }
1107                 __rotate(app_get_device_orientation(), ad);
1108         } else {
1109                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "show app-service view");
1110                 /* If message app is called by app-service to display composer view,
1111                  * list view should be destroyed because previous screen should be displayed
1112                  * when user tap back button.
1113                  */
1114                  MessageComposerUgType ug_type = MSG_COMPOSER_UG_TYPE_NONE;
1115
1116                 if (operation != NULL) {
1117                         int i = 0;
1118                         PMSG_THREAD_DATA pData = (PMSG_THREAD_DATA)ad->thread_data;
1119
1120                         if (g_strcmp0(operation, SERVICE_OPERATION_SEND) == 0 ||
1121                                 g_strcmp0(operation, SERVICE_OPERATION_SEND_TEXT) == 0) {
1122                                 if (ad->layout_main) {
1123                                         /* content unset composer */
1124                                         if (ad->ug_type == MSG_COMPOSER_UG_TYPE_VIEWER) {
1125                                                 if (pData)
1126                                                         elm_object_part_content_unset(pData->panes, "right");
1127                                         }
1128
1129                                         if (pData) {
1130                                                 for (i = MSG_THREAD_LIST_MAX_COUNT-1; i >= 0; i--) {
1131                                                         if (pData->list_data[i] != NULL) {
1132                                                                 msg_ui_thread_destroy_thread_list_data(pData->list_data[i]);
1133                                                         }
1134                                                 }
1135                                         }
1136                                         evas_object_del(ad->layout_main);
1137                                         ad->layout_main = NULL;
1138                                 }
1139                                 ug_type = MSG_COMPOSER_UG_TYPE_COMPOSER;
1140                         } else if (g_strcmp0(operation, SERVICE_OPERATION_DEFAULT) == 0) {
1141                                 char *key_type = NULL;
1142
1143                                 service_get_extra_data(service, MSG_BUNDLE_KEY_TYPE, &key_type);
1144                                 if (g_strcmp0(key_type, MSG_BUNDLE_VALUE_MSG_ID) == 0) {
1145                                         if (ad->layout_main) {
1146                                                 /* content unset composer */
1147                                                 if (ad->ug_type == MSG_COMPOSER_UG_TYPE_VIEWER) {
1148                                                         if (pData)
1149                                                                 elm_object_part_content_unset(pData->panes, "right");
1150                                                 }
1151
1152                                                 if (pData) {
1153                                                         for (i = MSG_THREAD_LIST_MAX_COUNT-1; i >= 0; i--) {
1154                                                                 if (pData->list_data[i] != NULL) {
1155                                                                         msg_ui_thread_destroy_thread_list_data(pData->list_data[i]);
1156                                                                 }
1157                                                         }
1158                                                 }
1159                                                 evas_object_del(ad->layout_main);
1160                                                 ad->layout_main = NULL;
1161                                         }
1162                                         ug_type = MSG_COMPOSER_UG_TYPE_VIEWER;
1163                                 }
1164                         }
1165                 }
1166
1167                 if (ad->composer_ug) {
1168                         ug_destroy(ad->composer_ug);
1169                         ad->composer_ug = NULL;
1170                         ad->ug_type = MSG_COMPOSER_UG_TYPE_NONE;
1171                 }
1172
1173                 ad->composer_ug = ug_create(NULL, MSG_COMPOSER_UG_NAME, UG_MODE_FULLVIEW, svc_handle, &ad->cbs);
1174                 ad->ug_type = ug_type;
1175         }
1176
1177         if (svc_handle)
1178                 service_destroy(svc_handle);
1179
1180         if (ad->win_main) {
1181                 evas_object_show(ad->win_main);
1182                 elm_win_activate(ad->win_main);
1183         }
1184
1185         if (ad->layout_main == NULL && ad->composer_ug == NULL)
1186                 elm_exit();
1187
1188         D_LEAVE;
1189 }
1190
1191 int main(int argc, char *argv[])
1192 {
1193         D_ENTER;
1194
1195         struct appdata ad;
1196         memset(&ad, 0x0, sizeof(struct appdata));
1197
1198         app_event_callback_s event_callback;
1199
1200         event_callback.create = app_create;
1201         event_callback.terminate = app_terminate;
1202         event_callback.pause = app_pause;
1203         event_callback.resume = app_resume;
1204         event_callback.service = app_service;
1205         event_callback.low_memory = NULL;
1206         event_callback.low_battery = low_battery_cb;
1207         event_callback.device_orientation = device_orientation;
1208         event_callback.language_changed = lang_changed;
1209         event_callback.region_format_changed = region_changed_cb;
1210
1211         D_LEAVE;
1212         return app_efl_main(&argc, &argv, &event_callback, &ad);
1213 }