summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2010-09-12 11:29:58 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2010-09-12 11:29:58 +0000
commit883c738c0a30622dcc4189b63bf1af18b45295fb (patch)
treef0cc9ee4252ebc70026fc7a1313dbef8c12d521e
parentc0332c43946c1e700cc47835af047435d7b9d587 (diff)
downloadnetsurf-883c738c0a30622dcc4189b63bf1af18b45295fb.tar.gz
netsurf-883c738c0a30622dcc4189b63bf1af18b45295fb.tar.bz2
Stop launch-handler from reporting unknown protocols more than once
svn path=/trunk/netsurf/; revision=10760
-rwxr-xr-xamiga/fetch_mailto.c81
1 files changed, 77 insertions, 4 deletions
diff --git a/amiga/fetch_mailto.c b/amiga/fetch_mailto.c
index c710f3949..d031d12a4 100755
--- a/amiga/fetch_mailto.c
+++ b/amiga/fetch_mailto.c
@@ -21,14 +21,78 @@
*/
#include <string.h>
+#include <stdbool.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/utility.h>
#include <proto/openurl.h>
+#include <utils/url.h>
struct Library *OpenURLBase;
struct OpenURLIFace *IOpenURL;
+struct MinList ami_unsupportedprotocols;
+
+struct ami_protocol
+{
+ struct MinNode node;
+ char *protocol;
+};
+
+struct ami_protocol *ami_openurl_add_protocol(const char *url)
+{
+ struct ami_protocol *ami_p =
+ (struct ami_protocol *)AllocVec(sizeof(struct ami_protocol),
+ MEMF_PRIVATE | MEMF_CLEAR);
+
+ if(url_scheme(url, &ami_p->protocol) != URL_FUNC_OK)
+ {
+ FreeVec(ami_p);
+ return NULL;
+ }
+
+ AddTail((struct List *)&ami_unsupportedprotocols, (struct Node *)ami_p);
+ return ami_p;
+}
+
+void ami_openurl_free_list(struct MinList *list)
+{
+ struct ami_protocol *node;
+ struct ami_protocol *nnode;
+
+ if(IsMinListEmpty(list)) return;
+ node = (struct ami_protocol *)GetHead((struct List *)list);
+
+ do
+ {
+ nnode=(struct ami_protocol *)GetSucc((struct Node *)node);
+
+ Remove((struct Node *)node);
+ if(node->protocol) free(node->protocol);
+ FreeVec(node);
+ node = NULL;
+ }while(node=nnode);
+}
+
+BOOL ami_openurl_check_list(struct MinList *list, const char *url)
+{
+ struct ami_protocol *node;
+ struct ami_protocol *nnode;
+
+ if(IsMinListEmpty(list)) return FALSE;
+ node = (struct ami_protocol *)GetHead((struct List *)list);
+
+ do
+ {
+ nnode=(struct ami_protocol *)GetSucc((struct Node *)node);
+
+ if(!strncasecmp(url, node->protocol, strlen(node->protocol)))
+ return TRUE;
+ }while(node=nnode);
+
+ return FALSE;
+}
+
/**
* Initialise the fetcher.
*
@@ -37,16 +101,24 @@ struct OpenURLIFace *IOpenURL;
void ami_openurl_open(void)
{
+ struct ami_protocol *ami_p;
+
if(OpenURLBase = OpenLibrary("openurl.library",0))
{
IOpenURL = (struct OpenURLIFace *)GetInterface(OpenURLBase,"main",1,NULL);
}
+
+ NewMinList(&ami_unsupportedprotocols);
+ ami_openurl_add_protocol("about:");
+ ami_openurl_add_protocol("javascript:");
}
void ami_openurl_close(const char *scheme)
{
if(IOpenURL) DropInterface((struct Interface *)IOpenURL);
if(OpenURLBase) CloseLibrary(OpenURLBase);
+
+ ami_openurl_free_list(&ami_unsupportedprotocols);
}
void gui_launch_url(const char *url)
@@ -55,14 +127,15 @@ void gui_launch_url(const char *url)
char *launchurl = NULL;
BPTR fptr = 0;
- if((strncasecmp(url,"ABOUT:",6)) &&
- (strncasecmp(url,"JAVASCRIPT:",11)))
+ if(ami_openurl_check_list(&ami_unsupportedprotocols, url) == FALSE)
{
launchurl = ASPrintf("URL:%s",url);
- if(launchurl && (fptr = Open(launchurl,MODE_OLDFILE)))
+ if(launchurl)
{
- Close(fptr);
+ fptr = Open(launchurl,MODE_OLDFILE);
+ if(fptr) Close(fptr);
+ else ami_openurl_add_protocol(url);
}
else if(IOpenURL)
URL_OpenA(url,NULL);