[gnome-user-share] Port to GSettings
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-user-share] Port to GSettings
- Date: Fri, 24 Aug 2012 15:24:02 +0000 (UTC)
commit 7dc8a2be556b99e9cead45329fbaedf4fff533bb
Author: L.Lopez <ldotlopez gmail com>
Date: Mon Jun 4 08:01:00 2012 +0000
Port to GSettings
https://bugzilla.gnome.org/show_bug.cgi?id=662766
configure.in | 13 +-
data/Makefile.am | 31 +--
data/desktop_gnome_file_sharing.schemas.in | 94 -------
...rg.gnome.desktop.file-sharing.gschema.xml.in.in | 52 ++++
src/file-share-properties.c | 254 +++-----------------
src/http.c | 12 +-
src/obexftp.c | 11 +-
src/obexpush.c | 19 +-
src/user_share-private.h | 21 +-
src/user_share.c | 199 ++++++----------
10 files changed, 207 insertions(+), 499 deletions(-)
---
diff --git a/configure.in b/configure.in
index d67decd..a28845d 100644
--- a/configure.in
+++ b/configure.in
@@ -60,11 +60,11 @@ 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.28 gio-2.0 gtk+-3.0 gconf-2.0 dbus-glib-1 libnotify libcanberra-gtk3 $DBUS_MODULES gnome-bluetooth-1.0 >= 2.91.5)
+PKG_CHECK_MODULES(USER_SHARE, glib-2.0 >= 2.28 gio-2.0 gtk+-3.0 dbus-glib-1 libnotify libcanberra-gtk3 $DBUS_MODULES gnome-bluetooth-1.0 >= 2.91.5)
AC_SUBST(USER_SHARE_CFLAGS)
AC_SUBST(USER_SHARE_LIBS)
-PKG_CHECK_MODULES(USER_SHARE_CONFIG, glib-2.0 >= 2.28 gtk+-3.0 >= 2.12.0 gconf-2.0)
+PKG_CHECK_MODULES(USER_SHARE_CONFIG, glib-2.0 >= 2.28 gtk+-3.0 >= 2.12.0)
AC_SUBST(USER_SHARE_CONFIG_CFLAGS)
AC_SUBST(USER_SHARE_CONFIG_LIBS)
@@ -85,13 +85,9 @@ fi
AC_PATH_PROG([GLIB_GENMARSHAL],[glib-genmarshal])
-AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
+AC_PATH_PROG(GLIB_COMPILE_SCHEMAS, glib-compile-schemas)
-if test x"$GCONFTOOL" = xno; then
- AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
-fi
-
-AM_GCONF_SOURCE_2
+GLIB_GSETTINGS
dnl where to install the gnome-user-share binary
if test "x$prefix" = "xNONE"; then
@@ -201,6 +197,7 @@ data/icons/22x22/Makefile
data/icons/32x32/Makefile
data/icons/48x48/Makefile
data/gnome-user-share.desktop.in
+data/org.gnome.desktop.file-sharing.gschema.xml.in
po/Makefile.in
src/Makefile
help/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index a693a8b..2b3f418 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,10 +1,5 @@
SUBDIRS = icons
- INTLTOOL_SCHEMAS_RULE@
-schemadir = $(GCONF_SCHEMA_FILE_DIR)
-schema_in_files = desktop_gnome_file_sharing.schemas.in
-schema_DATA = $(schema_in_files:.schemas.in=.schemas)
-
@INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@@ -17,26 +12,26 @@ autostart_in_files = gnome-user-share.desktop.in
appdir = $(datadir)/gnome-user-share
app_DATA=dav_user_2.0.conf dav_user_2.2.conf dav_groupfile file-share-properties.ui
+gsettingsdir = $(datadir)/glib-2.0/schemas
+gsettings_in_files = org.gnome.desktop.file-sharing.gschema.xml.in
+gsettings_DATA = $(gsettings_in_files:.xml.in=.xml)
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
+
install-data-local:
-if GCONF_SCHEMAS_INSTALL
- -GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \
- $(GCONFTOOL) --makefile-install-rule $(schema_DATA)
-endif
+ -$(GLIB_COMPILE_SCHEMAS) $(DESTDIR)/$(datadir)/glib-2.0/schemas
-if GCONF_SCHEMAS_INSTALL
uninstall-local:
- -GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \
- $(GCONFTOOL) --makefile-uninstall-rule $(schema_DATA)
-endif
+ -$(GLIB_COMPILE_SCHEMAS) $(DESTDIR)/$(datadir)/glib-2.0/schemas
-EXTRA_DIST = $(schema_in_files) \
- $(app_DATA) \
- $(desktop_in_files) \
+EXTRA_DIST = $(app_DATA) \
+ $(desktop_in_files) \
+ $(gsettings_in_files) \
gnome-user-share.desktop.in.in \
file-share-properties.ui
-CLEANFILES = $(desktop_DATA) $(autostart_DATA)
+CLEANFILES = $(desktop_DATA) $(autostart_DATA) $(gsettings_DATA)
-DISTCLEANFILES = $(schema_DATA)
+DISTCLEANFILES = $(gsettings_DATA)
-include $(top_srcdir)/git.mk
diff --git a/data/org.gnome.desktop.file-sharing.gschema.xml.in.in b/data/org.gnome.desktop.file-sharing.gschema.xml.in.in
new file mode 100644
index 0000000..022ed86
--- /dev/null
+++ b/data/org.gnome.desktop.file-sharing.gschema.xml.in.in
@@ -0,0 +1,52 @@
+<schemalist>
+<schema gettext-domain="gnome-user-share" id="org.gnome.desktop.file-sharing" path="/org/gnome/desktop/file-sharing/">
+ <key name="enabled" type="b">
+ <default>false</default>
+ <_summary>Share Public directory over the network</_summary>
+ <_description>If this is true, the Public directory in the users home directory will be shared over the network when the user is logged in.</_description>
+ </key>
+
+ <key name="require-password" type="s">
+ <default>'never'</default>
+ <_summary>When to require passwords</_summary>
+ <_description>When to ask for passwords. Possible values are "never", "on_write", and "always".</_description>
+ </key>
+
+ <key name="bluetooth-enabled" type="b">
+ <default>false</default>
+ <_summary>Share Public directory over Bluetooth</_summary>
+ <_description>If this is true, the Public directory in the users home directory will be shared over Bluetooth when the user is logged in.</_description>
+ </key>
+
+ <key name="bluetooth-allow-write" type="b">
+ <default>false</default>
+ <_summary>Whether to allow Bluetooth clients to write files.</_summary>
+ <_description>Whether to allow Bluetooth clients to write files, or share the files read-only.</_description>
+ </key>
+
+ <key name="bluetooth-require-pairing" type="b">
+ <default>true</default>
+ <_summary>Whether Bluetooth clients need to pair with the computer to send files.</_summary>
+ <_description>Whether Bluetooth clients need to pair with the computer to send files.</_description>
+ </key>
+
+ <key name="bluetooth-obexpush-enabled" type="b">
+ <default>false</default>
+ <_summary>Whether Bluetooth clients can send files using ObexPush.</_summary>
+ <_description>If this is true, Bluetooth devices can send files to the user's Downloads directory when logged in.</_description>
+ </key>
+
+ <key name="bluetooth-accept-files" type="s">
+ <default>'bonded'</default>
+ <_summary>When to accept files sent over Bluetooth</_summary>
+ <_description>When to accept files sent over Bluetooth. Possible values are "always", "bonded" and "ask".</_description>
+ </key>
+
+ <key name="bluetooth-notify" type="b">
+ <default>false</default>
+ <_summary>Whether to notify about newly received files.</_summary>
+ <_description>Whether to notify about newly received files.</_description>
+ </key>
+</schema>
+</schemalist>
+
diff --git a/src/file-share-properties.c b/src/file-share-properties.c
index 59e9f1b..7939bca 100644
--- a/src/file-share-properties.c
+++ b/src/file-share-properties.c
@@ -28,7 +28,6 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include <gconf/gconf-client.h>
#include "user_share-private.h"
@@ -36,7 +35,7 @@
#define USER "guest"
static GtkBuilder* builder;
-
+static GSettings* settings;
static void
write_out_password (const char *password)
@@ -84,7 +83,6 @@ flush_password (void)
static void
update_ui (void)
{
- GConfClient *client;
gboolean enabled, bluetooth_enabled, bluetooth_write_enabled, require_pairing_enabled;
gboolean bluetooth_obexpush_enabled, bluetooth_obexpush_notify;
char *str;
@@ -100,32 +98,24 @@ update_ui (void)
GtkWidget *accept_obexpush_combo;
GtkWidget *notify_received_obexpush_check;
- client = gconf_client_get_default ();
-
- enabled = gconf_client_get_bool (client,
- FILE_SHARING_ENABLED,
- NULL);
- bluetooth_enabled = gconf_client_get_bool (client,
- FILE_SHARING_BLUETOOTH_ENABLED,
- NULL);
- bluetooth_write_enabled = gconf_client_get_bool (client,
- FILE_SHARING_BLUETOOTH_ALLOW_WRITE,
- NULL);
- require_pairing_enabled = gconf_client_get_bool (client,
- FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING,
- NULL);
- bluetooth_obexpush_enabled = gconf_client_get_bool (client,
- FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED,
- NULL);
- bluetooth_obexpush_notify = gconf_client_get_bool (client,
- FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY,
- NULL);
-
- str = gconf_client_get_string (client, FILE_SHARING_REQUIRE_PASSWORD, NULL);
+ enabled = g_settings_get_boolean (settings,
+ FILE_SHARING_ENABLED);
+ bluetooth_enabled = g_settings_get_boolean (settings,
+ FILE_SHARING_BLUETOOTH_ENABLED);
+ bluetooth_write_enabled = g_settings_get_boolean (settings,
+ FILE_SHARING_BLUETOOTH_ALLOW_WRITE);
+ require_pairing_enabled = g_settings_get_boolean (settings,
+ FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING);
+ bluetooth_obexpush_enabled = g_settings_get_boolean (settings,
+ FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED);
+ 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 = gconf_client_get_string (client, FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES, NULL);
+ str = g_settings_get_string (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES);
accept_setting = accept_setting_from_string (str);
g_free (str);
@@ -167,97 +157,18 @@ update_ui (void)
gtk_combo_box_set_active (GTK_COMBO_BOX (accept_obexpush_combo),
accept_setting);
-
- g_object_unref (client);
-}
-
-static void
-file_sharing_enabled_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
-{
- update_ui ();
-}
-
-static void
-password_required_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
-{
- update_ui ();
-}
-
-static void
-file_sharing_bluetooth_enabled_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
-{
- update_ui ();
-}
-
-static void
-file_sharing_bluetooth_allow_write_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
-{
- update_ui ();
-}
-
-static void
-file_sharing_bluetooth_require_pairing_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
-{
- update_ui ();
-}
-
-static void
-file_sharing_bluetooth_obexpush_enabled_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
-{
- update_ui ();
-}
-
-static void
-file_sharing_bluetooth_obexpush_accept_files_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
-{
- update_ui ();
-}
-
-static void
-file_sharing_bluetooth_obexpush_notify_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
-{
- update_ui ();
}
static void
password_combo_changed (GtkComboBox *combo_box)
{
- GConfClient *client;
guint setting;
setting = gtk_combo_box_get_active (combo_box);
- client = gconf_client_get_default ();
-
- gconf_client_set_string (client,
+ g_settings_set_string (settings,
FILE_SHARING_REQUIRE_PASSWORD,
- password_string_from_setting (setting),
- NULL);
- g_object_unref (client);
+ password_string_from_setting (setting));
}
static void
@@ -285,19 +196,13 @@ launch_share (void)
static void
enable_bluetooth_check_toggled (GtkWidget *check)
{
- GConfClient *client;
gboolean enabled;
enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
- client = gconf_client_get_default ();
-
- gconf_client_set_bool (client,
+ g_settings_set_boolean (settings,
FILE_SHARING_BLUETOOTH_ENABLED,
- enabled,
- NULL);
-
- g_object_unref (client);
+ enabled);
if (enabled != FALSE)
launch_share ();
@@ -306,19 +211,13 @@ enable_bluetooth_check_toggled (GtkWidget *check)
static void
enable_check_toggled (GtkWidget *check)
{
- GConfClient *client;
gboolean enabled;
enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
- client = gconf_client_get_default ();
-
- gconf_client_set_bool (client,
+ g_settings_set_boolean (settings,
FILE_SHARING_ENABLED,
- enabled,
- NULL);
-
- g_object_unref (client);
+ enabled);
if (enabled != FALSE)
launch_share ();
@@ -335,55 +234,37 @@ password_entry_changed (GtkEditable *editable)
static void
bluetooth_allow_write_check_toggled (GtkWidget *check)
{
- GConfClient *client;
gboolean enabled;
enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
- client = gconf_client_get_default ();
-
- gconf_client_set_bool (client,
+ g_settings_set_boolean (settings,
FILE_SHARING_BLUETOOTH_ALLOW_WRITE,
- enabled,
- NULL);
-
- g_object_unref (client);
+ enabled);
}
static void
bluetooth_require_pairing_check_toggled (GtkWidget *check)
{
- GConfClient *client;
gboolean enabled;
enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
- client = gconf_client_get_default ();
-
- gconf_client_set_bool (client,
+ g_settings_set_boolean (settings,
FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING,
- enabled,
- NULL);
-
- g_object_unref (client);
+ enabled);
}
static void
enable_obexpush_check_toggled (GtkWidget *check)
{
- GConfClient *client;
gboolean enabled;
enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
- client = gconf_client_get_default ();
-
- gconf_client_set_bool (client,
+ g_settings_set_boolean (settings,
FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED,
- enabled,
- NULL);
-
- g_object_unref (client);
+ enabled);
if (enabled != FALSE)
launch_share ();
@@ -392,36 +273,25 @@ enable_obexpush_check_toggled (GtkWidget *check)
static void
accept_obexpush_combo_changed (GtkComboBox *combo_box)
{
- GConfClient *client;
guint setting;
setting = gtk_combo_box_get_active (combo_box);
- client = gconf_client_get_default ();
-
- gconf_client_set_string (client,
+ g_settings_set_string (settings,
FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES,
- accept_string_from_setting (setting),
- NULL);
- g_object_unref (client);
+ accept_string_from_setting (setting));
}
static void
notify_received_obexpush_check_toggled (GtkWidget *check)
{
- GConfClient *client;
gboolean enabled;
enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
- client = gconf_client_get_default ();
-
- gconf_client_set_bool (client,
+ g_settings_set_boolean (settings,
FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY,
- enabled,
- NULL);
-
- g_object_unref (client);
+ enabled);
}
static GtkWidget *
@@ -473,7 +343,6 @@ static GtkWidget *
create_window (void)
{
GError *error = NULL;
- GConfClient *client;
GtkWidget *check;
GtkWidget *password_combo;
GtkWidget *password_entry;
@@ -504,12 +373,6 @@ create_window (void)
window = GTK_WIDGET (gtk_builder_get_object (builder, "user_share_dialog"));
- client = gconf_client_get_default ();
- gconf_client_add_dir (client,
- FILE_SHARING_DIR,
- GCONF_CLIENT_PRELOAD_RECURSIVE,
- NULL);
-
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"));
@@ -598,56 +461,7 @@ create_window (void)
"clicked", G_CALLBACK (help_button_clicked),
gtk_builder_get_object (builder, "user_share_dialog"));
- gconf_client_notify_add (client,
- FILE_SHARING_ENABLED,
- file_sharing_enabled_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_REQUIRE_PASSWORD,
- password_required_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_BLUETOOTH_ENABLED,
- file_sharing_bluetooth_enabled_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_BLUETOOTH_ALLOW_WRITE,
- file_sharing_bluetooth_allow_write_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING,
- file_sharing_bluetooth_require_pairing_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED,
- file_sharing_bluetooth_obexpush_enabled_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES,
- file_sharing_bluetooth_obexpush_accept_files_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY,
- file_sharing_bluetooth_obexpush_notify_changed,
- NULL,
- NULL,
- NULL);
-
- g_object_unref (client);
+ g_signal_connect_swapped (settings, "changed", G_CALLBACK(update_ui), NULL);
return window;
}
@@ -683,6 +497,8 @@ main (int argc, char *argv[])
app = gtk_application_new ("org.gnome.user-share.properties",
G_APPLICATION_FLAGS_NONE);
+ settings = g_settings_new (GSETTINGS_DOMAIN);
+
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
diff --git a/src/http.c b/src/http.c
index 52bd5eb..3d75d21 100644
--- a/src/http.c
+++ b/src/http.c
@@ -31,8 +31,6 @@
#include <dbus/dbus.h>
#endif
-#include <gconf/gconf-client.h>
-
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
@@ -327,7 +325,7 @@ spawn_httpd (int port, pid_t *pid_out)
char *pidfile;
GError *error;
gboolean got_pidfile;
- GConfClient *client;
+ GSettings *settings;
char *str;
char *public_dir;
@@ -346,9 +344,9 @@ spawn_httpd (int port, pid_t *pid_out)
argv[i++] = "-C";
free3 = argv[i++] = g_strdup_printf ("Listen %d", port);
- client = gconf_client_get_default ();
- str = gconf_client_get_string (client,
- FILE_SHARING_REQUIRE_PASSWORD, NULL);
+ settings = g_settings_new (GSETTINGS_DOMAIN);
+ str = g_settings_get_string (settings,
+ FILE_SHARING_REQUIRE_PASSWORD);
if (str && strcmp (str, "never") == 0) {
/* Do nothing */
@@ -361,7 +359,7 @@ spawn_httpd (int port, pid_t *pid_out)
argv[i++] = "RequirePasswordAlways";
}
g_free (str);
- g_object_unref (client);
+ g_object_unref (settings);
argv[i] = NULL;
diff --git a/src/obexftp.c b/src/obexftp.c
index 1037a10..ada35f2 100644
--- a/src/obexftp.c
+++ b/src/obexftp.c
@@ -25,7 +25,6 @@
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <gconf/gconf-client.h>
#include <string.h>
@@ -41,12 +40,12 @@ void
obexftp_up (void)
{
GError *err = NULL;
- GConfClient *client;
+ GSettings *settings;
char *public_dir, *server;
gboolean allow_write, require_pairing;
- client = gconf_client_get_default ();
- require_pairing = gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING, NULL);
+ settings = g_settings_new (GSETTINGS_DOMAIN);
+ require_pairing = g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING);
server = NULL;
if (manager_proxy == NULL) {
@@ -67,8 +66,8 @@ obexftp_up (void)
}
public_dir = lookup_public_dir ();
- allow_write = gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_ALLOW_WRITE, NULL);
- g_object_unref (client);
+ allow_write = g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ALLOW_WRITE);
+ g_object_unref (settings);
if (server_proxy == NULL) {
server_proxy = dbus_g_proxy_new_for_name (connection,
diff --git a/src/obexpush.c b/src/obexpush.c
index 481cc7e..fd93942 100644
--- a/src/obexpush.c
+++ b/src/obexpush.c
@@ -30,7 +30,6 @@
#include <gtk/gtk.h>
#include <libnotify/notify.h>
#include <dbus/dbus-glib.h>
-#include <gconf/gconf-client.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <canberra-gtk.h>
@@ -341,8 +340,8 @@ static void
transfer_completed_cb (DBusGProxy *session,
gpointer user_data)
{
- GConfClient *client;
- gboolean display_notify;
+ GSettings *settings;
+ gboolean display_notify;
const char *filename;
filename = (const char *) g_object_get_data (G_OBJECT (session), "filename");
@@ -351,11 +350,11 @@ transfer_completed_cb (DBusGProxy *session,
if (filename == NULL)
return;
-
- client = gconf_client_get_default ();
- display_notify = gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY, NULL);
- g_object_unref (client);
-
+
+ settings = g_settings_new (GSETTINGS_DOMAIN);
+ display_notify = g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY);
+ g_object_unref (settings);
+
if (display_notify) {
show_notification (filename);
} else {
@@ -536,9 +535,9 @@ obexpush_init (void)
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT64, G_TYPE_INVALID);
if (!notify_init("gnome-user-share")) {
- g_warning("Unable to initialize the notification system\n");
+ g_warning("Unable to initialize the notification system\n");
}
-
+
dbus_connection_set_exit_on_disconnect (dbus_g_connection_get_connection (connection), FALSE);
return TRUE;
diff --git a/src/user_share-private.h b/src/user_share-private.h
index 508dce2..8a1bc01 100644
--- a/src/user_share-private.h
+++ b/src/user_share-private.h
@@ -25,16 +25,17 @@
#ifndef _USER_SHARE_PRIVATE_H_
#define _USER_SHARE_PRIVATE_H_
-#define FILE_SHARING_DIR "/desktop/gnome/file_sharing"
-#define FILE_SHARING_ENABLED FILE_SHARING_DIR "/enabled"
-#define FILE_SHARING_BLUETOOTH_ENABLED FILE_SHARING_DIR "/bluetooth_enabled"
-#define FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED FILE_SHARING_DIR "/bluetooth_obexpush_enabled"
-
-#define FILE_SHARING_REQUIRE_PASSWORD FILE_SHARING_DIR "/require_password"
-#define FILE_SHARING_BLUETOOTH_ALLOW_WRITE FILE_SHARING_DIR "/bluetooth_allow_write"
-#define FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING FILE_SHARING_DIR "/bluetooth_require_pairing"
-#define FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES FILE_SHARING_DIR "/bluetooth_accept_files"
-#define FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY FILE_SHARING_DIR "/bluetooth_notify"
+#define GSETTINGS_DOMAIN "org.gnome.desktop.file-sharing"
+
+#define FILE_SHARING_ENABLED "enabled"
+#define FILE_SHARING_BLUETOOTH_ENABLED "bluetooth-enabled"
+#define FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED "bluetooth-obexpush-enabled"
+
+#define FILE_SHARING_REQUIRE_PASSWORD "require-password"
+#define FILE_SHARING_BLUETOOTH_ALLOW_WRITE "bluetooth-allow-write"
+#define FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING "bluetooth-require-pairing"
+#define FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES "bluetooth-accept-files"
+#define FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY "bluetooth-notify"
typedef enum {
PASSWORD_NEVER,
diff --git a/src/user_share.c b/src/user_share.c
index 87deae6..e3512f8 100644
--- a/src/user_share.c
+++ b/src/user_share.c
@@ -40,8 +40,6 @@
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
-#include <gconf/gconf-client.h>
-
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
@@ -57,6 +55,8 @@
#define CK_SEAT_INTERFACE "org.freedesktop.ConsoleKit.Seat"
#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
+static GSettings *settings = NULL;
+
static guint disabled_timeout_tag = 0;
static gboolean has_console = TRUE;
@@ -68,22 +68,16 @@ static gboolean bluetoothd_enabled = FALSE;
static void
obex_services_start (void)
{
- GConfClient *client;
-
if (bluetoothd_enabled == FALSE ||
has_console == FALSE)
return;
- client = gconf_client_get_default ();
-
- if (gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED, NULL) == TRUE) {
+ if (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == TRUE) {
obexpush_up ();
}
- if (gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_ENABLED, NULL) == TRUE) {
+ if (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) == TRUE) {
obexftp_up ();
}
-
- g_object_unref (client);
}
static void
@@ -278,10 +272,7 @@ migrate_old_configuration (void)
}
static void
-require_password_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
+require_password_changed (void)
{
/* Need to restart to get new password setting */
if (http_get_pid () != 0) {
@@ -293,22 +284,18 @@ require_password_changed (GConfClient* client,
/* File sharing was disabled for some time, exit now */
/* If we re-enable it in the ui, this will be restarted anyway */
static gboolean
-disabled_timeout_callback (gpointer user_data)
+disabled_timeout_callback (void)
{
- GConfClient* client = (GConfClient *) user_data;
http_down ();
- if (gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_ENABLED, NULL) == FALSE &&
- gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED, NULL) == FALSE)
+ if (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) == FALSE &&
+ g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == FALSE)
_exit (0);
return FALSE;
}
static void
-file_sharing_enabled_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
+file_sharing_enabled_changed (void)
{
gboolean enabled;
@@ -317,8 +304,8 @@ file_sharing_enabled_changed (GConfClient* client,
disabled_timeout_tag = 0;
}
- enabled = gconf_client_get_bool (client,
- FILE_SHARING_ENABLED, NULL);
+ enabled = g_settings_get_boolean (settings,
+ FILE_SHARING_ENABLED);
if (enabled) {
if (http_get_pid () == 0) {
http_up ();
@@ -326,28 +313,22 @@ file_sharing_enabled_changed (GConfClient* client,
} else {
http_down ();
disabled_timeout_tag = g_timeout_add_seconds (3,
- (GSourceFunc)disabled_timeout_callback,
- client);
+ (GSourceFunc) disabled_timeout_callback,
+ NULL);
}
}
static void
-file_sharing_bluetooth_allow_write_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
+file_sharing_bluetooth_allow_write_changed (void)
{
- if (gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_ENABLED, NULL) != FALSE)
+ if (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) != FALSE)
obexftp_restart ();
}
static void
-file_sharing_bluetooth_require_pairing_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
+file_sharing_bluetooth_require_pairing_changed (void)
{
- if (gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_ENABLED, NULL) != FALSE) {
+ if (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) != FALSE) {
/* We need to fully reset the session,
* otherwise the new setting isn't taken into account */
obexftp_down ();
@@ -356,16 +337,13 @@ file_sharing_bluetooth_require_pairing_changed (GConfClient* client,
}
static void
-file_sharing_bluetooth_enabled_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
+file_sharing_bluetooth_enabled_changed (void)
{
- if (gconf_client_get_bool (client,
- FILE_SHARING_BLUETOOTH_ENABLED, NULL) == FALSE) {
+ if (g_settings_get_boolean (settings,
+ FILE_SHARING_BLUETOOTH_ENABLED) == FALSE) {
obexftp_down ();
- if (gconf_client_get_bool (client, FILE_SHARING_ENABLED, NULL) == FALSE &&
- gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED, NULL) == FALSE) {
+ if (g_settings_get_boolean (settings, FILE_SHARING_ENABLED) == FALSE &&
+ g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == FALSE) {
_exit (0);
}
} else if (OBEX_ENABLED) {
@@ -374,16 +352,13 @@ file_sharing_bluetooth_enabled_changed (GConfClient* client,
}
static void
-file_sharing_bluetooth_obexpush_enabled_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
+file_sharing_bluetooth_obexpush_enabled_changed (void)
{
- if (gconf_client_get_bool (client,
- FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED, NULL) == FALSE) {
+ if (g_settings_get_boolean (settings,
+ FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == FALSE) {
obexpush_down ();
- if (gconf_client_get_bool (client, FILE_SHARING_ENABLED, NULL) == FALSE &&
- gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_ENABLED, NULL) == FALSE) {
+ if (g_settings_get_boolean (settings, FILE_SHARING_ENABLED) == FALSE &&
+ g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) == FALSE) {
_exit (0);
}
} else if (OBEX_ENABLED) {
@@ -392,15 +367,12 @@ file_sharing_bluetooth_obexpush_enabled_changed (GConfClient* client,
}
static void
-file_sharing_bluetooth_obexpush_accept_files_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
+file_sharing_bluetooth_obexpush_accept_files_changed (void)
{
AcceptSetting setting;
char *str;
- str = gconf_client_get_string (client, FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES, NULL);
+ str = g_settings_get_string (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES);
setting = accept_setting_from_string (str);
g_free (str);
@@ -408,12 +380,39 @@ file_sharing_bluetooth_obexpush_accept_files_changed (GConfClient* client,
}
static void
-file_sharing_bluetooth_obexpush_notify_changed (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer data)
+file_sharing_bluetooth_obexpush_notify_changed (void)
+{
+ obexpush_set_notify (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY));
+}
+
+static void
+setttings_changed (GSettings *settings,
+ gchar *path,
+ gpointer data)
{
- obexpush_set_notify (gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY, NULL));
+ if (g_strcmp0 (FILE_SHARING_ENABLED, path) == 0)
+ file_sharing_enabled_changed ();
+
+ else if (g_strcmp0 (FILE_SHARING_REQUIRE_PASSWORD, path) == 0)
+ require_password_changed ();
+
+ else if (g_strcmp0 (FILE_SHARING_BLUETOOTH_ENABLED, path) == 0)
+ file_sharing_bluetooth_enabled_changed ();
+
+ else if (g_strcmp0 (FILE_SHARING_BLUETOOTH_ALLOW_WRITE, path) == 0)
+ file_sharing_bluetooth_allow_write_changed ();
+
+ else if (g_strcmp0 (FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING, path) == 0)
+ file_sharing_bluetooth_require_pairing_changed ();
+
+ else if (g_strcmp0 (FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED, path) == 0)
+ file_sharing_bluetooth_obexpush_enabled_changed ();
+
+ else if (g_strcmp0 (FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES, path) == 0)
+ file_sharing_bluetooth_obexpush_accept_files_changed ();
+
+ else if (g_strcmp0 (FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY, path) == 0)
+ file_sharing_bluetooth_obexpush_notify_changed ();
}
static void
@@ -436,7 +435,6 @@ x_io_error_handler (Display *xdisplay)
int
main (int argc, char **argv)
{
- GConfClient *client;
Display *xdisplay;
G_GNUC_UNUSED int x_fd;
Window selection_owner;
@@ -485,10 +483,10 @@ main (int argc, char **argv)
migrate_old_configuration ();
- client = gconf_client_get_default ();
- if (gconf_client_get_bool (client, FILE_SHARING_ENABLED, NULL) == FALSE &&
- gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_ENABLED, NULL) == FALSE &&
- gconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED, NULL) == FALSE)
+ settings = g_settings_new (GSETTINGS_DOMAIN);
+ 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;
x_fd = ConnectionNumber (xdisplay);
@@ -501,73 +499,20 @@ main (int argc, char **argv)
if (obexpush_init () == FALSE)
return 1;
- gconf_client_add_dir (client,
- FILE_SHARING_DIR,
- GCONF_CLIENT_PRELOAD_RECURSIVE,
- NULL);
-
- gconf_client_notify_add (client,
- FILE_SHARING_ENABLED,
- file_sharing_enabled_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_REQUIRE_PASSWORD,
- require_password_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_BLUETOOTH_ENABLED,
- file_sharing_bluetooth_enabled_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_BLUETOOTH_ALLOW_WRITE,
- file_sharing_bluetooth_allow_write_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING,
- file_sharing_bluetooth_require_pairing_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED,
- file_sharing_bluetooth_obexpush_enabled_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES,
- file_sharing_bluetooth_obexpush_accept_files_changed,
- NULL,
- NULL,
- NULL);
- gconf_client_notify_add (client,
- FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY,
- file_sharing_bluetooth_obexpush_notify_changed,
- NULL,
- NULL,
- NULL);
-
- g_object_unref (client);
+ g_signal_connect (settings, "changed", G_CALLBACK(setttings_changed), NULL);
bluez_init ();
consolekit_init ();
/* Initial setting */
- file_sharing_enabled_changed (client, 0, NULL, NULL);
- file_sharing_bluetooth_enabled_changed (client, 0, NULL, NULL);
- file_sharing_bluetooth_obexpush_accept_files_changed (client, 0, NULL, NULL);
- file_sharing_bluetooth_obexpush_notify_changed (client, 0, NULL, NULL);
- file_sharing_bluetooth_obexpush_enabled_changed (client, 0, NULL, NULL);
+ file_sharing_enabled_changed ();
+ file_sharing_bluetooth_enabled_changed ();
+ file_sharing_bluetooth_obexpush_accept_files_changed ();
+ file_sharing_bluetooth_obexpush_notify_changed ();
+ file_sharing_bluetooth_obexpush_enabled_changed ();
gtk_main ();
+ g_object_unref (settings);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]