[gnome-user-share] build: Make Bluetooth support optional
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-user-share] build: Make Bluetooth support optional
- Date: Wed, 24 Jul 2013 07:55:34 +0000 (UTC)
commit 0667a68288fa105e1136b0882a8064f2db693c88
Author: Bastien Nocera <hadess hadess net>
Date: Wed Jul 24 09:46:35 2013 +0200
build: Make Bluetooth support optional
This is useful for platforms where gnome-bluetooth isn't available
(eg. non-Linux) and for Linux right now, as obexd isn't quite
suitable for use in a Desktop setting:
- there's no control over ObexFTP enablement, or clients
- Neither ObexPush nor ObexFTP can be turned off when the
user loses the console, leading to multiple ObexFTP/ObexPush
instances on a single machine, which will confuse clients
configure.ac | 22 ++++++++++++++++++----
src/Makefile.am | 10 ++++++++--
src/share-extension.c | 13 ++++++++++++-
src/user_share.c | 30 +++++++++++++++++++++++++++---
4 files changed, 65 insertions(+), 10 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 0a5fc08..fa8a9ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,7 +54,18 @@ fi
AC_SUBST(HTTPD)
-PKG_CHECK_MODULES(USER_SHARE, glib-2.0 >= 2.28 gio-2.0 >= 2.26 gtk+-3.0 dbus-1 >= 1.1.1 dbus-glib-1
libnotify libcanberra-gtk3 gnome-bluetooth-1.0 >= 2.91.5)
+BLUETOOTH_PKG="gnome-bluetooth-1.0 >= 2.91.5"
+AC_ARG_ENABLE(bluetooth, AS_HELP_STRING([--disable-bluetooth],[compile without bluetooth
support]),,enable_bluetooth=no)
+if test "x$enable_bluetooth" = "xyes"; then
+ PKG_CHECK_MODULES(BLUETOOTH, $BLUETOOTH_PKG)
+ AC_DEFINE(HAVE_BLUETOOTH, 1, [Set to true if gnome-bluetooth support is available])
+else
+ BLUETOOTH_PKG=""
+ AC_MSG_WARN([Bluetooth support is disabled.])
+fi
+AM_CONDITIONAL(USE_BLUETOOTH, [test "$enable_bluetooth" = "yes"])
+
+PKG_CHECK_MODULES(USER_SHARE, glib-2.0 >= 2.28 gio-2.0 >= 2.26 gtk+-3.0 dbus-1 >= 1.1.1 dbus-glib-1
libnotify libcanberra-gtk3 $BLUETOOTH_PKG)
AC_SUBST(USER_SHARE_CFLAGS)
AC_SUBST(USER_SHARE_LIBS)
@@ -104,8 +115,6 @@ AC_SUBST(SELINUX_LIBS)
dnl ==========================================================================
dnl Check for the HTTPD modules path
-
-
AC_ARG_WITH([modules-path],
[AS_HELP_STRING([--with-modules-path],[Path where the httpd modules are located (default:
/etc/httpd/modules/)])],
[with_modules_path=$withval])
@@ -122,7 +131,7 @@ AC_ARG_WITH(nautilusdir,
[ac_with_nautilusdir=""])
PKG_CHECK_MODULES(EXTENSION,
- libnautilus-extension >= 2.91.7 gnome-bluetooth-1.0)
+ libnautilus-extension >= 2.91.7 $BLUETOOTH_PKG)
if test "${ac_with_nautilusdir}" = ""; then
ac_with_nautilusdir=`pkg-config --variable=extensiondir libnautilus-extension`
fi
@@ -196,6 +205,11 @@ AC_MSG_NOTICE([gnome-user-share was configured with the following options:])
AC_MSG_NOTICE([** httpd location: $HTTP])
AC_MSG_NOTICE([** httpd modules path: $MODULES_PATH])
AC_MSG_NOTICE([** nautilus extension path: $ac_with_nautilusdir])
+if test "x$enable_bluetooth" = "xyes"; then
+ AC_MSG_NOTICE([** Bluetooth support enabled (ObexPush and ObexFTP)])
+else
+ AC_MSG_NOTICE([ Bluetooth support disabled])
+fi
echo "
Do note Apache 2.2 and mod_dnssd 0.6 are required to use gnome-user-share.
diff --git a/src/Makefile.am b/src/Makefile.am
index b2287cf..39017f1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,10 +27,16 @@ gnome_user_share_SOURCES = \
user_share-private.c \
http.c \
http.h \
- obexpush.c \
- obexpush.h \
$(NULL)
+if USE_BLUETOOTH
+gnome_user_share_SOURCES += \
+ obexpush.c \
+ obexpush.h
+else
+EXTRA_DIST = obexpush.c obexpush.h
+endif
+
gnome_user_share_LDADD = \
libuser-share-common.la \
$(USER_SHARE_LIBS) \
diff --git a/src/share-extension.c b/src/share-extension.c
index 7e81b5a..c1654d4 100644
--- a/src/share-extension.c
+++ b/src/share-extension.c
@@ -28,10 +28,13 @@
#include <glib/gi18n-lib.h>
#include <gio/gdesktopappinfo.h>
#include <gtk/gtk.h>
-#include <bluetooth-client.h>
#include <libnautilus-extension/nautilus-menu-provider.h>
#include <libnautilus-extension/nautilus-location-widget-provider.h>
+#ifdef HAVE_BLUETOOTH
+#include <bluetooth-client.h>
+#endif
+
#include "nautilus-share-bar.h"
#include "user_share-common.h"
@@ -89,6 +92,7 @@ bar_response_cb (NautilusShareBar *bar,
launch_prefs_on_window ();
}
+#ifdef HAVE_BLUETOOTH
static void
downloads_bar_set_from_bluetooth_status (GtkWidget *bar)
{
@@ -109,6 +113,7 @@ default_adapter_powered_cb (GObject *gobject,
{
downloads_bar_set_from_bluetooth_status (bar);
}
+#endif /* HAVE_BLUETOOTH */
static GtkWidget *
nautilus_user_share_get_location_widget (NautilusLocationWidgetProvider *iface,
@@ -151,8 +156,13 @@ nautilus_user_share_get_location_widget (NautilusLocationWidgetProvider *iface,
if (is_dir[0] != FALSE && is_dir[1] != FALSE) {
bar = nautilus_share_bar_new (_("May be used to share or receive files"));
} else if (is_dir[0] != FALSE) {
+#ifndef HAVE_BLUETOOTH
bar = nautilus_share_bar_new (_("May be shared over the network or Bluetooth"));
+#else
+ bar = nautilus_share_bar_new (_("May be shared over the network"));
+#endif /* !HAVE_BLUETOOTH */
} else {
+#ifdef HAVE_BLUETOOTH
BluetoothClient *client;
bar = nautilus_share_bar_new (_("May be used to receive files over Bluetooth"));
@@ -162,6 +172,7 @@ nautilus_user_share_get_location_widget (NautilusLocationWidgetProvider *iface,
g_signal_connect (G_OBJECT (client), "notify::default-adapter-powered",
G_CALLBACK (default_adapter_powered_cb), bar);
downloads_bar_set_from_bluetooth_status (bar);
+#endif /* HAVE_BLUETOOTH */
}
g_signal_connect (bar, "response",
diff --git a/src/user_share.c b/src/user_share.c
index 2bd79c9..7dd4499 100644
--- a/src/user_share.c
+++ b/src/user_share.c
@@ -27,7 +27,6 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <bluetooth-client.h>
#include <gio/gio.h>
#include <X11/Xlib.h>
@@ -44,6 +43,10 @@
#include <signal.h>
#include <unistd.h>
+#ifdef HAVE_BLUETOOTH
+#include <bluetooth-client.h>
+#endif
+
/* GNOME Session */
#define GNOME_SESSION_DBUS_NAME "org.gnome.SessionManager"
#define GNOME_SESSION_DBUS_OBJECT "/org/gnome/SessionManager"
@@ -57,6 +60,7 @@ static gboolean has_console = TRUE;
#define OBEX_ENABLED (has_console)
+#ifdef HAVE_BLUETOOTH
static void
obex_services_start (void)
{
@@ -135,6 +139,7 @@ session_init (void)
NULL);
has_console = is_session_active ();
}
+#endif /* HAVE_BLUETOOTH */
static void
migrate_old_configuration (void)
@@ -166,8 +171,10 @@ disabled_timeout_callback (void)
{
http_down ();
+#ifdef HAVE_BLUETOOTH
if (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == FALSE)
_exit (0);
+#endif /* HAVE_BLUETOOTH */
return FALSE;
}
@@ -195,6 +202,7 @@ file_sharing_enabled_changed (void)
}
}
+#ifdef HAVE_BLUETOOTH
static void
file_sharing_bluetooth_obexpush_enabled_changed (void)
{
@@ -227,7 +235,7 @@ file_sharing_bluetooth_obexpush_notify_changed (void)
{
obex_agent_set_notify (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY));
}
-
+#endif /* HAVE_BLUETOOTH */
static void
setttings_changed (GSettings *settings,
gchar *path,
@@ -238,7 +246,7 @@ setttings_changed (GSettings *settings,
else if (g_strcmp0 (FILE_SHARING_REQUIRE_PASSWORD, path) == 0)
require_password_changed ();
-
+#ifdef HAVE_BLUETOOTH
else if (g_strcmp0 (FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED, path) == 0)
file_sharing_bluetooth_obexpush_enabled_changed ();
@@ -247,13 +255,16 @@ setttings_changed (GSettings *settings,
else if (g_strcmp0 (FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY, path) == 0)
file_sharing_bluetooth_obexpush_notify_changed ();
+#endif /* HAVE_BLUETOOTH */
}
static void
cleanup_handler (int sig)
{
http_down ();
+#ifdef HAVE_BLUETOOTH
obex_agent_down ();
+#endif
_exit (2);
}
@@ -261,7 +272,9 @@ static int
x_io_error_handler (Display *xdisplay)
{
http_down ();
+#ifdef HAVE_BLUETOOTH
obex_agent_down ();
+#endif
_exit (2);
}
@@ -317,27 +330,38 @@ main (int argc, char **argv)
migrate_old_configuration ();
settings = g_settings_new (GNOME_USER_SHARE_SCHEMAS);
+#ifdef HAVE_BLUETOOTH
if (g_settings_get_boolean (settings, FILE_SHARING_ENABLED) == FALSE &&
g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == FALSE)
return 1;
+#else
+ if (g_settings_get_boolean (settings, FILE_SHARING_ENABLED) == FALSE)
+ return 1;
+#endif /* HAVE_BLUETOOTH */
x_fd = ConnectionNumber (xdisplay);
XSetIOErrorHandler (x_io_error_handler);
if (http_init () == FALSE)
return 1;
+#ifdef HAVE_BLUETOOTH
if (obex_agent_up () == FALSE)
return 1;
+#endif
g_signal_connect (settings, "changed", G_CALLBACK(setttings_changed), NULL);
+#ifdef HAVE_BLUETOOTH
session_init ();
+#endif
/* Initial setting */
file_sharing_enabled_changed ();
+#ifdef HAVE_BLUETOOTH
file_sharing_bluetooth_obexpush_accept_files_changed ();
file_sharing_bluetooth_obexpush_notify_changed ();
file_sharing_bluetooth_obexpush_enabled_changed ();
+#endif /* HAVE_BLUETOOTH */
gtk_main ();
g_object_unref (settings);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]