[evolution-patches] folder info->path removal patch




I got bored with fixing crappy little bugs today so I took on the removal of the now redundant 'path' from CamelFolderInfo.

Ahh yeah, so this was a bit more involved than I thought it would be.  But I think I managed to get all cases - not really sure so sending this patch out for comment.  All the basics seem to work, dnd folders, renaming folders, filters auto-fixing, etc.

Michael Zucchi <notzed ximian com>

Ximian Evolution and Free Software Developer


Novell, Inc.
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.2146
diff -u -3 -r1.2146 ChangeLog
--- camel/ChangeLog	24 May 2004 08:02:10 -0000	1.2146
+++ camel/ChangeLog	25 May 2004 11:10:36 -0000
@@ -1,3 +1,11 @@
+2004-05-25  Not Zed  <NotZed Ximian com>
+
+	* camel-store.c (camel_folder_info_build_path): removed.
+
+	* camel-store.h (CamelFolderInfo): removed 'path', fixed all
+	callers.
+	(struct _CamelStore): removed 'dir_sep' fixed all uses.
+
 2004-05-24  Not Zed  <NotZed Ximian com>
 
 	* camel-mime-utils.c (camel_header_newsgroups_decode):
Index: camel/camel-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-store.c,v
retrieving revision 1.151
diff -u -3 -r1.151 camel-store.c
--- camel/camel-store.c	22 May 2004 01:37:22 -0000	1.151
+++ camel/camel-store.c	25 May 2004 11:10:36 -0000
@@ -138,8 +138,6 @@
 	/* set vtrash and vjunk on by default */
 	store->flags = CAMEL_STORE_VTRASH | CAMEL_STORE_VJUNK;
 
-	store->dir_sep = '/';
-	
 	store->priv = g_malloc0 (sizeof (*store->priv));
 	store->priv->folder_lock = e_mutex_new (E_MUTEX_REC);
 }
@@ -459,7 +457,7 @@
 			     strcmp(folder->full_name, old_name) == 0)
 			    || ((namelen > oldlen)
 				&& strncmp(folder->full_name, old_name, oldlen) == 0
-				&& folder->full_name[oldlen] == store->dir_sep)) {
+				&& folder->full_name[oldlen] == '/')) {
 				d(printf("Found subfolder of '%s' == '%s'\n", old_name, folder->full_name));
 				CAMEL_FOLDER_LOCK(folder, lock);
 			} else {
@@ -730,7 +728,6 @@
 		g_free (vinfo->full_name);
 		g_free (vinfo->name);
 		g_free (vinfo->uri);
-		g_free (vinfo->path);
 	} else {
 		/* There wasn't a Trash/Junk folder so create a new folder entry */
 		vinfo = g_new0 (CamelFolderInfo, 1);
@@ -751,7 +748,6 @@
 	vinfo->uri = uri;
 	if (!unread_count)
 		vinfo->unread = -1;
-	vinfo->path = g_strdup_printf ("/%s", vinfo->full_name);
 }
 
 static void
@@ -889,39 +885,11 @@
 		camel_folder_info_free (fi->child);
 		g_free (fi->name);
 		g_free (fi->full_name);
-		g_free (fi->path);
 		g_free (fi->uri);
 		g_free (fi);
 	}
 }
 
-/**
- * camel_folder_info_build_path:
- * @fi: folder info
- * @separator: directory separator
- *
- * Sets the folder info path based on the folder's full name and
- * directory separator.
- **/
-void
-camel_folder_info_build_path (CamelFolderInfo *fi, char separator)
-{
-	const char *full_name;
-	char *p;
-	
-	full_name = fi->full_name;
-	while (*full_name == separator)
-		full_name++;
-	
-	fi->path = g_strdup_printf ("/%s", full_name);
-	if (separator != '/') {
-		for (p = fi->path; *p; p++) {
-			if (*p == separator)
-				*p = '/';
-		}
-	}
-}
-
 static int
 folder_info_cmp (const void *ap, const void *bp)
 {
@@ -997,10 +965,6 @@
 		if (*name == separator)
 			name++;
 
-		/* set the path if it isn't already set */
-		if (!fi->path)
-			camel_folder_info_build_path (fi, separator);
-
 		p = strrchr (name, separator);
 		if (p) {
 			pname = g_strndup (name, p - name);
@@ -1079,7 +1043,6 @@
 	info->uri = g_strdup(fi->uri);
 	info->name = g_strdup(fi->name);
 	info->full_name = g_strdup(fi->full_name);
-	info->path = g_strdup(fi->path);
 	info->unread = fi->unread;
 	info->flags = fi->flags;
 	
Index: camel/camel-store.h
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-store.h,v
retrieving revision 1.68
diff -u -3 -r1.68 camel-store.h
--- camel/camel-store.h	11 Mar 2004 03:04:40 -0000	1.68
+++ camel/camel-store.h	25 May 2004 11:10:36 -0000
@@ -50,7 +50,6 @@
 	char *uri;
 	char *name;
 	char *full_name;
-	char *path;
 
 	guint32 flags;
 	guint32 unread;
@@ -102,14 +101,8 @@
 	CamelObjectBag *folders;
 
 	int flags;
-
-	/* FIXME: This is a temporary measure until IMAP namespaces are properly implemented,
-	   after that, all external folder api's will assume a dir separator of '/' */
-	/* This is always a copy of IMAP_STORE()->dir_sep, or '/' */
-	char dir_sep;
 };
 
-
 /* open mode for folder */
 #define CAMEL_STORE_FOLDER_CREATE (1<<0)
 #define CAMEL_STORE_FOLDER_EXCL (1<<1)
@@ -214,8 +207,6 @@
 						    CamelFolderInfo *fi);
 
 void             camel_folder_info_free            (CamelFolderInfo *fi);
-void             camel_folder_info_build_path      (CamelFolderInfo *fi,
-						    char separator);
 CamelFolderInfo *camel_folder_info_build           (GPtrArray *folders,
 						    const char *namespace,
 						    char separator,
Index: camel/camel-vee-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-vee-store.c,v
retrieving revision 1.31
diff -u -3 -r1.31 camel-vee-store.c
--- camel/camel-vee-store.c	27 Apr 2004 08:23:55 -0000	1.31
+++ camel/camel-vee-store.c	25 May 2004 11:10:37 -0000
@@ -149,7 +149,6 @@
 	fi->flags = CAMEL_FOLDER_VIRTUAL;
 	if (!(flags & CHANGE_DELETE))
 		fi->flags |= CAMEL_FOLDER_NOCHILDREN;
-	camel_folder_info_build_path(fi, '/');
 	camel_object_trigger_event(store, (flags&CHANGE_DELETE)?"folder_deleted":"folder_created", fi);
 	camel_folder_info_free(fi);
 }
@@ -272,7 +271,6 @@
 			info->name = g_strdup(((CamelFolder *)folder)->name);
 			info->unread = camel_folder_get_unread_message_count((CamelFolder *)folder);
 			info->flags = CAMEL_FOLDER_NOCHILDREN|CAMEL_FOLDER_VIRTUAL;
-			camel_folder_info_build_path(info, '/');
 			g_hash_table_insert(infos_hash, info->full_name, info);
 
 			if (res == NULL)
@@ -329,7 +327,6 @@
 		info->name = g_strdup(_("Unmatched"));
 		info->unread = -1;
 		info->flags = CAMEL_FOLDER_NOCHILDREN|CAMEL_FOLDER_NOINFERIORS|CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_VIRTUAL;
-		camel_folder_info_build_path(info, '/');
 
 		if (res == NULL)
 			res = info;
Index: camel/providers/imap/camel-imap-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/imap/camel-imap-store.c,v
retrieving revision 1.293
diff -u -3 -r1.293 camel-imap-store.c
--- camel/providers/imap/camel-imap-store.c	24 May 2004 06:47:26 -0000	1.293
+++ camel/providers/imap/camel-imap-store.c	25 May 2004 11:10:38 -0000
@@ -296,7 +296,6 @@
 			} else {
 				imap_store->namespace = g_strdup(is->namespace->full_name);
 				imap_store->dir_sep = is->namespace->sep;
-				store->dir_sep = is->namespace->sep;
 			}
 		}
  
