2013-03-20 22:26:31 +00:00
|
|
|
/*
|
|
|
|
* oFono - Open Source Telephony
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 Instituto Nokia de Tecnologia - INdT
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2013-03-20 22:26:33 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <gdbus.h>
|
|
|
|
|
2013-03-20 22:26:31 +00:00
|
|
|
#include "dundee.h"
|
2013-03-20 22:26:33 +00:00
|
|
|
#include "plugins/bluez5.h"
|
|
|
|
|
|
|
|
#define DUN_DT_PROFILE_PATH "/bluetooth/profile/dun_dt"
|
|
|
|
|
|
|
|
static GDBusClient *bluez;
|
|
|
|
|
|
|
|
static void proxy_added(GDBusProxy *proxy, void *user_data)
|
|
|
|
{
|
|
|
|
const char *path = g_dbus_proxy_get_path(proxy);
|
|
|
|
const char *interface = g_dbus_proxy_get_interface(proxy);
|
|
|
|
|
|
|
|
if (!g_str_equal(BLUEZ_DEVICE_INTERFACE, interface))
|
|
|
|
return;
|
|
|
|
|
|
|
|
DBG("%s %s", path, interface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void connect_handler(DBusConnection *conn, void *user_data)
|
|
|
|
{
|
|
|
|
DBG("");
|
|
|
|
|
|
|
|
bt_register_profile_with_role(conn, DUN_GW_UUID, DUN_VERSION_1_2,
|
|
|
|
"dun_dt", DUN_DT_PROFILE_PATH, "client");
|
|
|
|
}
|
2013-03-20 22:26:31 +00:00
|
|
|
|
|
|
|
int __dundee_bluetooth_init(void)
|
|
|
|
{
|
2013-03-20 22:26:33 +00:00
|
|
|
DBusConnection *conn = ofono_dbus_get_connection();
|
|
|
|
|
2013-03-20 22:26:31 +00:00
|
|
|
DBG("");
|
|
|
|
|
2013-03-20 22:26:33 +00:00
|
|
|
bluez = g_dbus_client_new(conn, BLUEZ_SERVICE, BLUEZ_MANAGER_PATH);
|
|
|
|
g_dbus_client_set_connect_watch(bluez, connect_handler, NULL);
|
|
|
|
g_dbus_client_set_proxy_handlers(bluez, proxy_added, NULL, NULL, NULL);
|
|
|
|
|
2013-03-20 22:26:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __dundee_bluetooth_cleanup(void)
|
|
|
|
{
|
|
|
|
DBG("");
|
2013-03-20 22:26:33 +00:00
|
|
|
|
|
|
|
g_dbus_client_unref(bluez);
|
2013-03-20 22:26:31 +00:00
|
|
|
}
|