summaryrefslogtreecommitdiff
path: root/src/Daemon/main.cpp
blob: 84e6b773d9a0504c70dcd6846112c9649ccb0a67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
 *
 *    Licensed under the Flora License, Version 1.1 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://floralicense.org/license/
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
/**
 * @file    main.cpp
 * @author  Yunchan Cho (yunchan.cho@samsung.com)
 */
#include <aul.h>
#include <app.h>
#include <Elementary.h>
#include <Core/Util/Log.h>
#include "BoxDaemon.h"

static bool app_create(void *data)
{
    LogD("app create");
    elm_config_preferred_engine_set("software_x11");
    return true;
}

static void app_reset(service_h service, void *data)
{
    LogD("app reset");

    int ret;
    char* name;

    BoxDaemon *daemon = static_cast<BoxDaemon*>(data);
    ret = service_get_extra_data(service, "name", &name);
    if (ret == SERVICE_ERROR_NONE) {
        std::string daemonName(name);
        if(!(daemon->start(daemonName))) {
            LogD("daemon failed to start");
            aul_terminate_pid(getpid());
        }
        return;
    }

    daemon->handleAppService(service);
}

static void app_pause(void *data)
{
}

static void app_resume(void *data)
{
}

static void app_terminate(void *data)
{
    BoxDaemon *daemon = static_cast<BoxDaemon *>(data);
    daemon->stop();
}

int main (int argc, char *argv[])
{
    int ret;

    app_event_callback_s ops;
    memset(&ops, 0x00, sizeof(app_event_callback_s));
    BoxDaemon daemon;

    ops.create = app_create;
    ops.terminate = app_terminate;
    ops.pause = app_pause;
    ops.resume = app_resume;
    ops.service = app_reset;

#if !defined(TIZEN_PUBLIC)
    setenv("COREGL_FASTPATH", "1", 1);
#endif
    setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
    setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
    setenv("ELM_IMAGE_CACHE", "0", 1);

    ret = app_efl_main(&argc, &argv, &ops, &daemon);
    return ret;
}