change "gboolean show_passwd" to "guint32 flags".
authorDan Winship <danw@src.gnome.org>
Thu, 29 Mar 2001 17:34:00 +0000 (17:34 +0000)
committerDan Winship <danw@src.gnome.org>
Thu, 29 Mar 2001 17:34:00 +0000 (17:34 +0000)
* camel-url.c (camel_url_to_string): change "gboolean show_passwd"
to "guint32 flags".

* tests/misc/url.c (main): Update calls to camel_url_to_string

* providers/imap/camel-imap-store.c (construct): Call
camel_url_to_string with flags to hide password, authtype, and
params to create the base_url.
(etc): Update for the fact that the base_url no longer has the "/"
at the end.

* camel-service.c (construct): Update calls to camel_url_to_string
(pass CAMEL_URL_HIDE_PASSWORD)

camel/ChangeLog
camel/camel-service.c
camel/camel-url.c
camel/camel-url.h
camel/providers/imap/camel-imap-store.c
camel/tests/misc/url.c

index ccb68df..bfcfe69 100644 (file)
@@ -1,3 +1,19 @@
+2001-03-29  Dan Winship  <danw@ximian.com>
+
+       * camel-url.c (camel_url_to_string): change "gboolean show_passwd"
+       to "guint32 flags".
+
+       * tests/misc/url.c (main): Update calls to camel_url_to_string
+
+       * providers/imap/camel-imap-store.c (construct): Call
+       camel_url_to_string with flags to hide password, authtype, and
+       params to create the base_url.
+       (etc): Update for the fact that the base_url no longer has the "/"
+       at the end.
+
+       * camel-service.c (construct): Update calls to camel_url_to_string
+       (pass CAMEL_URL_HIDE_PASSWORD)
+
 2001-03-28  Jeffrey Stedfast  <fejj@ximian.com>
 
        * camel-pgp-context.[c,h]: New class for PGP encrypting,
index cbf0e5b..b0e8c1e 100644 (file)
@@ -134,7 +134,7 @@ construct (CamelService *service, CamelSession *session,
 
        if (CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_USER) &&
            (url->user == NULL || url->user[0] == '\0')) {
-               url_string = camel_url_to_string (url, FALSE);
+               url_string = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD);
                camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
                                      _("URL '%s' needs a username component"),
                                      url_string);
@@ -142,7 +142,7 @@ construct (CamelService *service, CamelSession *session,
                return;
        } else if (CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_HOST) &&
                   (url->host == NULL || url->host[0] == '\0')) {
-               url_string = camel_url_to_string (url, FALSE);
+               url_string = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD);
                camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
                                      _("URL '%s' needs a host component"),
                                      url_string);
@@ -150,7 +150,7 @@ construct (CamelService *service, CamelSession *session,
                return;
        } else if (CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_PATH) &&
                   (url->path == NULL || url->path[0] == '\0')) {
-               url_string = camel_url_to_string (url, FALSE);
+               url_string = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD);
                camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
                                      _("URL '%s' needs a path component"),
                                      url_string);
index 28f9134..535564f 100644 (file)
@@ -292,12 +292,12 @@ camel_url_new (const char *url_string, CamelException *ex)
 /**
  * camel_url_to_string:
  * @url: a CamelURL
- * @show_password: whether or not to include the password in the output
+ * @flags: additional translation options.
  *
  * Return value: a string representing @url, which the caller must free.
  **/
 char *
-camel_url_to_string (CamelURL *url, gboolean show_passwd)
+camel_url_to_string (CamelURL *url, guint32 flags)
 {
        GString *str;
        char *enc, *return_result;
@@ -322,7 +322,7 @@ camel_url_to_string (CamelURL *url, gboolean show_passwd)
                        g_string_sprintfa (str, ";auth=%s", enc);
                        g_free (enc);
                }
