2008-12-14 02:28:26 +03:00
|
|
|
/*
|
2010-03-15 02:00:39 +03:00
|
|
|
* Copyright 2008-10 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
2008-12-14 02:28:26 +03:00
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* Fetching of data from a file (implementation).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <proto/exec.h>
|
2010-01-16 18:53:00 +03:00
|
|
|
#include <proto/dos.h>
|
|
|
|
#include <proto/utility.h>
|
2008-12-14 02:28:26 +03:00
|
|
|
#include <proto/openurl.h>
|
|
|
|
|
|
|
|
struct Library *OpenURLBase;
|
|
|
|
struct OpenURLIFace *IOpenURL;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialise the fetcher.
|
|
|
|
*
|
|
|
|
* Must be called once before any other function.
|
|
|
|
*/
|
|
|
|
|
2009-01-11 00:22:46 +03:00
|
|
|
void ami_openurl_open(void)
|
2008-12-14 02:28:26 +03:00
|
|
|
{
|
|
|
|
if(OpenURLBase = OpenLibrary("openurl.library",0))
|
|
|
|
{
|
2009-01-11 00:22:46 +03:00
|
|
|
IOpenURL = (struct OpenURLIFace *)GetInterface(OpenURLBase,"main",1,NULL);
|
2008-12-14 02:28:26 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-11 00:22:46 +03:00
|
|
|
void ami_openurl_close(const char *scheme)
|
2008-12-14 02:28:26 +03:00
|
|
|
{
|
|
|
|
if(IOpenURL) DropInterface((struct Interface *)IOpenURL);
|
|
|
|
if(OpenURLBase) CloseLibrary(OpenURLBase);
|
|
|
|
}
|
|
|
|
|
2009-01-11 00:22:46 +03:00
|
|
|
void gui_launch_url(const char *url)
|
2008-12-14 02:28:26 +03:00
|
|
|
{
|
2010-03-07 03:46:08 +03:00
|
|
|
APTR procwin = SetProcWindow((APTR)-1L);
|
|
|
|
char *launchurl = NULL;
|
|
|
|
BPTR fptr = 0;
|
2010-01-16 18:53:00 +03:00
|
|
|
|
2010-03-26 01:44:59 +03:00
|
|
|
if((strncasecmp(url,"ABOUT:",6)) &&
|
|
|
|
(strncasecmp(url,"JAVASCRIPT:",11)))
|
2010-03-07 03:46:08 +03:00
|
|
|
{
|
2010-03-15 02:00:39 +03:00
|
|
|
launchurl = ASPrintf("URL:%s",url);
|
|
|
|
|
|
|
|
if(launchurl && (fptr = Open(launchurl,MODE_OLDFILE)))
|
|
|
|
{
|
|
|
|
Close(fptr);
|
|
|
|
}
|
|
|
|
else if(IOpenURL)
|
|
|
|
URL_OpenA(url,NULL);
|
|
|
|
|
|
|
|
FreeVec(launchurl);
|
2009-01-11 00:22:46 +03:00
|
|
|
}
|
2010-03-07 03:46:08 +03:00
|
|
|
|
|
|
|
SetProcWindow(procwin);
|
2008-12-14 02:28:26 +03:00
|
|
|
}
|