From 99c20ca79435c5ab1130258801008b963dd2d098 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Fri, 28 Sep 2012 12:34:50 +0200 Subject: convert to gsettings --- src/file-share-properties.c | 270 ++++++++++++++++++-------------------------- src/http.c | 14 ++- src/obexftp.c | 14 ++- src/obexpush.c | 11 +- src/user_share-private.h | 20 ++-- src/user_share.c | 159 +++++++------------------- 6 files changed, 181 insertions(+), 307 deletions(-) (limited to 'src') 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 #include -#include +#include #include #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"))); diff --git a/src/http.c b/src/http.c index 64d4706..0e198aa 100644 --- a/src/http.c +++ b/src/http.c @@ -31,7 +31,7 @@ #include #endif -#include +#include #include #include @@ -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 #include -#include +#include #include @@ -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 #include #include -#include #include #include @@ -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 #include -#include +#include #include #include @@ -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 (); -- cgit v1.2.1