Commit a84fc316 authored by Thomas Haller's avatar Thomas Haller

bluez: merge adding support for BlueZ 5 (bgo #701078)

Merge adding support for BlueZ 5. Both BlueZ 4 and 5 still work, but you
have to decide at compile time which version to use. By default BlueZ 5
will be build, use ./configure --enable-bluez4=yes to enable BlueZ 4.

BlueZ 5 currently only works with PAN devices, DUN devices are not yet
supported.

https://bugzilla.gnome.org/show_bug.cgi?id=701078Signed-off-by: Thomas Haller's avatarThomas Haller <thaller@redhat.com>
parents 024f7e10 e0e10a06
......@@ -267,6 +267,18 @@ else
fi
AC_SUBST(UDEV_BASE_DIR)
# BlueZ
AC_ARG_ENABLE(bluez4, AS_HELP_STRING([--enable-bluez4],
[build with BlueZ 4 support instead of BlueZ 5]),
[enable_bluez4=${enableval}])
if (test "${enable_bluez4}" = "yes"); then
AC_DEFINE(WITH_BLUEZ4, 1, [Define if you have BlueZ 4 support])
else
AC_DEFINE(WITH_BLUEZ4, 0, [Define if you have BlueZ 4 support])
enable_bluez4=no
fi
AM_CONDITIONAL(WITH_BLUEZ4, test "${enable_bluez4}" = "yes")
# systemd unit support
AC_ARG_WITH([systemdsystemunitdir], AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
[Directory for systemd service files]))
......@@ -814,6 +826,7 @@ echo " modemmanager-1: $with_modem_manager_1"
echo " concheck: $enable_concheck"
echo " libndp: $libndp_location"
echo " libteamdctl: $enable_teamdctl"
echo " bluez 4: $enable_bluez4"
echo
echo "Configuration plugins"
......
......@@ -36,6 +36,7 @@ libnm-util/nm-setting-wireless.c
libnm-util/nm-utils.c
policy/org.freedesktop.NetworkManager.policy.in.in
src/main.c
src/bluez-manager/nm-bluez-device.c
src/dhcp-manager/nm-dhcp-dhclient.c
src/dhcp-manager/nm-dhcp-dhclient-utils.c
src/dhcp-manager/nm-dhcp-manager.c
......
......@@ -49,14 +49,6 @@ NetworkManager_LDADD = libNetworkManager.la $(top_builddir)/libgsystem.la $(LIBN
noinst_LTLIBRARIES = libNetworkManager.la
nm_sources = \
bluez-manager/nm-bluez-adapter.c \
bluez-manager/nm-bluez-adapter.h \
bluez-manager/nm-bluez-common.h \
bluez-manager/nm-bluez-device.c \
bluez-manager/nm-bluez-device.h \
bluez-manager/nm-bluez-manager.c \
bluez-manager/nm-bluez-manager.h \
\
config/nm-config.c \
config/nm-config.h \
config/nm-config-device.c \
......@@ -266,6 +258,22 @@ nm_sources = \
NetworkManagerUtils.c \
NetworkManagerUtils.h
nm_sources += \
bluez-manager/nm-bluez-common.h \
bluez-manager/nm-bluez-device.c \
bluez-manager/nm-bluez-device.h \
bluez-manager/nm-bluez-manager.h
if WITH_BLUEZ4
nm_sources += \
bluez-manager/nm-bluez4-adapter.h \
bluez-manager/nm-bluez4-adapter.c \
bluez-manager/nm-bluez4-manager.c
else
nm_sources += \
bluez-manager/nm-bluez-manager.c
endif
if WITH_MODEM_MANAGER_1
nm_sources += \
modem-manager/nm-modem-broadband.c \
......
......@@ -21,14 +21,31 @@
#ifndef NM_BLUEZ_COMMON_H
#define NM_BLUEZ_COMMON_H
#include <config.h>
#define BLUETOOTH_CONNECT_DUN "dun"
#define BLUETOOTH_CONNECT_NAP "nap"
#define BLUEZ_SERVICE "org.bluez"
#define BLUEZ_MANAGER_PATH "/"
#define OBJECT_MANAGER_INTERFACE "org.freedesktop.DBus.ObjectManager"
#if ! WITH_BLUEZ4
#define BLUEZ_ADAPTER_INTERFACE "org.bluez.Adapter1"
#define BLUEZ_DEVICE_INTERFACE "org.bluez.Device1"
#define BLUEZ_NETWORK_INTERFACE "org.bluez.Network1"
#else
#define BLUEZ_MANAGER_INTERFACE "org.bluez.Manager"
#define BLUEZ_ADAPTER_INTERFACE "org.bluez.Adapter"
#define BLUEZ_DEVICE_INTERFACE "org.bluez.Device"
#define BLUEZ_SERIAL_INTERFACE "org.bluez.Serial"
#define BLUEZ_NETWORK_INTERFACE "org.bluez.Network"
#endif /* WITH_BLUEZ */
#endif /* NM_BLUEZ_COMMON_H */
This diff is collapsed.
......@@ -23,7 +23,9 @@
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <config.h>
#include "nm-connection.h"
#include "nm-connection-provider.h"
......@@ -40,6 +42,7 @@
#define NM_BLUEZ_DEVICE_CAPABILITIES "capabilities"
#define NM_BLUEZ_DEVICE_RSSI "rssi"
#define NM_BLUEZ_DEVICE_USABLE "usable"
#define NM_BLUEZ_DEVICE_CONNECTED "connected"
typedef struct {
GObject parent;
......@@ -74,5 +77,21 @@ guint32 nm_bluez_device_get_capabilities (NMBluezDevice *self);
gint nm_bluez_device_get_rssi (NMBluezDevice *self);
gboolean nm_bluez_device_get_connected (NMBluezDevice *self);
void
nm_bluez_device_connect_async (NMBluezDevice *self,
NMBluetoothCapabilities connection_bt_type,
GAsyncReadyCallback callback,
gpointer user_data);
const char *
nm_bluez_device_connect_finish (NMBluezDevice *self,
GAsyncResult *result,
GError **error);
void
nm_bluez_device_disconnect (NMBluezDevice *self);
#endif /* NM_BLUEZ_DEVICE_H */
This diff is collapsed.
......@@ -25,6 +25,7 @@
#include <glib.h>
#include <glib-object.h>
#include <config.h>
#include "nm-connection-provider.h"
G_BEGIN_DECLS
......
......@@ -23,7 +23,7 @@
#include "NetworkManager.h"
#include "nm-dbus-manager.h"
#include "nm-bluez-adapter.h"
#include "nm-bluez4-adapter.h"
#include "nm-bluez-device.h"
#include "nm-bluez-common.h"
#include "nm-dbus-glib-types.h"
......
This diff is collapsed.
This diff is collapsed.
......@@ -22,6 +22,7 @@
#define NM_DEVICE_BT_H
#include <nm-device.h>
#include "nm-bluez-device.h"
#include "nm-modem.h"
G_BEGIN_DECLS
......@@ -41,6 +42,7 @@ typedef enum {
#define NM_DEVICE_BT_NAME "name"
#define NM_DEVICE_BT_CAPABILITIES "bt-capabilities"
#define NM_DEVICE_BT_DEVICE "bt-device"
typedef struct {
NMDevice parent;
......@@ -55,7 +57,8 @@ typedef struct {
GType nm_device_bt_get_type (void);
NMDevice *nm_device_bt_new (const char *udi,
NMDevice *nm_device_bt_new (NMBluezDevice *bt_device,
const char *udi,
const char *bdaddr,
const char *name,
guint32 capabilities);
......
......@@ -40,6 +40,27 @@ nm_connection_provider_get_connections (NMConnectionProvider *self)
return NULL;
}
gboolean
nm_connection_provider_has_connections_loaded (NMConnectionProvider *self)
{
g_return_val_if_fail (NM_IS_CONNECTION_PROVIDER (self), FALSE);
g_assert (NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->has_connections_loaded);
return NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->has_connections_loaded (self);
}
NMConnection *
nm_connection_provider_add_connection (NMConnectionProvider *self,
NMConnection *connection,
gboolean save_to_disk,
GError **error)
{
g_return_val_if_fail (NM_IS_CONNECTION_PROVIDER (self), NULL);
g_assert (NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->add_connection);
return NM_CONNECTION_PROVIDER_GET_INTERFACE (self)->add_connection (self, connection, save_to_disk, error);
}
/*****************************************************************************/
static void
......
......@@ -58,6 +58,13 @@ struct _NMConnectionProvider {
const GSList * (*get_connections) (NMConnectionProvider *self);
gboolean (*has_connections_loaded) (NMConnectionProvider *self);
NMConnection * (*add_connection) (NMConnectionProvider *self,
NMConnection *connection,
gboolean save_to_disk,
GError **error);
/* Signals */
void (*connection_added) (NMConnectionProvider *self, NMConnection *connection);
......@@ -103,4 +110,31 @@ GSList *nm_connection_provider_get_best_connections (NMConnectionProvider *self,
*/
const GSList *nm_connection_provider_get_connections (NMConnectionProvider *self);
/**
* nm_connection_provider_has_connections_loaded:
* @self: the #NMConnectionProvider
*
* Returns: TRUE or FALSE indicating whether the connections of the provider are already
* loaded. If they are not yet loaded, the provider will not emit the signals
* NM_CP_SIGNAL_CONNECTION_ADDED, NM_CP_SIGNAL_CONNECTION_UPDATED and
* NM_CP_SIGNAL_CONNECTION_REMOVED until NM_CP_SIGNAL_CONNECTIONS_LOADED gets
* emited.
*/
gboolean nm_connection_provider_has_connections_loaded (NMConnectionProvider *self);
/**
* nm_connection_provider_add_connection:
* @self: the #NMConnectionProvider
* @connection: the connection to be added
* @save_to_disk: whether to store the connection on disk
* @error: returns any error if adding fails
*
* returns: a newly added #NMConnection.
*/
NMConnection *nm_connection_provider_add_connection (NMConnectionProvider *self,
NMConnection *connection,
gboolean save_to_disk,
GError **error);
#endif /* NM_CONNECTION_PROVIDER_H */
......@@ -139,6 +139,7 @@ static void impl_manager_check_connectivity (NMManager *manager,
#include "nm-manager-glue.h"
static void bluez_manager_bdaddr_added_cb (NMBluezManager *bluez_mgr,
NMBluezDevice *bt_device,
const char *bdaddr,
const char *name,
const char *object_path,
......@@ -2184,6 +2185,7 @@ add_device (NMManager *self, NMDevice *device)
static void
bluez_manager_bdaddr_added_cb (NMBluezManager *bluez_mgr,
NMBluezDevice *bt_device,
const char *bdaddr,
const char *name,
const char *object_path,
......@@ -2198,12 +2200,13 @@ bluez_manager_bdaddr_added_cb (NMBluezManager *bluez_mgr,
g_return_if_fail (name != NULL);
g_return_if_fail (object_path != NULL);
g_return_if_fail (capabilities != NM_BT_CAPABILITY_NONE);
g_return_if_fail (NM_IS_BLUEZ_DEVICE (bt_device));
/* Make sure the device is not already in the device list */
if (nm_manager_get_device_by_udi (manager, object_path))
return;
device = nm_device_bt_new (object_path, bdaddr, name, capabilities);
device = nm_device_bt_new (bt_device, object_path, bdaddr, name, capabilities);
if (device) {
nm_log_info (LOGD_HW, "BT device %s (%s) added (%s%s%s)",
name,
......
......@@ -930,6 +930,16 @@ nm_settings_add_connection (NMSettings *self,
return NULL;
}
static NMConnection *
_nm_connection_provider_add_connection (NMConnectionProvider *provider,
NMConnection *connection,
gboolean save_to_disk,
GError **error)
{
g_assert (NM_IS_CONNECTION_PROVIDER (provider) && NM_IS_SETTINGS (provider));
return NM_CONNECTION (nm_settings_add_connection (NM_SETTINGS (provider), connection, save_to_disk, error));
}
static gboolean
secrets_filter_cb (NMSetting *setting,
const char *secret,
......@@ -1635,6 +1645,14 @@ get_connections (NMConnectionProvider *provider)
return g_slist_reverse (list);
}
static gboolean
has_connections_loaded (NMConnectionProvider *provider)
{
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (provider);
return priv->connections_loaded;
}
/***************************************************************/
NMSettings *
......@@ -1667,6 +1685,8 @@ connection_provider_init (NMConnectionProvider *cp_class)
{
cp_class->get_best_connections = get_best_connections;
cp_class->get_connections = get_connections;
cp_class->has_connections_loaded = has_connections_loaded;
cp_class->add_connection = _nm_connection_provider_add_connection;
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment