• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
6  *  Authors:
7  *  Santiago Carot Nemesio <sancane at gmail.com>
8  *  Jose Antonio Santos-Cadenas <santoscadenas at gmail.com>
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program; if not, write to the Free Software
22  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23  *
24  */
25 
26 #ifdef HAVE_CONFIG_H
27 #include <config.h>
28 #endif
29 
30 #include <bluetooth/sdp.h>
31 #include <bluetooth/sdp_lib.h>
32 
33 #include <btio.h>
34 #include <adapter.h>
35 #include <device.h>
36 
37 #include "hdp_types.h"
38 
39 #include "log.h"
40 #include "hdp_manager.h"
41 #include "hdp.h"
42 
43 #include "glib-helper.h"
44 
45 static DBusConnection *connection = NULL;
46 
hdp_adapter_probe(struct btd_adapter * adapter)47 static int hdp_adapter_probe(struct btd_adapter *adapter)
48 {
49 	return hdp_adapter_register(connection, adapter);
50 }
51 
hdp_adapter_remove(struct btd_adapter * adapter)52 static void hdp_adapter_remove(struct btd_adapter *adapter)
53 {
54 	hdp_adapter_unregister(adapter);
55 }
56 
57 static struct btd_adapter_driver hdp_adapter_driver = {
58 	.name	= "hdp-adapter-driver",
59 	.probe	= hdp_adapter_probe,
60 	.remove	= hdp_adapter_remove,
61 };
62 
hdp_driver_probe(struct btd_device * device,GSList * uuids)63 static int hdp_driver_probe(struct btd_device *device, GSList *uuids)
64 {
65 	return hdp_device_register(connection, device);
66 }
67 
hdp_driver_remove(struct btd_device * device)68 static void hdp_driver_remove(struct btd_device *device)
69 {
70 	hdp_device_unregister(device);
71 }
72 
73 static struct btd_device_driver hdp_device_driver = {
74 	.name	= "hdp-device-driver",
75 	.uuids	= BTD_UUIDS(HDP_UUID, HDP_SOURCE_UUID, HDP_SINK_UUID),
76 	.probe	= hdp_driver_probe,
77 	.remove	= hdp_driver_remove
78 };
79 
hdp_manager_init(DBusConnection * conn)80 int hdp_manager_init(DBusConnection *conn)
81 {
82 	if (hdp_manager_start(conn))
83 		return -1;
84 
85 	connection = dbus_connection_ref(conn);
86 	btd_register_adapter_driver(&hdp_adapter_driver);
87 	btd_register_device_driver(&hdp_device_driver);
88 
89 	return 0;
90 }
91 
hdp_manager_exit(void)92 void hdp_manager_exit(void)
93 {
94 	btd_unregister_device_driver(&hdp_device_driver);
95 	btd_unregister_adapter_driver(&hdp_adapter_driver);
96 	hdp_manager_stop();
97 
98 	dbus_connection_unref(connection);
99 	connection = NULL;
100 }
101