[vino/3] remove GConf from server
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vino/3] remove GConf from server
- Date: Mon, 5 Jul 2010 06:59:04 +0000 (UTC)
commit 49beffe6ce88c78bde7cb69d47c9a83a57395909
Author: Ryan Lortie <desrt desrt ca>
Date: Mon Jul 5 00:08:13 2010 -0400
remove GConf from server
server/Makefile.am | 2 -
server/vino-background.c | 64 ----
server/vino-background.h | 36 --
server/vino-dbus-error.h | 2 -
server/vino-dbus-listener.c | 4 -
server/vino-dbus-listener.h | 8 -
server/vino-prefs.c | 781 ++++---------------------------------------
server/vino-server.c | 69 ++--
8 files changed, 100 insertions(+), 866 deletions(-)
---
diff --git a/server/Makefile.am b/server/Makefile.am
index da3a203..c8eb0cc 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -73,8 +73,6 @@ vino_server_SOURCES = \
vino-dbus-listener.h \
vino-dbus-error.c \
vino-dbus-error.h \
- vino-background.c \
- vino-background.h \
vino-upnp.h \
vino-upnp.c \
$(VINO_HTTP_SRC) \
diff --git a/server/vino-dbus-error.h b/server/vino-dbus-error.h
index b967150..44aefb4 100644
--- a/server/vino-dbus-error.h
+++ b/server/vino-dbus-error.h
@@ -23,8 +23,6 @@
#ifndef __VINO_DBUS_ERROR_H__
#define __VINO_DBUS_ERROR_H__
-#include <dbus/dbus-glib.h>
-
typedef enum
{
VINO_DBUS_ERROR_NOT_IMPLEMENTED,
diff --git a/server/vino-dbus-listener.c b/server/vino-dbus-listener.c
index 81df2c8..74777ed 100644
--- a/server/vino-dbus-listener.c
+++ b/server/vino-dbus-listener.c
@@ -40,10 +40,6 @@
#include <arpa/inet.h>
#include <netinet/in.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-glib-bindings.h>
-
#include "vino-dbus-error.h"
#ifdef HAVE_TELEPATHY_GLIB
diff --git a/server/vino-dbus-listener.h b/server/vino-dbus-listener.h
index 1e0d467..e3250ca 100644
--- a/server/vino-dbus-listener.h
+++ b/server/vino-dbus-listener.h
@@ -60,14 +60,6 @@ GType vino_dbus_listener_get_type (void) G_GNUC_CONST;
VinoDBusListener * vino_dbus_listener_new (VinoServer *server);
VinoServer *vino_dbus_listener_get_server (VinoDBusListener *listener);
-G_END_DECLS
-
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus.h>
-
-G_BEGIN_DECLS
-
-DBusGConnection *vino_dbus_get_connection (void);
gboolean vino_dbus_request_name (void);
G_END_DECLS
diff --git a/server/vino-prefs.c b/server/vino-prefs.c
index 0304154..87cc7cc 100644
--- a/server/vino-prefs.c
+++ b/server/vino-prefs.c
@@ -20,7 +20,11 @@
* Mark McLoughlin <mark skynet ie>
*/
-#include <config.h>
+#include "config.h"
+
+#include "vino-prefs.h"
+
+
#include <string.h>
#include <glib/gstdio.h>
#include <signal.h>
@@ -31,465 +35,28 @@
#include "vino-util.h"
#include "vino-mdns.h"
#include "vino-status-icon.h"
-#include "vino-background.h"
-
-#define VINO_PREFS_DIR "/desktop/gnome/remote_access"
-#define VINO_PREFS_ENABLED VINO_PREFS_DIR "/enabled"
-#define VINO_PREFS_PROMPT_ENABLED VINO_PREFS_DIR "/prompt_enabled"
-#define VINO_PREFS_VIEW_ONLY VINO_PREFS_DIR "/view_only"
-#define VINO_PREFS_LOCAL_ONLY VINO_PREFS_DIR "/local_only"
-#define VINO_PREFS_NETWORK_INTERFACE VINO_PREFS_DIR "/network_interface"
-#define VINO_PREFS_USE_ALTERNATIVE_PORT VINO_PREFS_DIR "/use_alternative_port"
-#define VINO_PREFS_ALTERNATIVE_PORT VINO_PREFS_DIR "/alternative_port"
-#define VINO_PREFS_REQUIRE_ENCRYPTION VINO_PREFS_DIR "/require_encryption"
-#define VINO_PREFS_AUTHENTICATION_METHODS VINO_PREFS_DIR "/authentication_methods"
-#define VINO_PREFS_VNC_PASSWORD VINO_PREFS_DIR "/vnc_password"
-#define VINO_PREFS_LOCK_SCREEN VINO_PREFS_DIR "/lock_screen_on_disconnect"
-#define VINO_PREFS_ICON_VISIBILITY VINO_PREFS_DIR "/icon_visibility"
-#define VINO_PREFS_DISABLE_BACKGROUND VINO_PREFS_DIR "/disable_background"
-#define VINO_PREFS_USE_UPNP VINO_PREFS_DIR "/use_upnp"
-#define VINO_PREFS_DISABLE_XDAMAGE VINO_PREFS_DIR "/disable_xdamage"
-
-#define VINO_N_LISTENERS 14
#define VINO_PREFS_LOCKFILE "vino-server.lock"
-static GConfClient *vino_client = NULL;
-static GSList *vino_servers = NULL;
-static guint vino_listeners [VINO_N_LISTENERS] = { 0, };
-
-static gboolean vino_enabled = FALSE;
-static gboolean vino_prompt_enabled = FALSE;
-static gboolean vino_view_only = FALSE;
-static char *vino_network_interface = NULL;
-static gboolean vino_require_encryption = FALSE;
-static VinoAuthMethod vino_auth_methods = VINO_AUTH_VNC;
-static char *vino_vnc_password = NULL;
-static gboolean vino_use_alternative_port = FALSE;
-static int vino_alternative_port = VINO_SERVER_DEFAULT_PORT;
-static gboolean vino_lock_screen = FALSE;
-static gboolean vino_disable_background = FALSE;
-static gboolean vino_use_upnp = TRUE;
-static gboolean vino_disable_xdamage = FALSE;
-static VinoStatusIconVisibility vino_icon_visibility = VINO_STATUS_ICON_VISIBILITY_CLIENT;
-
-static void
-vino_prefs_enabled_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
-{
- gboolean enabled;
- GSList *l;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- enabled = gconf_value_get_bool (entry->value) != FALSE;
-
- if (vino_enabled == enabled)
- return;
-
- vino_enabled = enabled;
-
- dprintf (PREFS, "Access enabled changed: %s\n", vino_enabled ? "(true)" : "(false)");
-
- if (vino_enabled)
- vino_mdns_start (vino_network_interface);
- else
- vino_mdns_stop ();
-
- for (l = vino_servers; l; l = l->next)
- vino_server_set_on_hold (l->data, !enabled);
-}
-
-static void
-vino_prefs_prompt_enabled_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
-{
- gboolean prompt_enabled;
- GSList *l;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- prompt_enabled = gconf_value_get_bool (entry->value) != FALSE;
-
- if (vino_prompt_enabled == prompt_enabled)
- return;
-
- vino_prompt_enabled = prompt_enabled;
-
- dprintf (PREFS, "Prompt enabled changed: %s\n", vino_prompt_enabled ? "(true)" : "(false)");
-
- for (l = vino_servers; l; l = l->next)
- vino_server_set_prompt_enabled (l->data, prompt_enabled);
-}
-
-static void
-vino_prefs_view_only_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
-{
- gboolean view_only;
- GSList *l;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- view_only = gconf_value_get_bool (entry->value) != FALSE;
-
- if (vino_view_only == view_only)
- return;
-
- vino_view_only = view_only;
-
- dprintf (PREFS, "View only changed: %s\n", vino_view_only ? "(true)" : "(false)");
-
- for (l = vino_servers; l; l = l->next)
- vino_server_set_view_only (l->data, view_only);
-}
-
-static void
-vino_prefs_network_interface_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
-{
- const char *network_interface;
- GSList *l;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
- return;
-
- network_interface = gconf_value_get_string (entry->value);
-
- if (!network_interface && !vino_network_interface)
- return;
-
- if (network_interface && vino_network_interface &&
- !strcmp (network_interface, vino_network_interface))
- return;
-
- if (vino_network_interface)
- g_free (vino_network_interface);
-
- vino_network_interface = g_strdup (network_interface);
-
- dprintf (PREFS, "Network Interface for bind() changed: %s\n",
- vino_network_interface ? vino_network_interface : "(null)");
-
- for (l = vino_servers; l; l = l->next)
- vino_server_set_network_interface (l->data, network_interface);
-}
-
-static void
-vino_prefs_require_encryption_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
-{
- gboolean require_encryption;
- GSList *l;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- require_encryption = gconf_value_get_bool (entry->value) != FALSE;
-
- if (vino_require_encryption == require_encryption)
- return;
-
- vino_require_encryption = require_encryption;
-
- dprintf (PREFS, "Require encryption changed: %s\n", vino_require_encryption ? "(true)" : "(false)");
-
- for (l = vino_servers; l; l = l->next)
- vino_server_set_require_encryption (l->data, require_encryption);
-}
-
-static VinoAuthMethod
-vino_prefs_translate_auth_methods_list (GSList *auth_methods_list,
- gboolean value_list)
-{
- VinoAuthMethod retval = VINO_AUTH_INVALID;
- GSList *l;
-
- for (l = auth_methods_list; l; l = l->next)
- {
- const char *method;
-
- if (value_list)
- method = gconf_value_get_string (l->data);
- else
- method = l->data;
-
- dprintf (PREFS, " %s", method);
-
- if (!g_ascii_strcasecmp (method, "none"))
- retval |= VINO_AUTH_NONE;
-
- else if (!g_ascii_strcasecmp (method, "vnc"))
- retval |= VINO_AUTH_VNC;
- }
-
- return retval != VINO_AUTH_INVALID ? retval : VINO_AUTH_NONE;
-}
-
-static void
-vino_prefs_authentication_methods_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
-{
- VinoAuthMethod auth_methods;
- GSList *auth_methods_list;
- GSList *l;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_LIST ||
- gconf_value_get_list_type (entry->value) != GCONF_VALUE_STRING)
- return;
-
- auth_methods_list = gconf_value_get_list (entry->value);
-
- dprintf (PREFS, "Authentication methods changed:");
- auth_methods = vino_prefs_translate_auth_methods_list (auth_methods_list, TRUE);
- dprintf (PREFS, "\n");
-
- if (vino_auth_methods == auth_methods)
- return;
-
- vino_auth_methods = auth_methods;
-
- for (l = vino_servers; l; l = l->next)
- vino_server_set_auth_methods (l->data, auth_methods);
-}
-
-static void
-vino_prefs_vnc_password_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
-{
- const char *vnc_password;
- GSList *l;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
- return;
-
- vnc_password = gconf_value_get_string (entry->value);
-
- if (!vnc_password && !vino_vnc_password)
- return;
-
- if (vnc_password && vino_vnc_password &&
- !strcmp (vnc_password, vino_vnc_password))
- return;
-
- if (vino_vnc_password)
- g_free (vino_vnc_password);
- vino_vnc_password = g_strdup (vnc_password);
-
- dprintf (PREFS, "Encoded password changed: %s\n",
- vino_vnc_password ? vino_vnc_password : "(null)");
-
- for (l = vino_servers; l; l = l->next)
- vino_server_set_vnc_password (l->data, vnc_password);
-}
+static GSettings *background_settings = NULL;
+static GSettings *vino_settings = NULL;
static void
-vino_prefs_restart_mdns (VinoServer *server, gpointer data)
+vino_prefs_restart_mdns (VinoServer *server,
+ gpointer data)
{
vino_mdns_stop ();
vino_mdns_add_service ("_rfb._tcp", vino_server_get_port (server));
- vino_mdns_start (vino_network_interface);
+ vino_mdns_start (vino_server_get_network_interface (server));
}
-static void
-vino_prefs_use_alternative_port_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
-{
- gboolean enabled;
- GSList *l;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- enabled = gconf_value_get_bool (entry->value) != FALSE;
-
- if (vino_use_alternative_port == enabled)
- return;
-
- vino_use_alternative_port = enabled;
-
- dprintf (PREFS, "Use alternative port changed: %s\n",
- vino_use_alternative_port ? "(true)" : "(false)");
-
- for (l = vino_servers; l; l = l->next)
- vino_server_set_use_alternative_port (l->data, vino_use_alternative_port);
-}
-
-static void
-vino_prefs_alternative_port_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
-{
- GSList *l;
- int port;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_INT)
- return;
-
- port = gconf_value_get_int (entry->value);
-
- if (vino_alternative_port == port || !VINO_SERVER_VALID_PORT (port))
- return;
-
- vino_alternative_port = port;
-
- dprintf (PREFS, "Alternative port changed: %d\n", vino_alternative_port);
-
- for (l = vino_servers; l; l = l->next)
- vino_server_set_alternative_port (l->data, vino_alternative_port);
-}
-
-static void
-vino_prefs_lock_screen_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
-{
- gboolean lock_screen;
- GSList *l;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- lock_screen = gconf_value_get_bool (entry->value) != FALSE;
-
- if (vino_lock_screen == lock_screen)
- return;
-
- vino_lock_screen = lock_screen;
-
- dprintf (PREFS, "Lock Screen changed: %s\n", vino_lock_screen ? "(true)" : "(false)");
-
- for (l = vino_servers; l; l = l->next)
- vino_server_set_lock_screen (l->data, lock_screen);
-}
-
-static VinoStatusIconVisibility
-vino_prefs_icon_visibility_from_string (const char *value)
-{
- VinoStatusIconVisibility ret_value = VINO_STATUS_ICON_VISIBILITY_INVALID;
-
- if (!g_ascii_strcasecmp (value, "always"))
- ret_value = VINO_STATUS_ICON_VISIBILITY_ALWAYS;
- else if (!g_ascii_strcasecmp (value, "client"))
- ret_value = VINO_STATUS_ICON_VISIBILITY_CLIENT;
- else if (!g_ascii_strcasecmp (value, "never"))
- ret_value = VINO_STATUS_ICON_VISIBILITY_NEVER;
-
- return ret_value;
-}
-
-static void
-vino_prefs_icon_visibility_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
-{
- const gchar *entry_str;
- GSList *l;
- VinoStatusIconVisibility visibility;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_STRING)
- return;
-
- entry_str = gconf_value_get_string (entry->value);
- visibility = vino_prefs_icon_visibility_from_string (entry_str);
-
- if (visibility == vino_icon_visibility)
- return;
-
- vino_icon_visibility = visibility;
-
- dprintf (PREFS, "Icon visibility changed: %s\n", entry_str);
-
- for (l = vino_servers; l; l = l->next)
- {
- VinoStatusIcon *icon;
-
- icon = vino_server_get_status_icon (l->data);
- vino_status_icon_set_visibility (icon, visibility);
- }
-}
-
-static void
-vino_prefs_disable_background_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
-{
- gboolean disable_background;
- GSList *l;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- disable_background = gconf_value_get_bool (entry->value) != FALSE;
-
- if (vino_disable_background == disable_background)
- return;
-
- vino_disable_background = disable_background;
-
- dprintf (PREFS, "Disable background changed: %s\n", vino_disable_background ? "(true)" : "(false)");
-
- for (l = vino_servers; l; l = l->next)
- vino_server_set_disable_background (l->data, disable_background);
-}
-
-static void
-vino_prefs_use_upnp_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
+static gboolean
+get_inverted_boolean (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
{
- gboolean use_upnp;
- GSList *l;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- use_upnp = gconf_value_get_bool (entry->value) != FALSE;
-
- if (vino_use_upnp == use_upnp)
- return;
-
- vino_use_upnp = use_upnp;
-
- dprintf (PREFS, "Use UPNP changed: %s\n", vino_use_upnp ? "(true)" : "(false)");
-
- for (l = vino_servers; l; l = l->next)
- vino_server_set_use_upnp (l->data, use_upnp);
-}
-
-static void
-vino_prefs_disable_xdamage_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry)
-{
- gboolean disable_xdamage;
- GSList *l;
-
- if (!entry->value || entry->value->type != GCONF_VALUE_BOOL)
- return;
-
- disable_xdamage = gconf_value_get_bool (entry->value) != FALSE;
-
- if (vino_disable_xdamage == disable_xdamage)
- return;
-
- vino_disable_xdamage = disable_xdamage;
-
- dprintf (PREFS, "Disable XDamage: %s\n", vino_disable_xdamage ? "(true)" : "(false)");
-
- for (l = vino_servers; l; l = l->next)
- vino_server_set_disable_xdamage (l->data, disable_xdamage);
+ g_value_set_boolean (value, !g_variant_get_boolean (variant));
+ return TRUE;
}
void
@@ -498,41 +65,59 @@ vino_prefs_create_server (GdkScreen *screen)
VinoServer *server;
VinoStatusIcon *icon;
-
+ /* Start the server 'on-hold' until all the settings are in, then go. */
server = g_object_new (VINO_TYPE_SERVER,
- "prompt-enabled", vino_prompt_enabled,
- "view-only", vino_view_only,
- "network-interface", vino_network_interface,
- "use-alternative-port", vino_use_alternative_port,
- "alternative-port", vino_alternative_port,
- "auth-methods", vino_auth_methods,
- "require-encryption", vino_require_encryption,
- "vnc-password", vino_vnc_password,
- "on-hold", !vino_enabled,
- "screen", screen,
- "lock-screen", vino_lock_screen,
- "disable-background", vino_disable_background,
- "use-upnp", vino_use_upnp,
- "disable-xdamage", vino_disable_xdamage,
- NULL);
-
- vino_servers = g_slist_prepend (vino_servers, server);
- if (vino_enabled)
- vino_mdns_start (vino_network_interface);
+ "on-hold", TRUE,
+ "screen", screen,
+ NULL);
+ icon = vino_server_get_status_icon (server);
+
+ g_settings_bind (vino_settings, "prompt-enabled",
+ server, "prompt-enabled", G_SETTINGS_BIND_GET);
+ g_settings_bind (vino_settings, "view-only",
+ server, "view-only", G_SETTINGS_BIND_GET);
+ g_settings_bind (vino_settings, "network-interface",
+ server, "network-interface", G_SETTINGS_BIND_GET);
+ g_settings_bind (vino_settings, "use-alternative-port",
+ server, "use-alternative-port", G_SETTINGS_BIND_GET);
+ g_settings_bind (vino_settings, "alternative-port",
+ server, "alternative-port", G_SETTINGS_BIND_GET);
+ g_settings_bind (vino_settings, "authentication-methods",
+ server, "auth-methods", G_SETTINGS_BIND_GET);
+ g_settings_bind (vino_settings, "require-encryption",
+ server, "require-encryption", G_SETTINGS_BIND_GET);
+ g_settings_bind (vino_settings, "require-encryption",
+ server, "require-encryption", G_SETTINGS_BIND_GET);
+ g_settings_bind (vino_settings, "vnc-password",
+ server, "vnc-password", G_SETTINGS_BIND_GET);
+ g_settings_bind (vino_settings, "lock-screen-on-disconnect",
+ server, "lock-screen", G_SETTINGS_BIND_GET);
+ g_settings_bind (vino_settings, "disable-background",
+ server, "disable-background", G_SETTINGS_BIND_GET);
+ g_settings_bind (vino_settings, "use-upnp",
+ server, "use-upnp", G_SETTINGS_BIND_GET);
+ g_settings_bind (vino_settings, "disable-xdamage",
+ server, "disable-xdamage", G_SETTINGS_BIND_GET);
+ g_settings_bind (vino_settings, "icon-visibility",
+ icon, "visibility", G_SETTINGS_BIND_GET);
+
+ /* bind this one last */
+ g_settings_bind_with_mapping (vino_settings, "enabled",
+ server, "on-hold",
+ G_SETTINGS_BIND_GET,
+ get_inverted_boolean,
+ NULL, NULL, NULL);
g_signal_connect (server, "notify::alternative-port", G_CALLBACK (vino_prefs_restart_mdns), NULL);
g_signal_connect (server, "notify::use-alternative-port", G_CALLBACK(vino_prefs_restart_mdns), NULL);
g_signal_connect (server, "notify::network-interface", G_CALLBACK (vino_prefs_restart_mdns), NULL);
-
- icon = vino_server_get_status_icon (server);
- vino_status_icon_set_visibility (icon, vino_icon_visibility);
}
static void
vino_prefs_restore_background (void)
{
- if (vino_background_get_status ())
- vino_background_draw (TRUE);
+ if (g_settings_get_boolean (vino_settings, "disable-background"))
+ g_settings_set_boolean (background_settings, "draw-background", TRUE);
}
static gchar *
@@ -613,259 +198,25 @@ vino_prefs_sighandler (int sig)
void
vino_prefs_init (gboolean view_only)
{
- GSList *auth_methods_list, *l;
- int i = 0;
- char *key_str;
-
+ background_settings = g_settings_new ("org.gnome.desktop.background");
+ vino_settings = g_settings_new ("org.gnome.Vino");
+
signal (SIGINT, vino_prefs_sighandler); /* Ctrl+C */
signal (SIGQUIT, vino_prefs_sighandler);
signal (SIGTERM, vino_prefs_sighandler); /* kill -15 */
signal (SIGSEGV, vino_prefs_sighandler); /* Segmentation fault */
- vino_client = gconf_client_get_default ();
-
- gconf_client_add_dir (vino_client,
- VINO_PREFS_DIR,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
-
if(!vino_prefs_lock ())
vino_prefs_restore_background ();
-
- vino_enabled = gconf_client_get_bool (vino_client, VINO_PREFS_ENABLED, NULL);
- dprintf (PREFS, "Access enabled: %s\n", vino_enabled ? "(true)" : "(false)");
-
- vino_prompt_enabled = gconf_client_get_bool (vino_client,
- VINO_PREFS_PROMPT_ENABLED,
- NULL);
- dprintf (PREFS, "Prompt enabled: %s\n", vino_prompt_enabled ? "(true)" : "(false)");
-
- if (view_only)
- {
- vino_view_only = TRUE;
- }
- else
- {
- vino_view_only = gconf_client_get_bool (vino_client,
- VINO_PREFS_VIEW_ONLY,
- NULL);
- }
- dprintf (PREFS, "View only: %s\n", vino_view_only ? "(true)" : "(false)");
-
- vino_network_interface = gconf_client_get_string (vino_client,
- VINO_PREFS_NETWORK_INTERFACE,
- NULL);
- /* Check for old key, local_only, vino <= 2.24 */
- if (!vino_network_interface && gconf_client_get_bool (vino_client, VINO_PREFS_LOCAL_ONLY, NULL))
- {
- gconf_client_set_string (vino_client, VINO_PREFS_NETWORK_INTERFACE, "lo", NULL);
- vino_network_interface = g_strdup ("lo");
- }
- dprintf (PREFS, "Network interface: %s\n",
- vino_network_interface ? vino_network_interface : "all");
-
- vino_use_alternative_port = gconf_client_get_bool (vino_client,
- VINO_PREFS_USE_ALTERNATIVE_PORT,
- NULL);
-
- dprintf (PREFS, "Use alternative port: %s\n",
- vino_use_alternative_port ? "(true)" : "(false)");
-
- vino_alternative_port = gconf_client_get_int (vino_client,
- VINO_PREFS_ALTERNATIVE_PORT,
- NULL);
- if (!VINO_SERVER_VALID_PORT (vino_alternative_port))
- vino_alternative_port = VINO_SERVER_DEFAULT_PORT;
- dprintf (PREFS, "Alternative port: %d\n", vino_alternative_port);
-
- vino_require_encryption = gconf_client_get_bool (vino_client,
- VINO_PREFS_REQUIRE_ENCRYPTION,
- NULL);
- dprintf (PREFS, "Require encryption: %s\n", vino_require_encryption ? "(true)" : "(false)");
-
- auth_methods_list = gconf_client_get_list (vino_client,
- VINO_PREFS_AUTHENTICATION_METHODS,
- GCONF_VALUE_STRING,
- NULL);
-
- dprintf (PREFS, "Authentication methods:");
- vino_auth_methods = vino_prefs_translate_auth_methods_list (auth_methods_list, FALSE);
- dprintf (PREFS, "\n");
-
- for (l = auth_methods_list; l; l = l->next)
- g_free (l->data);
- g_slist_free (auth_methods_list);
-
- vino_vnc_password = gconf_client_get_string (vino_client,
- VINO_PREFS_VNC_PASSWORD,
- NULL);
- dprintf (PREFS, "Encoded password: %s\n", vino_vnc_password ? vino_vnc_password : "(null)");
-
- vino_lock_screen = gconf_client_get_bool (vino_client,
- VINO_PREFS_LOCK_SCREEN,
- NULL);
- dprintf (PREFS, "Lock screen on disconnect: %s\n",
- vino_lock_screen ? "(true)" : "(false)");
-
- vino_disable_background = gconf_client_get_bool (vino_client,
- VINO_PREFS_DISABLE_BACKGROUND,
- NULL);
- dprintf (PREFS, "Disable background: %s\n", vino_disable_background ? "(true)" : "(false)");
-
- vino_use_upnp = gconf_client_get_bool (vino_client,
- VINO_PREFS_USE_UPNP,
- NULL);
- dprintf (PREFS, "Use UPNP: %s\n", vino_use_upnp ? "(true)" : "(false)");
-
- vino_disable_xdamage = gconf_client_get_bool (vino_client,
- VINO_PREFS_DISABLE_XDAMAGE,
- NULL);
- dprintf (PREFS, "Disable XDamage: %s\n", vino_disable_xdamage ? "(true)" : "(false)");
-
- key_str = gconf_client_get_string (vino_client,
- VINO_PREFS_ICON_VISIBILITY,
- NULL);
- vino_icon_visibility = vino_prefs_icon_visibility_from_string (key_str);
- dprintf (PREFS, "Icon policy: %s\n", key_str);
- g_free (key_str);
-
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_ENABLED,
- (GConfClientNotifyFunc) vino_prefs_enabled_changed,
- NULL, NULL, NULL);
- i++;
-
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_PROMPT_ENABLED,
- (GConfClientNotifyFunc) vino_prefs_prompt_enabled_changed,
- NULL, NULL, NULL);
- i++;
-
- if (!view_only)
- {
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_VIEW_ONLY,
- (GConfClientNotifyFunc) vino_prefs_view_only_changed,
- NULL, NULL, NULL);
- }
- i++;
-
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_NETWORK_INTERFACE,
- (GConfClientNotifyFunc) vino_prefs_network_interface_changed,
- NULL, NULL, NULL);
- i++;
-
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_USE_ALTERNATIVE_PORT,
- (GConfClientNotifyFunc) vino_prefs_use_alternative_port_changed,
- NULL, NULL, NULL);
- i++;
-
-
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_ALTERNATIVE_PORT,
- (GConfClientNotifyFunc) vino_prefs_alternative_port_changed,
- NULL, NULL, NULL);
- i++;
-
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_REQUIRE_ENCRYPTION,
- (GConfClientNotifyFunc) vino_prefs_require_encryption_changed,
- NULL, NULL, NULL);
- i++;
-
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_AUTHENTICATION_METHODS,
- (GConfClientNotifyFunc) vino_prefs_authentication_methods_changed,
- NULL, NULL, NULL);
- i++;
-
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_VNC_PASSWORD,
- (GConfClientNotifyFunc) vino_prefs_vnc_password_changed,
- NULL, NULL, NULL);
- i++;
-
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_LOCK_SCREEN,
- (GConfClientNotifyFunc) vino_prefs_lock_screen_changed,
- NULL, NULL, NULL);
-
- i++;
-
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_ICON_VISIBILITY,
- (GConfClientNotifyFunc) vino_prefs_icon_visibility_changed,
- NULL, NULL, NULL);
-
- i++;
-
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_DISABLE_BACKGROUND,
- (GConfClientNotifyFunc) vino_prefs_disable_background_changed,
- NULL, NULL, NULL);
-
- i++;
-
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_USE_UPNP,
- (GConfClientNotifyFunc) vino_prefs_use_upnp_changed,
- NULL, NULL, NULL);
-
- i++;
-
- vino_listeners [i] =
- gconf_client_notify_add (vino_client,
- VINO_PREFS_DISABLE_XDAMAGE,
- (GConfClientNotifyFunc) vino_prefs_disable_xdamage_changed,
- NULL, NULL, NULL);
-
- i++;
-
- g_assert (i == VINO_N_LISTENERS);
}
void
vino_prefs_shutdown (void)
{
- GSList *l;
- int i;
-
- for (l = vino_servers; l; l = l->next)
- g_object_unref (l->data);
- g_slist_free (vino_servers);
- vino_servers = NULL;
-
- if (vino_vnc_password)
- g_free (vino_vnc_password);
- vino_vnc_password = NULL;
-
- if (vino_network_interface)
- g_free (vino_network_interface);
- vino_network_interface = NULL;
-
- for (i = 0; i < VINO_N_LISTENERS; i++) {
- if (vino_listeners [i])
- gconf_client_notify_remove (vino_client, vino_listeners [i]);
- vino_listeners [i] = 0;
- }
-
- g_object_unref (vino_client);
- vino_client = NULL;
+ g_object_unref (background_settings);
+ g_object_unref (vino_settings);
+ background_settings = NULL;
+ vino_settings = NULL;
vino_prefs_unlock ();
}
diff --git a/server/vino-server.c b/server/vino-server.c
index 3c10d1c..2a76b54 100644
--- a/server/vino-server.c
+++ b/server/vino-server.c
@@ -35,11 +35,9 @@
#include "vino-prompt.h"
#include "vino-dbus-listener.h"
#include "vino-util.h"
-#include "vino-enums.h"
-#include "vino-background.h"
#include "vino-upnp.h"
+#include "vino-enums.h"
#include <sys/poll.h>
-#include <dbus/dbus-glib.h>
#include <gtk/gtk.h>
#ifdef VINO_ENABLE_KEYRING
@@ -147,18 +145,15 @@ static gpointer parent_class;
static void
vino_server_lock_screen (VinoServer *server)
{
-
- DBusGConnection *connection;
- GError *error;
- DBusGProxy *proxy;
+ GDBusConnection *connection;
+ GError *error = NULL;
if (!server->priv->lock_screen)
return;
-
+
dprintf(DBUS, "Locking screen via gnome-screensaver\n");
- error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
if (!connection)
{
dprintf (DBUS, _("Failed to open connection to bus: %s\n"), error->message);
@@ -166,29 +161,22 @@ vino_server_lock_screen (VinoServer *server)
return;
}
- proxy = dbus_g_proxy_new_for_name (connection,
- GNOME_SCREENSAVER_BUS_NAME,
- GNOME_SCREENSAVER_PATH,
- GNOME_SCREENSAVER_INTERFACE);
-
- dbus_g_proxy_call_no_reply (proxy, "Lock", G_TYPE_INVALID);
-
- g_object_unref (proxy);
- dbus_g_connection_unref (connection);
+ g_dbus_connection_call (connection, GNOME_SCREENSAVER_BUS_NAME,
+ GNOME_SCREENSAVER_PATH, GNOME_SCREENSAVER_INTERFACE,
+ "Lock", NULL, NULL,
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
+ g_object_unref (connection);
}
static void
vino_server_unlock_screen (void)
{
-
- DBusGConnection *connection;
- GError *error;
- DBusGProxy *proxy;
+ GDBusConnection *connection;
+ GError *error = NULL;
dprintf(DBUS, "Unlocking screen via gnome-screensaver\n");
- error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
if (!connection)
{
dprintf (DBUS, _("Failed to open connection to bus: %s\n"), error->message);
@@ -196,15 +184,11 @@ vino_server_unlock_screen (void)
return;
}
- proxy = dbus_g_proxy_new_for_name (connection,
- GNOME_SCREENSAVER_BUS_NAME,
- GNOME_SCREENSAVER_PATH,
- GNOME_SCREENSAVER_INTERFACE);
-
- dbus_g_proxy_call_no_reply (proxy, "SimulateUserActivity", G_TYPE_INVALID);
-
- g_object_unref (proxy);
- dbus_g_connection_unref (connection);
+ g_dbus_connection_call (connection, GNOME_SCREENSAVER_BUS_NAME,
+ GNOME_SCREENSAVER_PATH, GNOME_SCREENSAVER_INTERFACE,
+ "SimulateUserActivity", NULL, NULL,
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
+ g_object_unref (connection);
}
#undef GNOME_SCREENSAVER_BUS_NAME
@@ -300,6 +284,21 @@ vino_server_get_disable_xdamage (VinoServer *server)
}
static void
+vino_background_draw (gboolean status)
+{
+ static GSettings *background_settings;
+ gsize initialised;
+
+ if (g_once_init_enter (&initialised))
+ {
+ background_settings = g_settings_new ("org.gnome.desktop.background");
+ g_once_init_leave (&initialised, TRUE);
+ }
+
+ g_settings_set_boolean (background_settings, "draw-background", status);
+}
+
+static void
vino_server_client_accepted (VinoServer *server,
VinoClient *client)
{
@@ -309,7 +308,7 @@ vino_server_client_accepted (VinoServer *server,
vino_server_unlock_screen ();
if (vino_server_get_disable_background (server))
- vino_background_draw (FALSE);
+ vino_background_draw (FALSE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]