vino r989 - in trunk: . capplet server
- From: jwendell svn gnome org
- To: svn-commits-list gnome org
- Subject: vino r989 - in trunk: . capplet server
- Date: Wed, 8 Oct 2008 20:05:57 +0000 (UTC)
Author: jwendell
Date: Wed Oct 8 20:05:56 2008
New Revision: 989
URL: http://svn.gnome.org/viewvc/vino?rev=989&view=rev
Log:
2008-10-08 Jonh Wendell <jwendell gnome org>
Update label in vino-preferences when the port changes.
* server/vino-dbus-listener.c: Send a dbus signal when port changes.
* capplet/vino-preferences.c: Listen to this signal and updates
the label.
Modified:
trunk/ChangeLog
trunk/capplet/vino-preferences.c
trunk/server/vino-dbus-listener.c
trunk/server/vino-dbus-listener.h
Modified: trunk/capplet/vino-preferences.c
==============================================================================
--- trunk/capplet/vino-preferences.c (original)
+++ trunk/capplet/vino-preferences.c Wed Oct 8 20:05:56 2008
@@ -93,11 +93,15 @@
UniqueApp *app;
#endif
+ DBusGConnection *connection;
+ DBusGProxy *proxy_name, *proxy_port;
+
guint listeners [N_LISTENERS];
int n_listeners;
int expected_listeners;
guint use_password : 1;
+
} VinoPreferencesDialog;
static void
@@ -1084,31 +1088,37 @@
}
static void
-vino_preferences_start_listening (VinoPreferencesDialog *dialog)
+vino_preferences_server_port_changed (DBusGProxy *proxy, gpointer user_data)
{
- DBusGConnection *connection;
- GError *error;
- DBusGProxy *proxy;
-
- error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (!connection)
- {
- g_printerr (_("Failed to open connection to bus: %s\n"),
- error->message);
- g_error_free (error);
- return;
- }
+ vino_preferences_dialog_update_url_label ( (VinoPreferencesDialog *) user_data);
+}
- proxy = dbus_g_proxy_new_for_name (connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
+static void
+vino_preferences_start_listening (VinoPreferencesDialog *dialog)
+{
+ gchar *obj_path;
+ GdkScreen *screen;
- dbus_g_proxy_add_signal (proxy, "NameOwnerChanged",
+ dialog->proxy_name = dbus_g_proxy_new_for_name (dialog->connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+ dbus_g_proxy_add_signal (dialog->proxy_name, "NameOwnerChanged",
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (proxy, "NameOwnerChanged",
+ dbus_g_proxy_connect_signal (dialog->proxy_name, "NameOwnerChanged",
G_CALLBACK (vino_preferences_server_updated), dialog, NULL);
+
+ screen = gtk_window_get_screen (GTK_WINDOW (dialog->dialog));
+ obj_path = g_strdup_printf ("/org/gnome/vino/screens/%d",
+ gdk_screen_get_number (screen));
+ dialog->proxy_port = dbus_g_proxy_new_for_name (dialog->connection,
+ VINO_DBUS_BUS_NAME,
+ obj_path,
+ VINO_DBUS_INTERFACE);
+ g_free (obj_path);
+ dbus_g_proxy_add_signal (dialog->proxy_port, "ServerPortChanged", G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (dialog->proxy_port, "ServerPortChanged",
+ G_CALLBACK (vino_preferences_server_port_changed), dialog, NULL);
}
static int
@@ -1118,48 +1128,31 @@
#define VINO_MIN_PORT 5000
#define VINO_MAX_PORT 6000
- DBusGConnection *connection;
- GError *error;
- DBusGProxy *proxy;
- int port;
- GdkScreen *screen;
- char *obj_path;
+ DBusGProxy *proxy;
+ int port;
+ GdkScreen *screen;
+ char *obj_path;
- error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (!connection)
- {
- g_printerr (_("Failed to open connection to bus: %s\n"),
- error->message);
- g_error_free (error);
- return 0;
- }
-
screen = gtk_window_get_screen (GTK_WINDOW (dialog->dialog));
-
obj_path = g_strdup_printf ("/org/gnome/vino/screens/%d",
gdk_screen_get_number (screen));
- proxy = dbus_g_proxy_new_for_name (connection,
+ proxy = dbus_g_proxy_new_for_name (dialog->connection,
VINO_DBUS_BUS_NAME,
obj_path,
VINO_DBUS_INTERFACE);
-
g_free (obj_path);
- if (!dbus_g_proxy_call (proxy, "GetServerPort", &error,
+ if (!dbus_g_proxy_call (proxy, "GetServerPort", NULL,
G_TYPE_INVALID,
G_TYPE_INT, &port,
G_TYPE_INVALID))
{
g_object_unref (proxy);
- g_error_free (error);
- dbus_g_connection_unref (connection);
return 0;
}
g_object_unref (proxy);
- dbus_g_connection_unref (connection);
if (port >= VINO_MIN_PORT && port <= VINO_MAX_PORT)
return port - VINO_DEFAULT_PORT;
@@ -1176,48 +1169,31 @@
vino_preferences_get_http_server_port (VinoPreferencesDialog *dialog)
{
#define VINO_HTTP_DEFAULT_PORT 5800
- DBusGConnection *connection;
- GError *error;
- DBusGProxy *proxy;
- int port;
- GdkScreen *screen;
- char *obj_path;
+ DBusGProxy *proxy;
+ int port;
+ GdkScreen *screen;
+ char *obj_path;
- error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (!connection)
- {
- g_printerr (_("Failed to open connection to bus: %s\n"),
- error->message);
- g_error_free (error);
- return 0;
- }
-
screen = gtk_window_get_screen (GTK_WINDOW (dialog->dialog));
-
obj_path = g_strdup_printf ("/org/gnome/vino/screens/%d",
gdk_screen_get_number (screen));
- proxy = dbus_g_proxy_new_for_name (connection,
+ proxy = dbus_g_proxy_new_for_name (dialog->connection,
VINO_DBUS_BUS_NAME,
obj_path,
VINO_DBUS_INTERFACE);
-
g_free (obj_path);
- if (!dbus_g_proxy_call (proxy, "GetHttpServerPort", &error,
+ if (!dbus_g_proxy_call (proxy, "GetHttpServerPort", NULL,
G_TYPE_INVALID,
G_TYPE_INT, &port,
G_TYPE_INVALID))
{
g_object_unref (proxy);
- g_error_free (error);
- dbus_g_connection_unref (connection);
return VINO_HTTP_DEFAULT_PORT;
}
g_object_unref (proxy);
- dbus_g_connection_unref (connection);
return port;
#undef VINO_HTTP_DEFAULT_PORT
@@ -1464,6 +1440,7 @@
const char *glade_file;
gboolean allowed;
+ GError *error = NULL;
dialog->expected_listeners = N_LISTENERS;
@@ -1491,6 +1468,15 @@
dialog->client = gconf_client_get_default ();
gconf_client_add_dir (dialog->client, VINO_PREFS_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
+ dialog->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (!dialog->connection)
+ {
+ g_printerr (_("Failed to open connection to bus: %s\n"),
+ error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
vino_preferences_dialog_setup_url_labels (dialog);
dialog->writability_warning = glade_xml_get_widget (dialog->xml, "writability_warning");
@@ -1568,6 +1554,18 @@
g_object_unref (dialog->app);
dialog->app = NULL;
#endif
+
+ if (dialog->proxy_name)
+ g_object_unref (dialog->proxy_name);
+ dialog->proxy_name = NULL;
+
+ if (dialog->proxy_port)
+ g_object_unref (dialog->proxy_port);
+ dialog->proxy_port = NULL;
+
+ if (dialog->connection)
+ dbus_g_connection_unref (dialog->connection);
+ dialog->connection = NULL;
}
static gboolean
Modified: trunk/server/vino-dbus-listener.c
==============================================================================
--- trunk/server/vino-dbus-listener.c (original)
+++ trunk/server/vino-dbus-listener.c Wed Oct 8 20:05:56 2008
@@ -152,6 +152,8 @@
" <method name=\"GetServerPort\">\n"
" <arg name=\"port\" direction=\"out\" type=\"u\"/>\n"
" </method>\n"
+ " <signal name=\"ServerPortChanged\">\n"
+ " </signal>\n"
#ifdef VINO_ENABLE_HTTP_SERVER
" <method name=\"GetHttpServerPort\">\n"
" <arg name=\"port\" direction=\"out\" type=\"u\"/>\n"
@@ -300,6 +302,34 @@
#undef VINO_DBUS_INTERFACE
}
+static void
+vino_dbus_listener_port_changed (VinoServer *server, VinoDBusListener *listener)
+{
+ DBusMessage *message;
+ gchar *obj_path;
+
+ dprintf (DBUS, "Emitting ServerPortChanged signal\n");
+
+ obj_path = g_strdup_printf ("/org/gnome/vino/screens/%d",
+ gdk_screen_get_number (vino_server_get_screen (server)));
+
+ message = dbus_message_new_signal (obj_path,
+ "org.gnome.VinoScreen",
+ "ServerPortChanged");
+ g_free (obj_path);
+
+ if (!message)
+ {
+ g_warning ("Error creating signal\n");
+ return;
+ }
+
+ if (!dbus_connection_send (vino_dbus_get_connection (), message, NULL))
+ g_warning ("Error sending signal\n");
+
+ dbus_message_unref (message);
+}
+
static DBusObjectPathVTable vino_dbus_listener_vtable =
{
NULL, /* unregister_function */
@@ -338,6 +368,13 @@
dprintf (DBUS, "Object registered at path '%s'\n", obj_path);
+ g_signal_connect (server, "notify::alternative-port",
+ G_CALLBACK (vino_dbus_listener_port_changed),
+ listener);
+ g_signal_connect (server, "notify::use-alternative-port",
+ G_CALLBACK (vino_dbus_listener_port_changed),
+ listener);
+
g_free (obj_path);
}
Modified: trunk/server/vino-dbus-listener.h
==============================================================================
--- trunk/server/vino-dbus-listener.h (original)
+++ trunk/server/vino-dbus-listener.h Wed Oct 8 20:05:56 2008
@@ -62,10 +62,6 @@
G_END_DECLS
-/*
- * FIXME: remove define when we can require dbus-1 >= 0.95
- */
-#define DBUS_API_SUBJECT_TO_CHANGE
#include <dbus/dbus.h>
G_BEGIN_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]