Fix pkg-config files from returning wrong relative paths.
[platform/core/security/vasum.git] / zone-daemon / runner.cpp
1 /*
2  *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Jan Olszak (j.olszak@samsung.com)
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License
17  */
18
19 /**
20  * @file
21  * @author  Jan Olszak (j.olszak@samsung.com)
22  * @brief   Definition of the Runner class, that manages daemon's lifetime
23  */
24
25 #include "config.hpp"
26
27 #include "runner.hpp"
28 #include "daemon.hpp"
29
30 #include "logger/logger.hpp"
31 #include "utils/glib-loop.hpp"
32 #include "utils/latch.hpp"
33
34 #include <csignal>
35
36
37 namespace vasum {
38 namespace zone_daemon {
39
40
41 Runner::Runner()
42 {
43 }
44
45
46 Runner::~Runner()
47 {
48 }
49
50
51 namespace {
52 utils::Latch gSignalLatch;
53
54 void signalHandler(const int sig)
55 {
56     LOGI("Got signal " << sig);
57     gSignalLatch.set();
58 }
59 } // namespace
60
61
62 void Runner::run()
63 {
64     signal(SIGINT,  signalHandler);
65     signal(SIGTERM, signalHandler);
66
67     LOGI("Starting Zone Daemon...");
68     {
69         utils::ScopedGlibLoop loop;
70         LOGI("Zone Daemon started");
71
72         // Connects to dbus and registers API
73         zone_daemon::Daemon daemon;
74
75         gSignalLatch.wait();
76
77         LOGI("Stopping Zone Daemon...");
78
79     }
80     LOGI("Daemon stopped");
81 }
82
83 void Runner::terminate()
84 {
85     LOGI("Terminating Zone Daemon");
86     gSignalLatch.set();
87 }
88
89 } // namespace zone_daemon
90 } // namespace vasum