1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 #include "ppmsampleapp.h"
30 #include "PluginManager.h"
31 #include "OCPlatform.h"
32 #include "PluginManager.h"
46 Fan() : m_state(false), m_power(0), m_name("")
51 typedef struct appdata
55 Evas_Object *naviframe;
60 Evas_Object *send_msg_button;
61 Evas_Object *clear_log_button;
64 typedef struct threadContext
70 threadContext_s m_ThreadContext;
71 bool isSendMessage = true;
72 const int SUCCESS_RESPONSE = 0;
73 std::shared_ptr<OCResource> curFanResource;
74 static ObserveType OBSERVE_TYPE_TO_USE = ObserveType::Observe;
77 char log_buffer[10000];
78 PluginManager *m_pm = NULL;
79 char temp_string[2000];
82 void putFanRepresentation(std::shared_ptr<OCResource> resource);
84 void updateLog(appdata_s *ad, const char *newlog)
86 const char *log_text = NULL;
88 log_text = elm_entry_entry_get(ad->log);
89 strcpy(log_buffer, log_text);
90 strcat(log_buffer, newlog);
91 elm_entry_entry_set(ad->log, log_buffer);
92 elm_entry_cursor_end_set(ad->log);
95 void *updateCallbackLog(void *data)
97 threadContext_s *pThreadContext = (threadContext_s *)data;
98 updateLog(pThreadContext->ad, pThreadContext->log);
109 void onObserve(const HeaderOptions headerOptions, const OCRepresentation &rep,
110 const int &eCode, const int &sequenceNumber)
112 if (eCode == OC_STACK_OK)
114 std::cout << "OBSERVE RESULT:" << std::endl;
115 std::cout << "\tSequenceNumber: " << sequenceNumber << std::endl;
117 rep.getValue("state", myfan.m_state);
118 rep.getValue("power", myfan.m_power);
119 rep.getValue("name", myfan.m_name);
121 sprintf(buf, "OBSERVE RESULT: sequence number = %d<br>", sequenceNumber);
122 strcpy(temp_string, buf);
123 sprintf(buf, "state: = %d<br>", myfan.m_state);
124 strcat(temp_string, buf);
125 sprintf(buf, "power: = %d<br>", myfan.m_power);
126 strcat(temp_string, buf);
127 sprintf(buf, "name: = %s<br>", myfan.m_name.c_str());
128 strcat(temp_string, buf);
129 m_ThreadContext.log = temp_string;
130 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
131 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
134 if (observe_count() > 30)
136 std::cout << "Cancelling Observe..." << std::endl;
137 OCStackResult result = curFanResource->cancelObserve();
139 std::cout << "Cancel result: " << result << std::endl;
141 std::cout << "DONE" << std::endl;
147 std::cout << "onObserve Response error: " << eCode << std::endl;
148 sprintf(buf, "onObserve Response error: = %d<br>", eCode);
149 strcpy(temp_string, buf);
150 m_ThreadContext.log = temp_string;
151 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
152 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
158 void onPost2(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode)
160 if (eCode == OC_STACK_OK || eCode == OC_STACK_RESOURCE_CREATED)
162 std::cout << "POST request was successful" << std::endl;
164 if (rep.hasAttribute("createduri"))
166 std::cout << "\tUri of the created resource: "
167 << rep.getValue<std::string>("createduri") << std::endl;
171 rep.getValue("state", myfan.m_state);
172 rep.getValue("power", myfan.m_power);
173 rep.getValue("name", myfan.m_name);
175 std::cout << "\tstate: " << myfan.m_state << std::endl;
176 std::cout << "\tpower: " << myfan.m_power << std::endl;
177 std::cout << "\tname: " << myfan.m_name << std::endl;
179 strcpy(temp_string, "POST2 request was successful<br>");
180 sprintf(buf, "state: = %d<br>", myfan.m_state);
181 strcat(temp_string, buf);
182 sprintf(buf, "power: = %d<br>", myfan.m_power);
183 strcat(temp_string, buf);
184 sprintf(buf, "name: = %s<br>", myfan.m_name.c_str());
185 strcat(temp_string, buf);
186 m_ThreadContext.log = temp_string;
187 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
188 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
192 if (OBSERVE_TYPE_TO_USE == ObserveType::Observe)
193 std::cout << std::endl << "Observe is used." << std::endl;
194 else if (OBSERVE_TYPE_TO_USE == ObserveType::ObserveAll)
195 std::cout << std::endl << "ObserveAll is used." << std::endl;
197 // curFanResource->observe(OBSERVE_TYPE_TO_USE, QueryParamsMap(), &onObserve);
202 std::cout << "onPost Response error: " << eCode << std::endl;
203 sprintf(buf, "onPost Response error: = %d<br>", eCode);
204 strcpy(temp_string, buf);
205 m_ThreadContext.log = temp_string;
206 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
207 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
213 void onPost(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode)
215 if (eCode == OC_STACK_OK || eCode == OC_STACK_RESOURCE_CREATED)
217 std::cout << "POST request was successful" << std::endl;
219 if (rep.hasAttribute("createduri"))
221 std::cout << "\tUri of the created resource: "
222 << rep.getValue<std::string>("createduri") << std::endl;
226 rep.getValue("state", myfan.m_state);
227 rep.getValue("power", myfan.m_power);
228 rep.getValue("name", myfan.m_name);
230 std::cout << "\tstate: " << myfan.m_state << std::endl;
231 std::cout << "\tpower: " << myfan.m_power << std::endl;
232 std::cout << "\tname: " << myfan.m_name << std::endl;
234 strcpy(temp_string, "POST request was successful<br>");
235 sprintf(buf, "state: = %d<br>", myfan.m_state);
236 strcat(temp_string, buf);
237 sprintf(buf, "power: = %d<br>", myfan.m_power);
238 strcat(temp_string, buf);
239 sprintf(buf, "name: = %s<br>", myfan.m_name.c_str());
240 strcat(temp_string, buf);
241 m_ThreadContext.log = temp_string;
242 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
243 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
247 OCRepresentation rep2;
249 std::cout << "Posting fan representation..." << std::endl;
251 myfan.m_state = true;
254 rep2.setValue("state", myfan.m_state);
255 rep2.setValue("power", myfan.m_power);
257 curFanResource->post(rep2, QueryParamsMap(), &onPost2);
261 std::cout << "onPost Response error: " << eCode << std::endl;
262 sprintf(buf, "onPost Response error: = %d<br>", eCode);
263 strcpy(temp_string, buf);
264 m_ThreadContext.log = temp_string;
265 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
266 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
272 // Local function to put a different state for this resource
273 void postFanRepresentation(std::shared_ptr<OCResource> resource)
277 OCRepresentation rep;
279 std::cout << "Posting fan representation..." << std::endl;
281 myfan.m_state = false;
284 rep.setValue("state", myfan.m_state);
285 rep.setValue("power", myfan.m_power);
287 // Invoke resource's post API with rep, query map and the callback parameter
288 resource->post(rep, QueryParamsMap(), &onPost);
292 // Callback handler on PUT request
293 void onPut(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode)
295 if (eCode == OC_STACK_OK)
297 std::cout << "PUT request was successful" << std::endl;
299 rep.getValue("state", myfan.m_state);
300 rep.getValue("power", myfan.m_power);
301 rep.getValue("name", myfan.m_name);
303 std::cout << "\tstate: " << myfan.m_state << std::endl;
304 std::cout << "\tpower: " << myfan.m_power << std::endl;
305 std::cout << "\tname: " << myfan.m_name << std::endl;
307 strcpy(temp_string, "PUT request was successful<br>");
308 sprintf(buf, "state: = %d<br>", myfan.m_state);
309 strcat(temp_string, buf);
310 sprintf(buf, "power: = %d<br>", myfan.m_power);
311 strcat(temp_string, buf);
312 sprintf(buf, "name: = %s<br>", myfan.m_name.c_str());
313 strcat(temp_string, buf);
314 m_ThreadContext.log = temp_string;
315 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
316 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
319 putFanRepresentation(curFanResource);
323 std::cout << "onPut Response error: " << eCode << std::endl;
324 sprintf(buf, "onPut Response error: = %d<br>", eCode);
325 strcpy(temp_string, buf);
326 m_ThreadContext.log = temp_string;
327 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
328 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
334 // Local function to put a different state for this resource
335 void putFanRepresentation(std::shared_ptr<OCResource> resource)
339 OCRepresentation rep;
341 std::cout << "Putting fan representation..." << std::endl;
343 myfan.m_state = true;
344 if (myfan.m_power == 1)
349 rep.setValue("state", myfan.m_state);
350 rep.setValue("power", myfan.m_power);
352 // Invoke resource's put API with rep, query map and the callback parameter
353 resource->put(rep, QueryParamsMap(), &onPut);
357 // Callback handler on GET request
358 void onFanGet(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode)
360 if (eCode == OC_STACK_OK)
362 std::cout << "GET Fan request was successful" << std::endl;
363 std::cout << "Resource URI: " << rep.getUri() << std::endl;
365 rep.getValue("state", myfan.m_state);
366 rep.getValue("power", myfan.m_power);
367 rep.getValue("name", myfan.m_name);
369 std::cout << "\tstate: " << myfan.m_state << std::endl;
370 std::cout << "\tpower: " << myfan.m_power << std::endl;
371 std::cout << "\tname: " << myfan.m_name << std::endl;
373 strcpy(temp_string, "GET Fan request was successful<br>");
374 sprintf(buf, "state: = %d<br>", myfan.m_state);
375 strcat(temp_string, buf);
376 sprintf(buf, "power: = %d<br>", myfan.m_power);
377 strcat(temp_string, buf);
378 sprintf(buf, "name: = %s<br>", myfan.m_name.c_str());
379 strcat(temp_string, buf);
380 m_ThreadContext.log = temp_string;
381 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
382 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
385 putFanRepresentation(curFanResource);
389 std::cout << "onGET Response error: " << eCode << std::endl;
390 sprintf(buf, "onGET Response error: = %d<br>", eCode);
391 strcpy(temp_string, buf);
392 m_ThreadContext.log = temp_string;
393 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
394 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
401 // Local function to get representation of fan resource
402 void getFanRepresentation(std::shared_ptr<OCResource> resource)
406 std::cout << "Getting Fan Representation..." << std::endl;
408 // Invoke resource's get API with the callback parameter
410 resource->get(test, &onFanGet);
414 // Callback to found resources
415 void foundResourceFan(std::shared_ptr<OCResource> resource)
419 std::cout << "Found another resource, ignoring" << std::endl;
422 std::string resourceURI;
423 std::string hostAddress;
426 // Do some operations with resource object.
429 std::cout << "DISCOVERED Resource:" << std::endl;
430 strcpy(temp_string, "DISCOVERED Resource:");
432 // Get the resource URI
433 resourceURI = resource->uri();
434 std::cout << "\tURI of the resource: " << resourceURI << std::endl;
435 sprintf(buf, "URI of the resource: = %s<br>", resourceURI.c_str());
436 strcat(temp_string, buf);
438 // Get the resource host address
439 hostAddress = resource->host();
440 std::cout << "\tHost address of the resource: " << hostAddress << std::endl;
441 sprintf(buf, "Host address of the resource: = %s<br>", hostAddress.c_str());
442 strcat(temp_string, buf);
444 // Get the resource types
445 std::cout << "\tList of resource types: " << std::endl;
446 strcat(temp_string, "List of resource types: <br>");
447 for (auto & resourceTypes : resource->getResourceTypes())
449 std::cout << "\t\t" << resourceTypes << std::endl;
450 sprintf(buf, "%s<br>", resourceTypes.c_str());
451 strcat(temp_string, buf);
454 // Get the resource interfaces
455 std::cout << "\tList of resource interfaces: " << std::endl;
456 for (auto & resourceInterfaces : resource->getResourceInterfaces())
458 std::cout << "\t\t" << resourceInterfaces << std::endl;
459 sprintf(buf, "%s<br>", resourceInterfaces.c_str());
460 strcat(temp_string, buf);
463 if (resourceURI == "/a/fan")
465 curFanResource = resource;
466 /* Call a local function which will internally invoke get API
467 on the resource pointer */
468 putFanRepresentation(curFanResource);
470 m_ThreadContext.log = temp_string;
471 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
472 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
477 // Resource is invalid
478 std::cout << "Resource is invalid" << std::endl;
479 strcpy(temp_string, "Resource is invalid");
480 m_ThreadContext.log = temp_string;
481 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
482 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
487 catch (std::exception &e)
495 std::cout << std::endl;
496 std::cout << "Usage : simpleclient <ObserveType>" << std::endl;
497 std::cout << " ObserveType : 1 - Observe" << std::endl;
498 std::cout << " ObserveType : 2 - ObserveAll" << std::endl;
502 win_delete_request_cb(void *data , Evas_Object *obj , void *event_info)
508 win_back_cb(void *data, Evas_Object *obj, void *event_info)
514 send_msg_clicked_cb(void *data , Evas_Object *obj , void *event_info)
516 appdata_s *ad = (appdata_s *)data;
517 if (isSendMessage == true)
521 m_pm = new PluginManager();
524 std::vector<Plugin> user_plugin;
526 user_plugin = m_pm->getPlugins();
528 for (unsigned int i = 0; i < user_plugin.size(); i++)
530 strcpy(temp_string, "Calling Get Plugin<br>");
531 sprintf(buf, "value Name = %s<br>", user_plugin[i].getName().c_str());
532 strcat(temp_string, buf);
533 sprintf(buf, "value ID = %s<br>", user_plugin[i].getID().c_str());
534 strcat(temp_string, buf);
535 m_ThreadContext.log = temp_string;
536 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
537 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
539 std::cout << "value Name = " << user_plugin[i].getName() << std::endl;
540 std::cout << "value ID = " << user_plugin[i].getID() << std::endl;
544 std::cout << "start fan Plugin by Resource Type" << std::endl;
545 strcpy(temp_string, "start fan Plugin<br>");
546 strcat(temp_string, "fan Plugin is getting started. Please wait...<br>");
547 m_ThreadContext.log = temp_string;
548 dlog_print(DLOG_INFO, LOG_TAG, " %s", m_ThreadContext.log);
549 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateCallbackLog,
551 m_pm->startPlugins("ResourceType", "oic.fan");
553 // Makes it so that all boolean values are printed as 'true/false' in this stream
554 std::cout.setf(std::ios::boolalpha);
555 std::cout << "Before find Resource... " << std::endl;
557 // Find fan resources
558 std::ostringstream requestURI;
559 requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=core.fan";
560 OCPlatform::findResource("", requestURI.str(), OC_ALL, &foundResourceFan);
561 std::cout << "Finding Resource... " << std::endl;
563 catch (OCException &e)
568 elm_object_text_set(ad->send_msg_button, "Press here to close the App");
569 isSendMessage = false;
573 isSendMessage = true;
579 clear_log_clicked_cb(void *data , Evas_Object *obj , void *event_info)
581 appdata_s *ad = (appdata_s *)data;
582 elm_entry_entry_set(ad->log, "");
586 create_base_gui(appdata_s *ad)
589 ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
590 elm_win_autodel_set(ad->win, EINA_TRUE);
592 if (elm_win_wm_rotation_supported_get(ad->win))
594 int rots[4] = { 0, 90, 180, 270 };
595 elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
598 evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
599 eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
602 ad->conform = elm_conformant_add(ad->win);
603 elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
604 elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
605 evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
606 elm_win_resize_object_add(ad->win, ad->conform);
607 evas_object_show(ad->conform);
610 ad->naviframe = elm_naviframe_add(ad->conform);
611 elm_object_content_set(ad->conform, ad->naviframe);
612 evas_object_show(ad->naviframe);
615 ad->box = elm_box_add(ad->naviframe);
616 elm_box_horizontal_set(ad->box, EINA_FALSE);
617 evas_object_size_hint_weight_set(ad->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
618 evas_object_size_hint_align_set(ad->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
619 elm_box_padding_set(ad->box, 0, 15 * elm_config_scale_get());
620 elm_naviframe_item_push(ad->naviframe, "ProtocolPlugin App", NULL, NULL, ad->box, NULL);
621 evas_object_show(ad->box);
623 ad->send_msg_button = elm_button_add(ad->box);
624 evas_object_size_hint_align_set(ad->send_msg_button, EVAS_HINT_FILL, 0.0);
625 elm_object_text_set(ad->send_msg_button, "Invoke Fan Plugin");
626 evas_object_smart_callback_add(ad->send_msg_button, "clicked", send_msg_clicked_cb, ad);
627 elm_box_pack_end(ad->box, ad->send_msg_button);
628 evas_object_show(ad->send_msg_button);
630 ad->clear_log_button = elm_button_add(ad->box);
631 evas_object_size_hint_align_set(ad->clear_log_button, EVAS_HINT_FILL, 0.0);
632 elm_object_text_set(ad->clear_log_button, "Clear Log");
633 evas_object_smart_callback_add(ad->clear_log_button, "clicked", clear_log_clicked_cb, ad);
634 elm_box_pack_end(ad->box, ad->clear_log_button);
635 evas_object_show(ad->clear_log_button);
637 ad->log = elm_entry_add(ad->box);
638 elm_object_part_text_set(ad->log, "elm.guide", "Log messages will be update here!!!");
639 elm_entry_scrollable_set(ad->log, EINA_TRUE);
640 evas_object_size_hint_weight_set(ad->log, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
641 evas_object_size_hint_align_set(ad->log, EVAS_HINT_FILL, EVAS_HINT_FILL);
642 elm_box_pack_end(ad->box, ad->log);
643 evas_object_show(ad->log);
645 // Show window after base gui is set up
646 evas_object_show(ad->win);
649 std::string key = "Name";
650 std::string state = "";
653 // Create PlatformConfig object
656 OC::ServiceType::InProc,
660 OC::QualityOfService::LowQos
663 OCPlatform::Configure(cfg);
667 app_create(void *data)
669 /* Hook to take necessary actions before main event loop starts
670 Initialize UI resources and application's data
671 If this function returns true, the main loop of application starts
672 If this function returns false, the application is terminated */
673 appdata_s *ad = (appdata_s *)data;
674 m_ThreadContext.ad = ad;
675 m_ThreadContext.log = NULL;
682 app_control(app_control_h app_control, void *data)
684 // Handle the launch request.
685 dlog_print(DLOG_INFO, LOG_TAG, "#### in app_control");
689 app_pause(void *data)
691 // Take necessary actions when application becomes invisible.
692 dlog_print(DLOG_INFO, LOG_TAG, "#### in app_pause");
696 app_resume(void *data)
698 // Take necessary actions when application becomes visible.
699 dlog_print(DLOG_INFO, LOG_TAG, "#### in app_resume");
703 app_terminate(void *data)
705 // Release all resources.
706 dlog_print(DLOG_INFO, LOG_TAG, "#### in app_terminate");
711 ui_app_lang_changed(app_event_info_h event_info, void *user_data)
713 // APP_EVENT_LANGUAGE_CHANGED
715 system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
716 elm_language_set(locale);
722 ui_app_orient_changed(app_event_info_h event_info, void *user_data)
724 // APP_EVENT_DEVICE_ORIENTATION_CHANGED
725 dlog_print(DLOG_INFO, LOG_TAG, "#### app orient changed");
730 ui_app_region_changed(app_event_info_h event_info, void *user_data)
732 // APP_EVENT_REGION_FORMAT_CHANGED
736 ui_app_low_battery(app_event_info_h event_info, void *user_data)
738 // APP_EVENT_LOW_BATTERY
742 ui_app_low_memory(app_event_info_h event_info, void *user_data)
744 // APP_EVENT_LOW_MEMORY
748 main(int argc, char *argv[])
753 ui_app_lifecycle_callback_s event_callback = {0,};
754 app_event_handler_h handlers[5] = {NULL, };
756 event_callback.create = app_create;
757 event_callback.terminate = app_terminate;
758 event_callback.pause = app_pause;
759 event_callback.resume = app_resume;
760 event_callback.app_control = app_control;
762 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY,
763 ui_app_low_battery, &ad);
764 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY,
765 ui_app_low_memory, &ad);
766 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED],
767 APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad);
768 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED,
769 ui_app_lang_changed, &ad);
770 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED],
771 APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad);
772 ui_app_remove_event_handler(handlers[APP_EVENT_LOW_MEMORY]);
774 ret = ui_app_main(argc, argv, &event_callback, &ad);
776 if (ret != APP_ERROR_NONE)
778 dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret);