diff options
-rw-r--r-- | configure.in | 16 | ||||
-rw-r--r-- | data/Makefile.am | 22 | ||||
-rw-r--r-- | data/desktop_mate_file_sharing.schemas.in | 94 | ||||
-rw-r--r-- | data/org.mate.FileSharing.gschema.xml | 44 | ||||
-rw-r--r-- | src/file-share-properties.c | 270 | ||||
-rw-r--r-- | src/http.c | 14 | ||||
-rw-r--r-- | src/obexftp.c | 14 | ||||
-rw-r--r-- | src/obexpush.c | 11 | ||||
-rw-r--r-- | src/user_share-private.h | 20 | ||||
-rw-r--r-- | src/user_share.c | 159 |
10 files changed, 235 insertions, 429 deletions
diff --git a/configure.in b/configure.in index fddebf7..c45422a 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -AC_INIT(mate-user-share, 1.4.1) +AC_INIT(mate-user-share, 1.5.0) AM_INIT_AUTOMAKE([1.9 dist-bzip2 no-dist-gzip check-news]) AM_CONFIG_HEADER(config.h) @@ -56,11 +56,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.15.2 gio-2.0 gdk-x11-2.0 gtk+-2.0 mateconf-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 mate-bluetooth-1.0 >= 1.2.0) AC_SUBST(USER_SHARE_CFLAGS) AC_SUBST(USER_SHARE_LIBS) -PKG_CHECK_MODULES(USER_SHARE_CONFIG, glib-2.0 >= 2.15.2 gtk+-2.0 >= 2.12.0 mateconf-2.0 unique-1.0) +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) @@ -81,13 +81,11 @@ fi AC_PATH_PROG([GLIB_GENMARSHAL],[glib-genmarshal]) -AC_PATH_PROG(MATECONFTOOL, mateconftool-2, no) +dnl +dnl Enable gsettigns schema macros +dnl -if test x"$MATECONFTOOL" = xno; then - AC_MSG_ERROR([mateconftool-2 executable not found in your path - should be installed with GConf]) -fi - -AM_MATECONF_SOURCE_2 +GLIB_GSETTINGS dnl where to install the mate-user-share binary if test "x$prefix" = "xNONE"; then diff --git a/data/Makefile.am b/data/Makefile.am index 1f29328..93ce715 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,10 +1,5 @@ SUBDIRS = icons -@INTLTOOL_SCHEMAS_RULE@ -schemadir = $(MATECONF_SCHEMA_FILE_DIR) -schema_in_files = desktop_mate_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,19 +12,10 @@ autostart_in_files = mate-user-share.desktop.in appdir = $(datadir)/mate-user-share app_DATA=dav_user_2.0.conf dav_user_2.2.conf dav_groupfile file-share-properties.ui -install-data-local: -if MATECONF_SCHEMAS_INSTALL - -MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) \ - $(MATECONFTOOL) --makefile-install-rule $(schema_DATA) -endif +gsettings_SCHEMAS = org.mate.FileSharing.gschema.xml +@GSETTINGS_RULES@ -if MATECONF_SCHEMAS_INSTALL -uninstall-local: - -MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) \ - $(MATECONFTOOL) --makefile-uninstall-rule $(schema_DATA) -endif - -EXTRA_DIST = $(schema_in_files) \ +EXTRA_DIST = $(gsettings_SCHEMAS) \ $(app_DATA) \ $(desktop_in_files) \ mate-user-share.desktop.in.in \ @@ -37,6 +23,4 @@ EXTRA_DIST = $(schema_in_files) \ CLEANFILES = $(desktop_DATA) $(autostart_DATA) -DISTCLEANFILES = $(schema_DATA) - -include $(top_srcdir)/git.mk diff --git a/data/desktop_mate_file_sharing.schemas.in b/data/desktop_mate_file_sharing.schemas.in deleted file mode 100644 index ea04681..0000000 --- a/data/desktop_mate_file_sharing.schemas.in +++ /dev/null @@ -1,94 +0,0 @@ -<?xml version="1.0"?> -<mateconfschemafile> - <schemalist> - <schema> - <key>/schemas/desktop/mate/file_sharing/enabled</key> - <applyto>/desktop/mate/file_sharing/enabled</applyto> - <owner>mate-user-share</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Share Public directory over the network</short> - <long>If this is true, the Public directory in the users home directory will be shared over the network when the user is logged in.</long> - </locale> - </schema> - <schema> - <key>/schemas/desktop/mate/file_sharing/require_password</key> - <applyto>/desktop/mate/file_sharing/require_password</applyto> - <owner>mate-user-share</owner> - <type>string</type> - <default>never</default> - <locale name="C"> - <short>When to require passwords</short> - <long>When to ask for passwords. Possible values are "never", "on_write", and "always".</long> - </locale> - </schema> - <schema> - <key>/schemas/desktop/mate/file_sharing/bluetooth_enabled</key> - <applyto>/desktop/mate/file_sharing/bluetooth_enabled</applyto> - <owner>mate-user-share</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Share Public directory over Bluetooth</short> - <long>If this is true, the Public directory in the users home directory will be shared over Bluetooth when the user is logged in.</long> - </locale> - </schema> - <schema> - <key>/schemas/desktop/mate/file_sharing/bluetooth_allow_write</key> - <applyto>/desktop/mate/file_sharing/bluetooth_allow_write</applyto> - <owner>mate-user-share</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Whether to allow Bluetooth clients to write files.</short> - <long>Whether to allow Bluetooth clients to write files, or share the files read-only.</long> - </locale> - </schema> - <schema> - <key>/schemas/desktop/mate/file_sharing/bluetooth_require_pairing</key> - <applyto>/desktop/mate/file_sharing/bluetooth_require_pairing</applyto> - <owner>mate-user-share</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Whether Bluetooth clients need to pair with the computer to send files.</short> - <long>Whether Bluetooth clients need to pair with the computer to send files.</long> - </locale> - </schema> - <schema> - <key>/schemas/desktop/mate/file_sharing/bluetooth_obexpush_enabled</key> - <applyto>/desktop/mate/file_sharing/bluetooth_obexpush_enabled</applyto> - <owner>mate-user-share</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Whether Bluetooth clients can send files using ObexPush.</short> - <long>If this is true, Bluetooth devices can send files to the user's Downloads directory when logged in.</long> - </locale> - </schema> - <schema> - <key>/schemas/desktop/mate/file_sharing/bluetooth_accept_files</key> - <applyto>/desktop/mate/file_sharing/bluetooth_accept_files</applyto> - <owner>mate-user-share</owner> - <type>string</type> - <default>bonded</default> - <locale name="C"> - <short>When to accept files sent over Bluetooth</short> - <long>When to accept files sent over Bluetooth. Possible values are "always", "bonded" and "ask".</long> - </locale> - </schema> - <schema> - <key>/schemas/desktop/mate/file_sharing/bluetooth_notify</key> - <applyto>/desktop/mate/file_sharing/bluetooth_notify</applyto> - <owner>mate-user-share</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Whether to notify about newly received files.</short> - <long>Whether to notify about newly received files.</long> - </locale> - </schema> - </schemalist> -</mateconfschemafile> - diff --git a/data/org.mate.FileSharing.gschema.xml b/data/org.mate.FileSharing.gschema.xml new file mode 100644 index 0000000..4711582 --- /dev/null +++ b/data/org.mate.FileSharing.gschema.xml @@ -0,0 +1,44 @@ +<schemalist> + <schema id="org.mate.FileSharing" path="/desktop/mate/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 d46958f..6d0fbd6 100644 --- a/src/file-share-properties.c +++ b/src/file-share-properties.c @@ -28,13 +28,22 @@ #include <gtk/gtk.h> #include <glib/gi18n.h> -#include <mateconf/mateconf-client.h> +#include <gio/gio.h> #include <unique/uniqueapp.h> #include "user_share-private.h" #define REALM "Please log in as the user guest" #define USER "guest" +#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" +#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES "bluetooth-accept-files" +#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY "bluetooth-notify" static GtkBuilder* builder; @@ -85,7 +94,7 @@ flush_password (void) static void update_ui (void) { - MateConfClient *client; + GSettings *settings; gboolean enabled, bluetooth_enabled, bluetooth_write_enabled, require_pairing_enabled; gboolean bluetooth_obexpush_enabled, bluetooth_obexpush_notify; char *str; @@ -101,32 +110,26 @@ update_ui (void) GtkWidget *accept_obexpush_combo; GtkWidget *notify_received_obexpush_check; - client = mateconf_client_get_default (); - - enabled = mateconf_client_get_bool (client, - FILE_SHARING_ENABLED, - NULL); - bluetooth_enabled = mateconf_client_get_bool (client, - FILE_SHARING_BLUETOOTH_ENABLED, - NULL); - bluetooth_write_enabled = mateconf_client_get_bool (client, - FILE_SHARING_BLUETOOTH_ALLOW_WRITE, - NULL); - require_pairing_enabled = mateconf_client_get_bool (client, - FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING, - NULL); - bluetooth_obexpush_enabled = mateconf_client_get_bool (client, - FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED, - NULL); - bluetooth_obexpush_notify = mateconf_client_get_bool (client, - FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY, - NULL); - - str = mateconf_client_get_string (client, FILE_SHARING_REQUIRE_PASSWORD, NULL); + settings = g_settings_new (GSETTINGS_SCHEMA); + + 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 = mateconf_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); @@ -169,77 +172,53 @@ update_ui (void) gtk_combo_box_set_active (GTK_COMBO_BOX (accept_obexpush_combo), accept_setting); - g_object_unref (client); + g_object_unref (settings); } static void -file_sharing_enabled_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_enabled_changed (GSettings *settings, gchar *key, gpointer data) { update_ui (); } static void -password_required_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +password_required_changed (GSettings *settings, gchar *key, gpointer data) { update_ui (); } static void -file_sharing_bluetooth_enabled_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_bluetooth_enabled_changed (GSettings *settings, gchar *key, gpointer data) { update_ui (); } static void -file_sharing_bluetooth_allow_write_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_bluetooth_allow_write_changed (GSettings *settings, gchar *key, gpointer data) { update_ui (); } static void -file_sharing_bluetooth_require_pairing_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_bluetooth_require_pairing_changed (GSettings *settings, gchar *key, gpointer data) { update_ui (); } static void -file_sharing_bluetooth_obexpush_enabled_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_bluetooth_obexpush_enabled_changed (GSettings *settings, gchar *key, gpointer data) { update_ui (); } static void -file_sharing_bluetooth_obexpush_accept_files_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_bluetooth_obexpush_accept_files_changed (GSettings *settings, gchar *key, gpointer data) { update_ui (); } static void -file_sharing_bluetooth_obexpush_notify_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_bluetooth_obexpush_notify_changed (GSettings *settings, gchar *key, gpointer data) { update_ui (); } @@ -247,18 +226,17 @@ file_sharing_bluetooth_obexpush_notify_changed (MateConfClient* client, static void password_combo_changed (GtkComboBox *combo_box) { - MateConfClient *client; + GSettings *settings; guint setting; setting = gtk_combo_box_get_active (combo_box); - client = mateconf_client_get_default (); + settings = g_settings_new (GSETTINGS_SCHEMA) ; - mateconf_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)); + g_object_unref (settings); } static void @@ -286,19 +264,18 @@ launch_share (void) static void enable_bluetooth_check_toggled (GtkWidget *check) { - MateConfClient *client; + GSettings *settings; gboolean enabled; enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)); - client = mateconf_client_get_default (); + settings = g_settings_new (GSETTINGS_SCHEMA) ; - mateconf_client_set_bool (client, + g_settings_set_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED, - enabled, - NULL); + enabled); - g_object_unref (client); + g_object_unref (settings); if (enabled != FALSE) launch_share (); @@ -307,19 +284,18 @@ enable_bluetooth_check_toggled (GtkWidget *check) static void enable_check_toggled (GtkWidget *check) { - MateConfClient *client; + GSettings *settings; gboolean enabled; enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)); - client = mateconf_client_get_default (); + settings = g_settings_new (GSETTINGS_SCHEMA); - mateconf_client_set_bool (client, + g_settings_set_boolean (settings, FILE_SHARING_ENABLED, - enabled, - NULL); + enabled); - g_object_unref (client); + g_object_unref (settings); if (enabled != FALSE) launch_share (); @@ -336,55 +312,52 @@ password_entry_changed (GtkEditable *editable) static void bluetooth_allow_write_check_toggled (GtkWidget *check) { - MateConfClient *client; + GSettings *settings; gboolean enabled; enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)); - client = mateconf_client_get_default (); + settings = g_settings_new (GSETTINGS_SCHEMA) ; - mateconf_client_set_bool (client, + g_settings_set_boolean (settings, FILE_SHARING_BLUETOOTH_ALLOW_WRITE, - enabled, - NULL); + enabled); - g_object_unref (client); + g_object_unref (settings); } static void bluetooth_require_pairing_check_toggled (GtkWidget *check) { - MateConfClient *client; + GSettings *settings; gboolean enabled; enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)); - client = mateconf_client_get_default (); + settings = g_settings_new (GSETTINGS_SCHEMA) ; - mateconf_client_set_bool (client, + g_settings_set_boolean (settings, FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING, - enabled, - NULL); + enabled); - g_object_unref (client); + g_object_unref (settings); } static void enable_obexpush_check_toggled (GtkWidget *check) { - MateConfClient *client; + GSettings *settings; gboolean enabled; enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)); - client = mateconf_client_get_default (); + settings = g_settings_new (GSETTINGS_SCHEMA) ; - mateconf_client_set_bool (client, + g_settings_set_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED, - enabled, - NULL); + enabled); - g_object_unref (client); + g_object_unref (settings); if (enabled != FALSE) launch_share (); @@ -393,36 +366,34 @@ enable_obexpush_check_toggled (GtkWidget *check) static void accept_obexpush_combo_changed (GtkComboBox *combo_box) { - MateConfClient *client; + GSettings *settings; guint setting; setting = gtk_combo_box_get_active (combo_box); - client = mateconf_client_get_default (); + settings = g_settings_new (GSETTINGS_SCHEMA) ; - mateconf_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)); + g_object_unref (settings); } static void notify_received_obexpush_check_toggled (GtkWidget *check) { - MateConfClient *client; + GSettings *settings; gboolean enabled; enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)); - client = mateconf_client_get_default (); + settings = g_settings_new (GSETTINGS_SCHEMA) ; - mateconf_client_set_bool (client, + g_settings_set_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY, - enabled, - NULL); + enabled); - g_object_unref (client); + g_object_unref (settings); } static GtkWidget * @@ -486,7 +457,7 @@ int main (int argc, char *argv[]) { GError *error = NULL; - MateConfClient *client; + GSettings *settings; GtkWidget *check; GtkWidget *password_combo; GtkWidget *password_entry; @@ -535,11 +506,7 @@ main (int argc, char *argv[]) g_signal_connect (app, "message-received", G_CALLBACK (message_received_cb), window); - client = mateconf_client_get_default (); - mateconf_client_add_dir (client, - FILE_SHARING_DIR, - MATECONF_CLIENT_PRELOAD_RECURSIVE, - NULL); + settings = g_settings_new (GSETTINGS_SCHEMA); check = GTK_WIDGET (gtk_builder_get_object (builder, "enable_check")); password_combo = GTK_WIDGET (gtk_builder_get_object (builder, "password_combo")); @@ -629,56 +596,35 @@ main (int argc, char *argv[]) "clicked", G_CALLBACK (help_button_clicked), gtk_builder_get_object (builder, "user_share_dialog")); - mateconf_client_notify_add (client, - FILE_SHARING_ENABLED, - file_sharing_enabled_changed, - NULL, - NULL, - NULL); - mateconf_client_notify_add (client, - FILE_SHARING_REQUIRE_PASSWORD, - password_required_changed, - NULL, - NULL, - NULL); - mateconf_client_notify_add (client, - FILE_SHARING_BLUETOOTH_ENABLED, - file_sharing_bluetooth_enabled_changed, - NULL, - NULL, - NULL); - mateconf_client_notify_add (client, - FILE_SHARING_BLUETOOTH_ALLOW_WRITE, - file_sharing_bluetooth_allow_write_changed, - NULL, - NULL, - NULL); - mateconf_client_notify_add (client, - FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING, - file_sharing_bluetooth_require_pairing_changed, - NULL, - NULL, - NULL); - mateconf_client_notify_add (client, - FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED, - file_sharing_bluetooth_obexpush_enabled_changed, - NULL, - NULL, - NULL); - mateconf_client_notify_add (client, - FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES, - file_sharing_bluetooth_obexpush_accept_files_changed, - NULL, - NULL, - NULL); - mateconf_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::" GSETTINGS_KEY_FILE_SHARING_ENABLED, + G_CALLBACK (file_sharing_enabled_changed), NULL); + g_signal_connect (settings, + "changed::" GSETTINGS_KEY_FILE_SHARING_REQUIRE_PASSWORD, + G_CALLBACK (password_required_changed), NULL); + g_signal_connect (settings, + "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ENABLED, + G_CALLBACK (file_sharing_bluetooth_enabled_changed), NULL); + g_signal_connect (settings, + "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ALLOW_WRITE, + G_CALLBACK (file_sharing_bluetooth_allow_write_changed), NULL); + g_signal_connect (settings, + "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING, + G_CALLBACK (file_sharing_bluetooth_require_pairing_changed), NULL); + g_signal_connect (settings, + "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED, + G_CALLBACK (file_sharing_bluetooth_obexpush_enabled_changed), NULL); + g_signal_connect (settings, + "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES, + G_CALLBACK (file_sharing_bluetooth_obexpush_accept_files_changed), NULL); + g_signal_connect (settings, + "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY, + G_CALLBACK (file_sharing_bluetooth_obexpush_notify_changed), NULL); + + + + g_object_unref (settings); gtk_widget_show (GTK_WIDGET (gtk_builder_get_object (builder, "user_share_dialog"))); @@ -31,7 +31,7 @@ #include <dbus/dbus.h> #endif -#include <mateconf/mateconf-client.h> +#include <gio/gio.h> #include <stdarg.h> #include <string.h> @@ -55,6 +55,8 @@ /* From avahi-common/domain.h */ #define AVAHI_LABEL_MAX 64 +#define GSETTINGS_SCHEMA "org.mate.FileSharing" + #ifdef HAVE_DBUS_1_1 static char *dbus_session_id; #endif @@ -326,7 +328,7 @@ spawn_httpd (int port, pid_t *pid_out) char *pidfile; GError *error; gboolean got_pidfile; - MateConfClient *client; + GSettings *settings; char *str; char *public_dir; @@ -345,9 +347,9 @@ spawn_httpd (int port, pid_t *pid_out) argv[i++] = "-C"; free3 = argv[i++] = g_strdup_printf ("Listen %d", port); - client = mateconf_client_get_default (); - str = mateconf_client_get_string (client, - FILE_SHARING_REQUIRE_PASSWORD, NULL); + settings = g_settings_new (GSETTINGS_SCHEMA); + str = g_settings_get_string (settings, + FILE_SHARING_REQUIRE_PASSWORD); if (str && strcmp (str, "never") == 0) { /* Do nothing */ @@ -360,7 +362,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 6d94c97..b06cf09 100644 --- a/src/obexftp.c +++ b/src/obexftp.c @@ -25,7 +25,7 @@ #include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> -#include <mateconf/mateconf-client.h> +#include <gio/gio.h> #include <string.h> @@ -33,6 +33,8 @@ #include "user_share-common.h" #include "user_share-private.h" +#define GSETTINGS_SCHEMA "org.mate.FileSharing" + static DBusGConnection *connection = NULL; static DBusGProxy *manager_proxy = NULL; static DBusGProxy *server_proxy = NULL; @@ -41,12 +43,12 @@ void obexftp_up (void) { GError *err = NULL; - MateConfClient *client; + GSettings *settings; char *public_dir, *server; gboolean allow_write, require_pairing; - client = mateconf_client_get_default (); - require_pairing = mateconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING, NULL); + settings = g_settings_new (GSETTINGS_SCHEMA); + require_pairing =g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING); server = NULL; if (manager_proxy == NULL) { @@ -67,8 +69,8 @@ obexftp_up (void) } public_dir = lookup_public_dir (); - allow_write = mateconf_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 75238f5..cb3cde0 100644 --- a/src/obexpush.c +++ b/src/obexpush.c @@ -30,7 +30,6 @@ #include <gtk/gtk.h> #include <libmatenotify/notify.h> #include <dbus/dbus-glib.h> -#include <mateconf/mateconf-client.h> #include <dbus/dbus-glib-lowlevel.h> #include <canberra-gtk.h> @@ -43,6 +42,8 @@ #define DBUS_TYPE_G_STRING_VARIANT_HASHTABLE (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING)) +#define GSETTINGS_SCHEMA "org.mate.FileSharing" + static DBusGConnection *connection = NULL; static DBusGProxy *manager_proxy = NULL; static DBusGProxy *server_proxy = NULL; @@ -348,7 +349,7 @@ static void transfer_completed_cb (DBusGProxy *session, gpointer user_data) { - MateConfClient *client; + GSettings *settings; gboolean display_notify; const char *filename; @@ -359,9 +360,9 @@ transfer_completed_cb (DBusGProxy *session, if (filename == NULL) return; - client = mateconf_client_get_default (); - display_notify = mateconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY, NULL); - g_object_unref (client); + settings = g_settings_new (GSETTINGS_SCHEMA); + display_notify = g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY); + g_object_unref (settings); if (display_notify) { show_notification (filename); diff --git a/src/user_share-private.h b/src/user_share-private.h index 4ce936c..e065e98 100644 --- a/src/user_share-private.h +++ b/src/user_share-private.h @@ -25,16 +25,16 @@ #ifndef _USER_SHARE_PRIVATE_H_ #define _USER_SHARE_PRIVATE_H_ -#define FILE_SHARING_DIR "/desktop/mate/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 FILE_SHARING_DIR "/desktop/mate/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 e55863a..fab1cee 100644 --- a/src/user_share.c +++ b/src/user_share.c @@ -39,7 +39,7 @@ #include <dbus/dbus.h> #include <dbus/dbus-glib.h> -#include <mateconf/mateconf-client.h> +#include <gio/gio.h> #include <stdarg.h> #include <string.h> @@ -63,22 +63,23 @@ static BluetoothClient *client = NULL; static gboolean bluetoothd_enabled = FALSE; #define OBEX_ENABLED (bluetoothd_enabled && has_console) +#define GSETTINGS_SCHEMA "org.mate.FileSharing" static void obex_services_start (void) { - MateConfClient *client; + GSettings *settings; if (bluetoothd_enabled == FALSE || has_console == FALSE) return; - client = mateconf_client_get_default (); + settings = g_settings_new(GSETTINGS_SCHEMA); - if (mateconf_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 (mateconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_ENABLED, NULL) == TRUE) { + if (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) == TRUE) { obexftp_up (); } @@ -277,10 +278,7 @@ migrate_old_configuration (void) } static void -require_password_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +require_password_changed (GSettings *settings, gchar *key, gpointer data) { /* Need to restart to get new password setting */ if (http_get_pid () != 0) { @@ -294,20 +292,17 @@ require_password_changed (MateConfClient* client, static gboolean disabled_timeout_callback (gpointer user_data) { - MateConfClient* client = (MateConfClient *) user_data; + GSettings* settings = (GSettings*) user_data; http_down (); - if (mateconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_ENABLED, NULL) == FALSE && - mateconf_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 (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_enabled_changed (GSettings *settings, gchar *key, gpointer data) { gboolean enabled; @@ -316,8 +311,8 @@ file_sharing_enabled_changed (MateConfClient* client, disabled_timeout_tag = 0; } - enabled = mateconf_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 (); @@ -331,22 +326,16 @@ file_sharing_enabled_changed (MateConfClient* client, } static void -file_sharing_bluetooth_allow_write_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_bluetooth_allow_write_changed (GSettings *settings, gchar *key, gpointer data) { - if (mateconf_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 (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_bluetooth_require_pairing_changed (GSettings *settings, gchar *key, gpointer data) { - if (mateconf_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 (); @@ -355,16 +344,13 @@ file_sharing_bluetooth_require_pairing_changed (MateConfClient* client, } static void -file_sharing_bluetooth_enabled_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_bluetooth_enabled_changed (GSettings *settings, gchar *key, gpointer data) { - if (mateconf_client_get_bool (client, - FILE_SHARING_BLUETOOTH_ENABLED, NULL) == FALSE) { + if (g_settings_get_boolean (settings, + FILE_SHARING_BLUETOOTH_ENABLED) == FALSE) { obexftp_down (); - if (mateconf_client_get_bool (client, FILE_SHARING_ENABLED, NULL) == FALSE && - mateconf_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) { @@ -373,16 +359,13 @@ file_sharing_bluetooth_enabled_changed (MateConfClient* client, } static void -file_sharing_bluetooth_obexpush_enabled_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_bluetooth_obexpush_enabled_changed (GSettings *settings, gchar *key, gpointer data) { - if (mateconf_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 (mateconf_client_get_bool (client, FILE_SHARING_ENABLED, NULL) == FALSE && - mateconf_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) { @@ -391,15 +374,12 @@ file_sharing_bluetooth_obexpush_enabled_changed (MateConfClient* client, } static void -file_sharing_bluetooth_obexpush_accept_files_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_bluetooth_obexpush_accept_files_changed (GSettings *settings, gchar *key, gpointer data) { AcceptSetting setting; char *str; - str = mateconf_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); @@ -407,12 +387,9 @@ file_sharing_bluetooth_obexpush_accept_files_changed (MateConfClient* client, } static void -file_sharing_bluetooth_obexpush_notify_changed (MateConfClient* client, - guint cnxn_id, - MateConfEntry *entry, - gpointer data) +file_sharing_bluetooth_obexpush_notify_changed (GSettings *settings, gchar *key, gpointer data) { - obexpush_set_notify (mateconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY, NULL)); + obexpush_set_notify (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY)); } static RETSIGTYPE @@ -435,7 +412,7 @@ x_io_error_handler (Display *xdisplay) int main (int argc, char **argv) { - MateConfClient *client; + GSettings* gsettings; Display *xdisplay; int x_fd; Window selection_owner; @@ -484,10 +461,10 @@ main (int argc, char **argv) migrate_old_configuration (); - client = mateconf_client_get_default (); - if (mateconf_client_get_bool (client, FILE_SHARING_ENABLED, NULL) == FALSE && - mateconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_ENABLED, NULL) == FALSE && - mateconf_client_get_bool (client, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED, NULL) == FALSE) + gsettings = g_settings_new (GSETTINGS_SCHEMA); + if (g_settings_get_boolean (gsettings, FILE_SHARING_ENABLED) == FALSE && + g_settings_get_boolean (gsettings, FILE_SHARING_BLUETOOTH_ENABLED) == FALSE && + g_settings_get_boolean (gsettings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == FALSE) return 1; x_fd = ConnectionNumber (xdisplay); @@ -500,71 +477,17 @@ main (int argc, char **argv) if (obexpush_init () == FALSE) return 1; - mateconf_client_add_dir (client, - FILE_SHARING_DIR, - MATECONF_CLIENT_PRELOAD_RECURSIVE, - NULL); - - mateconf_client_notify_add (client, - FILE_SHARING_ENABLED, - file_sharing_enabled_changed, - NULL, - NULL, - NULL); - mateconf_client_notify_add (client, - FILE_SHARING_REQUIRE_PASSWORD, - require_password_changed, - NULL, - NULL, - NULL); - mateconf_client_notify_add (client, - FILE_SHARING_BLUETOOTH_ENABLED, - file_sharing_bluetooth_enabled_changed, - NULL, - NULL, - NULL); - mateconf_client_notify_add (client, - FILE_SHARING_BLUETOOTH_ALLOW_WRITE, - file_sharing_bluetooth_allow_write_changed, - NULL, - NULL, - NULL); - mateconf_client_notify_add (client, - FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING, - file_sharing_bluetooth_require_pairing_changed, - NULL, - NULL, - NULL); - mateconf_client_notify_add (client, - FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED, - file_sharing_bluetooth_obexpush_enabled_changed, - NULL, - NULL, - NULL); - mateconf_client_notify_add (client, - FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES, - file_sharing_bluetooth_obexpush_accept_files_changed, - NULL, - NULL, - NULL); - mateconf_client_notify_add (client, - FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY, - file_sharing_bluetooth_obexpush_notify_changed, - NULL, - NULL, - NULL); - g_object_unref (client); 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 (gsettings, NULL, NULL); + file_sharing_bluetooth_enabled_changed (gsettings, NULL, NULL); + file_sharing_bluetooth_obexpush_accept_files_changed (gsettings, NULL, NULL); + file_sharing_bluetooth_obexpush_notify_changed (gsettings, NULL, NULL); + file_sharing_bluetooth_obexpush_enabled_changed (gsettings, NULL, NULL); gtk_main (); |