From b0635ea5dd4d55c0cf1f0fdae4bda39292ba47be Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 26 Feb 2011 17:38:43 +0000 Subject: Rename confusingly-named file; Remove about from unsupported protocols, as will never reach this code now. svn path=/trunk/netsurf/; revision=11829 --- amiga/Makefile.target | 2 +- amiga/fetch_mailto.c | 150 -------------------------------------------------- amiga/fetch_mailto.h | 28 ---------- amiga/gui.c | 2 +- amiga/launch.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++++ amiga/launch.h | 28 ++++++++++ 6 files changed, 179 insertions(+), 180 deletions(-) delete mode 100755 amiga/fetch_mailto.c delete mode 100755 amiga/fetch_mailto.h create mode 100755 amiga/launch.c create mode 100755 amiga/launch.h diff --git a/amiga/Makefile.target b/amiga/Makefile.target index 8b49f204e..68d76efd3 100644 --- a/amiga/Makefile.target +++ b/amiga/Makefile.target @@ -58,7 +58,7 @@ S_AMIGA := compat.c gui.c tree.c history.c hotlist.c schedule.c \ thumbnail.c misc.c bitmap.c font.c filetype.c utf8.c login.c \ plotters.c object.c menu.c save_pdf.c arexx.c version.c \ cookies.c context_menu.c clipboard.c save_complete.c \ - fetch_mailto.c search.c history_local.c download.c iff_dr2d.c \ + launch.c search.c history_local.c download.c iff_dr2d.c \ sslcert.c gui_options.c print.c theme.c drag.c icon.c system_colour.c \ stringview/stringview.c stringview/urlhistory.c S_AMIGA := $(addprefix amiga/,$(S_AMIGA)) diff --git a/amiga/fetch_mailto.c b/amiga/fetch_mailto.c deleted file mode 100755 index 7212a2138..000000000 --- a/amiga/fetch_mailto.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2008-10 Chris Young - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** \file - * Fetching of data from a file (implementation). - */ - -#include "amiga/os3support.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -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. - * - * Must be called once before any other function. - */ - -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) -{ - APTR procwin = SetProcWindow((APTR)-1L); - char *launchurl = NULL; - BPTR fptr = 0; - - if(ami_openurl_check_list(&ami_unsupportedprotocols, url) == FALSE) - { - launchurl = ASPrintf("URL:%s",url); - - if(launchurl) - { - fptr = Open(launchurl,MODE_OLDFILE); - if(fptr) Close(fptr); - else ami_openurl_add_protocol(url); - } - else if(IOpenURL) - URL_OpenA(url,NULL); - - FreeVec(launchurl); - } - - SetProcWindow(procwin); -} diff --git a/amiga/fetch_mailto.h b/amiga/fetch_mailto.h deleted file mode 100755 index 40f7dae30..000000000 --- a/amiga/fetch_mailto.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2008-9 Chris Young - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** \file - * Fetching of data from a URL (Registration). - */ - -#ifndef AMIGA_FETCH_MAILTO_H -#define AMIGA_FETCH_MAILTO_H - -void ami_openurl_open(void); -void ami_openurl_close(void); -#endif diff --git a/amiga/gui.c b/amiga/gui.c index 8a366a4ee..e445a9c80 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -44,13 +44,13 @@ #include "amiga/cookies.h" #include "amiga/download.h" #include "amiga/drag.h" -#include "amiga/fetch_mailto.h" #include "amiga/font.h" #include "amiga/gui.h" #include "amiga/gui_options.h" #include "amiga/history.h" #include "amiga/history_local.h" #include "amiga/hotlist.h" +#include "amiga/launch.h" #include "amiga/login.h" #include "amiga/menu.h" #include "amiga/misc.h" diff --git a/amiga/launch.c b/amiga/launch.c new file mode 100755 index 000000000..dcfc83f05 --- /dev/null +++ b/amiga/launch.c @@ -0,0 +1,149 @@ +/* + * Copyright 2008-10 Chris Young + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file + * Fetching of data from a file (implementation). + */ + +#include "amiga/os3support.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +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. + * + * Must be called once before any other function. + */ + +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("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) +{ + APTR procwin = SetProcWindow((APTR)-1L); + char *launchurl = NULL; + BPTR fptr = 0; + + if(ami_openurl_check_list(&ami_unsupportedprotocols, url) == FALSE) + { + launchurl = ASPrintf("URL:%s",url); + + if(launchurl) + { + fptr = Open(launchurl,MODE_OLDFILE); + if(fptr) Close(fptr); + else ami_openurl_add_protocol(url); + } + else if(IOpenURL) + URL_OpenA(url,NULL); + + FreeVec(launchurl); + } + + SetProcWindow(procwin); +} diff --git a/amiga/launch.h b/amiga/launch.h new file mode 100755 index 000000000..40f7dae30 --- /dev/null +++ b/amiga/launch.h @@ -0,0 +1,28 @@ +/* + * Copyright 2008-9 Chris Young + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** \file + * Fetching of data from a URL (Registration). + */ + +#ifndef AMIGA_FETCH_MAILTO_H +#define AMIGA_FETCH_MAILTO_H + +void ami_openurl_open(void); +void ami_openurl_close(void); +#endif -- cgit v1.2.3