Add new line at end of exception log message.
[profile/ivi/settings-daemon.git] / src / daemon.cpp
1 /**
2  * @file daemon.cpp
3  *
4  * @brief Main settingsd source file.
5  *
6  * @copyright @par
7  * Copyright 2012, 2013 Intel Corporation All Rights Reserved.
8  * @par
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation;
12  * version 2.1 of the License.
13  * @par
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  * @par
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  * Boston, MA  02110-1301  USA
23  */
24
25 #include "../lib/config.hpp"
26 #include "../lib/manager.hpp"
27
28 #include "configurator.hpp"
29 #include "websocket_server.hpp"
30
31 #include <settingsd/glib_traits.hpp>
32 #include <settingsd/smart_ptr.hpp>
33
34 #include <glib.h>
35 #include <iostream>
36
37
38 /**
39  * settingsd program entry point.
40  *
41  * @param[in] argc The number of settingsd command line arguments.
42  * @param[in] argv The settingsd command line option/argument vector.
43  */
44 int
45 main(int argc, char * argv[])
46 {
47   std::cerr << PACKAGE_STRING << '\n';
48
49   try {
50     using namespace ivi;
51
52     settings::configurator config(argc, argv, IVI_SETTINGS_DBUS_NAME);
53
54     settings::manager manager(config.settings_dir());
55
56     // The websocket server will run in its own thread.
57     settings::websocket_server server(config, manager);
58     server.run();
59
60     // Glib related events, including GDbus related signal handlers,
61     // will handled in this (main) thread.
62     settings::smart_ptr<GMainLoop> const loop(g_main_loop_new(nullptr, false));
63     g_main_loop_run(loop.get());
64   }
65   catch (std::exception & e) {
66     std::cerr << e.what() << '\n';
67     return -1;
68   }
69
70   return 0;
71 }
72
73
74 // Local Variables:
75 // mode:c++
76 // c-basic-offset:2
77 // indent-tabs-mode: nil
78 // End: