--- ./camel-imap-command.c	2006/01/10 17:43:35	1.1
+++ ./camel-imap-command.c	2006/01/10 18:23:38
@@ -133,13 +133,14 @@ camel_imap_command (CamelImapStore *stor
  *	%s, %d, %%: as with printf
  *	%S: an IMAP "string" (quoted string or literal)
  *	%F: an IMAP folder name
+ *	%G: an IMAP folder name, with namespace already prepended
  *
  * %S strings will be passed as literals if the server supports LITERAL+
  * and quoted strings otherwise. (%S does not support strings that
  * contain newlines.)
  *
- * %F will have the imap store's namespace prepended and then be processed
- * like %S.
+ * %F will have the imap store's namespace prepended; %F and %G will then
+ * be converted to UTF-7 and processed like %S.
  *
  * On success, the store's connect_lock will be locked. It will be
  * freed when %CAMEL_IMAP_RESPONSE_TAGGED or %CAMEL_IMAP_RESPONSE_ERROR
@@ -765,8 +766,9 @@ imap_command_strdup_vprintf (CamelImapSt
 			break;
 		case 'S':
 		case 'F':
+		case 'G':
 			string = va_arg (ap, char *);
-			/* NB: string is freed during output */
+			/* NB: string is freed during output for %F and %G */
 			if (*p == 'F') {
 				char *s = camel_imap_store_summary_full_from_path(store->summary, string);
 				if (s) {
@@ -775,7 +777,7 @@ imap_command_strdup_vprintf (CamelImapSt
 				} else {
 					string = camel_utf8_utf7(string);
 				}
-			} else {
+			} else if (*p == 'G') {
 				string = camel_utf8_utf7(string);
 			}
 				
@@ -828,6 +830,7 @@ imap_command_strdup_vprintf (CamelImapSt
 			break;
 		case 'S':
 		case 'F':
+		case 'G':
 			string = args->pdata[i++];
 			if (imap_is_atom (string)) {
 				outptr += sprintf (outptr, "%s", string);
@@ -843,7 +846,8 @@ imap_command_strdup_vprintf (CamelImapSt
 				}
 			}
 			
-			g_free (string);
+			if (*p == 'F' || *p == 'G')
+				g_free (string);
 			break;
 		default:
 			*outptr++ = '%';
--- ./camel-imap-store.c	2006/01/10 17:45:05	1.1
+++ ./camel-imap-store.c	2006/01/10 18:28:41
@@ -1471,7 +1471,7 @@ imap_connect_online (CamelService *servi
 			 * the folder doesn't exist (eg, if namespace is "").
 			 */
 			response = camel_imap_command (store, NULL, ex,
-						       "LIST \"\" %S",
+						       "LIST \"\" %G",
 						       store->namespace);
 		}
 		if (!response)
@@ -1899,7 +1899,7 @@ get_folder_online (CamelStore *store, co
 			guint32 flags;
 			int i;
 			
-			if (!(response = camel_imap_command (imap_store, NULL, ex, "LIST \"\" %S", parent_real))) {
+			if (!(response = camel_imap_command (imap_store, NULL, ex, "LIST \"\" %G", parent_real))) {
 				CAMEL_SERVICE_UNLOCK (imap_store, connect_lock);
 				g_free (parent_name);
 				g_free (parent_real);
@@ -1964,7 +1964,7 @@ get_folder_online (CamelStore *store, co
 				
 				/* add the dirsep to the end of parent_name */
 				name = g_strdup_printf ("%s%c", parent_real, imap_store->dir_sep);
-				response = camel_imap_command (imap_store, NULL, ex, "CREATE %S",
+				response = camel_imap_command (imap_store, NULL, ex, "CREATE %G",
 							       name);
 				g_free (name);
 				
@@ -1983,7 +1983,7 @@ get_folder_online (CamelStore *store, co
 		g_free (parent_name);
 
 		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);
+		response = camel_imap_command (imap_store, NULL, ex, "CREATE %G", folder_real);
 		if (response) {
 			camel_imap_store_summary_add_from_full(imap_store->summary, folder_real, imap_store->dir_sep);
 
@@ -2150,7 +2150,7 @@ rename_folder_info (CamelImapStore *imap
 			if (imap_store->dir_sep == '.') {
 				CamelImapResponse *response;
 
-				response = camel_imap_command (imap_store, NULL, NULL, "RENAME %F %S", path, nfull);
+				response = camel_imap_command (imap_store, NULL, NULL, "RENAME %F %G", path, nfull);
 				if (response)
 					camel_imap_response_free (imap_store, response);
 			}
@@ -2268,7 +2268,7 @@ create_folder (CamelStore *store, const 
 	}
 
 	need_convert = FALSE;
-	response = camel_imap_command (imap_store, NULL, ex, "LIST \"\" %S",
+	response = camel_imap_command (imap_store, NULL, ex, "LIST \"\" %G",
 				       parent_real);
 	if (!response) /* whoa, this is bad */ {
 		g_free(parent_real);
@@ -2328,7 +2328,7 @@ create_folder (CamelStore *store, const 
 		
 		/* add the dirsep to the end of parent_name */
 		name = g_strdup_printf ("%s%c", parent_real, imap_store->dir_sep);
-		response = camel_imap_command (imap_store, NULL, ex, "CREATE %S",
+		response = camel_imap_command (imap_store, NULL, ex, "CREATE %G",
 					       name);
 		g_free (name);
 		
@@ -2345,7 +2345,7 @@ create_folder (CamelStore *store, const 
 	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);
+	response = camel_imap_command (imap_store, NULL, ex, "CREATE %G", full_name);
 	
 	if (response) {
 		CamelImapStoreInfo *si;
@@ -2508,7 +2508,7 @@ get_folders_sync(CamelImapStore *imap_st
 	present = g_hash_table_new(folder_hash, folder_eq);
 	for (j=0;j<2;j++) {
 		response = camel_imap_command (imap_store, NULL, ex,
-					       "%s \"\" %S", j==1 ? "LSUB" : "LIST",
+					       "%s \"\" %G", j==1 ? "LSUB" : "LIST",
 					       pattern);
 		if (!response)
 			goto fail;
