3 * BlueZ - Bluetooth protocol stack for Linux
5 * Copyright (C) 2011 Nokia Corporation
6 * Copyright (C) 2011 Marcel Holtmann <marcel@holtmann.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program 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
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
39 static DBusConnection *connection = NULL;
40 static GKeyFile *config = NULL;
42 static GKeyFile *open_config_file(const char *file)
47 keyfile = g_key_file_new();
49 g_key_file_set_list_separator(keyfile, ',');
51 if (!g_key_file_load_from_file(keyfile, file, 0, &gerr)) {
52 error("Parsing %s failed: %s", file, gerr->message);
54 g_key_file_free(keyfile);
61 static int proximity_init(void)
63 if (!main_opts.gatt_enabled) {
64 DBG("GATT is disabled");
68 connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
69 if (connection == NULL)
72 config = open_config_file(CONFIGDIR "/proximity.conf");
74 if (proximity_manager_init(connection, config) < 0) {
75 dbus_connection_unref(connection);
82 static void proximity_exit(void)
84 if (!main_opts.gatt_enabled)
88 g_key_file_free(config);
90 proximity_manager_exit();
91 dbus_connection_unref(connection);
94 BLUETOOTH_PLUGIN_DEFINE(proximity, VERSION,
95 BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
96 proximity_init, proximity_exit)