@@ -1011,13 +1010,11 @@
 	url->path = g_strdup_printf ("/%s", folder_name);
 	fi->uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
 	camel_url_free(url);
-	fi->path = g_strdup_printf("/%s", folder_name);
-	name = strrchr (fi->path, '/');
-	if (name)
-		name++;
+	name = strrchr (fi->full_name, '/');
+	if (name == NULL)
+		name = fi->full_name;
 	else
-		name = fi->path;
-
+		name++;
 	fi->name = g_strdup (name);
 	
 	return fi;
@@ -1414,7 +1411,6 @@
 				sep = imap_parse_string ((const char **) &name, &len);
 				if (sep) {
 					store->dir_sep = *sep;
-					((CamelStore *)store)->dir_sep = store->dir_sep;
 					g_free (sep);
 				}
 			}
@@ -1452,7 +1448,6 @@
 		}
 		if (!store->dir_sep) {
 			store->dir_sep = '/';	/* Guess */
-			((CamelStore *)store)->dir_sep = store->dir_sep;
 		}
 	}
 	
@@ -1875,7 +1870,7 @@
 		
 		if ((parent_name = strrchr (folder_name, '/'))) {
 			parent_name = g_strndup (folder_name, parent_name - folder_name);
-			parent_real = camel_imap_store_summary_path_to_full (imap_store->summary, parent_name, store->dir_sep);
+			parent_real = camel_imap_store_summary_path_to_full (imap_store->summary, parent_name, imap_store->dir_sep);
 		} else {
 			parent_real = NULL;
 		}
@@ -1983,11 +1978,11 @@
 		
 		g_free (parent_name);
 		
