mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-22 22:41:30 +03:00
Migrate to new MIMEtyper
svn path=/trunk/netsurf/; revision=12375
This commit is contained in:
parent
4f8995ae8d
commit
38bcb14d77
@ -92,17 +92,18 @@ nserror amiga_dt_anim_init(void)
|
||||
lwc_error lerror;
|
||||
nserror error;
|
||||
BPTR fh = 0;
|
||||
struct Node *node = NULL;
|
||||
|
||||
while((dt = ObtainDataType(DTST_RAM, NULL,
|
||||
DTA_DataType, prevdt,
|
||||
DTA_GroupID, GID_ANIMATION,
|
||||
DTA_GroupID, GID_PICTURE, // we only support images for now
|
||||
TAG_DONE)) != NULL)
|
||||
{
|
||||
ReleaseDataType(prevdt);
|
||||
prevdt = dt;
|
||||
ami_datatype_to_mimetype(dt, dt_mime);
|
||||
|
||||
LOG(("Guessed MIME from DT: %s", dt_mime));
|
||||
LOG(("Guessed MIME from anim DT: %s", dt_mime));
|
||||
|
||||
lerror = lwc_intern_string(dt_mime, strlen(dt_mime), &type);
|
||||
if (lerror != lwc_error_ok)
|
||||
@ -116,32 +117,24 @@ nserror amiga_dt_anim_init(void)
|
||||
if (error != NSERROR_OK)
|
||||
return error;
|
||||
|
||||
do {
|
||||
node = ami_mime_from_datatype(dt, &type, node);
|
||||
|
||||
if(node)
|
||||
{
|
||||
error = content_factory_register_handler(type,
|
||||
&amiga_dt_anim_content_handler);
|
||||
|
||||
if (error != NSERROR_OK)
|
||||
return error;
|
||||
}
|
||||
|
||||
}while (node != NULL);
|
||||
|
||||
}
|
||||
|
||||
ReleaseDataType(prevdt);
|
||||
|
||||
if(fh = FOpen("PROGDIR:Resources/MIME/dt.animation", MODE_OLDFILE, 0))
|
||||
{
|
||||
while(FGets(fh, (UBYTE *)&dt_mime, 50) != 0)
|
||||
{
|
||||
dt_mime[strlen(dt_mime) - 1] = '\0';
|
||||
if((dt_mime[0] == '\0') || (dt_mime[0] == '#'))
|
||||
continue; /* Skip blank lines and comments */
|
||||
|
||||
lerror = lwc_intern_string(dt_mime, strlen(dt_mime), &type);
|
||||
if (lerror != lwc_error_ok)
|
||||
return NSERROR_NOMEM;
|
||||
|
||||
error = content_factory_register_handler(type,
|
||||
&amiga_dt_anim_content_handler);
|
||||
|
||||
lwc_string_unref(type);
|
||||
|
||||
if (error != NSERROR_OK)
|
||||
return error;
|
||||
}
|
||||
FClose(fh);
|
||||
}
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,7 @@ void ami_mime_entry_free(struct ami_mime_entry *mimeentry)
|
||||
/**
|
||||
* Return next matching MIME entry
|
||||
*
|
||||
* \param search lwc_string to search for
|
||||
* \param search lwc_string to search for (or NULL for all)
|
||||
* \param type of value being searched for (AMI_MIME_#?)
|
||||
* \param start_node node to continue search (updated on exit)
|
||||
* \return entry or NULL if no match
|
||||
@ -412,7 +412,6 @@ struct Node *ami_mime_from_datatype(struct DataType *dt,
|
||||
lwc_string *dt_name;
|
||||
lwc_error lerror;
|
||||
|
||||
if(IsMinListEmpty(ami_mime_list)) return NULL;
|
||||
if(dt == NULL) return NULL;
|
||||
|
||||
dth = dt->dtn_Header;
|
||||
@ -451,8 +450,6 @@ struct Node *ami_mime_to_filetype(lwc_string *mimetype,
|
||||
struct Node *node;
|
||||
struct ami_mime_entry *mimeentry;
|
||||
|
||||
if(IsMinListEmpty(ami_mime_list)) return NULL;
|
||||
|
||||
node = start_node;
|
||||
mimeentry = ami_mime_entry_locate(mimetype, AMI_MIME_MIMETYPE, &node);
|
||||
|
||||
@ -467,6 +464,62 @@ struct Node *ami_mime_to_filetype(lwc_string *mimetype,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all MIME types containing a plugincmd
|
||||
*
|
||||
* \param mimetype ptr to lwc_string MIME type
|
||||
* \param start_node node to feed back in to continue search
|
||||
* \return node or NULL if no match
|
||||
*/
|
||||
|
||||
struct Node *ami_mime_has_cmd(lwc_string **mimetype, struct Node *start_node)
|
||||
{
|
||||
struct Node *node;
|
||||
struct ami_mime_entry *mimeentry;
|
||||
|
||||
node = start_node;
|
||||
mimeentry = ami_mime_entry_locate(NULL, AMI_MIME_PLUGINCMD, &node);
|
||||
|
||||
if(mimeentry != NULL)
|
||||
{
|
||||
*mimetype = mimeentry->mimetype;
|
||||
return (struct Node *)node;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plugincmd matching a MIME type
|
||||
*
|
||||
* \param mimetype lwc_string MIME type
|
||||
* \param plugincmd ptr to lwc_string to hold plugincmd
|
||||
* \param start_node node to feed back in to continue search
|
||||
* \return node or NULL if no match
|
||||
*/
|
||||
|
||||
struct Node *ami_mime_to_plugincmd(lwc_string *mimetype,
|
||||
lwc_string **plugincmd, struct Node *start_node)
|
||||
{
|
||||
struct Node *node;
|
||||
struct ami_mime_entry *mimeentry;
|
||||
|
||||
node = start_node;
|
||||
mimeentry = ami_mime_entry_locate(mimetype, AMI_MIME_MIMETYPE, &node);
|
||||
|
||||
if(mimeentry != NULL)
|
||||
{
|
||||
*plugincmd = mimeentry->plugincmd;
|
||||
return (struct Node *)node;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the MIME type of an hlcache_handle to a DefIcons type
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
* Copyright 2010 - 2011 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
@ -33,8 +33,16 @@ void ami_mime_entry_free(struct ami_mime_entry *mimeentry);
|
||||
|
||||
struct Node *ami_mime_from_datatype(struct DataType *dt,
|
||||
lwc_string **mimetype, struct Node *start_node);
|
||||
struct Node *ami_mime_to_filetype(lwc_string *mimetype,
|
||||
lwc_string **filetype, struct Node *start_node);
|
||||
struct Node *ami_mime_to_plugincmd(lwc_string *mimetype,
|
||||
lwc_string **plugincmd, struct Node *start_node);
|
||||
|
||||
struct Node *ami_mime_has_cmd(lwc_string **mimetype, struct Node *start_node);
|
||||
|
||||
bool ami_mime_compare(struct hlcache_handle *c, const char *type);
|
||||
|
||||
/* deprecated */
|
||||
const char *ami_content_type_to_file_type(content_type type);
|
||||
void ami_datatype_to_mimetype(struct DataType *dtn, char *mimetype);
|
||||
bool ami_mime_compare(struct hlcache_handle *c, const char *type);
|
||||
#endif
|
||||
|
@ -39,12 +39,6 @@
|
||||
|
||||
typedef struct amiga_plugin_hack_content {
|
||||
struct content base;
|
||||
|
||||
Object *dto;
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
} amiga_plugin_hack_content;
|
||||
|
||||
static nserror amiga_plugin_hack_create(const content_handler *handler,
|
||||
@ -83,35 +77,26 @@ static const content_handler amiga_plugin_hack_content_handler = {
|
||||
|
||||
nserror amiga_plugin_hack_init(void)
|
||||
{
|
||||
char dt_mime[50];
|
||||
struct DataType *dt, *prevdt = NULL;
|
||||
struct Node *node = NULL;
|
||||
lwc_string *type;
|
||||
lwc_error lerror;
|
||||
nserror error;
|
||||
BPTR fh = 0;
|
||||
|
||||
if(fh = FOpen("PROGDIR:Resources/MIME/pluginhack", MODE_OLDFILE, 0))
|
||||
{
|
||||
while(FGets(fh, (UBYTE *)&dt_mime, 50) != 0)
|
||||
do {
|
||||
node = ami_mime_has_cmd(&type, node);
|
||||
|
||||
if(node)
|
||||
{
|
||||
dt_mime[strlen(dt_mime) - 1] = '\0';
|
||||
if((dt_mime[0] == '\0') || (dt_mime[0] == '#'))
|
||||
continue; /* Skip blank lines and comments */
|
||||
|
||||
lerror = lwc_intern_string(dt_mime, strlen(dt_mime), &type);
|
||||
if (lerror != lwc_error_ok)
|
||||
return NSERROR_NOMEM;
|
||||
printf("plugin_hack registered %s\n",lwc_string_data(type));
|
||||
|
||||
error = content_factory_register_handler(type,
|
||||
&amiga_plugin_hack_content_handler);
|
||||
|
||||
lwc_string_unref(type);
|
||||
&amiga_plugin_hack_content_handler);
|
||||
|
||||
if (error != NSERROR_OK)
|
||||
return error;
|
||||
}
|
||||
FClose(fh);
|
||||
}
|
||||
|
||||
}while (node != NULL);
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user