[Release] livebox.web-provider-1.59
[platform/framework/web/web-provider.git] / src / Daemon / BoxDaemonImpl.cpp
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Flora License, Version 1.1 (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  * @file    BoxDaemonImpl.cpp
18  * @author  Yunchan Cho (yunchan.cho@samsung.com)
19  */
20 #include <API/web_provider_livebox_info.h>
21 #include <app.h>
22 #include <appcore-efl.h>
23 #include <aul.h>
24 #include <Core/Util/Log.h>
25 #include <Core/Util/Util.h>
26 #include <cstring>
27 #include <Ecore_X.h>
28 #include <Elementary.h>
29 #include <livebox-service.h>
30 #include <Plugin/IBoxPluginConnector.h>
31 #include <Plugin/BoxPluginConnector.h>
32 #include <provider.h>
33 #include <sys/types.h>
34 #include <string>
35 #include <unistd.h>
36 #include <vconf.h>
37
38 #include "BoxDaemonUtil.h"
39 #include "BoxDaemonImpl.h"
40
41 #define MASTER_PROVIDER_PING_TIME  120.0f
42
43 // These are string for handling application service from app
44 static const std::string BOX_SERVICE_SCHEME("box-service://");
45 static const std::string OPERATION_UPDATE_BOX(
46         "http://tizen.org/appcontrol/operation/dynamicbox/web/update");
47 static const std::string CONTENT_INFO_KEY("content-info");
48 static const std::string ALARM_CALLER_KEY("__ALARM_MGR_CALLER_APPID");
49
50 BoxDaemonImpl::BoxDaemonImpl()
51     : m_pluginConnector(BoxPluginConnector::create())
52 {
53     appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, requestChangeLanguageCallback, this);
54     appcore_set_event_callback(APPCORE_EVENT_LOW_MEMORY, requestLowMemoryCallback, this);
55     appcore_set_event_callback(APPCORE_EVENT_REGION_CHANGE, requestChangeRegionCallback, this);
56     // reserved
57     appcore_set_event_callback(APPCORE_EVENT_LOW_BATTERY, NULL, NULL);
58
59     if (vconf_notify_key_changed("db/setting/accessibility/font_name", requestChangeFontCallback, this) != true) {
60         LogD("vconf_notify_key_changed returned FALSE!");
61     }
62     if (vconf_notify_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, requestChangeTimeCallback,  this) != true) {
63         LogD("vconf_notify_key_changed returned FALSE!");
64     }
65 }
66
67 BoxDaemonImpl::~BoxDaemonImpl()
68 {
69 }
70
71 bool BoxDaemonImpl::start(std::string& name)
72 {
73     LogD("enter");
74
75     // initialize existing plugins for web livebox
76     if (!m_pluginConnector->initialize()) {
77         LogD("failed to initialize plugins");
78         return false;
79     }
80
81     // set name
82     m_daemonName = name;
83
84     // provider init
85     ProviderCallbacks callbacks;
86     setProviderCallbacks(callbacks);
87
88     int ret = provider_init(ecore_x_display_get(),
89                             m_daemonName.c_str(),
90                             &callbacks,
91                             this);
92     if (ret < 0) {
93         LogD("failed to initialize provider");
94         return false;
95     }
96
97     return true;
98 }
99
100 bool BoxDaemonImpl::stop()
101 {
102     LogD("enter");
103
104     // deinitialize provider
105     provider_fini();
106
107     // deinitialize existing plugins for web livebox
108     if (!m_pluginConnector->shutdown()) {
109         LogD("failed to shutdown plugins");
110         return false;
111     }
112
113     return true;
114 }
115
116 bool BoxDaemonImpl::handleAppService(service_h service)
117 {
118     LogD("enter");
119     bool result = false;
120     char* operation;
121
122     if (service_get_operation(service, &operation) != SERVICE_ERROR_NONE) {
123         LogD("no operation");
124         return false;
125     }
126
127     if (OPERATION_UPDATE_BOX == operation) {
128         BoxInfoPtr info = handleOperationUpdate(service);
129         if (info) {
130             JobInfo* jobInfo = new JobInfo(REQUEST_CMD_UPDATE_BOX, info, this);
131             if (ecore_job_add(requestBoxJobCallback, jobInfo)) {
132                 result = true;
133             }
134         }
135     } else {
136         LogD("unknown operation: %s", operation);
137     }
138
139     delete[] operation;
140     return result;
141 }
142
143 int BoxDaemonImpl::connectedCallback(ProviderEventArgPtr arg, void* data)
144 {
145     LogD("enter");
146     UNUSED_PARAM(arg);
147
148     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
149     if (!provider_send_hello()) {
150         This->m_pingTimer =
151             ecore_timer_add(MASTER_PROVIDER_PING_TIME, pingToMasterCallback, This);
152     }
153
154     return 0;
155 }
156
157 int BoxDaemonImpl::disconnectedCallback(ProviderEventArgPtr arg, void* data)
158 {
159     LogD("enter");
160     UNUSED_PARAM(arg);
161     UNUSED_PARAM(data);
162
163     aul_terminate_pid(getpid());
164
165     return 0;
166 }
167
168 int BoxDaemonImpl::boxCreateCallback(
169         ProviderEventArgPtr arg,
170         int* width, int* height,
171         double* priority, void* data)
172 {
173     LogD("enter");
174     UNUSED_PARAM(priority);
175
176     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
177     BoxInfoPtr info = This->initializeBoxInfo(arg);
178     if (!info) {
179         return -1;
180     }
181
182     if ((arg->info.lb_create.width == 0) || (arg->info.lb_create.height == 0)) {
183         livebox_service_get_size(LB_SIZE_TYPE_1x1, width, height);
184     } else {
185         *width = arg->info.lb_create.width;
186         *height = arg->info.lb_create.height;
187     }
188
189     info->boxWidth = *width;
190     info->boxHeight = *height;
191     info->priority = 1.0f;
192     info->period = arg->info.lb_create.period;
193     if (arg->info.lb_create.content) {
194         info->contentInfo = std::string(arg->info.lb_create.content);
195     }
196
197     // box information
198     LogD("--------------------------------------------");
199     LogD("boxId: %s", info->boxId.c_str());
200     LogD("InstanceId: %s", info->instanceId.c_str());
201     LogD("width: %d", info->boxWidth);
202     LogD("height: %d", info->boxHeight);
203     LogD("update period: %f", info->period);
204     LogD("--------------------------------------------");
205
206     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_ADD_BOX, info, This);
207     Ecore_Job* ret = ecore_job_add(requestBoxJobCallback, jobInfo);
208
209     return ret ? 0 : -1;
210 }
211
212 int BoxDaemonImpl::boxReCreateCallback(ProviderEventArgPtr arg, void* data)
213 {
214     LogD("enter");
215
216     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
217     BoxInfoPtr info = This->initializeBoxInfo(arg);
218     if (!info) {
219         return -1;
220     }
221
222     int* width  = NULL;
223     int* height = NULL;
224
225     if ((arg->info.lb_recreate.width == 0) || (arg->info.lb_recreate.height == 0)) {
226         livebox_service_get_size(LB_SIZE_TYPE_1x1, width, height);
227         arg->info.lb_recreate.width = *width;
228         arg->info.lb_recreate.height = *height;
229     }
230
231     info->boxWidth = arg->info.lb_recreate.width;
232     info->boxHeight = arg->info.lb_recreate.height;
233     info->priority = 1.0f;
234     info->period = arg->info.lb_recreate.period;
235     if (arg->info.lb_recreate.content) {
236         info->contentInfo = std::string(arg->info.lb_recreate.content);
237     }
238
239     // box information
240     LogD("--------------------------------------------");
241     LogD("boxId: %s", info->boxId.c_str());
242     LogD("InstanceId: %s", info->instanceId.c_str());
243     LogD("width: %d", info->boxWidth);
244     LogD("height: %d", info->boxHeight);
245     LogD("update period: %f", info->period);
246     LogD("--------------------------------------------");
247
248     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_ADD_BOX, info, This);
249     Ecore_Job* ret = ecore_job_add(requestBoxJobCallback, jobInfo);
250
251     return ret ? 0 : -1;
252 }
253
254 int BoxDaemonImpl::boxDestroyCallback(ProviderEventArgPtr arg, void* data)
255 {
256     LogD("enter");
257
258     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
259     BoxInfoPtr info = This->initializeBoxInfo(arg);
260     if (!info) {
261         return -1;
262     }
263
264     LogD("--------------------------------------------");
265     LogD("boxId: %s", info->boxId.c_str());
266     LogD("InstanceId: %s", info->instanceId.c_str());
267     LogD("--------------------------------------------");
268
269     This->m_pluginConnector->requestCommand(REQUEST_CMD_REMOVE_BOX, info);
270
271     return 0;
272 }
273
274 int BoxDaemonImpl::pdCreateCallback(ProviderEventArgPtr arg, void* data)
275 {
276     LogD("enter");
277
278     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
279     BoxInfoPtr info = This->initializeBoxInfo(arg);
280     if (!info) {
281         return -1;
282     }
283     if (arg->info.pd_create.w == 0 || arg->info.pd_create.h == 0) {
284         return -1;
285     }
286
287     //Use the screen width to fix the device width
288     ecore_x_window_size_get(0, &info->pdWidth, NULL);
289     info->pdHeight = arg->info.pd_create.h;
290     info->pdX = arg->info.pd_create.x;
291     info->pdY = arg->info.pd_create.y;
292
293     LogD("--------------------------------------------");
294     LogD("boxId: %s", info->boxId.c_str());
295     LogD("InstanceId: %s", info->instanceId.c_str());
296     LogD("width: %d", info->pdWidth);
297     LogD("height: %d", info->pdHeight);
298     LogD("x: %f", info->pdX);
299     LogD("y: %f", info->pdY);
300     LogD("--------------------------------------------");
301
302     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_OPEN_PD, info, This);
303     Ecore_Job* ret = ecore_job_add(requestBoxJobCallback, jobInfo);
304
305     return ret ? 0 : -1;
306 }
307
308 int BoxDaemonImpl::pdDestroyCallback(ProviderEventArgPtr arg, void* data)
309 {
310     LogD("enter");
311
312     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
313     BoxInfoPtr info = This->initializeBoxInfo(arg);
314     if (!info) {
315         return -1;
316     }
317
318     LogD("--------------------------------------------");
319     LogD("boxId: %s", info->boxId.c_str());
320     LogD("InstanceId: %s", info->instanceId.c_str());
321     LogD("--------------------------------------------");
322
323     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_CLOSE_PD, info, This);
324     Ecore_Job* ret = ecore_job_add(requestBoxJobCallback, jobInfo);
325
326     return ret ? 0 : -1;
327 }
328
329 int BoxDaemonImpl::clickedCallback(ProviderEventArgPtr arg, void* data)
330 {
331     LogD("enter");
332
333     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
334     BoxInfoPtr info = This->initializeBoxInfo(arg);
335     if (!info) {
336         return -1;
337     }
338
339     int flag = web_provider_livebox_get_auto_launch(info->boxId.c_str());
340     if (!flag) {
341         return -1;
342     }
343
344     BoxDaemonUtil::launchApplication(info->boxId, info->instanceId);
345     return 0;
346 }
347
348 int BoxDaemonImpl::boxResizeCallback(ProviderEventArgPtr arg, void* data)
349 {
350     LogD("enter");
351
352     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
353     BoxInfoPtr info = This->initializeBoxInfo(arg);
354     if (!info) {
355         return -1;
356     }
357     if (arg->info.resize.w == 0 || arg->info.resize.h == 0) {
358         return -1;
359     }
360
361     info->boxWidth = arg->info.resize.w;
362     info->boxHeight = arg->info.resize.h;
363
364     // box information
365     LogD("--------------------------------------------");
366     LogD("boxId: %s", info->boxId.c_str());
367     LogD("InstanceId: %s", info->instanceId.c_str());
368     LogD("width: %d", info->boxWidth);
369     LogD("height: %d", info->boxHeight);
370     LogD("--------------------------------------------");
371
372     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_RESIZE_BOX, info, This);
373     Ecore_Job* ret = ecore_job_add(requestBoxJobCallback, jobInfo);
374
375     return ret ? 0 : -1;
376 }
377
378 int BoxDaemonImpl::boxPauseCallback(ProviderEventArgPtr arg, void* data)
379 {
380     LogD("enter");
381
382     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
383     BoxInfoPtr info = This->initializeBoxInfo(arg);
384     if (!info) {
385         return -1;
386     }
387
388     // box information
389     LogD("--------------------------------------------");
390     LogD("boxId: %s", info->boxId.c_str());
391     LogD("InstanceId: %s", info->instanceId.c_str());
392     LogD("--------------------------------------------");
393
394     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_PAUSE_BOX, info, This);
395     Ecore_Job* ret = ecore_job_add(requestBoxJobCallback, jobInfo);
396
397     return ret ? 0 : -1;
398 }
399
400 int BoxDaemonImpl::boxResumeCallback(ProviderEventArgPtr arg, void* data)
401 {
402     LogD("enter");
403
404     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
405     BoxInfoPtr info = This->initializeBoxInfo(arg);
406     if (!info) {
407         return -1;
408     }
409
410     // box information
411     LogD("--------------------------------------------");
412     LogD("boxId: %s", info->boxId.c_str());
413     LogD("InstanceId: %s", info->instanceId.c_str());
414     LogD("--------------------------------------------");
415
416     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_RESUME_BOX, info, This);
417     Ecore_Job* ret = ecore_job_add(requestBoxJobCallback, jobInfo);
418
419     return ret ? 0 : -1;
420 }
421
422 int BoxDaemonImpl::pauseCallback(ProviderEventArgPtr arg, void* data)
423 {
424     LogD("enter");
425     UNUSED_PARAM(arg);
426
427     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
428
429     LogD("--------------------------------------------");
430     LogD("web-provider is paused");
431     LogD("--------------------------------------------");
432
433     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_PAUSE_ALL, BoxInfoPtr(), This);
434     Ecore_Job* ret = ecore_job_add(requestBoxJobCallback, jobInfo);
435
436     return ret ? 0 : -1;
437 }
438
439 int BoxDaemonImpl::resumeCallback(ProviderEventArgPtr arg, void* data)
440 {
441     LogD("enter");
442     UNUSED_PARAM(arg);
443
444     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
445
446     LogD("--------------------------------------------");
447     LogD("web-provider is resumed");
448     LogD("--------------------------------------------");
449
450     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_RESUME_ALL, BoxInfoPtr(), This);
451     Ecore_Job* ret = ecore_job_add(requestBoxJobCallback, jobInfo);
452
453     return ret ? 0 : -1;
454 }
455
456 int BoxDaemonImpl::boxPeriodChangeCallback(ProviderEventArgPtr arg, void* data)
457 {
458     LogD("enter");
459     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
460     BoxInfoPtr info = This->initializeBoxInfo(arg);
461     if (!info) {
462         return -1;
463     }
464     info->period = arg->info.set_period.period;
465
466     LogD("--------------------------------------------");
467     LogD("boxId: %s", info->boxId.c_str());
468     LogD("InstanceId: %s", info->instanceId.c_str());
469     LogD("period: %f", info->period);
470     LogD("--------------------------------------------");
471
472     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_CHANGE_PERIOD, info, This);
473     Ecore_Job* ret = ecore_job_add(requestBoxJobCallback, jobInfo);
474
475     return ret ? 0 : -1;
476 }
477
478 int BoxDaemonImpl::boxUpdateCallback(ProviderEventArgPtr arg, void* data)
479 {
480     LogD("enter");
481
482     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
483     BoxInfoPtr info = This->initializeBoxInfo(arg);
484     if (!info) {
485         return -1;
486     }
487
488     LogD("--------------------------------------------");
489     LogD("boxId: %s", info->boxId.c_str());
490     LogD("InstanceId: %s", info->instanceId.c_str());
491     LogD("--------------------------------------------");
492
493     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_UPDATE_BOX, info, This);
494     Ecore_Job* ret = ecore_job_add(requestBoxJobCallback, jobInfo);
495
496     return ret ? 0 : -1;
497 }
498
499 void BoxDaemonImpl::setProviderCallbacks(ProviderCallbacks& callbacks)
500 {
501     LogD("enter");
502
503     memset(&callbacks, 0, sizeof(callbacks));
504     callbacks.connected = BoxDaemonImpl::connectedCallback;
505     callbacks.disconnected = BoxDaemonImpl::disconnectedCallback;
506     callbacks.pause = BoxDaemonImpl::pauseCallback;
507     callbacks.resume = BoxDaemonImpl::resumeCallback;
508     callbacks.lb_create = BoxDaemonImpl::boxCreateCallback;
509     callbacks.lb_recreate = BoxDaemonImpl::boxReCreateCallback;
510     callbacks.lb_destroy = BoxDaemonImpl::boxDestroyCallback;
511     callbacks.lb_pause = BoxDaemonImpl::boxPauseCallback;
512     callbacks.lb_resume = BoxDaemonImpl::boxResumeCallback;
513     callbacks.pd_create = BoxDaemonImpl::pdCreateCallback;
514     callbacks.pd_destroy = BoxDaemonImpl::pdDestroyCallback;
515     callbacks.clicked = BoxDaemonImpl::clickedCallback;
516     callbacks.resize = BoxDaemonImpl::boxResizeCallback;
517     callbacks.update_content = BoxDaemonImpl::boxUpdateCallback;
518     callbacks.set_period = BoxDaemonImpl::boxPeriodChangeCallback;
519 }
520
521 std::string BoxDaemonImpl::getBoxType(const char* boxId)
522 {
523     LogD("enter");
524
525     if (!boxId) {
526         return std::string();
527     }
528
529     const char* type = web_provider_livebox_get_box_type(boxId);
530     if (!type) {
531         std::string boxType = m_pluginConnector->getBoxType(boxId);
532         if (boxType.empty()) {
533             LogD("unrecognized box id");
534         } else {
535             LogD("box id: %s, type: %s", boxId, boxType.c_str());
536         }
537         return boxType;
538     }
539
540     LogD("box id: %s, type: %s", boxId, type);
541     std::string result{type};
542     free(const_cast<char*>(type));
543     return result;
544 }
545
546 BoxInfoPtr BoxDaemonImpl::initializeBoxInfo(ProviderEventArgPtr arg)
547 {
548     LogD("enter");
549
550     if (!arg) {
551         return BoxInfoPtr();
552     }
553
554     if (!arg->pkgname || !arg->id) {
555         LogD("pkgname or id don't exist");
556         return BoxInfoPtr();
557     }
558
559     std::string type = getBoxType(arg->pkgname);
560     if (type.empty()) {
561         return BoxInfoPtr();
562     }
563     BoxInfoPtr infoPtr = BoxInfoPtr(new BoxInfo(type, arg->pkgname, arg->id));
564
565     return infoPtr;
566 }
567
568 std::string BoxDaemonImpl::getBoxIdFromService(service_h service)
569 {
570     LogD("enter");
571
572     int ret;
573     char* serviceUri = NULL;
574     ret = service_get_uri(service, &serviceUri);
575     if (ret != SERVICE_ERROR_NONE) {
576         LogD("no box uri");
577         return std::string();
578     }
579
580     std::string uri(serviceUri);
581     delete[] serviceUri;
582
583     if(uri.compare(0, BOX_SERVICE_SCHEME.size(), BOX_SERVICE_SCHEME)) {
584         // uri is not box-service scheme
585         return std::string();
586     }
587
588     std::string boxId = uri.substr(BOX_SERVICE_SCHEME.size());
589     return boxId;
590 }
591
592 bool BoxDaemonImpl::isServiceCallerBoxOwner(service_h service)
593 {
594     LogD("enter");
595
596     int ret;
597
598     std::string boxId = getBoxIdFromService(service);
599     if (boxId.empty()) {
600         LogD("error box-id");
601         return false;
602     }
603
604     // check if caller is owner of this box
605     const char* appId = web_provider_livebox_get_app_id(boxId.c_str());
606     if (!appId) {
607         return false;
608     }
609     std::string ownerAppId(appId);
610     delete[] appId;
611
612     char* caller = NULL;
613     ret = service_get_caller(service, &caller);
614     if (ret != SERVICE_ERROR_NONE) {
615         ret = service_get_extra_data(
616                 service, ALARM_CALLER_KEY.c_str(), &caller);
617         if (ret != SERVICE_ERROR_NONE) {
618             LogD("failed to get caller's appid from service");
619             return false;
620         }
621     }
622     std::string callerAppId(caller);
623
624     // release strings
625     delete[] caller;
626
627     if (ownerAppId != callerAppId) {
628         LogD("caller is not matched with owner of requested box");
629         return false;
630     }
631
632     return true;
633 }
634
635 BoxInfoPtr BoxDaemonImpl::handleOperationUpdate(service_h service)
636 {
637     LogD("enter");
638
639     if (!isServiceCallerBoxOwner(service)) {
640         return BoxInfoPtr();
641     }
642
643     std::string boxId = getBoxIdFromService(service);
644     if (boxId.empty()) {
645         LogD("error box-id");
646         return BoxInfoPtr();
647     }
648
649     char* contentInfo = NULL;
650     service_get_extra_data(service, CONTENT_INFO_KEY.c_str(), &contentInfo);
651
652     std::string type(getBoxType(boxId.c_str()));
653     if (type.empty()) {
654         LogD("no type for this box");
655         delete[] contentInfo;
656         return BoxInfoPtr();
657     }
658     BoxInfoPtr info = BoxInfoPtr(new BoxInfo(type, boxId, ""));
659     if (contentInfo) {
660         info->contentInfo = std::string(contentInfo);
661     }
662
663     // release string
664     delete[] contentInfo;
665
666     return info;
667 }
668
669 Eina_Bool BoxDaemonImpl::pingToMasterCallback(void* data)
670 {
671     LogD("enter");
672     UNUSED_PARAM(data);
673
674     provider_send_ping();
675
676     return ECORE_CALLBACK_RENEW;
677 }
678
679 void BoxDaemonImpl::requestBoxJobCallback(void* data)
680 {
681     JobInfo* jobInfo = static_cast<JobInfo*>(data);
682     if (!jobInfo) {
683         LogD("no information for job");
684         return;
685     }
686
687     // just for debugging
688     //volatile int flag = 0;
689     //while(flag == 0) {;}
690
691     // request box job!
692     jobInfo->daemonImpl->m_pluginConnector->requestCommand(
693             jobInfo->cmdType, jobInfo->boxInfo);
694
695     delete jobInfo;
696 }
697
698 int BoxDaemonImpl::requestChangeLanguageCallback(void* data)
699 {
700     LogD("enter");
701
702     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
703     BoxInfoPtr info = BoxInfoPtr(new BoxInfo());
704     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_CHANGE_LANGUAGE,  info, This);
705
706     ecore_job_add(requestBoxJobCallback, jobInfo);
707     return 0;
708 }
709
710 int BoxDaemonImpl::requestChangeRegionCallback(void* data)
711 {
712     LogD("enter");
713
714     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
715     BoxInfoPtr info = BoxInfoPtr(new BoxInfo());
716     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_CHANGE_LANGUAGE,  info, This);
717
718     ecore_job_add(requestBoxJobCallback, jobInfo);
719     return 0;
720 }
721 int BoxDaemonImpl::requestLowMemoryCallback(void* data)
722 {
723     LogD("enter");
724     UNUSED_PARAM(data);
725
726     // terminate box daemon and revive
727     elm_exit();
728     return 0;
729 }
730
731 void BoxDaemonImpl::requestChangeFontCallback(keynode_t* key, void* data)
732 {
733     LogD("enter");
734     UNUSED_PARAM(key);
735
736     char* fontstr = vconf_get_str("db/setting/accessibility/font_name");
737
738     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
739     BoxInfoPtr info = BoxInfoPtr(new BoxInfo());
740     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_CHANGE_LANGUAGE,  info, This);
741
742     free(fontstr);
743     ecore_job_add(requestBoxJobCallback, jobInfo);
744 }
745
746 void BoxDaemonImpl::requestChangeTimeCallback(keynode_t* key, void* data)
747 {
748     LogD("enter");
749     UNUSED_PARAM(key);
750
751     char* timestr = vconf_get_str(VCONFKEY_SYSTEM_TIME_CHANGED);
752
753     BoxDaemonImpl* This = static_cast<BoxDaemonImpl*>(data);
754     BoxInfoPtr info = BoxInfoPtr(new BoxInfo());
755     JobInfo* jobInfo = new JobInfo(REQUEST_CMD_CHANGE_LANGUAGE,  info, This);
756
757     free(timestr);
758     ecore_job_add(requestBoxJobCallback, jobInfo);
759 }