mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
Revert "mime: Pass @term to the get_mime_handler."
This reverts commit 6913f1b4f7
.
This commit is contained in:
parent
6b059d3d36
commit
0ee52be73f
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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. */
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 *
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user