vinagre r161 - trunk/src



Author: jwendell
Date: Wed Jan 30 18:44:43 2008
New Revision: 161
URL: http://svn.gnome.org/viewvc/vinagre?rev=161&view=rev

Log:
Handle vnc:// protocol

Modified:
   trunk/src/vinagre-main.c
   trunk/src/vinagre-utils.c

Modified: trunk/src/vinagre-main.c
==============================================================================
--- trunk/src/vinagre-main.c	(original)
+++ trunk/src/vinagre-main.c	Wed Jan 30 18:44:43 2008
@@ -33,6 +33,7 @@
 
 /* command line */
 static gchar **files = NULL;
+static gchar **urls = NULL;
 static gchar **remaining_args = NULL;
 static GSList *servers = NULL;
 
@@ -41,6 +42,9 @@
   { "file", 'f', 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
     N_("Opens a .vnc file"), N_("filename")},
 
+  { "url", 'u', 0, G_OPTION_ARG_STRING_ARRAY, &urls,
+    N_("Handles an URL like vnc://host[:port]"), N_("url")},
+
   { 
     G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args,
     NULL, N_("[server:port]") },
@@ -54,7 +58,9 @@
   gint               i;
   VinagreConnection *conn;
   gchar             *error;
-  GSList            *errors = NULL;
+  gchar             **url;
+  GSList            *file_errors = NULL;
+  GSList            *url_errors = NULL;
 
   if (files)
     {
@@ -62,15 +68,35 @@
 	{
 	  conn = vinagre_connection_new_from_file (files[i], &error);
 	  if (conn)
-	    servers = g_slist_append (servers, conn);
+	    servers = g_slist_prepend (servers, conn);
 	  else
 	    {
-	      errors = g_slist_append (errors, files[i]);
+	      file_errors = g_slist_prepend (file_errors, g_strdup (files[i]));
 	      if (error)
 	        g_free (error);
 	    }
 	}
-      g_free (files);
+      g_strfreev (files);
+    }
+
+  if (urls)
+    {
+      for (i = 0; urls[i]; i++) 
+	{
+	  url = g_strsplit (urls[i], "://", 2);
+	  if (g_strv_length (url) == 2)
+	    {
+	      conn = vinagre_connection_new_from_string (url[1]);
+	      if (conn)
+		servers = g_slist_prepend (servers, conn);
+	    }
+	  else
+	    {
+	      url_errors = g_slist_prepend (url_errors, g_strdup (urls[i]));
+	    }
+	  g_strfreev (url);
+	}
+      g_strfreev (urls);
     }
 
   if (remaining_args)
@@ -79,17 +105,31 @@
 	{
 	  conn = vinagre_connection_new_from_string (remaining_args[i]);
 	  if (conn)
-	    servers = g_slist_append (servers, conn);
+	    servers = g_slist_prepend (servers, conn);
 	}
-      g_free (remaining_args);
+      g_strfreev (remaining_args);
+    }
+
+  if (file_errors)
+    {
+      vinagre_utils_show_many_errors (ngettext ("The following file could not be opened:",
+						"The following files could not be opened:",
+						g_slist_length (file_errors)),
+				      file_errors,
+				      GTK_WINDOW (window));
+      g_slist_free (file_errors);
+    }
+
+  if (url_errors)
+    {
+      vinagre_utils_show_many_errors (ngettext ("The following URL could not be opened:",
+						"The following URL's could not be opened:",
+						g_slist_length (url_errors)),
+				      url_errors,
+				      GTK_WINDOW (window));
+      g_slist_free (url_errors);
     }
 
-  if (errors)
-    vinagre_utils_show_many_errors (ngettext ("The following file could not be opened:",
-					      "The following files could not be opened:",
-					      g_slist_length (errors)),
-				    errors,
-				    GTK_WINDOW (window));
 }
 
 int main (int argc, char **argv) {

Modified: trunk/src/vinagre-utils.c
==============================================================================
--- trunk/src/vinagre-utils.c	(original)
+++ trunk/src/vinagre-utils.c	Wed Jan 30 18:44:43 2008
@@ -2,7 +2,7 @@
  * vinagre-utils.c
  * This file is part of vinagre
  *
- * Copyright (C) 2007 - Jonh Wendell <wendell bani com br>
+ * Copyright (C) 2007,2008 - Jonh Wendell <wendell bani com br>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -151,13 +151,9 @@
   g_string_append_c (msg, '\n');
 
   for (l = items; l; l = l->next)
-    {
-      g_string_append_printf (msg, "\n%s", (gchar *)l->data);
-      g_free (l->data);
-    }
-
-    vinagre_utils_show_error (msg->str, parent);
-    g_slist_free (items);
-    g_string_free (msg, TRUE);
+    g_string_append_printf (msg, "\n%s", (gchar *)l->data);
+
+  vinagre_utils_show_error (msg->str, parent);
+  g_string_free (msg, TRUE);
 }
 /* vim: ts=8 */



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