vino r1130 - in trunk: . capplet server



Author: jwendell
Date: Fri Feb 27 12:51:21 2009
New Revision: 1130
URL: http://svn.gnome.org/viewvc/vino?rev=1130&view=rev

Log:
2009-02-27  Jonh Wendell  <jwendell gnome org>

	* capplet/vino-preferences.c,
	* server/vino-mdns.[ch],
	* server/vino-dbus-listener.c:
	Fixes #330691 â show .local hostname if avahi is present.



Modified:
   trunk/ChangeLog
   trunk/capplet/vino-preferences.c
   trunk/server/vino-dbus-listener.c
   trunk/server/vino-mdns.c
   trunk/server/vino-mdns.h

Modified: trunk/capplet/vino-preferences.c
==============================================================================
--- trunk/capplet/vino-preferences.c	(original)
+++ trunk/capplet/vino-preferences.c	Fri Feb 27 12:51:21 2009
@@ -821,31 +821,41 @@
 static void
 error_message (VinoPreferencesDialog *dialog)
 {
-  gchar *msg1, *msg2, *host, *url, *message;
+  gchar   *host, *avahi_host;
+  GString *message, *url;
+
+  url = g_string_new (NULL);
+  message = g_string_new (_("Your desktop is only reachable over the local network."));
 
   if (!dbus_g_proxy_call (dialog->proxy,
                           "GetInternalData",
                           NULL,
                           G_TYPE_INVALID,
                           G_TYPE_STRING, &host,
+                          G_TYPE_STRING, &avahi_host,
                           G_TYPE_INT, &dialog->port,
                           G_TYPE_INVALID))
     {
       dialog->port = 5900;
       host = g_strdup ("localhost");
+      avahi_host = NULL;
     }
 
-  url = g_strdup_printf ("<a href=\"vnc://%s::%d\">%s</a>", host, dialog->port, host);
-  msg1 = g_strdup (_("Your desktop is only reachable over the local network."));
-  msg2 = g_strdup_printf (_("Others can access your computer using the address %s."), url);
-  message = g_strjoin (" ", msg1, msg2, NULL);
+  
+  g_string_append_printf (url, "<a href=\"vnc://%s::%d\">%s</a>", host, dialog->port, host);
+
+  if (avahi_host && avahi_host[0])
+    g_string_append_printf (url, " , <a href=\"vnc://%s::%d\">%s</a>", avahi_host, dialog->port, avahi_host);
+
+  g_string_append_c (message, ' ');
+  g_string_append_printf (message, _("Others can access your computer using the address %s."), url->str);
   vino_message_box_hide_image (VINO_MESSAGE_BOX (dialog->message));
-  vino_message_box_set_label (VINO_MESSAGE_BOX (dialog->message), message);
-  g_free (msg1);
-  g_free (msg2);
-  g_free (message);
-  g_free (url);
+  vino_message_box_set_label (VINO_MESSAGE_BOX (dialog->message), message->str);
+
+  g_string_free (message, TRUE);
+  g_string_free (url, TRUE);
   g_free (host);
+  g_free (avahi_host);
 }
 
 static void
@@ -856,7 +866,7 @@
   GHashTable     *hash;
   GHashTableIter iter;
   gpointer       key, value;
-  gchar          *ip, *message, *url;
+  gchar          *ip;
 
   error = NULL;
   ip = NULL;
