From 0ee52be73fb225d0da6c90fc2d2709ade2e49fa7 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 2 Sep 2007 16:59:05 +0200 Subject: [PATCH] Revert "mime: Pass @term to the get_mime_handler." This reverts commit 6913f1b4f724edba7e63a8fafa30bc5809cf493c. --- 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, 14 insertions(+), 19 deletions(-) diff --git a/src/mime/backend/common.c b/src/mime/backend/common.c index c456ee54..a103c199 100644 --- a/src/mime/backend/common.c +++ b/src/mime/backend/common.c @@ -13,7 +13,6 @@ #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" @@ -56,7 +55,7 @@ get_content_type_backends(unsigned char *extension) } struct mime_handler * -get_mime_handler_backends(unsigned char *ctype, struct terminal *term) +get_mime_handler_backends(unsigned char *ctype, int have_x) { const struct mime_backend *backend; int i; @@ -65,7 +64,7 @@ get_mime_handler_backends(unsigned char *ctype, struct terminal *term) if (backend->get_mime_handler) { struct mime_handler *handler; - handler = backend->get_mime_handler(ctype, term); + handler = backend->get_mime_handler(ctype, have_x); if (handler) return handler; } } diff --git a/src/mime/backend/common.h b/src/mime/backend/common.h index 42c16fc7..7c01443c 100644 --- a/src/mime/backend/common.h +++ b/src/mime/backend/common.h @@ -2,7 +2,6 @@ #ifndef EL__MIME_BACKEND_COMMON_H #define EL__MIME_BACKEND_COMMON_H -struct terminal; #include "mime/mime.h" struct mime_backend { @@ -11,7 +10,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, struct terminal *term); + struct mime_handler *(*get_mime_handler)(unsigned char *type, int have_x); }; /* Multiplexor functions for the backends. */ @@ -19,7 +18,7 @@ struct mime_backend { unsigned char *get_content_type_backends(unsigned char *extension); struct mime_handler * -get_mime_handler_backends(unsigned char *content_type, struct terminal *term); +get_mime_handler_backends(unsigned char *content_type, int have_x); /* 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 2478ff24..30f27319 100644 --- a/src/mime/backend/default.c +++ b/src/mime/backend/default.c @@ -188,11 +188,10 @@ get_mime_handler_option(struct option *type_opt, int xwin) } static struct mime_handler * -get_mime_handler_default(unsigned char *type, struct terminal *term) +get_mime_handler_default(unsigned char *type, int have_x) { 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 e301c50b..752c626c 100644 --- a/src/mime/backend/mailcap.c +++ b/src/mime/backend/mailcap.c @@ -34,7 +34,6 @@ #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" @@ -634,7 +633,7 @@ get_mailcap_entry(unsigned char *type) } static struct mime_handler * -get_mime_handler_mailcap(unsigned char *type, struct terminal *term) +get_mime_handler_mailcap(unsigned char *type, int options) { struct mailcap_entry *entry; struct mime_handler *handler; diff --git a/src/mime/mime.c b/src/mime/mime.c index 1033638e..81d64820 100644 --- a/src/mime/mime.c +++ b/src/mime/mime.c @@ -21,7 +21,6 @@ #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" @@ -116,7 +115,7 @@ check_extension_type(unsigned char *extension) if (!content_type) return NULL; - handler = get_mime_type_handler(content_type, NULL); + handler = get_mime_type_handler(content_type, 1); if (handler) { mem_free(handler); return content_type; @@ -318,9 +317,9 @@ get_content_type(struct cache_entry *cached) } struct mime_handler * -get_mime_type_handler(unsigned char *content_type, struct terminal *term) +get_mime_type_handler(unsigned char *content_type, int xwin) { - return get_mime_handler_backends(content_type, term); + return get_mime_handler_backends(content_type, xwin); } struct string * diff --git a/src/mime/mime.h b/src/mime/mime.h index 48dd70ba..01524fdd 100644 --- a/src/mime/mime.h +++ b/src/mime/mime.h @@ -4,7 +4,6 @@ #include "main/module.h" struct cache_entry; -struct terminal; struct uri; struct mime_handler { @@ -25,9 +24,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 @term->environment tells about X capabilities. */ +/* Find program to handle mimetype. The @xwin tells about X capabilities. */ struct mime_handler * -get_mime_type_handler(unsigned char *content_type, struct terminal *term); +get_mime_type_handler(unsigned char *content_type, int xwin); /* 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 bc897f49..c96c2c29 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 i; + int xwin, i; if (!ctype || !*ctype) goto plaintext_follow; @@ -1343,7 +1343,8 @@ setup_download_handler(struct session *ses, struct download *loading, goto plaintext_follow; } - handler = get_mime_type_handler(ctype, ses->tab->term); + xwin = ses->tab->term->environment & ENV_XWIN; + handler = get_mime_type_handler(ctype, xwin); if (!handler && strlen(ctype) >= 4 && !strncasecmp(ctype, "text", 4)) goto plaintext_follow;