-		folder_real = camel_imap_store_summary_path_to_full(imap_store->summary, folder_name, store->dir_sep);
+		folder_real = camel_imap_store_summary_path_to_full(imap_store->summary, folder_name, imap_store->dir_sep);
 		response = camel_imap_command (imap_store, NULL, ex, "CREATE %S", folder_real);
 		
 		if (response) {
-			camel_imap_store_summary_add_from_full(imap_store->summary, folder_real, store->dir_sep);
+			camel_imap_store_summary_add_from_full(imap_store->summary, folder_real, imap_store->dir_sep);
 
 			camel_imap_response_free (imap_store, response);
 			
@@ -2204,7 +2199,7 @@
 	if (store->flags & CAMEL_STORE_SUBSCRIPTIONS)
 		manage_subscriptions(store, old_name, FALSE);
 
-	new_name = camel_imap_store_summary_path_to_full(imap_store->summary, new_name_in, store->dir_sep);
+	new_name = camel_imap_store_summary_path_to_full(imap_store->summary, new_name_in, imap_store->dir_sep);
 	response = camel_imap_command (imap_store, NULL, ex, "RENAME %F %S", old_name, new_name);
 	
 	if (!response) {
@@ -2354,7 +2349,7 @@
 	}
 	
 	/* ok now we can create the folder */
-	real_name = camel_imap_store_summary_path_to_full(imap_store->summary, folder_name, store->dir_sep);
+	real_name = camel_imap_store_summary_path_to_full(imap_store->summary, folder_name, imap_store->dir_sep);
 	full_name = imap_concat (imap_store, parent_real, real_name);
 	g_free(real_name);
 	response = camel_imap_command (imap_store, NULL, ex, "CREATE %S", full_name);
@@ -2365,7 +2360,7 @@
 
 		camel_imap_response_free (imap_store, response);
 
-		si = camel_imap_store_summary_add_from_full(imap_store->summary, full_name, store->dir_sep);
+		si = camel_imap_store_summary_add_from_full(imap_store->summary, full_name, imap_store->dir_sep);
 		camel_store_summary_save((CamelStoreSummary *)imap_store->summary);
 		fi = imap_build_folder_info(imap_store, camel_store_info_path(imap_store->summary, si));
 		fi->flags |= CAMEL_FOLDER_NOCHILDREN;
@@ -2395,7 +2390,7 @@
 {
 	CamelFolderInfo *fi;
 	int flags;
-	char sep, *dir;
+	char sep, *dir, *path;
 	CamelURL *url;
 	CamelImapStoreInfo *si;
 	guint32 newflags;
@@ -2417,8 +2412,7 @@
 	
 	fi = g_new0 (CamelFolderInfo, 1);
 	fi->name = g_strdup(camel_store_info_name(imap_store->summary, si));
-	fi->path = g_strdup_printf("/%s", camel_store_info_path(imap_store->summary, si));
-	fi->full_name = g_strdup(fi->path+1);
+	fi->full_name = g_strdup(camel_store_info_path(imap_store->summary, si));
 	if (!g_ascii_strcasecmp(fi->full_name, "inbox"))
 		flags |= CAMEL_FOLDER_SYSTEM;
 	/* HACK: some servers report noinferiors for all folders (uw-imapd)
@@ -2429,7 +2423,9 @@
 	fi->flags = flags;
 	
 	url = camel_url_new (imap_store->base_url, NULL);
-	camel_url_set_path(url, fi->path);
+	path = alloca(strlen(fi->full_name)+2);
+	sprintf(path, "/%s", fi->full_name);
+	camel_url_set_path(url, path);
 
 	if (flags & CAMEL_FOLDER_NOSELECT || fi->name[0] == 0)
 		camel_url_set_param (url, "noselect", "yes");
@@ -2563,7 +2559,7 @@
 		if (si == NULL)
 			continue;
 
-		if (imap_match_pattern(((CamelStore *)imap_store)->dir_sep, pattern, camel_imap_store_info_full_name(imap_store->summary, si))) {
+		if (imap_match_pattern(imap_store->dir_sep, pattern, camel_imap_store_info_full_name(imap_store->summary, si))) {
 			if (g_hash_table_lookup(present, camel_store_info_path(imap_store->summary, si)) != NULL) {
 				if (lsub && (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) == 0) {
 					si->flags |= CAMEL_STORE_INFO_FOLDER_SUBSCRIBED;
@@ -2831,14 +2827,14 @@
 			i = strlen(top)-1;
 			name = g_malloc(i+2);
 			strcpy(name, top);
-			while (i>0 && name[i] == store->dir_sep)
+			while (i>0 && name[i] == imap_store->dir_sep)
 				name[i--] = 0;
 		} else
 			name = g_strdup("");
 	} else {
 		name = camel_imap_store_summary_full_from_path(imap_store->summary, top);
 		if (name == NULL)
-			name = camel_imap_store_summary_path_to_full(imap_store->summary, top, store->dir_sep);
+			name = camel_imap_store_summary_path_to_full(imap_store->summary, top, imap_store->dir_sep);
 	}
 
 	d(printf("\n\nList '%s' %s\n", name, flags&CAMEL_STORE_FOLDER_INFO_RECURSIVE?"RECURSIVE":"NON-RECURSIVE"));
Index: camel/providers/imapp/camel-imapp-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/imapp/camel-imapp-store.c,v
retrieving revision 1.9
diff -u -3 -r1.9 camel-imapp-store.c
--- camel/providers/imapp/camel-imapp-store.c	21 May 2004 09:08:09 -0000	1.9
+++ camel/providers/imapp/camel-imapp-store.c	25 May 2004 11:10:39 -0000
@@ -543,7 +543,6 @@
 	fi->uri = camel_url_to_string(base, CAMEL_URL_HIDE_ALL);
 	fi->name = g_strdup(name);
 	fi->full_name = full_name;
-	fi->path = g_strdup(path);
 	fi->unread = -1;
 	fi->total = -1;
 	fi->flags = li->flags;
Index: camel/providers/local/camel-local-folder.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/local/camel-local-folder.c,v
retrieving revision 1.49
diff -u -3 -r1.49 camel-local-folder.c
--- camel/providers/local/camel-local-folder.c	12 May 2004 07:12:26 -0000	1.49
+++ camel/providers/local/camel-local-folder.c	25 May 2004 11:10:39 -0000
@@ -319,7 +319,6 @@
 	fi->name = g_strdup (name);
 	fi->uri = camel_url_to_string (url, 0);
 	fi->unread = camel_folder_get_unread_message_count(folder);
-	camel_folder_info_build_path(fi, '/');
 	fi->flags = CAMEL_FOLDER_NOCHILDREN;
 	
 	camel_url_free (url);
Index: camel/providers/local/camel-local-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/local/camel-local-store.c,v
retrieving revision 1.35
diff -u -3 -r1.35 camel-local-store.c
--- camel/providers/local/camel-local-store.c	17 May 2004 05:38:30 -0000	1.35
+++ camel/providers/local/camel-local-store.c	25 May 2004 11:10:39 -0000
@@ -469,7 +469,6 @@
 	fi->uri = g_strdup_printf ("%s:%s#%s", ((CamelService *) store)->url->protocol,
 				   CAMEL_LOCAL_STORE(store)->toplevel_dir, folder_name);
 	fi->unread = -1;
-	camel_folder_info_build_path(fi, '/');
 	
 	camel_object_trigger_event (store, "folder_deleted", fi);
 	
Index: camel/providers/local/camel-maildir-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/local/camel-maildir-store.c,v
retrieving revision 1.34
diff -u -3 -r1.34 camel-maildir-store.c
--- camel/providers/local/camel-maildir-store.c	18 May 2004 07:26:10 -0000	1.34
+++ camel/providers/local/camel-maildir-store.c	25 May 2004 11:10:39 -0000
@@ -232,7 +232,6 @@
 	fi->name = g_strdup(name);
 	fi->unread = -1;
 	fi->total = -1;
-	camel_folder_info_build_path(fi, '/');
 
 	if (!strcmp(full, "."))
 		fi->flags |= CAMEL_FOLDER_SYSTEM;
Index: camel/providers/local/camel-mbox-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/local/camel-mbox-store.c,v
retrieving revision 1.36
diff -u -3 -r1.36 camel-mbox-store.c
--- camel/providers/local/camel-mbox-store.c	4 May 2004 07:48:14 -0000	1.36
+++ camel/providers/local/camel-mbox-store.c	25 May 2004 11:10:40 -0000
@@ -333,7 +333,6 @@
 	fi->name = g_path_get_basename(folder_name);
 	fi->uri = g_strdup_printf("mbox:%s#%s",((CamelService *) store)->url->path, folder_name);
 	fi->unread = -1;
-	camel_folder_info_build_path(fi, '/');
 	
 	camel_object_trigger_event(store, "folder_deleted", fi);
 	
@@ -705,7 +704,6 @@
 			fi->uri = camel_url_to_string (url, 0);
 			fi->name = short_name;
 			fi->full_name = full_name;
-			fi->path = g_strdup_printf("/%s", full_name);
 			fi->unread = -1;
 			fi->total = -1;
 
@@ -815,7 +813,6 @@
 	fi->full_name = g_strdup(top);
 	fi->unread = -1;
 	fi->total = -1;
-	fi->path = g_strdup_printf("/%s", top);
 	
 	subdir = g_strdup_printf("%s.sbd", path);
 	if (stat(subdir, &st) == 0) {
Index: camel/providers/local/camel-mh-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/local/camel-mh-store.c,v
retrieving revision 1.19
diff -u -3 -r1.19 camel-mh-store.c
--- camel/providers/local/camel-mh-store.c	17 May 2004 05:12:17 -0000	1.19
+++ camel/providers/local/camel-mh-store.c	25 May 2004 11:10:40 -0000
@@ -350,7 +350,6 @@
 	fi->uri = camel_url_to_string (url, 0);
 	fi->full_name = g_strdup(path);
 	fi->name = g_strdup(base?base+1:path);
-	camel_folder_info_build_path(fi, '/');
 	fill_fi(store, fi, flags);
 
 	d(printf("New folderinfo:\n '%s'\n '%s'\n '%s'\n", fi->full_name, fi->uri, fi->path));
Index: camel/providers/local/camel-spool-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/local/camel-spool-store.c,v
retrieving revision 1.21
diff -u -3 -r1.21 camel-spool-store.c
--- camel/providers/local/camel-spool-store.c	11 Mar 2004 03:04:43 -0000	1.21
+++ camel/providers/local/camel-spool-store.c	25 May 2004 11:10:40 -0000
@@ -231,7 +231,6 @@
 		g_free(fi->uri);
 		g_free(fi->name);
 		g_free(fi->full_name);
-		g_free(fi->path);
 		g_free(fi);
 	}
 }
@@ -246,7 +245,6 @@
 	fi->full_name = g_strdup(full);
 	fi->name = g_strdup(name);
 	fi->unread = unread;
-	camel_folder_info_build_path(fi, '/');
 
 	d(printf("Adding spoold info: '%s' '%s' '%s' '%s'\n", fi->path, fi->name, fi->full_name, fi->url));
 
@@ -466,8 +464,6 @@
 			camel_object_unref(folder);
 		} else
 			fi->unread = -1;
-
-		camel_folder_info_build_path(fi, '/');
 	}
 
 	return fi;
Index: camel/providers/nntp/camel-nntp-store.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/providers/nntp/camel-nntp-store.c,v
retrieving revision 1.60
diff -u -3 -r1.60 camel-nntp-store.c
--- camel/providers/nntp/camel-nntp-store.c	21 May 2004 09:08:09 -0000	1.60
+++ camel/providers/nntp/camel-nntp-store.c	25 May 2004 11:10:41 -0000
@@ -390,6 +390,7 @@
 	CamelURL *base_url = ((CamelService *) store)->url;
 	CamelFolderInfo *fi = g_malloc0(sizeof(*fi));
 	CamelURL *url;
+	char *path;
 	
 	fi->full_name = g_strdup (si->path);
 	
@@ -399,16 +400,9 @@
 		fi->name = g_strdup (si->path);
 	
 	fi->unread = -1;
-	/* fi->path is the 'canonicalised' path used by the UI (folder-tree). Not
-	 * as important these days, but folders used to get added to the tree based
-	 * on its path rather than the structure of the CamelFolderInfo's.
-	 *
-	 * must be delimited by '/' which also means that if the user doesn't want
-	 * a flat list of newsgroups, you'll have to replace '.' with '/' for
-	 * full_name too. */	
-	/*camel_folder_info_build_path(fi, '/');*/
-	fi->path = g_strdup_printf ("/%s", si->path);
-	url = camel_url_new_with_base (base_url, fi->path);
+	path = alloca(strlen(fi->full_name)+2);
+	sprintf(path, "/%s", fi->full_name);
+	url = camel_url_new_with_base (base_url, path);
 	fi->uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
 	camel_url_free (url);
 	
@@ -421,7 +415,8 @@
 	CamelFolderInfo *fi = g_malloc0(sizeof(*fi));
 	CamelURL *base_url = ((CamelService *)store)->url;
 	CamelURL *url;
-	
+	char *path;
+
 	fi->full_name = g_strdup (name);
 	
 	if (short_notation)
@@ -431,9 +426,9 @@
 	
 	fi->unread = -1;
 	
-	fi->path = g_strdup_printf ("/%s", name);
-	
-	url = camel_url_new_with_base (base_url, fi->path);
+	path = alloca(strlen(fi->full_name)+2);
+	sprintf(path, "/%s", fi->full_name);
+	url = camel_url_new_with_base (base_url, path);
 	fi->uri = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
 	camel_url_free (url);
 	
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3350
diff -u -3 -r1.3350 ChangeLog
--- mail/ChangeLog	25 May 2004 04:10:23 -0000	1.3350
+++ mail/ChangeLog	25 May 2004 11:10:46 -0000
@@ -1,5 +1,19 @@
 2004-05-25  Not Zed  <NotZed Ximian com>
 
+	* mail-component.c (mc_add_local_store_done): removed, now
+	redundant.
+
+	* em-folder-tree.c (em_folder_tree_set_selected): fix for path changes.
+
+	* em-folder-tree-model.c (em_folder_tree_model_set_unread_count):
+	change to use full name rather than path name.
+
+	* em-folder-tree-model.h: renamed path_hash to full_hash.
+
+	* em-folder-tree-model.c (folder_subscribed): dont use
+	g_path_get_dirname here, it is os dependent, we want / always.
+	(full_hash_free): rename from path_hash free.
+
 	* em-folder-view.c (emfv_popup_menu[]): disable add sender to
 	addressbook bar if it is also disabled.  #58955.
 
Index: mail/em-folder-selector.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-selector.c,v
retrieving revision 1.23
diff -u -3 -r1.23 em-folder-selector.c
--- mail/em-folder-selector.c	18 May 2004 07:28:10 -0000	1.23
+++ mail/em-folder-selector.c	25 May 2004 11:10:47 -0000
@@ -357,8 +357,15 @@
 			
 			camel_url_set_fragment (url, newpath);
 		} else {
-			newpath = g_strdup_printf("%s/%s", (url->path == NULL || strcmp(url->path, "/") == 0) ? "":url->path, name);
+			char *path;
+
+			path = g_strdup_printf("%s/%s", (url->path == NULL || strcmp(url->path, "/") == 0) ? "":url->path, name);
 			camel_url_set_path(url, newpath);
+			if (path[0] == '/') {
+				newpath = g_strdup(path+1);
+				g_free(path);
+			} else
+				newpath = path;
 		}
 		
 		g_free (emfs->selected_path);
@@ -406,7 +413,7 @@
 		char *newpath;
 		
 		name = gtk_entry_get_text (emfs->name_entry);
-		if (strcmp (path, "/") != 0)
+		if (strcmp (path, "") != 0)
 			newpath = g_strdup_printf ("%s/%s", path, name);
 		else
 			newpath = g_strdup_printf ("/%s", name);
Index: mail/em-folder-tree-model.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-tree-model.c,v
retrieving revision 1.51
diff -u -3 -r1.51 em-folder-tree-model.c
--- mail/em-folder-tree-model.c	7 May 2004 20:36:18 -0000	1.51
+++ mail/em-folder-tree-model.c	25 May 2004 11:10:47 -0000
@@ -238,7 +238,7 @@
 }
 
 static void
