13b7abd61d47e7a09c6e006e19347e7499fd2198
[platform/framework/web/web-provider.git] / src / Daemon / main.cpp
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
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  * @file    main.cpp
18  * @author  Yunchan Cho (yunchan.cho@samsung.com)
19  */
20 #include <aul.h>
21 #include <bundle.h>
22 #include <appcore-efl.h>
23 #include <Elementary.h>
24 #include <Core/Util/Log.h>
25 #include "BoxDaemon.h"
26
27 static int app_create(void *data)
28 {
29     LogD("app create");
30         elm_config_preferred_engine_set("opengl_x11");
31     return 0;
32 }
33
34 static int app_reset(bundle *b, void *data)
35 {
36     bool ret;
37     const char *name;
38
39     LogD("app reset");
40
41     name = bundle_get_val(b, "name");
42     if (!name) {
43         LogD("slave name is NULL");
44         return -EINVAL;
45     }
46
47     BoxDaemon *daemon = static_cast<BoxDaemon*>(data);
48     std::string daemonName(name);
49     ret = daemon->start(daemonName);
50     if (!ret) {
51         LogD("livebox daemon failed to start");
52             aul_terminate_pid(getpid());
53     }
54
55     return static_cast<int>(ret);
56 }
57
58 static int app_pause(void *data)
59 {
60     return 0;
61 }
62
63 static int app_resume(void *data)
64 {
65     return 0;
66 }
67
68 static int app_terminate(void *data)
69 {
70     BoxDaemon *daemon = static_cast<BoxDaemon *>(data);
71     daemon->stop();
72
73     return 0;
74 }
75
76 int main (int argc, char *argv[])
77 {
78     int ret;
79
80         struct appcore_ops ops;
81     BoxDaemon daemon;
82
83     ops.create = app_create;
84     ops.terminate = app_terminate;
85     ops.pause = app_pause;
86     ops.resume = app_resume;
87     ops.reset = app_reset;
88     ops.data = &daemon;
89
90 #if !defined(TIZEN_PUBLIC)
91     setenv("COREGL_FASTPATH", "1", 1);
92 #endif
93     setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
94     setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
95     setenv("ELM_IMAGE_CACHE", "0", 1);
96
97     ret = appcore_efl_main("web-provider", &argc, &argv, &ops);
98     return ret;
99 }