2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
|
|
|
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
2003-05-31 22:47:00 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "netsurf/content/content.h"
|
|
|
|
#include "netsurf/render/html.h"
|
|
|
|
#include "netsurf/riscos/plugin.h"
|
|
|
|
#include "netsurf/utils/log.h"
|
|
|
|
#include "netsurf/utils/utils.h"
|
|
|
|
|
2003-06-03 01:09:50 +04:00
|
|
|
#include "oslib/mimemap.h"
|
|
|
|
|
2003-05-31 22:47:00 +04:00
|
|
|
|
2003-07-08 02:10:51 +04:00
|
|
|
/**
|
|
|
|
* plugin_create
|
|
|
|
* initialises plugin system in readiness for recieving object data
|
|
|
|
*
|
|
|
|
* TODO: implement aborting the fetch
|
|
|
|
*/
|
|
|
|
void plugin_create(struct content *c)
|
|
|
|
{
|
2003-07-10 01:33:01 +04:00
|
|
|
/* we can't create the plugin here, because this is only called
|
|
|
|
* once, even if the object appears several times */
|
|
|
|
}
|
2003-07-08 02:10:51 +04:00
|
|
|
|
|
|
|
|
2003-07-10 01:33:01 +04:00
|
|
|
/**
|
|
|
|
* plugin_add_user
|
|
|
|
*
|
|
|
|
* The content has been added to a page somewhere: launch the plugin.
|
|
|
|
* This may be called anytime after plugin_create any number of times.
|
|
|
|
* Each must launch a new plugin.
|
|
|
|
*/
|
|
|
|
void plugin_add_user(struct content *c, struct object_params *params)
|
|
|
|
{
|
|
|
|
assert(params != 0);
|
2003-07-08 02:10:51 +04:00
|
|
|
/* ok, it looks like we can handle this object.
|
|
|
|
* Broadcast Message_PlugIn_Open (&4D540) and listen for response
|
|
|
|
* Message_PlugIn_Opening (&4D541). If no response, try to launch
|
|
|
|
* plugin by Wimp_StartTask(sysvar). Then re-broadcast Message_PlugIn_Open
|
|
|
|
* and listen for response. If there is still no response, give up and set
|
|
|
|
* can_handle to FALSE.
|
|
|
|
* NB: For the bounding box in Message_PlugIn_Open, we choose arbitrary
|
|
|
|
* values outside the area displayed. This is corrected when
|
|
|
|
* plugin_redraw is called.
|
|
|
|
*/
|
2003-07-10 01:33:01 +04:00
|
|
|
}
|
2003-07-08 02:10:51 +04:00
|
|
|
|
|
|
|
|
2003-07-10 01:33:01 +04:00
|
|
|
/**
|
|
|
|
* plugin_remove_user
|
|
|
|
*
|
|
|
|
* A plugin is no longer required, eg. the page containing it has
|
|
|
|
* been closed.
|
|
|
|
*/
|
|
|
|
void plugin_remove_user(struct content *c, struct object_params *params)
|
|
|
|
{
|
|
|
|
assert(params != 0);
|
|
|
|
}
|
2003-07-08 02:10:51 +04:00
|
|
|
|
2003-05-31 22:47:00 +04:00
|
|
|
|
|
|
|
|
2003-07-08 02:10:51 +04:00
|
|
|
static const char * const ALIAS_PREFIX = "Alias$@PlugInType_";
|
|
|
|
|
2003-05-31 22:47:00 +04:00
|
|
|
/**
|
2003-07-08 02:10:51 +04:00
|
|
|
* plugin_handleable
|
|
|
|
* Tests whether we can handle an object using a browser plugin
|
|
|
|
* returns TRUE if we can handle it, FALSE if we can't.
|
2003-05-31 22:47:00 +04:00
|
|
|
*/
|
2003-07-10 01:33:01 +04:00
|
|
|
bool plugin_handleable(const char *mime_type)
|
2003-07-08 02:10:51 +04:00
|
|
|
{
|
|
|
|
char *sysvar;
|
|
|
|
unsigned int *fv;
|
|
|
|
os_error *e;
|
2003-05-31 22:47:00 +04:00
|
|
|
|
2003-07-08 02:10:51 +04:00
|
|
|
/* prefix + 3 for file type + 1 for terminating \0 */
|
|
|
|
sysvar = xcalloc(strlen(ALIAS_PREFIX)+4, sizeof(char));
|
2003-05-31 22:47:00 +04:00
|
|
|
|
2003-07-10 01:33:01 +04:00
|
|
|
e = xmimemaptranslate_mime_type_to_filetype(mime_type, (bits *) &fv);
|
2003-07-08 02:10:51 +04:00
|
|
|
|
2003-07-10 01:33:01 +04:00
|
|
|
sprintf(sysvar, "%s%x", ALIAS_PREFIX, e == NULL ? fv : 0 );
|
|
|
|
if (getenv(sysvar) == 0)
|
2003-07-10 02:06:39 +04:00
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
2003-05-31 22:47:00 +04:00
|
|
|
}
|
2003-06-06 06:08:56 +04:00
|
|
|
|
|
|
|
/**
|
2003-07-08 02:10:51 +04:00
|
|
|
* plugin_process_data
|
|
|
|
* processes data retrieved by the fetch process
|
|
|
|
*
|
|
|
|
* TODO: plugin stream protocol
|
|
|
|
*
|
2003-06-06 06:08:56 +04:00
|
|
|
*/
|
2003-07-08 02:10:51 +04:00
|
|
|
void plugin_process_data(struct content *c, char *data, unsigned long size)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* If the plugin requests, we send the data to it via the
|
|
|
|
* plugin stream protocol.
|
|
|
|
* Also, we should listen for Message_PlugIn_URL_Access (&4D54D)
|
|
|
|
* as the plugin may need us to retrieve URLs for it.
|
|
|
|
* We should also listen for Message_PlugIn_Closed (&4D543).
|
|
|
|
* If this occurs, the plugin has exited with an error.
|
|
|
|
* Therefore, we need to stop the fetch and exit.
|
|
|
|
*/
|
2003-06-06 06:08:56 +04:00
|
|
|
|
2003-07-10 01:33:01 +04:00
|
|
|
/* I think we should just buffer the data here, in case the
|
|
|
|
* plugin requests it sometime in the future. - James */
|
2003-07-08 02:10:51 +04:00
|
|
|
}
|
2003-06-06 06:08:56 +04:00
|
|
|
|
2003-07-08 02:10:51 +04:00
|
|
|
/**
|
|
|
|
* plugin_convert
|
|
|
|
* This isn't needed by the plugin system as all the data processing is done
|
|
|
|
* externally. Therefore, just tell NetSurf that everything's OK.
|
|
|
|
*/
|
|
|
|
int plugin_convert(struct content *c, unsigned int width, unsigned int height)
|
|
|
|
{
|
|
|
|
c->status=CONTENT_STATUS_DONE;
|
|
|
|
return 0;
|
|
|
|
}
|
2003-06-06 06:08:56 +04:00
|
|
|
|
2003-07-08 02:10:51 +04:00
|
|
|
void plugin_revive(struct content *c, unsigned int width, unsigned int height)
|
|
|
|
{
|
|
|
|
}
|
2003-06-06 06:08:56 +04:00
|
|
|
|
2003-07-08 02:10:51 +04:00
|
|
|
void plugin_reformat(struct content *c, unsigned int width, unsigned int height)
|
|
|
|
{
|
2003-06-06 06:08:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-07-08 02:10:51 +04:00
|
|
|
* plugin_destroy
|
|
|
|
* we've finished with this data, destroy it. Also, shutdown plugin.
|
|
|
|
*
|
|
|
|
* TODO: clean up
|
2003-06-06 06:08:56 +04:00
|
|
|
*/
|
2003-07-08 02:10:51 +04:00
|
|
|
void plugin_destroy(struct content *c)
|
|
|
|
{
|
|
|
|
}
|
2003-06-06 06:08:56 +04:00
|
|
|
|
2003-07-08 02:10:51 +04:00
|
|
|
/**
|
|
|
|
* plugin_redraw
|
|
|
|
* redraw plugin on page.
|
|
|
|
*
|
|
|
|
* TODO: Message_PlugIn_Reshape
|
|
|
|
*/
|
|
|
|
void plugin_redraw(struct content *c, long x, long y,
|
|
|
|
unsigned long width, unsigned long height)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* By now, we've got the plugin up and running in a nested window
|
|
|
|
* off the viewable page area. Now we want to display it in its place.
|
|
|
|
* Therefore, broadcast a Message_PlugIn_Reshape (&4D544) with the values
|
|
|
|
* given to us.
|
|
|
|
*/
|
2003-06-06 06:08:56 +04:00
|
|
|
}
|