summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.in13
-rw-r--r--data/file-share-properties.ui10
-rw-r--r--src/Makefile.am14
-rw-r--r--src/file-share-properties.c45
-rw-r--r--src/user_share.c44
5 files changed, 102 insertions, 24 deletions
diff --git a/configure.in b/configure.in
index e96149a..a0c57bf 100644
--- a/configure.in
+++ b/configure.in
@@ -56,10 +56,21 @@ if $have_dbus_1_1 ; then
AC_DEFINE(HAVE_DBUS_1_1, 1, [Set to true if we have D-BUS 1.1])
fi
-PKG_CHECK_MODULES(USER_SHARE, glib-2.0 >= 2.15.2 gio-2.0 >= 2.25.0 gdk-x11-2.0 gtk+-2.0 dbus-glib-1 libmatenotify libcanberra-gtk $DBUS_MODULES mate-bluetooth-1.0 >= 1.2.0)
+PKG_CHECK_MODULES(USER_SHARE, glib-2.0 >= 2.15.2 gio-2.0 >= 2.25.0 gdk-x11-2.0 gtk+-2.0 dbus-glib-1 libmatenotify libcanberra-gtk $DBUS_MODULES)
AC_SUBST(USER_SHARE_CFLAGS)
AC_SUBST(USER_SHARE_LIBS)
+PKG_CHECK_MODULES(BLUETOOTH, mate-bluetooth-1.0 >= 1.2.0,
+ have_bluetooth=true, have_bluetooth=false)
+AC_SUBST(BLUETOOTH_CFLAGS)
+AC_SUBST(BLUETOOTH_LIBS)
+if $have_bluetooth; then
+ AC_DEFINE(HAVE_BLUETOOTH, 1, [Set to true if mate-bluetooth support is available])
+else
+ AC_MSG_WARN([Bluetooth support is disabled.])
+fi
+AM_CONDITIONAL(USE_BLUETOOTH, [test "$have_bluetooth" = "true"])
+
PKG_CHECK_MODULES(USER_SHARE_CONFIG, glib-2.0 >= 2.15.2 gio-2.0 >= 2.25.0 gtk+-2.0 >= 2.12.0 unique-1.0)
AC_SUBST(USER_SHARE_CONFIG_CFLAGS)
AC_SUBST(USER_SHARE_CONFIG_LIBS)
diff --git a/data/file-share-properties.ui b/data/file-share-properties.ui
index ad7f36c..9178a9d 100644
--- a/data/file-share-properties.ui
+++ b/data/file-share-properties.ui
@@ -19,7 +19,7 @@
<property name="border_width">5</property>
<property name="spacing">18</property>
<child>
- <object class="GtkVBox" id="vbox3">
+ <object class="GtkVBox" id="vbox_share_http">
<property name="visible">True</property>
<property name="spacing">6</property>
<child>
@@ -130,8 +130,8 @@
</packing>
</child>
<child>
- <object class="GtkVBox" id="vbox4">
- <property name="visible">True</property>
+ <object class="GtkVBox" id="vbox_share_bluetooth">
+ <property name="visible">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label7">
@@ -213,8 +213,8 @@
</packing>
</child>
<child>
- <object class="GtkVBox" id="vbox5">
- <property name="visible">True</property>
+ <object class="GtkVBox" id="vbox_receive_bluetooth">
+ <property name="visible">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label8">
diff --git a/src/Makefile.am b/src/Makefile.am
index 90be13d..a340ef6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,6 +31,7 @@ INCLUDES= \
-I$(top_builddir) \
$(EXTENSION_CFLAGS) \
$(USER_SHARE_CFLAGS) \
+ $(BLUETOOTH_CFLAGS) \
$(USER_SHARE_CONFIG_CFLAGS) \
$(X_CFLAGS)
@@ -41,10 +42,6 @@ mate_user_share_SOURCES = \
user_share-private.c \
http.c \
http.h \
- obexftp.c \
- obexftp.h \
- obexpush.c \
- obexpush.h \
$(MARSHALFILES)
mate_user_share_LDADD = \
@@ -53,6 +50,15 @@ mate_user_share_LDADD = \
$(SELINUX_LIBS) \
$(X_LIBS) $(X_PRE_LIBS) -lX11 $(X_EXTRA_LIBS)
+if USE_BLUETOOTH
+mate_user_share_SOURCES += \
+ obexftp.c \
+ obexftp.h \
+ obexpush.c \
+ obexpush.h
+mate_user_share_LDADD += $(BLUETOOTH_LIBS)
+endif
+
mate_file_share_properties_SOURCES = \
file-share-properties.c \
user_share-private.h \
diff --git a/src/file-share-properties.c b/src/file-share-properties.c
index e2aae02..57d6d29 100644
--- a/src/file-share-properties.c
+++ b/src/file-share-properties.c
@@ -96,25 +96,38 @@ static void
update_ui (void)
{
GSettings *settings;
- gboolean enabled, bluetooth_enabled, bluetooth_write_enabled, require_pairing_enabled;
+ gboolean enabled;
+#ifdef HAVE_BLUETOOTH
+ gboolean bluetooth_enabled, bluetooth_write_enabled, require_pairing_enabled;
gboolean bluetooth_obexpush_enabled, bluetooth_obexpush_notify;
+#endif /* HAVE_BLUETOOTH */
char *str;
PasswordSetting password_setting;
AcceptSetting accept_setting;
GtkWidget *check;
GtkWidget *password_combo;
GtkWidget *password_entry;
+#ifdef HAVE_BLUETOOTH
+ GtkWidget *vbox_share_bluetooth;
+ GtkWidget *vbox_receive_bluetooth;
GtkWidget *bluetooth_check;
GtkWidget *allow_write_bluetooth_check;
GtkWidget *require_pairing_check;
GtkWidget *enable_obexpush_check;
GtkWidget *accept_obexpush_combo;
GtkWidget *notify_received_obexpush_check;
+#endif /* HAVE_BLUETOOTH */
settings = g_settings_new (GSETTINGS_SCHEMA);
enabled = g_settings_get_boolean (settings,
FILE_SHARING_ENABLED);
+
+ str = g_settings_get_string (settings, FILE_SHARING_REQUIRE_PASSWORD);
+ password_setting = password_setting_from_string (str);
+ g_free (str);
+
+#ifdef HAVE_BLUETOOTH
bluetooth_enabled = g_settings_get_boolean (settings,
FILE_SHARING_BLUETOOTH_ENABLED);
bluetooth_write_enabled = g_settings_get_boolean (settings,
@@ -126,23 +139,24 @@ update_ui (void)
bluetooth_obexpush_notify = g_settings_get_boolean (settings,
FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY);
- str = g_settings_get_string (settings, FILE_SHARING_REQUIRE_PASSWORD);
- password_setting = password_setting_from_string (str);
- g_free (str);
-
str = g_settings_get_string (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES);
accept_setting = accept_setting_from_string (str);
g_free (str);
+#endif /* HAVE_BLUETOOTH */
check = GTK_WIDGET (gtk_builder_get_object (builder, "enable_check"));
password_combo = GTK_WIDGET (gtk_builder_get_object (builder, "password_combo"));
password_entry = GTK_WIDGET (gtk_builder_get_object (builder, "password_entry"));
+#ifdef HAVE_BLUETOOTH
+ vbox_share_bluetooth = GTK_WIDGET (gtk_builder_get_object (builder, "vbox_share_bluetooth"));
+ vbox_receive_bluetooth = GTK_WIDGET (gtk_builder_get_object (builder, "vbox_receive_bluetooth"));
bluetooth_check = GTK_WIDGET (gtk_builder_get_object (builder, "enable_bluetooth_check"));
allow_write_bluetooth_check = GTK_WIDGET (gtk_builder_get_object (builder, "allow_write_bluetooth_check"));
require_pairing_check = GTK_WIDGET (gtk_builder_get_object (builder, "require_pairing_check"));
enable_obexpush_check = GTK_WIDGET (gtk_builder_get_object (builder, "enable_obexpush_check"));
accept_obexpush_combo = GTK_WIDGET (gtk_builder_get_object (builder, "accept_obexpush_combo"));
notify_received_obexpush_check = GTK_WIDGET (gtk_builder_get_object (builder, "notify_received_obexpush_check"));
+#endif /* HAVE_BLUETOOTH */
/* Network */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), enabled);
@@ -152,7 +166,9 @@ update_ui (void)
gtk_combo_box_set_active (GTK_COMBO_BOX (password_combo),
password_setting);
+#ifdef HAVE_BLUETOOTH
/* Bluetooth ObexFTP */
+ gtk_widget_set_visible (vbox_share_bluetooth, TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bluetooth_check), bluetooth_enabled);
gtk_widget_set_sensitive (allow_write_bluetooth_check, bluetooth_enabled);
gtk_widget_set_sensitive (require_pairing_check, bluetooth_enabled);
@@ -163,6 +179,7 @@ update_ui (void)
require_pairing_enabled);
/* Bluetooth ObexPush */
+ gtk_widget_set_visible (vbox_receive_bluetooth, TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enable_obexpush_check), bluetooth_obexpush_enabled);
gtk_widget_set_sensitive (accept_obexpush_combo, bluetooth_obexpush_enabled);
gtk_widget_set_sensitive (notify_received_obexpush_check, bluetooth_obexpush_enabled);
@@ -172,6 +189,7 @@ update_ui (void)
gtk_combo_box_set_active (GTK_COMBO_BOX (accept_obexpush_combo),
accept_setting);
+#endif /* HAVE_BLUETOOTH */
g_object_unref (settings);
}
@@ -188,6 +206,7 @@ password_required_changed (GSettings *settings, gchar *key, gpointer data)
update_ui ();
}
+#ifdef HAVE_BLUETOOTH
static void
file_sharing_bluetooth_enabled_changed (GSettings *settings, gchar *key, gpointer data)
{
@@ -223,6 +242,7 @@ file_sharing_bluetooth_obexpush_notify_changed (GSettings *settings, gchar *key,
{
update_ui ();
}
+#endif /* HAVE_BLUETOOTH */
static void
password_combo_changed (GtkComboBox *combo_box)
@@ -247,6 +267,7 @@ launch_share (void)
g_warning ("Unable to start mate-user-share program");
}
+#ifdef HAVE_BLUETOOTH
static void
enable_bluetooth_check_toggled (GtkWidget *check)
{
@@ -266,6 +287,7 @@ enable_bluetooth_check_toggled (GtkWidget *check)
if (enabled != FALSE)
launch_share ();
}
+#endif /* HAVE_BLUETOOTH */
static void
enable_check_toggled (GtkWidget *check)
@@ -295,6 +317,7 @@ password_entry_changed (GtkEditable *editable)
flush_password ();
}
+#ifdef HAVE_BLUETOOTH
static void
bluetooth_allow_write_check_toggled (GtkWidget *check)
{
@@ -381,6 +404,7 @@ notify_received_obexpush_check_toggled (GtkWidget *check)
g_object_unref (settings);
}
+#endif /* HAVE_BLUETOOTH */
static GtkWidget *
error_dialog (const char *title,
@@ -447,12 +471,14 @@ main (int argc, char *argv[])
GtkWidget *check;
GtkWidget *password_combo;
GtkWidget *password_entry;
+#ifdef HAVE_BLUETOOTH
GtkWidget *bluetooth_check;
GtkWidget *bluetooth_allow_write_check;
GtkWidget *require_pairing_check;
GtkWidget *enable_obexpush_check;
GtkWidget *accept_obexpush_combo;
GtkWidget *notify_received_obexpush_check;
+#endif /* HAVE_BLUETOOTH */
GtkWidget *window;
GtkListStore *store;
GtkCellRenderer *cell;
@@ -497,12 +523,14 @@ main (int argc, char *argv[])
check = GTK_WIDGET (gtk_builder_get_object (builder, "enable_check"));
password_combo = GTK_WIDGET (gtk_builder_get_object (builder, "password_combo"));
password_entry = GTK_WIDGET (gtk_builder_get_object (builder, "password_entry"));
+#ifdef HAVE_BLUETOOTH
bluetooth_check = GTK_WIDGET (gtk_builder_get_object (builder, "enable_bluetooth_check"));
bluetooth_allow_write_check = GTK_WIDGET (gtk_builder_get_object (builder, "allow_write_bluetooth_check"));
require_pairing_check = GTK_WIDGET (gtk_builder_get_object (builder, "require_pairing_check"));
enable_obexpush_check = GTK_WIDGET (gtk_builder_get_object (builder, "enable_obexpush_check"));
accept_obexpush_combo = GTK_WIDGET (gtk_builder_get_object (builder, "accept_obexpush_combo"));
notify_received_obexpush_check = GTK_WIDGET (gtk_builder_get_object (builder, "notify_received_obexpush_check"));
+#endif /* HAVE_BLUETOOTH */
store = gtk_list_store_new (1, G_TYPE_STRING);
gtk_combo_box_set_model (GTK_COMBO_BOX (password_combo),
@@ -532,6 +560,7 @@ main (int argc, char *argv[])
g_signal_connect (password_entry,
"changed", G_CALLBACK (password_entry_changed), NULL);
+#ifdef HAVE_BLUETOOTH
/* Accept files combo */
store = gtk_list_store_new (1, G_TYPE_STRING);
gtk_combo_box_set_model (GTK_COMBO_BOX (accept_obexpush_combo),
@@ -556,6 +585,7 @@ main (int argc, char *argv[])
_("Ask"), -1);
#endif
g_object_unref (store);
+#endif /* HAVE_BLUETOOTH */
update_ui ();
@@ -563,6 +593,7 @@ main (int argc, char *argv[])
"toggled", G_CALLBACK (enable_check_toggled), NULL);
g_signal_connect (password_combo,
"changed", G_CALLBACK (password_combo_changed), NULL);
+#ifdef HAVE_BLUETOOTH
g_signal_connect (bluetooth_check,
"toggled", G_CALLBACK (enable_bluetooth_check_toggled), NULL);
g_signal_connect (bluetooth_allow_write_check,
@@ -575,6 +606,7 @@ main (int argc, char *argv[])
"changed", G_CALLBACK (accept_obexpush_combo_changed), NULL);
g_signal_connect (notify_received_obexpush_check,
"toggled", G_CALLBACK (notify_received_obexpush_check_toggled), NULL);
+#endif /* HAVE_BLUETOOTH */
g_signal_connect (GTK_WIDGET (gtk_builder_get_object (builder, "close_button")),
"clicked", G_CALLBACK (gtk_main_quit), NULL);
@@ -589,6 +621,7 @@ main (int argc, char *argv[])
g_signal_connect (settings,
"changed::" GSETTINGS_KEY_FILE_SHARING_REQUIRE_PASSWORD,
G_CALLBACK (password_required_changed), NULL);
+#ifdef HAVE_BLUETOOTH
g_signal_connect (settings,
"changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ENABLED,
G_CALLBACK (file_sharing_bluetooth_enabled_changed), NULL);
@@ -607,7 +640,7 @@ main (int argc, char *argv[])
g_signal_connect (settings,
"changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY,
G_CALLBACK (file_sharing_bluetooth_obexpush_notify_changed), NULL);
-
+#endif /* HAVE_BLUETOOTH */
gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (builder, "user_share_dialog")));
diff --git a/src/user_share.c b/src/user_share.c
index 91e9d69..35e4a27 100644
--- a/src/user_share.c
+++ b/src/user_share.c
@@ -27,18 +27,22 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <bluetooth-client.h>
#include <X11/Xlib.h>
#include "user_share.h"
#include "user_share-private.h"
#include "user_share-common.h"
#include "http.h"
+
+#ifdef HAVE_BLUETOOTH
+#include <bluetooth-client.h>
+
#include "obexftp.h"
#include "obexpush.h"
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
+#endif /* HAVE_BLUETOOTH */
#include <gio/gio.h>
@@ -49,6 +53,14 @@
#include <signal.h>
#include <unistd.h>
+static guint disabled_timeout_tag = 0;
+static GSettings* settings;
+
+#define GSETTINGS_SCHEMA "org.mate.FileSharing"
+#define GSETTINGS_KEY_FILE_SHARING_ENABLED "enabled"
+#define GSETTINGS_KEY_FILE_SHARING_REQUIRE_PASSWORD "require-password"
+
+#ifdef HAVE_BLUETOOTH
/* ConsoleKit */
#define CK_NAME "org.freedesktop.ConsoleKit"
#define CK_INTERFACE "org.freedesktop.ConsoleKit"
@@ -57,7 +69,6 @@
#define CK_SEAT_INTERFACE "org.freedesktop.ConsoleKit.Seat"
#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
-static guint disabled_timeout_tag = 0;
static gboolean has_console = TRUE;
static BluetoothClient *client = NULL;
@@ -65,10 +76,7 @@ static gboolean bluetoothd_enabled = FALSE;
#define OBEX_ENABLED (bluetoothd_enabled && has_console)
-#define GSETTINGS_SCHEMA "org.mate.FileSharing"
-#define GSETTINGS_KEY_FILE_SHARING_ENABLED "enabled"
#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ENABLED "bluetooth-enabled"
-#define GSETTINGS_KEY_FILE_SHARING_REQUIRE_PASSWORD "require-password"
#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ALLOW_WRITE "bluetooth-allow-write"
#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING "bluetooth-require-pairing"
#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED "bluetooth-obexpush-enabled"
@@ -76,8 +84,6 @@ static gboolean bluetoothd_enabled = FALSE;
#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY "bluetooth-notify"
-static GSettings* settings;
-
static void
obex_services_start (void)
{
@@ -276,6 +282,7 @@ bluez_init (void)
g_signal_connect (G_OBJECT (client), "notify::default-adapter-powered",
G_CALLBACK (default_adapter_changed), NULL);
}
+#endif /* HAVE_BLUETOOTH */
static void
migrate_old_configuration (void)
@@ -308,9 +315,14 @@ disabled_timeout_callback (gpointer user_data)
GSettings *settings = (GSettings *) user_data;
http_down ();
+#ifdef HAVE_BLUETOOTH
if (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) == FALSE &&
g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == FALSE)
_exit (0);
+#else /* HAVE_BLUETOOTH */
+ if (g_settings_get_boolean (settings, FILE_SHARING_ENABLED) == FALSE)
+ _exit (0);
+#endif /* HAVE_BLUETOOTH */
return FALSE;
}
@@ -338,6 +350,7 @@ file_sharing_enabled_changed (GSettings *settings, gchar *key, gpointer data)
}
}
+#ifdef HAVE_BLUETOOTH
static void
file_sharing_bluetooth_allow_write_changed (GSettings *settings, gchar *key, gpointer data)
{
@@ -404,13 +417,16 @@ file_sharing_bluetooth_obexpush_notify_changed (GSettings *settings, gchar *key,
{
obexpush_set_notify (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY));
}
+#endif /* HAVE_BLUETOOTH */
static RETSIGTYPE
cleanup_handler (int sig)
{
http_down ();
+#ifdef HAVE_BLUETOOTH
obexftp_down ();
obexpush_down ();
+#endif /* HAVE_BLUETOOTH */
_exit (2);
}
@@ -418,7 +434,9 @@ static int
x_io_error_handler (Display *xdisplay)
{
http_down ();
+#ifdef HAVE_BLUETOOTH
obexftp_down ();
+#endif /* HAVE_BLUETOOTH */
_exit (2);
}
@@ -475,20 +493,27 @@ main (int argc, char **argv)
migrate_old_configuration ();
settings = g_settings_new (GSETTINGS_SCHEMA);
+#ifdef HAVE_BLUETOOTH
if (g_settings_get_boolean (settings, FILE_SHARING_ENABLED) == FALSE &&
g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) == FALSE &&
g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == FALSE)
return 1;
+#else /* HAVE_BLUETOOTH */
+ 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 (obexftp_init () == FALSE)
return 1;
if (obexpush_init () == FALSE)
return 1;
+#endif /* HAVE_BLUETOOTH */
g_signal_connect (settings,
"changed::" GSETTINGS_KEY_FILE_SHARING_ENABLED,
@@ -498,6 +523,7 @@ main (int argc, char **argv)
"changed::" GSETTINGS_KEY_FILE_SHARING_REQUIRE_PASSWORD,
G_CALLBACK (require_password_changed), NULL);
+#ifdef HAVE_BLUETOOTH
g_signal_connect (settings,
"changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ENABLED,
G_CALLBACK (file_sharing_bluetooth_enabled_changed), NULL);
@@ -522,16 +548,18 @@ main (int argc, char **argv)
"changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY,
G_CALLBACK (file_sharing_bluetooth_obexpush_notify_changed), NULL);
-
bluez_init ();
consolekit_init ();
+#endif /* HAVE_BLUETOOTH */
/* Initial setting */
file_sharing_enabled_changed (settings, NULL, NULL);
+#ifdef HAVE_BLUETOOTH
file_sharing_bluetooth_enabled_changed (settings, NULL, NULL);
file_sharing_bluetooth_obexpush_accept_files_changed (settings, NULL, NULL);
file_sharing_bluetooth_obexpush_notify_changed (settings, NULL, NULL);
file_sharing_bluetooth_obexpush_enabled_changed (settings, NULL, NULL);
+#endif /* HAVE_BLUETOOTH */
gtk_main ();