-path_hash_free (gpointer key, gpointer value, gpointer user_data)
+full_hash_free (gpointer key, gpointer value, gpointer user_data)
 {
 	g_free (key);
 	gtk_tree_row_reference_free (value);
@@ -256,7 +256,7 @@
 	g_free (si->display_name);
 	camel_object_unref (si->store);
 	gtk_tree_row_reference_free (si->row);
-	g_hash_table_foreach (si->path_hash, path_hash_free, NULL);
+	g_hash_table_foreach (si->full_hash, full_hash_free, NULL);
 	g_free (si);
 }
 
@@ -430,7 +430,7 @@
 	gtk_tree_path_free (path);
 	
 	g_hash_table_insert (model->uri_hash, g_strdup (fi->uri), uri_row);
-	g_hash_table_insert (si->path_hash, g_strdup (fi->path), path_row);
+	g_hash_table_insert (si->full_hash, g_strdup (fi->full_name), path_row);
 	
 	/* HACK: if we have the folder, and its the outbox folder, we need the total count, not unread */
 	/* This is duplicated in mail-folder-cache too, should perhaps be functionised */
@@ -454,7 +454,7 @@
 	gtk_tree_store_set ((GtkTreeStore *) model, iter,
 			    COL_STRING_DISPLAY_NAME, fi->name,
 			    COL_POINTER_CAMEL_STORE, si->store,
-			    COL_STRING_FOLDER_PATH, fi->path,
+			    COL_STRING_FULL_NAME, fi->full_name,
 			    COL_STRING_URI, fi->uri,
 			    COL_UINT_UNREAD, unread,
 			    COL_UINT_FLAGS, fi->flags,
@@ -468,7 +468,7 @@
 		gtk_tree_store_set ((GtkTreeStore *) model, &sub,
 				    COL_STRING_DISPLAY_NAME, _("Loading..."),
 				    COL_POINTER_CAMEL_STORE, NULL,
-				    COL_STRING_FOLDER_PATH, NULL,
+				    COL_STRING_FULL_NAME, NULL,
 				    COL_BOOL_LOAD_SUBDIRS, FALSE,
 				    COL_BOOL_IS_STORE, FALSE,
 				    COL_STRING_URI, NULL,
@@ -515,26 +515,25 @@
 	GtkTreeIter parent, iter;
 	GtkTreePath *path;
 	gboolean load;
-	char *dirname;
-	
+	char *dirname, *p;
+
 	if (!(si = g_hash_table_lookup (model->store_hash, store)))
 		goto done;
 	
 	/* make sure we don't already know about it? */
-	if (g_hash_table_lookup (si->path_hash, fi->path))
+	if (g_hash_table_lookup (si->full_hash, fi->full_name))
 		goto done;
 	
 	/* get our parent folder's path */
-	if (!(dirname = g_path_get_dirname (fi->path)))
-		goto done;
-	
-	if (!strcmp (dirname, "/")) {
+	dirname = alloca(strlen(fi->full_name)+1);
+	strcpy(dirname, fi->full_name);
+	p = strrchr(dirname, '/');
+	if (p == NULL) {
 		/* user subscribed to a toplevel folder */
 		row = si->row;
-		g_free (dirname);
 	} else {
-		row = g_hash_table_lookup (si->path_hash, dirname);
-		g_free (dirname);
+		*p = 0;
+		row = g_hash_table_lookup (si->full_hash, dirname);
 		
 		/* if row is NULL, don't bother adding to the tree,
 		 * when the user expands enough nodes - it will be
@@ -560,8 +559,8 @@
 	gtk_tree_store_append ((GtkTreeStore *) model, &iter, &parent);
 	
 	em_folder_tree_model_set_folder_info (model, &iter, si, fi, TRUE);
-	
-	g_signal_emit (model, signals[FOLDER_ADDED], 0, fi->path, fi->uri);
+
+	g_signal_emit (model, signals[FOLDER_ADDED], 0, fi->full_name, fi->uri);
 	
  done:
 	
@@ -590,7 +589,7 @@
 	if (!(si = g_hash_table_lookup (model->store_hash, store)))
 		goto done;
 	
-	if (!(row = g_hash_table_lookup (si->path_hash, fi->path)))
+	if (!(row = g_hash_table_lookup (si->full_hash, fi->full_name)))
 		goto done;
 	
 	path = gtk_tree_row_reference_get_path (row);
@@ -621,7 +620,7 @@
 folder_created_cb (CamelStore *store, void *event_data, EMFolderTreeModel *model)
 {
 	CamelFolderInfo *fi;
-	
+
 	/* we only want created events to do more work if we don't support subscriptions */
 	if (camel_store_supports_subscriptions (store))
 		return;
@@ -657,12 +656,8 @@
 	if (!(si = g_hash_table_lookup (model->store_hash, store)))
 		goto done;
 	
-	parent = g_strdup_printf ("/%s", info->old_base);
-	if (!(row = g_hash_table_lookup (si->path_hash, parent))) {
-		g_free (parent);
+	if (!(row = g_hash_table_lookup (si->full_hash, info->old_base)))
 		goto done;
-	}
-	g_free (parent);
 	
 	path = gtk_tree_row_reference_get_path (row);
 	if (!(gtk_tree_model_get_iter ((GtkTreeModel *) model, &iter, path))) {
@@ -672,15 +667,15 @@
 	
 	em_folder_tree_model_remove_folders (model, si, &iter);
 	
-	parent = g_strdup (info->new->path);
+	parent = g_strdup(info->new->full_name);
 	p = strrchr(parent, '/');
-	g_assert(p);
-	*p = 0;
-	if (parent == p) {
+	if (p)
+		*p = 0;
+	if (p == NULL || parent == p) {
 		/* renamed to a toplevel folder on the store */
 		path = gtk_tree_row_reference_get_path (si->row);
 	} else {
-		if (!(row = g_hash_table_lookup (si->path_hash, parent))) {
+		if (!(row = g_hash_table_lookup (si->full_hash, parent))) {
 			/* NOTE: this should never happen, but I
 			 * suppose if it does in reality, we can add
 			 * code here to add the missing nodes to the
@@ -753,7 +748,7 @@
 	gtk_tree_store_set ((GtkTreeStore *) model, &iter,
 			    COL_STRING_DISPLAY_NAME, display_name,
 			    COL_POINTER_CAMEL_STORE, store,
-			    COL_STRING_FOLDER_PATH, "/",
+			    COL_STRING_FULL_NAME, "",
 			    COL_BOOL_LOAD_SUBDIRS, TRUE,
 			    COL_BOOL_IS_STORE, TRUE,
 			    COL_STRING_URI, uri, -1);
@@ -767,7 +762,7 @@
 	si->store = store;
 	si->account = account;
 	si->row = row;
-	si->path_hash = g_hash_table_new (g_str_hash, g_str_equal);
+	si->full_hash = g_hash_table_new (g_str_hash, g_str_equal);
 	g_hash_table_insert (model->store_hash, store, si);
 	g_hash_table_insert (model->account_hash, account, si);
 	
@@ -777,7 +772,7 @@
 	gtk_tree_store_set ((GtkTreeStore *) model, &iter,
 			    COL_STRING_DISPLAY_NAME, _("Loading..."),
 			    COL_POINTER_CAMEL_STORE, NULL,
-			    COL_STRING_FOLDER_PATH, NULL,
+			    COL_STRING_FULL_NAME, NULL,
 			    COL_BOOL_LOAD_SUBDIRS, FALSE,
 			    COL_BOOL_IS_STORE, FALSE,
 			    COL_STRING_URI, NULL,
@@ -850,11 +845,11 @@
 	}
 	
 	gtk_tree_model_get ((GtkTreeModel *) model, toplevel, COL_STRING_URI, &uri,
-			    COL_STRING_FOLDER_PATH, &folder_path,
+			    COL_STRING_FULL_NAME, &folder_path,
 			    COL_BOOL_IS_STORE, &is_store, -1);
 	
-	if (folder_path && (row = g_hash_table_lookup (si->path_hash, folder_path))) {
-		g_hash_table_remove (si->path_hash, folder_path);
+	if (folder_path && (row = g_hash_table_lookup (si->full_hash, folder_path))) {
+		g_hash_table_remove (si->full_hash, folder_path);
 		gtk_tree_row_reference_free (row);
 	}
 	
@@ -929,7 +924,7 @@
 	if (p[-1] == '/')
 		p[-1] = '\0';
 	p = NULL;
-	
+
 	do {
 		if ((p = strchr (name, '/')))
 			*p = '\0';
@@ -947,7 +942,7 @@
 		
 		name = p ? p + 1 : NULL;
 	} while (name && node);
-	
+
 	return FALSE;
 }
 
@@ -1061,7 +1056,7 @@
 }
 
 void
-em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *store, const char *path, int unread)
+em_folder_tree_model_set_unread_count (EMFolderTreeModel *model, CamelStore *store, const char *full, int unread)
 {
 	struct _EMFolderTreeModelStoreInfo *si;
 	GtkTreeRowReference *row;
@@ -1070,9 +1065,9 @@
 	
 	g_return_if_fail (EM_IS_FOLDER_TREE_MODEL (model));
 	g_return_if_fail (CAMEL_IS_STORE (store));
-	g_return_if_fail (path != NULL);
+	g_return_if_fail (full != NULL);
 
-	u(printf("set unread count %p '%s' %d\n", store, path, unread));
+	u(printf("set unread count %p '%s' %d\n", store, full, unread));
 
 	if (unread < 0)
 		unread = 0;
@@ -1082,7 +1077,7 @@
 		return;
 	}
 	
-	if (!(row = g_hash_table_lookup (si->path_hash, path))) {
+	if (!(row = g_hash_table_lookup (si->full_hash, full))) {
 		u(printf("  can't find row\n"));
 		return;
 	}
Index: mail/em-folder-tree-model.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-tree-model.h,v
retrieving revision 1.18
diff -u -3 -r1.18 em-folder-tree-model.h
--- mail/em-folder-tree-model.h	7 May 2004 20:36:18 -0000	1.18
+++ mail/em-folder-tree-model.h	25 May 2004 11:10:47 -0000
@@ -52,7 +52,7 @@
 enum {
 	COL_STRING_DISPLAY_NAME,  /* string that appears in the tree */
 	COL_POINTER_CAMEL_STORE,  /* CamelStore object */
-	COL_STRING_FOLDER_PATH,   /* if node is a folder, the full path of the folder */
+	COL_STRING_FULL_NAME,   /* if node is a folder, the full path name of the folder, no leading / */
 	COL_STRING_URI,           /* the uri to get the store or folder object */
 	COL_UINT_UNREAD,          /* unread count */
 	COL_UINT_FLAGS,		/* FolderInfo.flags */
@@ -68,7 +68,7 @@
 struct _EMFolderTreeModelStoreInfo {
 	CamelStore *store;
 	GtkTreeRowReference *row;
-	GHashTable *path_hash;  /* maps CamelFolderInfo::path's to GtkTreeRowReferences */
+	GHashTable *full_hash;  /* maps CamelFolderInfo::full_name's to GtkTreeRowReferences */
 	EAccount *account;
 	
 	char *display_name;
Index: mail/em-folder-tree.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-tree.c,v
retrieving revision 1.104
diff -u -3 -r1.104 em-folder-tree.c
--- mail/em-folder-tree.c	24 May 2004 07:17:10 -0000	1.104
+++ mail/em-folder-tree.c	25 May 2004 11:10:48 -0000
@@ -272,17 +272,17 @@
 		initialised = TRUE;
 	}
 	
-	gtk_tree_model_get (model, iter, COL_STRING_FOLDER_PATH, &path,
+	gtk_tree_model_get (model, iter, COL_STRING_FULL_NAME, &path,
 			    COL_BOOL_IS_STORE, &is_store, -1);
 	
 	if (!is_store && path != NULL) {
-		if (!strcasecmp (path, "/Inbox"))
+		if (!g_ascii_strcasecmp (path, "Inbox"))
 			pixbuf = folder_icons[FOLDER_ICON_INBOX];
-		else if (!strcasecmp (path, "/Outbox"))
+		else if (!g_ascii_strcasecmp (path, "Outbox"))
 			pixbuf = folder_icons[FOLDER_ICON_OUTBOX];
-		else if (*path == '/' && !strcasecmp (path + 1, CAMEL_VTRASH_NAME))
+		else if (!strcmp (path, CAMEL_VTRASH_NAME))
 			pixbuf = folder_icons[FOLDER_ICON_TRASH];
-		else if (*path == '/' && !strcasecmp (path + 1, CAMEL_VJUNK_NAME))
+		else if (!strcmp(path, CAMEL_VJUNK_NAME))
 			pixbuf = folder_icons[FOLDER_ICON_JUNK];
 		else
 			pixbuf = folder_icons[FOLDER_ICON_NORMAL];
@@ -546,7 +546,7 @@
 	camel_object_unref (store);
 	
 	if (p != NULL) {
-		if (!(row = g_hash_table_lookup (si->path_hash, p)))
+		if (!(row = g_hash_table_lookup (si->full_hash, p)))
 			return;
 	} else
 		row = si->row;
@@ -565,19 +565,19 @@
 	char *path, *key;
 	
 	gtk_tree_model_get ((GtkTreeModel *) model, iter,
-			    COL_STRING_FOLDER_PATH, &path,
+			    COL_STRING_FULL_NAME, &path,
 			    COL_POINTER_CAMEL_STORE, &store,
 			    -1);
 	
 	si = g_hash_table_lookup (model->store_hash, store);
 	if ((account = mail_config_get_account_by_name (si->display_name))) {
-	        key = g_strdup_printf ("%s%s", account->uid, path);
+	        key = g_strdup_printf ("%s/%s", account->uid, path);
 	} else if (CAMEL_IS_VEE_STORE (store)) {
 		/* vfolder store */
-		key = g_strdup_printf ("vfolder%s", path);
+		key = g_strdup_printf ("vfolder/%s", path);
 	} else {
 		/* local store */
-		key = g_strdup_printf ("local%s", path);
+		key = g_strdup_printf ("local/%s", path);
 	}
 	
 	if (em_folder_tree_model_get_expanded (model, key)) {
@@ -630,12 +630,11 @@
 {
 	struct _EMFolderTreePrivate *priv = emft->priv;
 	GtkTreePath *src_path;
-	const char *full_name;
 	gboolean is_store;
 	CamelStore *store;
 	CamelException ex;
 	GtkTreeIter iter;
-	char *path;
+	char *full_name;
 	
 	if (!priv->drag_row || (src_path = gtk_tree_row_reference_get_path (priv->drag_row)))
 		return;
@@ -645,14 +644,12 @@
 
 	gtk_tree_model_get((GtkTreeModel *)priv->model, &iter,
 			   COL_POINTER_CAMEL_STORE, &store,
-			   COL_STRING_FOLDER_PATH, &path,
+			   COL_STRING_FULL_NAME, &full_name,
 			   COL_BOOL_IS_STORE, &is_store, -1);
 	
 	if (is_store)
 		goto fail;
 	
-	full_name = path[0] == '/' ? path + 1 : path;
-	
 	camel_exception_init(&ex);
 	camel_store_delete_folder(store, full_name, &ex);
 	if (camel_exception_is_set(&ex))
@@ -666,12 +663,11 @@
 {
 	struct _EMFolderTreePrivate *priv = emft->priv;
 	GtkTreePath *src_path;
-	const char *full_name;
 	CamelFolder *folder;
 	CamelStore *store;
 	CamelException ex;
 	GtkTreeIter iter;
-	char *path, *uri;
+	char *full_name, *uri;
 	
 	if (!priv->drag_row || !(src_path = gtk_tree_row_reference_get_path(priv->drag_row)))
 		return;
@@ -681,15 +677,13 @@
 	
 	gtk_tree_model_get((GtkTreeModel *)priv->model, &iter,
 			   COL_POINTER_CAMEL_STORE, &store,
-			   COL_STRING_FOLDER_PATH, &path,
+			   COL_STRING_FULL_NAME, &full_name,
 			   COL_STRING_URI, &uri, -1);
 	
 	/* make sure user isn't trying to drag on a placeholder row */
-	if (path == NULL)
+	if (full_name == NULL)
 		goto fail;
 	
-	full_name = path[0] == '/' ? path + 1 : path;
-	
 	camel_exception_init(&ex);
 	
 	switch (info) {
@@ -968,14 +962,11 @@
 	GtkTreeViewDropPosition pos;
 	GtkTreePath *dest_path;
 	struct _DragDataReceivedAsync *m;
-	const char *full_name;
 	CamelStore *store;
 	GtkTreeIter iter;
-	char *path;
+	char *full_name;
 	int i;
 
-	printf("drag data received, action %d\n", context->action);
-	
 	if (!gtk_tree_view_get_dest_row_at_pos (priv->treeview, x, y, &dest_path, &pos))
 		return;
 	
@@ -992,16 +983,14 @@
 	
 	gtk_tree_model_get((GtkTreeModel *)priv->model, &iter,
 			   COL_POINTER_CAMEL_STORE, &store,
-			   COL_STRING_FOLDER_PATH, &path, -1);
+			   COL_STRING_FULL_NAME, &full_name, -1);
 	
 	/* make sure user isn't try to drop on a placeholder row */
-	if (path == NULL) {
+	if (full_name == NULL) {
 		gtk_drag_finish (context, FALSE, FALSE, GDK_CURRENT_TIME);
 		return;
 	}
 
-	full_name = path[0] == '/' ? path + 1 : path;
-	
 	m = mail_msg_new (&emft_drop_async_op, NULL, sizeof (struct _DragDataReceivedAsync));
 	m->context = context;
 	g_object_ref(context);
@@ -1067,7 +1056,7 @@
 		return GDK_NONE;
 	
 	gtk_tree_model_get((GtkTreeModel *)p->model, &iter, COL_BOOL_IS_STORE, &is_store,
-			   COL_STRING_FOLDER_PATH, &folder_path,
+			   COL_STRING_FULL_NAME, &folder_path,
 			   COL_POINTER_CAMEL_STORE, &dstore,
 			   COL_STRING_URI, &uri, -1);
 	
@@ -1077,8 +1066,6 @@
 	
 	/* Check for special destinations */
 	if (uri && folder_path) {
-		folder_path = folder_path[0] == '/' ? folder_path + 1 : folder_path;
-		
 #if 0
 		/* only allow copying/moving folders (not messages) into the local Outbox */
 		if (dstore == local && !strcmp (folder_path, "Outbox")) {
@@ -1503,7 +1490,7 @@
 	GList **list = (GList **) data;
 	char *path;
 	
-	gtk_tree_model_get (model, iter, COL_STRING_FOLDER_PATH, &path, -1);
+	gtk_tree_model_get (model, iter, COL_STRING_FULL_NAME, &path, -1);
 	*list = g_list_append (*list, g_strdup (path));
 }
 
@@ -1692,19 +1679,19 @@
 	char *path, *key;
 	
 	gtk_tree_model_get ((GtkTreeModel *) priv->model, iter,
-			    COL_STRING_FOLDER_PATH, &path,
+			    COL_STRING_FULL_NAME, &path,
 			    COL_POINTER_CAMEL_STORE, &store,
 			    -1);
 	
 	si = g_hash_table_lookup (priv->model->store_hash, store);
 	if ((account = mail_config_get_account_by_name (si->display_name))) {
-	        key = g_strdup_printf ("%s%s", account->uid, path);
+	        key = g_strdup_printf ("%s/%s", account->uid, path);
 	} else if (CAMEL_IS_VEE_STORE (store)) {
 		/* vfolder store */
-		key = g_strdup_printf ("vfolder%s", path);
+		key = g_strdup_printf ("vfolder/%s", path);
 	} else {
 		/* local store */
-		key = g_strdup_printf ("local%s", path);
+		key = g_strdup_printf ("local/%s", path);
 	}
 	
 	em_folder_tree_model_set_expanded (priv->model, key, expanded);
@@ -1718,14 +1705,13 @@
 	struct _EMFolderTreeGetFolderInfo *m;
 	GtkTreeModel *model;
 	CamelStore *store;
-	const char *top;
 	gboolean load;
 	char *path;
 	
 	model = gtk_tree_view_get_model (treeview);
 	
 	gtk_tree_model_get (model, root,
-			    COL_STRING_FOLDER_PATH, &path,
+			    COL_STRING_FULL_NAME, &path,
 			    COL_POINTER_CAMEL_STORE, &store,
 			    COL_BOOL_LOAD_SUBDIRS, &load,
 			    -1);
@@ -1737,18 +1723,13 @@
 		return;
 	}
 	
-	if (!path || !strcmp (path, "/"))
-		top = NULL;
-	else
-		top = path + 1;
-	
 	m = mail_msg_new (&get_folder_info_op, NULL, sizeof (struct _EMFolderTreeGetFolderInfo));
 	m->root = gtk_tree_row_reference_new (model, tree_path);
 	camel_object_ref (store);
 	m->store = store;
 	m->emft = emft;
 	g_object_ref(emft);
-	m->top = g_strdup (top);
+	m->top = g_strdup (path);
 	m->flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE;
 	m->select_uri = NULL;
 	
@@ -1779,7 +1760,7 @@
 	if (!gtk_tree_model_get_iter (model, &iter, tree_path))
 		return;
 	
-	gtk_tree_model_get (model, &iter, COL_STRING_FOLDER_PATH, &path,
+	gtk_tree_model_get (model, &iter, COL_STRING_FULL_NAME, &path,
 			    COL_STRING_URI, &uri, COL_UINT_FLAGS, &flags, -1);
 	
 	g_free (priv->selected_uri);
@@ -2329,16 +2310,14 @@
 }
 
 static void
-emft_popup_delete_folders (CamelStore *store, const char *path, CamelException *ex)
+emft_popup_delete_folders (CamelStore *store, const char *full_name, CamelException *ex)
 {
 	guint32 flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_FAST;
-	const char *full_name;
 	CamelFolderInfo *fi;
 	
 	if (camel_store_supports_subscriptions (store))
 		flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED;
 	
-	full_name = path[0] == '/' ? path + 1 : path;
 	fi = camel_store_get_folder_info (store, full_name, flags, ex);
 	if (camel_exception_is_set (ex))
 		return;
@@ -2392,7 +2371,7 @@
 	if (!emft_selection_get_selected (selection, &model, &iter))
 		return;
 	
-	gtk_tree_model_get (model, &iter, COL_STRING_FOLDER_PATH, &path,
+	gtk_tree_model_get (model, &iter, COL_STRING_FULL_NAME, &path,
 			    COL_POINTER_CAMEL_STORE, &store, -1);
 	
 	camel_exception_init (&ex);
@@ -2413,18 +2392,16 @@
 	GtkTreeModel *model;
 	GtkTreeIter iter;
 	GtkWidget *dialog;
-	const char *full_name;
-	char *path;
+	char *full_name;
 	
 	selection = gtk_tree_view_get_selection (priv->treeview);
 	if (!emft_selection_get_selected (selection, &model, &iter))
 		return;
 	
-	gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store, COL_STRING_FOLDER_PATH, &path, -1);
+	gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store, COL_STRING_FULL_NAME, &full_name, -1);
 	
 	local = mail_component_peek_local_store (NULL);
 	
-	full_name = path[0] == '/' ? path + 1 : path;
 	if (store == local && is_special_local_folder (full_name)) {
 		e_error_run(NULL, "mail:no-delete-spethal-folder", full_name, NULL);
 		return;
@@ -2440,9 +2417,9 @@
 emft_popup_rename_folder (GtkWidget *item, EMFolderTree *emft)
 {
 	struct _EMFolderTreePrivate *priv = emft->priv;
-	char *prompt, *folder_path, *name, *new_name, *uri;
+	char *prompt, *full_name, *name, *new_name, *uri;
 	GtkTreeSelection *selection;
-	const char *full_name, *p;
+	const char *p;
 	CamelStore *local, *store;
 	gboolean done = FALSE;
 	GtkTreeModel *model;
@@ -2455,13 +2432,11 @@
 	if (!emft_selection_get_selected (selection, &model, &iter))
 		return;
 	
-	gtk_tree_model_get (model, &iter, COL_STRING_FOLDER_PATH, &folder_path,
+	gtk_tree_model_get (model, &iter, COL_STRING_FULL_NAME, &full_name,
 			    COL_STRING_DISPLAY_NAME, &name,
 			    COL_POINTER_CAMEL_STORE, &store,
 			    COL_STRING_URI, &uri, -1);
 	
-	full_name = folder_path[0] == '/' ? folder_path + 1 : folder_path;
-	
 	/* don't allow user to rename one of the special local folders */
 	if (store == local && is_special_local_folder (full_name)) {
 		e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *)emft),
@@ -2571,7 +2546,6 @@
 {
 	GtkTreeSelection *selection;
 	CamelStore *local, *store;
-	const char *folder_name;
 	EMPopupTarget *target;
 	GtkTreePath *tree_path;
 	GtkTreeModel *model;
@@ -2580,7 +2554,7 @@
 	guint32 info_flags = 0;
 	guint32 flags = 0;
 	gboolean isstore;
-	char *uri, *path;
+	char *uri, *full_name;
 	GtkMenu *menu;
 	EMPopup *emp;
 	int i;
@@ -2608,10 +2582,10 @@
 		return FALSE;
 	
 	gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store,
-			    COL_STRING_URI, &uri, COL_STRING_FOLDER_PATH, &path,
+			    COL_STRING_URI, &uri, COL_STRING_FULL_NAME, &full_name,
 			    COL_BOOL_IS_STORE, &isstore, -1);
 	
-	if (path == NULL)
+	if (full_name == NULL)
 		return FALSE;
 	
 	if (isstore)
@@ -2621,14 +2595,12 @@
 	
 	local = mail_component_peek_local_store (NULL);
 	
-	folder_name = path[0] == '/' ? path + 1 : path;
-	
 	/* don't allow deletion of special local folders */
-	if (!(store == local && is_special_local_folder (folder_name)))
+	if (!(store == local && is_special_local_folder (full_name)))
 		flags |= EM_POPUP_FOLDER_DELETE;
 	
 	/* hack for vTrash/vJunk */
-	if (!strcmp (folder_name, CAMEL_VTRASH_NAME) || !strcmp (folder_name, CAMEL_VJUNK_NAME))
+	if (!strcmp (full_name, CAMEL_VTRASH_NAME) || !strcmp (full_name, CAMEL_VJUNK_NAME))
 		info_flags |= CAMEL_FOLDER_VIRTUAL | CAMEL_FOLDER_NOINFERIORS;
 	
 	/* handle right-click by opening a context menu */
@@ -2671,7 +2643,7 @@
 	if (!emft_selection_get_selected (selection, &model, &iter))
 		return;
 	
-	gtk_tree_model_get (model, &iter, COL_STRING_FOLDER_PATH, &path,
+	gtk_tree_model_get (model, &iter, COL_STRING_FULL_NAME, &path,
 			    COL_STRING_URI, &uri, COL_UINT_FLAGS, &flags, -1);
 	
 	g_free (priv->selected_uri);
@@ -2695,7 +2667,6 @@
 	GtkTreePath *tree_path;
 	CamelStore *store;
 	CamelException ex;
-	const char *top;
 	char *path, *p;
 	CamelURL *url;
 	
@@ -2720,17 +2691,16 @@
 	}
 	
 	if (((CamelService *) store)->provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)
-		path = g_strdup_printf ("/%s", url->fragment ? url->fragment : "");
+		path = url->fragment;
 	else
-		path = g_strdup (url->path ? url->path : "/");
-	
-	top = path[0] == '/' ? path + 1 : path;
+		path = url->path && url->path[0]=='/' ? url->path+1:url->path;
+	path = g_strdup(path?path:"");
 	camel_url_free (url);
 	
-	if (!strcmp (path, "/"))
+	if (path[0] == 0)
 		row = si->row;
 	
-	if (row || (row = g_hash_table_lookup (si->path_hash, path))) {
+	if (row || (row = g_hash_table_lookup (si->full_hash, path))) {
 		/* the folder-info node has already been loaded */
 		tree_path = gtk_tree_row_reference_get_path (row);
 		gtk_tree_view_expand_to_path (priv->treeview, tree_path);
@@ -2749,36 +2719,33 @@
 		if (*p == '/') {
 			*p = '\0';
 			
-			if ((row = g_hash_table_lookup (si->path_hash, path)))
+			if ((row = g_hash_table_lookup (si->full_hash, path)))
 				break;
 		}
 		
 		p--;
 	}
 	
-	if (row == NULL) {
-		/* none of the folders of the desired store have been loaded yet */
-		row = si->row;
-		top = NULL;
-	}
-	
 	/* FIXME: this gets all the subfolders of our first loaded
 	 * parent folder - ideally we'd only get what we needed, but
 	 * it's probably not worth the effort */
 	m = mail_msg_new (&get_folder_info_op, NULL, sizeof (struct _EMFolderTreeGetFolderInfo));
-	m->root = gtk_tree_row_reference_copy (row);
 	m->store = store;
 	m->emft = emft;
 	g_object_ref(emft);
-	m->top = top ? g_strdup (top) : NULL;
+	if (row) {
+		m->top = path;
+		m->root = gtk_tree_row_reference_copy(row);
+	} else {
+		g_free(path);
+		m->root = gtk_tree_row_reference_copy(si->row);
+	}
+
 	m->flags = CAMEL_STORE_FOLDER_INFO_FAST | CAMEL_STORE_FOLDER_INFO_RECURSIVE;
 	m->select_uri = g_strdup (uri);
 	
-	g_free (path);
-	
 	e_thread_put (mail_thread_new, (EMsg *) m);
 }
-
 
 const char *
 em_folder_tree_get_selected_uri (EMFolderTree *emft)
Index: mail/mail-component.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-component.c,v
retrieving revision 1.88
diff -u -3 -r1.88 mail-component.c
--- mail/mail-component.c	22 May 2004 00:45:47 -0000	1.88
+++ mail/mail-component.c	25 May 2004 11:10:49 -0000
@@ -182,23 +182,9 @@
 }
 
 static void
-mc_add_local_store_done(CamelStore *store, CamelFolderInfo *info, void *data)
-{
-	/*MailComponent *mc = data;*/
-	int i;
-
-#if 0
-	for (i=0;i<sizeof(mc_default_folders)/sizeof(mc_default_folders[0]);i++) {
-		if (mc_default_folders[i].folder)
-			mail_note_folder(mc_default_folders[i].folder);
-	}
-#endif
-}
-
-static void
 mc_add_local_store(CamelStore *store, const char *name, MailComponent *mc)
 {
-	mc_add_store(mc, store, name, mc_add_local_store_done);
+	mc_add_store(mc, store, name, NULL);
 	camel_object_unref(store);
 	g_object_unref(mc);
 }
@@ -331,7 +317,7 @@
 static void
 folder_selected_cb (EMFolderTree *emft, const char *path, const char *uri, guint32 flags, EMFolderView *view)
 {
-	if ((flags & CAMEL_FOLDER_NOSELECT) || !path || !strcmp (path, "/"))
+	if ((flags & CAMEL_FOLDER_NOSELECT) || !path || !strcmp (path, ""))
 		em_folder_view_set_folder (view, NULL, NULL);
 	else
 		em_folder_view_set_folder_uri (view, uri);
Index: mail/mail-folder-cache.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-folder-cache.c,v
retrieving revision 1.92
diff -u -3 -r1.92 mail-folder-cache.c
--- mail/mail-folder-cache.c	22 May 2004 01:36:58 -0000	1.92
+++ mail/mail-folder-cache.c	25 May 2004 11:10:49 -0000
@@ -66,7 +66,6 @@
 struct _folder_info {
 	struct _store_info *store_info;	/* 'parent' link */
 
-	char *path;		/* shell path */
 	char *full_name;	/* full name of folder/folderinfo */
 	char *uri;		/* uri of folder */
 	
@@ -86,9 +85,9 @@
 	unsigned int unsub:1;   /* unsubcribing? */
 	unsigned int new:1;     /* new mail arrived? */
 
-	char *path;
+	char *full_name;
 	char *uri;
-	char *oldpath;
+	char *oldfull;
 	char *olduri;
 
 	int unread;
@@ -134,11 +133,11 @@
 static void
 free_update(struct _folder_update *up)
 {
-	g_free(up->path);
+	g_free(up->full_name);
 	g_free(up->uri);
 	if (up->store)
 		camel_object_unref(up->store);
-	g_free(up->oldpath);
+	g_free(up->oldfull);
 	g_free(up->olduri);
 	g_free(up);
 }
@@ -221,7 +220,7 @@
 		}
 		
 		/* update unread counts */
-		em_folder_tree_model_set_unread_count (model, up->store, up->path, up->unread);
+		em_folder_tree_model_set_unread_count (model, up->store, up->full_name, up->unread);
 		
 		/* new mail notification */
 		if (notify_type == -1) {
@@ -277,7 +276,7 @@
 		up->delete = delete;
 		up->unsub = unsub;
 		up->store = mfi->store_info->store;
-		up->path = g_strdup (mfi->path);
+		up->full_name = g_strdup (mfi->full_name);
 		camel_object_ref(up->store);
 		up->uri = g_strdup(mfi->uri);
 
@@ -289,7 +288,6 @@
 static void
 free_folder_info(struct _folder_info *mfi)
 {
-	g_free(mfi->path);
 	g_free(mfi->full_name);
 	g_free(mfi->uri);
 	g_free(mfi);
@@ -356,7 +354,7 @@
 		return;
 
 	up = g_malloc0(sizeof(*up));
-	up->path = g_strdup(mfi->path);
+	up->full_name = g_strdup(mfi->full_name);
 	up->unread = unread;
 	up->new = new ? 1 : 0;
 	up->store = mfi->store_info->store;
@@ -377,7 +375,6 @@
 	} else {
 		/*d(printf("Adding new folder: %s (%s) %d unread\n", fi->path, fi->url, fi->unread_message_count));*/
 		mfi = g_malloc0(sizeof(*mfi));
-		mfi->path = g_strdup(fi->path);
 		mfi->full_name = g_strdup(fi->full_name);
 		mfi->uri = g_strdup(fi->uri);
 		mfi->store_info = si;
@@ -387,7 +384,7 @@
 		g_hash_table_insert(si->folders_uri, mfi->uri, mfi);
 
 		up = g_malloc0(sizeof(*up));
-		up->path = g_strdup(mfi->path);
+		up->full_name = g_strdup(mfi->full_name);
 		up->uri = g_strdup(fi->uri);
 		up->unread = (fi->unread==-1)?0:fi->unread;
 		up->store = si->store;
@@ -581,14 +578,12 @@
 	if (mfi) {
 		d(printf("Found old folder '%s' renaming to '%s'\n", mfi->full_name, fi->full_name));
 
-		up->oldpath = mfi->path;
+		up->oldfull = mfi->full_name;
 		up->olduri = mfi->uri;
 
 		/* Its a rename op */
 		g_hash_table_remove(si->folders, mfi->full_name);
 		g_hash_table_remove(si->folders, mfi->uri);
-		g_free(mfi->full_name);
-		mfi->path = g_strdup(fi->path);
 		mfi->full_name = g_strdup(fi->full_name);
 		mfi->uri = g_strdup(fi->uri);
 		mfi->flags = fi->flags;
@@ -599,7 +594,6 @@
 		d(printf("Rename found a new folder? old '%s' new '%s'\n", old, fi->full_name));
 		/* Its a new op */
 		mfi = g_malloc0(sizeof(*mfi));
-		mfi->path = g_strdup(fi->path);
 		mfi->full_name = g_strdup(fi->full_name);
 		mfi->uri = g_strdup(fi->uri);
 		mfi->store_info = si;
@@ -611,7 +605,7 @@
 
 	g_free(old);
 
-	up->path = g_strdup(mfi->path);
+	up->full_name = g_strdup(mfi->full_name);
 	up->uri = g_strdup(mfi->uri);
 	up->unread = fi->unread==-1?0:fi->unread;
 	up->store = si->store;
@@ -649,7 +643,7 @@
 	const CamelFolderInfo *a = ((CamelFolderInfo **)ap)[0];
 	const CamelFolderInfo *b = ((CamelFolderInfo **)bp)[0];
 
-	return strcmp(a->path, b->path);
+	return strcmp(a->full_name, b->full_name);
 }
 
 static void
 


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