-               if (show_passwd && url->passwd) {
+               if (url->passwd && !(flags & CAMEL_URL_HIDE_PASSWORD)) {
                        enc = camel_url_encode (url->passwd, TRUE, "@/");
                        g_string_sprintfa (str, ":%s", enc);
                        g_free (enc);
@@ -342,7 +342,7 @@ camel_url_to_string (CamelURL *url, gboolean show_passwd)
                g_string_sprintfa (str, "%s", enc);
                g_free (enc);
        }
-       if (url->params)
+       if (url->params && !(flags & CAMEL_URL_HIDE_PARAMS))
                g_datalist_foreach (&url->params, output_param, str);
        if (url->query) {
                enc = camel_url_encode (url->query, FALSE, "#");
index 85464a2..9465da0 100644 (file)
@@ -49,9 +49,13 @@ typedef struct {
        char  *fragment;
 } CamelURL;
 
+#define CAMEL_URL_HIDE_PASSWORD        (1 << 0)
+#define CAMEL_URL_HIDE_PARAMS  (1 << 1)
+#define CAMEL_URL_HIDE_AUTH    (1 << 2)
+
 CamelURL *camel_url_new_with_base (CamelURL *base, const char *url_string);
 CamelURL *camel_url_new (const char *url_string, CamelException *ex);
-char *camel_url_to_string (CamelURL *url, gboolean show_password);
+char *camel_url_to_string (CamelURL *url, guint32 flags);
 void camel_url_free (CamelURL *url);
 
 char *camel_url_encode (char *part, gboolean escape_unsafe, char *escape_extra);
index d9466e1..daa9871 100644 (file)
@@ -198,7 +198,6 @@ construct (CamelService *service, CamelSession *session,
 {
        CamelImapStore *imap_store = CAMEL_IMAP_STORE (service);
        CamelStore *store = CAMEL_STORE (service);
-       CamelURL *base_url;
 
        CAMEL_SERVICE_CLASS (remote_store_class)->construct (service, session, provider, url, ex);
        if (camel_exception_is_set (ex))
@@ -208,14 +207,9 @@ construct (CamelService *service, CamelSession *session,
        if (camel_exception_is_set (ex)) 
                return;
 
-       base_url = g_new0 (CamelURL, 1);
-       camel_url_set_protocol (base_url, service->url->protocol);
-       camel_url_set_user (base_url, service->url->user);
-       camel_url_set_host (base_url, service->url->host);
-       camel_url_set_port (base_url, service->url->port);
-       camel_url_set_path (base_url, "/");
-       imap_store->base_url = camel_url_to_string (base_url, FALSE);
-       camel_url_free (base_url);
+       imap_store->base_url = camel_url_to_string (service->url, (CAMEL_URL_HIDE_PASSWORD |
+                                                                  CAMEL_URL_HIDE_PARAMS |
+                                                                  CAMEL_URL_HIDE_AUTH));
 
        imap_store->parameters = 0;
        if (camel_url_get_param (url, "use_lsub"))
@@ -950,7 +944,7 @@ parse_list_response_as_folder_info (CamelImapStore *imap_store,
        else
                fi->name = g_strdup (dir);
        if (!(flags & IMAP_LIST_FLAG_NOSELECT))
-               fi->url = g_strdup_printf ("%s%s", imap_store->base_url, dir);
+               fi->url = g_strdup_printf ("%s/%s", imap_store->base_url, dir);
        if (!(flags & IMAP_LIST_FLAG_UNMARKED))
                fi->unread_message_count = -1;
 
@@ -1086,7 +1080,7 @@ get_folders_offline (CamelImapStore *imap_store, GPtrArray *folders,
                        fi->name = g_strdup (fi->name + 1);
                else
                        fi->name = g_strdup (fi->full_name);
-               fi->url = g_strdup_printf ("%s%s", imap_store->base_url,
+               fi->url = g_strdup_printf ("%s/%s", imap_store->base_url,
                                           fi->full_name);
                fi->unread_message_count = -1;
                folders->pdata[i++] = fi;
@@ -1182,7 +1176,7 @@ get_folder_info (CamelStore *store, const char *top, gboolean fast,
                fi = g_new0 (CamelFolderInfo, 1);
                fi->full_name = g_strdup ("INBOX");
                fi->name = g_strdup ("INBOX");
-               fi->url = g_strdup_printf ("%sINBOX", imap_store->base_url);
+               fi->url = g_strdup_printf ("%s/INBOX", imap_store->base_url);
                fi->unread_message_count = -1;
 
                g_ptr_array_add (folders, fi);
@@ -1275,7 +1269,7 @@ subscribe_folder (CamelStore *store, const char *folder_name,
                fi = g_new0 (CamelFolderInfo, 1);
                fi->full_name = g_strdup (folder_name);
                fi->name = g_strdup (name);
-               fi->url = g_strdup_printf ("%s%s", imap_store->base_url, folder_name);
+               fi->url = g_strdup_printf ("%s/%s", imap_store->base_url, folder_name);
                fi->unread_message_count = -1;
                
                camel_object_trigger_event (CAMEL_OBJECT (store),
@@ -1320,7 +1314,7 @@ unsubscribe_folder (CamelStore *store, const char *folder_name,
                fi = g_new0 (CamelFolderInfo, 1);
                fi->full_name = g_strdup (folder_name);
                fi->name = g_strdup (name);
-               fi->url = g_strdup_printf ("%s%s", imap_store->base_url, folder_name);
+               fi->url = g_strdup_printf ("%s/%s", imap_store->base_url, folder_name);
                fi->unread_message_count = -1;
                
                camel_object_trigger_event (CAMEL_OBJECT (store),
index 128eb29..cc61ef3 100644 (file)
@@ -73,7 +73,7 @@ main (int argc, char **argv)
        camel_test_pull ();
 
        camel_test_push ("base URL unparsing");
-       url_string = camel_url_to_string (base_url, TRUE);
+       url_string = camel_url_to_string (base_url, 0);
        if (strcmp (url_string, base) != 0) {
                camel_test_fail ("URL <%s> unparses to <%s>\n",
                                 base, url_string);
@@ -90,7 +90,7 @@ main (int argc, char **argv)
                        continue;
                }
 
-               url_string = camel_url_to_string (url, TRUE);
+               url_string = camel_url_to_string (url, 0);
                if (strcmp (url_string, tests[i].result) != 0)
                        camel_test_fail ("got <%s>!", url_string);
                g_free (url_string);