1/*
2 *      Copyright 2013 Julien Lavergne <gilir@ubuntu.com>
3 *
4 *      This program is free software; you can redistribute it and/or modify
5 *      it under the terms of the GNU General Public License as published by
6 *      the Free Software Foundation; either version 2 of the License, or
7 *      (at your option) any later version.
8 *
9 *      This program is distributed in the hope that it will be useful,
10 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 *      GNU General Public License for more details.
13 *
14 *      You should have received a copy of the GNU General Public License
15 *      along with this program; if not, write to the Free Software
16 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 *      MA 02110-1301, USA.
18 */
19public class Main: GLib.Object
20{
21        static bool persistent = false;
22        static string file = null;
23
24        const OptionEntry[] option_entries = {
25        { "file", 'f', 0, OptionArg.STRING, ref file, "path of the configuration file", "NAME" },
26        { "persistent", 'p', 0, OptionArg.NONE, ref persistent, "reload configuration on file change", null },
27        { null }
28        };
29
30    public static int main(string[] args)
31    {
32        if (file == null)
33        {
34            critical("Error, you need to specify a configuration file using -f argument. Exit");
35            return -1;
36        }
37        else
38        {
39            KeyFile kf = new KeyFile();
40
41            try
42            {
43                kf.load_from_file(file, KeyFileFlags.NONE);
44            }
45            catch (KeyFileError err)
46            {
47                warning (err.message);
48                critical("Problem when loading the configuration file. Exit");
49                return -1;
50            }
51            catch (FileError err)
52            {
53                warning (err.message);
54                critical("Problem when loading the configuration file. Exit");
55                return -1;
56            }
57
58            /* Start settings daemon */
59            settings_daemon_start(kf);
60
61            if (persistent == false)
62            {
63                /* Nothing to do, just exit */
64                return 0;
65            }
66            else
67            {
68                /* TODO Monitor desktop file change and reload on modification change */
69                return 0;
70            }
71        }
72    }
73}
74