[Goodies-commits] r7003 - in gigolo/trunk: . src

Enrico Troeger enrico at xfce.org
Thu Mar 26 19:25:27 CET 2009


Author: enrico
Date: 2009-03-26 18:25:27 +0000 (Thu, 26 Mar 2009)
New Revision: 7003

Modified:
   gigolo/trunk/ChangeLog
   gigolo/trunk/src/bookmark.c
   gigolo/trunk/src/main.c
Log:
Improve extracting the share name of an URI.
Extract also domain names from usernames (e.g. "smb://mydomain;myusername@host/share").

Modified: gigolo/trunk/ChangeLog
===================================================================
--- gigolo/trunk/ChangeLog	2009-03-26 18:25:21 UTC (rev 7002)
+++ gigolo/trunk/ChangeLog	2009-03-26 18:25:27 UTC (rev 7003)
@@ -5,6 +5,10 @@
    GIO_USE_VOLUME_MONITOR is set and if so, use its value as default.
  * src/backendgvfs.c:
    Don't show error message dialog when auto-connecting bookmarks.
+ * src/bookmark.c:
+   Improve extracting the share name of an URI.
+   Extract also domain names from usernames (e.g.
+   "smb://mydomain;myusername@host/share").
 
 
 2009-03-22  Enrico Tröger  <enrico(at)xfce(dot)org>

Modified: gigolo/trunk/src/bookmark.c
===================================================================
--- gigolo/trunk/src/bookmark.c	2009-03-26 18:25:21 UTC (rev 7002)
+++ gigolo/trunk/src/bookmark.c	2009-03-26 18:25:27 UTC (rev 7003)
@@ -98,7 +98,7 @@
 
 static gboolean parse_uri(GigoloBookmark *bm, const gchar *uri)
 {
-	gchar *s, *t, *x, *end;
+	gchar *s, *t, *x, *end, *tmp;
 	guint l;
 	GigoloBookmarkPrivate *priv = GIGOLO_BOOKMARK_GET_PRIVATE(bm);
 
@@ -139,14 +139,25 @@
 			bookmark_clear(bm);
 			return FALSE;
 		}
-		priv->user = g_strndup(s, l);
+		tmp = g_strndup(s, l);
+		/* look for a domain in the username, e.g. "mydomain;myuser" */
+		if (strchr(tmp, ';') != NULL)
+		{
+			gchar **fields = g_strsplit(tmp, ";", 2);
+			priv->domain = fields[0];
+			priv->user = fields[1];
+
+			g_free(fields); /* we free only the array, not the elements */
+		}
+		else
+			priv->user = tmp;
 	}
 
 	/* find hostname */
 	s = (t) ? t + 1 : s;
 	if (*s == '[') /* obex://[00:12:D1:94:1B:28]/ or http://[1080:0:0:0:8:800:200C:417A]/index.html */
 	{
-		gchar *hostend, *tmp;
+		gchar *hostend;
 
 		s++; /* skip the found '[' */
 		hostend = strchr(s, ']');
@@ -184,8 +195,6 @@
 	t = strchr(s, ':');
 	if (t != NULL)
 	{
-		gchar *tmp;
-
 		t++; /* skip the found ':' */
 		l = 0;
 		x = t;
@@ -200,9 +209,20 @@
 		priv->port = (guint) atoi(tmp);
 		g_free(tmp);
 	}
-	if (NZV(end))
-		priv->share = g_strdup(end + 1);
+	if (NZV(end) && *end == '/')
+	{
+		end++; /* skip the slash */
 
+		l = 0;
+		x = end;
+		while (*x != '\0' && *x != '/')
+		{
+			l++; /* count the len of the share name */
+			x++;
+		}
+		priv->share = g_strndup(end, l);
+	}
+
 	return TRUE;
 }
 

Modified: gigolo/trunk/src/main.c
===================================================================
--- gigolo/trunk/src/main.c	2009-03-26 18:25:21 UTC (rev 7002)
+++ gigolo/trunk/src/main.c	2009-03-26 18:25:27 UTC (rev 7003)
@@ -155,7 +155,7 @@
 		g_setenv("GIO_USE_VOLUME_MONITOR", vm_impl, 0);
 
 	window = gigolo_window_new(settings);
-    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
+	g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
 
 	if (gis != NULL)
 		gigolo_single_instance_set_parent(gis, GTK_WINDOW(window));




More information about the Goodies-commits mailing list