[evolution/webkit: 34/154] em_format_build_mail_uri() accepts varying number of arguments.
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit: 34/154] em_format_build_mail_uri() accepts varying number of arguments.
- Date: Tue, 14 Feb 2012 14:04:29 +0000 (UTC)
commit 61fc8adb9ac8745cff7d5efa8410e5860964ec9b
Author: Dan VrÃtil <dvratil redhat com>
Date: Thu Sep 22 19:04:58 2011 +0200
em_format_build_mail_uri() accepts varying number of arguments.
The additional arguments are appended as URL query items.
em-format/em-format.c | 43 ++++++++++++++++++++++++++++++-------------
em-format/em-format.h | 3 ++-
mail/e-mail-display.c | 7 +++++--
3 files changed, 37 insertions(+), 16 deletions(-)
---
diff --git a/em-format/em-format.c b/em-format/em-format.c
index d3eb1b1..cc43152 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -2150,35 +2150,52 @@ em_format_snoop_type (CamelMimePart *part)
gchar*
em_format_build_mail_uri (CamelFolder *folder,
const gchar *message_uid,
- const gchar *part_uid)
+ const gchar *first_param_name,
+ ...)
{
CamelStore *store;
gchar *uri, *tmp;
+ va_list ap;
+ const gchar *name;
+ char separator;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
g_return_val_if_fail (message_uid && *message_uid, NULL);
store = camel_folder_get_parent_store (folder);
- if (part_uid && *part_uid) {
- uri = g_strdup_printf ("mail://%s/%s/%s?part_id=%s",
- camel_service_get_uid (CAMEL_SERVICE (store)),
- camel_folder_get_full_name (folder),
- message_uid,
- part_uid);
- } else {
- uri = g_strdup_printf ("mail://%s/%s/%s",
- camel_service_get_uid (CAMEL_SERVICE (store)),
- camel_folder_get_full_name (folder),
- message_uid);
+ tmp = g_strdup_printf ("mail://%s/%s/%s",
+ camel_service_get_uid (CAMEL_SERVICE (store)),
+ camel_folder_get_full_name (folder),
+ message_uid);
+
+ va_start (ap, first_param_name);
+ name = first_param_name;
+ separator = '?';
+ while (name) {
+ gchar *tmp2;
+ gchar *val = va_arg (ap, char *);
+ if (val) {
+ tmp2 = g_strdup_printf ("%s%c%s=%s", tmp, separator, name, val);
+ g_free (tmp);
+ tmp = tmp2;
+ }
+
+ if (separator == '?')
+ separator = '&';
+
+ name = va_arg (ap, char *);
}
+ va_end (ap);
+
+ uri = tmp;
/* For some reason, webkit won't accept URL with username, but
* without password (mail://store host/folder/mail), so we
* will replace the '@' symbol by '/' to get URL like
* mail://store/host/folder/mail which is OK
*/
- tmp = strchr (uri, '@');
+ tmp = strchr (tmp, '@');
if (tmp) {
tmp[0] = '/';
}
diff --git a/em-format/em-format.h b/em-format/em-format.h
index c7d69a9..60c7581 100644
--- a/em-format/em-format.h
+++ b/em-format/em-format.h
@@ -268,7 +268,8 @@ const gchar* em_format_snoop_type (CamelMimePart *part);
gchar * em_format_build_mail_uri (CamelFolder *folder,
const gchar *message_uid,
- const gchar *part_uid);
+ const gchar *part_uid,
+ ...) G_GNUC_NULL_TERMINATED;
/* EMFormatParseFunc that does nothing. Use it to disable
* parsing of a specific mime type parts */
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 6968d0c..b1d18d7 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -345,7 +345,8 @@ mail_display_resource_requested (WebKitWebView *web_view,
/* Redirect cid:part_id to mail://mail_id/cid:part_id */
if (g_str_has_prefix (uri, "cid:")) {
- gchar *new_uri = em_format_build_mail_uri (EM_FORMAT (formatter)->folder, EM_FORMAT (formatter)->message_uid, uri);
+ gchar *new_uri = em_format_build_mail_uri (EM_FORMAT (formatter)->folder,
+ EM_FORMAT (formatter)->message_uid, "part_id", uri, NULL);
webkit_network_request_set_uri (request, new_uri);
@@ -657,7 +658,9 @@ e_mail_display_load (EMailDisplay *display,
GtkWidget *widget = NULL;
puri = iter->data;
- uri = em_format_build_mail_uri (emf->folder, emf->message_uid, puri->uri);
+ uri = em_format_build_mail_uri (emf->folder, emf->message_uid,
+ "part_id", puri->uri, NULL);
+ g_message ("%s", uri);
if (puri->widget_func) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]