mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
mime: Pass @term to the get_mime_handler.
@term will be used by proper mailcap handling on slave terminals.
This commit is contained in:
parent
199232b501
commit
6913f1b4f7
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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. */
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 *
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user