From 6913f1b4f724edba7e63a8fafa30bc5809cf493c Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sat, 14 Jul 2007 22:24:20 +0200 Subject: [PATCH] mime: Pass @term to the get_mime_handler. @term will be used by proper mailcap handling on slave terminals. --- src/mime/backend/common.c | 5 +++-- src/mime/backend/common.h | 5 +++-- src/mime/backend/default.c | 3 ++- src/mime/backend/mailcap.c | 3 ++- src/mime/mime.c | 7 ++++--- src/mime/mime.h | 5 +++-- src/session/download.c | 5 ++--- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/mime/backend/common.c b/src/mime/backend/common.c index a103c1994..c456ee541 100644 --- a/src/mime/backend/common.c +++ b/src/mime/backend/common.c @@ -13,6 +13,7 @@ #include "main/module.h" #include "mime/backend/common.h" #include "mime/mime.h" +#include "terminal/terminal.h" #include "util/file.h" #include "util/memory.h" #include "util/string.h" @@ -55,7 +56,7 @@ get_content_type_backends(unsigned char *extension) } struct mime_handler * -get_mime_handler_backends(unsigned char *ctype, int have_x) +get_mime_handler_backends(unsigned char *ctype, struct terminal *term) { const struct mime_backend *backend; int i; @@ -64,7 +65,7 @@ get_mime_handler_backends(unsigned char *ctype, int have_x) if (backend->get_mime_handler) { struct mime_handler *handler; - handler = backend->get_mime_handler(ctype, have_x); + handler = backend->get_mime_handler(ctype, term); if (handler) return handler; } } diff --git a/src/mime/backend/common.h b/src/mime/backend/common.h index 7c01443c7..42c16fc70 100644 --- a/src/mime/backend/common.h +++ b/src/mime/backend/common.h @@ -2,6 +2,7 @@ #ifndef EL__MIME_BACKEND_COMMON_H #define EL__MIME_BACKEND_COMMON_H +struct terminal; #include "mime/mime.h" struct mime_backend { @@ -10,7 +11,7 @@ struct mime_backend { /* Given a mime type find a associated handler. The handler can * be given options such */ - struct mime_handler *(*get_mime_handler)(unsigned char *type, int have_x); + struct mime_handler *(*get_mime_handler)(unsigned char *type, struct terminal *term); }; /* Multiplexor functions for the backends. */ @@ -18,7 +19,7 @@ struct mime_backend { unsigned char *get_content_type_backends(unsigned char *extension); struct mime_handler * -get_mime_handler_backends(unsigned char *content_type, int have_x); +get_mime_handler_backends(unsigned char *content_type, struct terminal *term); /* Extracts a filename from @path separated by @separator. Targeted for use * with the general unix PATH style strings. */ diff --git a/src/mime/backend/default.c b/src/mime/backend/default.c index 30f273194..2478ff244 100644 --- a/src/mime/backend/default.c +++ b/src/mime/backend/default.c @@ -188,10 +188,11 @@ get_mime_handler_option(struct option *type_opt, int xwin) } static struct mime_handler * -get_mime_handler_default(unsigned char *type, int have_x) +get_mime_handler_default(unsigned char *type, struct terminal *term) { struct option *type_opt = get_mime_type_option(type); struct option *handler_opt; + int have_x = term ? (term->environment & ENV_XWIN) : 1; if (!type_opt) return NULL; diff --git a/src/mime/backend/mailcap.c b/src/mime/backend/mailcap.c index aaa17b3fb..d2e072274 100644 --- a/src/mime/backend/mailcap.c +++ b/src/mime/backend/mailcap.c @@ -34,6 +34,7 @@ #include "mime/mime.h" #include "osdep/osdep.h" /* For exe() */ #include "session/session.h" +#include "terminal/terminal.h" #include "util/file.h" #include "util/hash.h" #include "util/lists.h" @@ -633,7 +634,7 @@ get_mailcap_entry(unsigned char *type) } static struct mime_handler * -get_mime_handler_mailcap(unsigned char *type, int options) +get_mime_handler_mailcap(unsigned char *type, struct terminal *term) { struct mailcap_entry *entry; struct mime_handler *handler; diff --git a/src/mime/mime.c b/src/mime/mime.c index 81d64820e..1033638eb 100644 --- a/src/mime/mime.c +++ b/src/mime/mime.c @@ -21,6 +21,7 @@ #include "mime/mime.h" #include "protocol/header.h" /* For parse_header() */ #include "protocol/uri.h" +#include "terminal/terminal.h" #include "util/conv.h" #include "util/file.h" #include "util/memory.h" @@ -115,7 +116,7 @@ check_extension_type(unsigned char *extension) if (!content_type) return NULL; - handler = get_mime_type_handler(content_type, 1); + handler = get_mime_type_handler(content_type, NULL); if (handler) { mem_free(handler); return content_type; @@ -317,9 +318,9 @@ get_content_type(struct cache_entry *cached) } struct mime_handler * -get_mime_type_handler(unsigned char *content_type, int xwin) +get_mime_type_handler(unsigned char *content_type, struct terminal *term) { - return get_mime_handler_backends(content_type, xwin); + return get_mime_handler_backends(content_type, term); } struct string * diff --git a/src/mime/mime.h b/src/mime/mime.h index 01524fdd5..48dd70ba7 100644 --- a/src/mime/mime.h +++ b/src/mime/mime.h @@ -4,6 +4,7 @@ #include "main/module.h" struct cache_entry; +struct terminal; struct uri; struct mime_handler { @@ -24,9 +25,9 @@ unsigned char *get_content_type(struct cache_entry *cached); /* Guess content type by looking at configurations of the given @extension */ unsigned char *get_extension_content_type(unsigned char *extension); -/* Find program to handle mimetype. The @xwin tells about X capabilities. */ +/* Find program to handle mimetype. The @term->environment tells about X capabilities. */ struct mime_handler * -get_mime_type_handler(unsigned char *content_type, int xwin); +get_mime_type_handler(unsigned char *content_type, struct terminal *term); /* Extracts strictly the filename part (the crap between path and query) and * adds it to the @string. Note that there are cases where the string will be diff --git a/src/session/download.c b/src/session/download.c index f0e3299f0..53985cdd8 100644 --- a/src/session/download.c +++ b/src/session/download.c @@ -1330,7 +1330,7 @@ setup_download_handler(struct session *ses, struct download *loading, unsigned char *ctype = get_content_type(cached); int plaintext = 1; int ret = 0; - int xwin, i; + int i; if (!ctype || !*ctype) goto plaintext_follow; @@ -1343,8 +1343,7 @@ setup_download_handler(struct session *ses, struct download *loading, goto plaintext_follow; } - xwin = ses->tab->term->environment & ENV_XWIN; - handler = get_mime_type_handler(ctype, xwin); + handler = get_mime_type_handler(ctype, ses->tab->term); if (!handler && strlen(ctype) >= 4 && !strncasecmp(ctype, "text", 4)) goto plaintext_follow;