@@ -886,12 +896,37 @@
 
       if (status)
 	{
-	  url = g_strdup_printf ("<a href=\"vnc://%s::%d\">%s</a>", ip, dialog->port, ip);
-	  message = g_strdup_printf (_("Others can access your computer using the address %s."), url);
+	  gchar   *avahi_host, *host, *message;
+	  gint     port;
+	  GString *url;
+
+	  if (!dbus_g_proxy_call (dialog->proxy,
+                             "GetInternalData",
+                             NULL,
+                             G_TYPE_INVALID,
+                             G_TYPE_STRING, &host,
+                             G_TYPE_STRING, &avahi_host,
+                             G_TYPE_INT, &port,
+                             G_TYPE_INVALID))
+	    {
+	      host = NULL;
+	      avahi_host = NULL;
+	    }
+
+	  url = g_string_new (NULL);
+	  g_string_append_printf (url, "<a href=\"vnc://%s::%d\">%s</a>", ip, dialog->port, ip);
+
+	  if (avahi_host && avahi_host[0])
+	    g_string_append_printf (url, " , <a href=\"vnc://%s::%d\">%s</a>", avahi_host, port, avahi_host);
+
+	  message = g_strdup_printf (_("Others can access your computer using the address %s."), url->str);
 	  vino_message_box_hide_image (VINO_MESSAGE_BOX (dialog->message));
 	  vino_message_box_set_label (VINO_MESSAGE_BOX (dialog->message), message);
+
 	  g_free (message);
-	  g_free (url);
+	  g_string_free (url, TRUE);
+	  g_free (host);
+	  g_free (avahi_host);
 	}
       else
 	error_message (dialog);

Modified: trunk/server/vino-dbus-listener.c
==============================================================================
--- trunk/server/vino-dbus-listener.c	(original)
+++ trunk/server/vino-dbus-listener.c	Fri Feb 27 12:51:21 2009
@@ -42,6 +42,7 @@
 #include <dbus/dbus-glib-lowlevel.h>
 
 #include "vino-util.h"
+#include "vino-mdns.h"
 #ifdef VINO_ENABLE_HTTP_SERVER
 #include "vino-http.h"
 #endif
@@ -243,6 +244,7 @@
   "  <interface name=\"org.gnome.VinoScreen\">\n"
   "    <method name=\"GetInternalData\">\n"
   "      <arg name=\"hostname\" direction=\"out\" type=\"s\"/>\n"
+  "      <arg name=\"avahi_hostname\" direction=\"out\" type=\"s\"/>\n"
   "      <arg name=\"port\" direction=\"out\" type=\"d\"/>\n"
   "    </method>\n"
   "    <method name=\"GetExternalPort\">\n"
@@ -320,6 +322,7 @@
   DBusMessage *reply;
   gint        port;
   char        *host = NULL;
+  const char  *avahi_host;
 
   if (!(reply = dbus_message_new_method_return (message)))
     goto oom;
@@ -331,8 +334,10 @@
 #endif
 
   host = get_local_hostname (listener);
+  avahi_host = vino_mdns_get_hostname ();
   if (!dbus_message_append_args (reply,
                                  DBUS_TYPE_STRING, &host,
+                                 DBUS_TYPE_STRING, &avahi_host,
                                  DBUS_TYPE_INT32, &port,
                                  DBUS_TYPE_INVALID))
     goto oom;

Modified: trunk/server/vino-mdns.c
==============================================================================
--- trunk/server/vino-mdns.c	(original)
+++ trunk/server/vino-mdns.c	Fri Feb 27 12:51:21 2009
@@ -333,6 +333,12 @@
   mdns_services = NULL;
 }
 
+const char *
+vino_mdns_get_hostname (void)
+{
+  return avahi_client_get_host_name_fqdn (mdns_client);
+}
+
 #else /* !defined (VINO_HAVE_AVAHI) */
 
 void 
@@ -356,4 +362,10 @@
 {
 }
 
+const char *
+vino_mdns_get_hostname (void)
+{
+  return "";
+}
+
 #endif /* VINO_HAVE_AVAHI */

Modified: trunk/server/vino-mdns.h
==============================================================================
--- trunk/server/vino-mdns.h	(original)
+++ trunk/server/vino-mdns.h	Fri Feb 27 12:51:21 2009
@@ -35,6 +35,8 @@
 void vino_mdns_stop  (void);
 void vino_mdns_shutdown (void);
 
+const char *vino_mdns_get_hostname (void);
+
 G_END_DECLS
 
 #endif /* __VINO_MDNS_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]