diff options
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 16 | ||||
-rw-r--r-- | camel/camel-service.c | 6 | ||||
-rw-r--r-- | camel/camel-url.c | 8 | ||||
-rw-r--r-- | camel/camel-url.h | 6 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 22 | ||||
-rw-r--r-- | camel/tests/misc/url.c | 4 |
6 files changed, 38 insertions, 24 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index ccb68df5ea..bfcfe693a1 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -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, diff --git a/camel/camel-service.c b/camel/camel-service.c index cbf0e5b681..b0e8c1ec59 100644 --- a/camel/camel-service.c +++ b/camel/camel-service.c @@ -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); diff --git a/camel/camel-url.c b/camel/camel-url.c index 28f913495d..535564f28e 100644 --- a/camel/camel-url.c +++ b/camel/camel-url.c @@ -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, "#"); diff --git a/camel/camel-url.h b/camel/camel-url.h index 85464a2fd0..9465da06a1 100644 --- a/camel/camel-url.h +++ b/camel/camel-url.h @@ -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); diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index d9466e120e..daa9871539 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -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), diff --git a/camel/tests/misc/url.c b/camel/tests/misc/url.c index 128eb29fc5..cc61ef3cd6 100644 --- a/camel/tests/misc/url.c +++ b/camel/tests/misc/url.c @@ -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); |