12792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio/* 22792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * 32792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * BlueZ - Bluetooth protocol stack for Linux 42792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * 52792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. 62792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * Authors: 72792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * Santiago Carot Nemesio <sancane at gmail.com> 82792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * Jose Antonio Santos-Cadenas <santoscadenas at gmail.com> 92792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * 102792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * This program is free software; you can redistribute it and/or modify 112792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * it under the terms of the GNU General Public License as published by 122792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * the Free Software Foundation; either version 2 of the License, or 132792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * (at your option) any later version. 142792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * 152792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * This program is distributed in the hope that it will be useful, 162792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * but WITHOUT ANY WARRANTY; without even the implied warranty of 172792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 182792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * GNU General Public License for more details. 192792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * 202792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * You should have received a copy of the GNU General Public License 212792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * along with this program; if not, write to the Free Software 222792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 232792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio * 242792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio */ 252792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio 262792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio#ifdef HAVE_CONFIG_H 272792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio#include <config.h> 282792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio#endif 292792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio 302792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio#include <errno.h> 312792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio 322792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio#include <gdbus.h> 332792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio 342792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio#include "plugin.h" 352792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio#include "hdp_manager.h" 362792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio 3773d16df5fccdfbeee8564bb4a6d22cb7d8442220Johan Hedbergstatic DBusConnection *connection = NULL; 382792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio 392792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesiostatic int hdp_init(void) 402792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio{ 412792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); 422792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio if (connection == NULL) 432792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio return -EIO; 442792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio 452792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio if (hdp_manager_init(connection) < 0) { 462792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio dbus_connection_unref(connection); 472792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio return -EIO; 482792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio } 4973d16df5fccdfbeee8564bb4a6d22cb7d8442220Johan Hedberg 502792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio return 0; 512792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio} 522792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio 532792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesiostatic void hdp_exit(void) 542792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio{ 552792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio hdp_manager_exit(); 562792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio 572792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio dbus_connection_unref(connection); 5873d16df5fccdfbeee8564bb4a6d22cb7d8442220Johan Hedberg connection = NULL; 592792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio} 602792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio 612792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-NemesioBLUETOOTH_PLUGIN_DEFINE(health, VERSION, 622792e639a9f6c5738ded6745a2077b8db0baf1fbSantiago Carot-Nemesio BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, hdp_init, hdp_exit) 63