2008-09-29 23:35:30 +04:00
|
|
|
/*
|
2016-09-10 22:53:17 +03:00
|
|
|
* Copyright 2008-2010, 2016 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
2008-09-29 23:35:30 +04: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/>.
|
|
|
|
*/
|
|
|
|
|
2015-01-11 03:07:11 +03:00
|
|
|
#include "amiga/os3support.h"
|
|
|
|
|
2015-01-11 02:10:05 +03:00
|
|
|
#include <stdlib.h>
|
2011-03-13 20:32:00 +03:00
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
2008-09-29 23:35:30 +04:00
|
|
|
|
2011-03-13 20:32:00 +03:00
|
|
|
#include <proto/intuition.h>
|
|
|
|
#include <proto/dos.h>
|
|
|
|
#include <proto/exec.h>
|
2010-07-20 21:20:16 +04:00
|
|
|
#include <proto/clicktab.h>
|
|
|
|
#include <gadgets/clicktab.h>
|
2011-03-13 20:32:00 +03:00
|
|
|
#include <reaction/reaction_macros.h>
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2016-04-20 17:54:18 +03:00
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/nsoption.h"
|
|
|
|
#include "utils/nsurl.h"
|
2016-06-06 10:59:23 +03:00
|
|
|
#include "netsurf/content.h"
|
2016-05-30 19:32:57 +03:00
|
|
|
#include "netsurf/browser_window.h"
|
2014-10-16 12:55:01 +04:00
|
|
|
#include "desktop/version.h"
|
|
|
|
|
|
|
|
#include "amiga/arexx.h"
|
|
|
|
#include "amiga/gui.h"
|
2016-06-01 09:59:19 +03:00
|
|
|
#include "amiga/download.h"
|
2014-10-16 12:55:01 +04:00
|
|
|
#include "amiga/hotlist.h"
|
2015-01-26 03:05:01 +03:00
|
|
|
#include "amiga/libs.h"
|
2015-01-11 03:07:11 +03:00
|
|
|
#include "amiga/misc.h"
|
2014-10-16 12:55:01 +04:00
|
|
|
#include "amiga/theme.h"
|
|
|
|
|
2016-11-20 20:12:18 +03:00
|
|
|
#ifndef __amigaos4__
|
|
|
|
#include "amiga/memory.h"
|
|
|
|
#endif
|
|
|
|
|
2011-06-05 16:37:44 +04:00
|
|
|
extern const char * const verarexx;
|
|
|
|
extern const char * const wt_revid;
|
2008-11-24 11:06:11 +03:00
|
|
|
|
2008-09-29 23:35:30 +04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
RX_OPEN=0,
|
2008-10-06 21:47:31 +04:00
|
|
|
RX_QUIT,
|
2008-10-26 02:22:34 +03:00
|
|
|
RX_TOFRONT,
|
2008-11-24 11:06:11 +03:00
|
|
|
RX_GETURL,
|
|
|
|
RX_GETTITLE,
|
2009-01-11 00:33:34 +03:00
|
|
|
RX_VERSION,
|
2009-07-04 16:16:22 +04:00
|
|
|
RX_SAVE,
|
2010-07-11 19:34:35 +04:00
|
|
|
RX_PUBSCREEN,
|
|
|
|
RX_BACK,
|
|
|
|
RX_FORWARD,
|
|
|
|
RX_HOME,
|
2010-07-20 21:20:16 +04:00
|
|
|
RX_RELOAD,
|
2010-08-29 02:44:35 +04:00
|
|
|
RX_WINDOWS,
|
|
|
|
RX_ACTIVE,
|
2012-10-15 02:10:09 +04:00
|
|
|
RX_CLOSE,
|
2016-11-20 20:12:18 +03:00
|
|
|
RX_HOTLIST,
|
|
|
|
RX_SLABSTATS
|
2008-09-29 23:35:30 +04:00
|
|
|
};
|
|
|
|
|
2016-06-02 02:44:20 +03:00
|
|
|
static Object *arexx_obj = NULL;
|
2008-10-26 02:22:34 +03:00
|
|
|
STATIC char result[100];
|
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
#ifdef __amigaos4__
|
|
|
|
#define RXHOOKF(func) static VOID func(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
#else
|
|
|
|
#define RXHOOKF(func) static ASM VOID func(REG(a0, struct ARexxCmd* cmd), REG(a1, struct RexxMsg* msg))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
RXHOOKF(rx_open);
|
|
|
|
RXHOOKF(rx_quit);
|
|
|
|
RXHOOKF(rx_tofront);
|
|
|
|
RXHOOKF(rx_geturl);
|
|
|
|
RXHOOKF(rx_gettitle);
|
|
|
|
RXHOOKF(rx_version);
|
|
|
|
RXHOOKF(rx_save);
|
|
|
|
RXHOOKF(rx_pubscreen);
|
|
|
|
RXHOOKF(rx_back);
|
|
|
|
RXHOOKF(rx_forward);
|
|
|
|
RXHOOKF(rx_home);
|
|
|
|
RXHOOKF(rx_reload);
|
|
|
|
RXHOOKF(rx_windows);
|
|
|
|
RXHOOKF(rx_active);
|
|
|
|
RXHOOKF(rx_close);
|
|
|
|
RXHOOKF(rx_hotlist);
|
2016-11-20 20:12:18 +03:00
|
|
|
RXHOOKF(rx_slabstats);
|
2008-09-29 23:35:30 +04:00
|
|
|
|
|
|
|
STATIC struct ARexxCmd Commands[] =
|
|
|
|
{
|
2016-09-10 22:36:11 +03:00
|
|
|
{"OPEN",RX_OPEN,rx_open,"URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,W=WINDOW/K/N,T=TAB/K/N,ACTIVE/S", 0, NULL, 0, 0, NULL },
|
2008-10-06 21:47:31 +04:00
|
|
|
{"QUIT",RX_QUIT,rx_quit,NULL, 0, NULL, 0, 0, NULL },
|
2008-10-26 02:22:34 +03:00
|
|
|
{"TOFRONT",RX_TOFRONT,rx_tofront,NULL, 0, NULL, 0, 0, NULL },
|
2010-08-29 03:48:33 +04:00
|
|
|
{"GETURL",RX_GETURL,rx_geturl, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
|
|
|
|
{"GETTITLE",RX_GETTITLE,rx_gettitle, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
|
2008-11-24 11:06:11 +03:00
|
|
|
{"VERSION",RX_VERSION,rx_version,"VERSION/N,SVN=REVISION/N,RELEASE/S", 0, NULL, 0, 0, NULL },
|
2010-08-29 03:48:33 +04:00
|
|
|
{"SAVE",RX_SAVE,rx_save,"FILENAME/A,W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
|
2009-07-04 16:16:22 +04:00
|
|
|
{"GETSCREENNAME",RX_PUBSCREEN,rx_pubscreen,NULL, 0, NULL, 0, 0, NULL },
|
2010-08-29 03:48:33 +04:00
|
|
|
{"BACK", RX_BACK, rx_back, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
|
|
|
|
{"FORWARD", RX_FORWARD, rx_forward, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
|
|
|
|
{"HOME", RX_HOME, rx_home, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
|
|
|
|
{"RELOAD", RX_RELOAD, rx_reload, "FORCE/S,W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
|
|
|
|
{"WINDOWS", RX_WINDOWS, rx_windows, "W=WINDOW/K/N", 0, NULL, 0, 0, NULL },
|
|
|
|
{"ACTIVE", RX_ACTIVE, rx_active, "T=TAB/S", 0, NULL, 0, 0, NULL },
|
|
|
|
{"CLOSE", RX_CLOSE, rx_close, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
|
2012-10-15 02:10:09 +04:00
|
|
|
{"HOTLIST", RX_HOTLIST, rx_hotlist, "A=ACTION/A", 0, NULL, 0, 0, NULL },
|
2016-11-27 20:10:03 +03:00
|
|
|
{"SLABSTATS", RX_SLABSTATS, rx_slabstats, "FILE", 0, NULL, 0, 0, NULL },
|
2008-09-29 23:35:30 +04:00
|
|
|
{ NULL, 0, NULL, NULL, 0, NULL, 0, 0, NULL }
|
|
|
|
};
|
|
|
|
|
2016-06-02 02:14:10 +03:00
|
|
|
bool ami_arexx_init(ULONG *rxsig)
|
2008-09-29 23:35:30 +04:00
|
|
|
{
|
2015-01-26 03:05:01 +03:00
|
|
|
if((arexx_obj = ARexxObj,
|
2008-09-29 23:35:30 +04:00
|
|
|
AREXX_HostName,"NETSURF",
|
|
|
|
AREXX_Commands,Commands,
|
|
|
|
AREXX_NoSlot,TRUE,
|
|
|
|
AREXX_ReplyHook,NULL,
|
|
|
|
AREXX_DefExtension,"nsrx",
|
2014-10-16 12:55:01 +04:00
|
|
|
End))
|
2008-09-29 23:35:30 +04:00
|
|
|
{
|
2016-06-02 02:14:10 +03:00
|
|
|
GetAttr(AREXX_SigMask, arexx_obj, rxsig);
|
2008-11-16 17:42:40 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-01 02:45:25 +03:00
|
|
|
/* Create a temporary ARexx port so we can send commands to the NetSurf which
|
2008-11-16 17:42:40 +03:00
|
|
|
* is already running */
|
2015-01-26 03:05:01 +03:00
|
|
|
arexx_obj = ARexxObj,
|
2008-11-16 17:42:40 +03:00
|
|
|
AREXX_HostName,"NETSURF",
|
|
|
|
AREXX_Commands,Commands,
|
|
|
|
AREXX_NoSlot,FALSE,
|
|
|
|
AREXX_ReplyHook,NULL,
|
|
|
|
AREXX_DefExtension,"nsrx",
|
|
|
|
End;
|
2016-07-04 00:08:29 +03:00
|
|
|
|
2008-11-16 17:42:40 +03:00
|
|
|
return false;
|
2008-09-29 23:35:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-26 15:25:26 +03:00
|
|
|
void ami_arexx_handle(void)
|
2008-09-29 23:35:30 +04:00
|
|
|
{
|
|
|
|
RA_HandleRexx(arexx_obj);
|
|
|
|
}
|
|
|
|
|
2016-07-04 00:08:29 +03:00
|
|
|
static void ami_arexx_command(const char *cmd, const char *port)
|
2016-06-02 02:09:30 +03:00
|
|
|
{
|
|
|
|
if(arexx_obj == NULL) return;
|
2016-07-04 00:08:29 +03:00
|
|
|
IDoMethod(arexx_obj, AM_EXECUTE, cmd, port, NULL, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ami_arexx_self(const char *cmd)
|
|
|
|
{
|
|
|
|
ami_arexx_command(cmd, "NETSURF");
|
2016-06-02 02:09:30 +03:00
|
|
|
}
|
|
|
|
|
2008-10-26 15:25:26 +03:00
|
|
|
void ami_arexx_execute(char *script)
|
|
|
|
{
|
2015-02-21 15:21:14 +03:00
|
|
|
char full_script_path[1025];
|
|
|
|
BPTR lock;
|
|
|
|
|
2016-01-15 22:58:24 +03:00
|
|
|
if((lock = Lock(script, ACCESS_READ))) {
|
2015-02-21 15:21:14 +03:00
|
|
|
DevNameFromLock(lock, full_script_path, 1024, DN_FULLPATH);
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Executing script: %s", full_script_path);
|
2016-07-04 00:08:29 +03:00
|
|
|
ami_arexx_command(full_script_path, NULL);
|
2015-02-21 15:21:14 +03:00
|
|
|
UnLock(lock);
|
|
|
|
}
|
2008-10-26 15:25:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ami_arexx_cleanup(void)
|
2008-09-29 23:35:30 +04:00
|
|
|
{
|
|
|
|
if(arexx_obj) DisposeObject(arexx_obj);
|
|
|
|
}
|
|
|
|
|
2014-11-16 19:13:13 +03:00
|
|
|
static struct gui_window *ami_find_tab_gwin(struct gui_window_2 *gwin, int tab)
|
2010-07-20 21:20:16 +04:00
|
|
|
{
|
|
|
|
int tabs = 0;
|
|
|
|
struct Node *ctab;
|
|
|
|
struct Node *ntab;
|
2014-11-16 19:13:13 +03:00
|
|
|
struct gui_window *gw;
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2014-11-16 19:13:13 +03:00
|
|
|
if((tab == 0) || (gwin->tabs == 0)) return gwin->gw;
|
2010-07-20 21:20:16 +04:00
|
|
|
|
|
|
|
ctab = GetHead(&gwin->tab_list);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
tabs++;
|
|
|
|
ntab=GetSucc(ctab);
|
|
|
|
GetClickTabNodeAttrs(ctab,
|
2014-11-16 19:13:13 +03:00
|
|
|
TNA_UserData, &gw,
|
2010-07-20 21:20:16 +04:00
|
|
|
TAG_DONE);
|
2014-11-16 19:13:13 +03:00
|
|
|
if(tabs == tab) return gw;
|
2014-10-16 12:55:01 +04:00
|
|
|
} while((ctab=ntab));
|
2010-07-20 21:20:16 +04:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-10-16 12:55:01 +04:00
|
|
|
static int ami_find_tab_bw(struct gui_window_2 *gwin, struct browser_window *bw)
|
2010-08-29 02:44:35 +04:00
|
|
|
{
|
|
|
|
int tabs = 0;
|
|
|
|
struct Node *ctab;
|
|
|
|
struct Node *ntab;
|
2014-11-16 19:13:13 +03:00
|
|
|
struct gui_window *tgw = NULL;
|
2010-08-29 02:44:35 +04:00
|
|
|
|
|
|
|
if((bw == NULL) || (gwin->tabs == 0)) return 1;
|
|
|
|
|
|
|
|
ctab = GetHead(&gwin->tab_list);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
tabs++;
|
|
|
|
ntab=GetSucc(ctab);
|
|
|
|
GetClickTabNodeAttrs(ctab,
|
2014-11-16 19:13:13 +03:00
|
|
|
TNA_UserData, &tgw,
|
2010-08-29 02:44:35 +04:00
|
|
|
TAG_DONE);
|
2014-11-16 19:13:13 +03:00
|
|
|
if(tgw->bw == bw) return tabs;
|
2014-10-16 12:55:01 +04:00
|
|
|
} while((ctab=ntab));
|
2010-08-29 02:44:35 +04:00
|
|
|
|
2011-07-03 19:01:56 +04:00
|
|
|
return 0;
|
2010-08-29 02:44:35 +04:00
|
|
|
}
|
|
|
|
|
2014-11-16 19:13:13 +03:00
|
|
|
static struct gui_window *ami_find_tab(int window, int tab)
|
2010-07-20 21:20:16 +04:00
|
|
|
{
|
|
|
|
struct nsObject *node, *nnode;
|
|
|
|
|
|
|
|
if(!IsMinListEmpty(window_list))
|
|
|
|
{
|
2014-04-05 22:56:28 +04:00
|
|
|
int windows = 0;
|
|
|
|
|
2010-07-20 21:20:16 +04:00
|
|
|
node = (struct nsObject *)GetHead((struct List *)window_list);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
nnode=(struct nsObject *)GetSucc((struct Node *)node);
|
|
|
|
|
|
|
|
if(node->Type == AMINS_WINDOW)
|
|
|
|
{
|
|
|
|
windows++;
|
|
|
|
if(windows == window)
|
|
|
|
return ami_find_tab_gwin(node->objstruct, tab);
|
|
|
|
}
|
2014-10-16 12:55:01 +04:00
|
|
|
} while((node = nnode));
|
2010-07-20 21:20:16 +04:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_open)
|
2008-09-29 23:35:30 +04:00
|
|
|
{
|
2009-03-28 15:50:19 +03:00
|
|
|
struct dlnode *dln;
|
2014-11-16 19:13:13 +03:00
|
|
|
struct gui_window *gw = cur_gw;
|
2013-02-14 19:09:28 +04:00
|
|
|
nsurl *url;
|
2009-03-28 15:50:19 +03:00
|
|
|
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
2010-07-20 21:20:16 +04:00
|
|
|
if((cmd->ac_ArgList[4]) && (cmd->ac_ArgList[5]))
|
2014-11-16 19:13:13 +03:00
|
|
|
gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[4], *(ULONG *)cmd->ac_ArgList[5]);
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2013-02-14 19:09:28 +04:00
|
|
|
if (nsurl_create((char *)cmd->ac_ArgList[0], &url) != NSERROR_OK) {
|
2016-05-01 16:00:47 +03:00
|
|
|
amiga_warn_user("NoMemory", 0);
|
2013-02-14 19:09:28 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-07-20 21:20:16 +04:00
|
|
|
if(cmd->ac_ArgList[3])
|
2009-02-01 02:45:25 +03:00
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
if(!gw) return;
|
2009-04-14 22:51:10 +04:00
|
|
|
|
2016-11-19 20:02:18 +03:00
|
|
|
dln = calloc(1, sizeof(struct dlnode));
|
2010-07-20 21:20:16 +04:00
|
|
|
dln->filename = strdup((char *)cmd->ac_ArgList[3]);
|
2009-03-28 15:50:19 +03:00
|
|
|
dln->node.ln_Name = strdup((char *)cmd->ac_ArgList[0]);
|
|
|
|
dln->node.ln_Type = NT_USER;
|
2014-11-16 19:13:13 +03:00
|
|
|
AddTail(&gw->dllist, (struct Node *)dln);
|
2014-12-04 15:01:22 +03:00
|
|
|
browser_window_navigate(gw->bw,
|
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
BW_NAVIGATE_DOWNLOAD,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2010-07-20 21:20:16 +04:00
|
|
|
}
|
|
|
|
else if(cmd->ac_ArgList[2])
|
|
|
|
{
|
2016-08-15 20:00:12 +03:00
|
|
|
if(gw == NULL) {
|
|
|
|
browser_window_create(BW_CREATE_HISTORY,
|
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
} else {
|
|
|
|
browser_window_create(BW_CREATE_HISTORY |
|
2014-02-10 18:08:45 +04:00
|
|
|
BW_CREATE_TAB,
|
2013-02-14 22:21:11 +04:00
|
|
|
url,
|
|
|
|
NULL,
|
2014-11-16 19:13:13 +03:00
|
|
|
gw->bw,
|
2013-02-14 22:21:11 +04:00
|
|
|
NULL);
|
2016-09-10 22:36:11 +03:00
|
|
|
|
|
|
|
if(cmd->ac_ArgList[6]) {
|
|
|
|
ami_gui_switch_to_new_tab(gw->shared);
|
|
|
|
}
|
2016-08-15 20:00:12 +03:00
|
|
|
}
|
2009-02-01 02:45:25 +03:00
|
|
|
}
|
|
|
|
else if(cmd->ac_ArgList[1])
|
2008-10-26 02:22:34 +03:00
|
|
|
{
|
2014-02-10 18:08:45 +04:00
|
|
|
browser_window_create(BW_CREATE_HISTORY,
|
2013-02-14 22:21:11 +04:00
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2008-10-26 02:22:34 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
if(gw)
|
2009-09-29 02:17:09 +04:00
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
browser_window_navigate(gw->bw,
|
2013-02-14 19:09:28 +04:00
|
|
|
url,
|
|
|
|
NULL,
|
2014-02-11 02:40:04 +04:00
|
|
|
BW_NAVIGATE_HISTORY,
|
2013-02-14 19:09:28 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2009-09-29 02:17:09 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-02-10 18:08:45 +04:00
|
|
|
browser_window_create(BW_CREATE_HISTORY,
|
2013-02-14 22:21:11 +04:00
|
|
|
url,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
2009-09-29 02:17:09 +04:00
|
|
|
}
|
2008-10-26 02:22:34 +03:00
|
|
|
}
|
2013-02-14 19:09:28 +04:00
|
|
|
nsurl_unref(url);
|
2008-09-29 23:35:30 +04:00
|
|
|
}
|
2008-10-06 21:47:31 +04:00
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_save)
|
2009-01-11 00:33:34 +03:00
|
|
|
{
|
|
|
|
BPTR fh = 0;
|
2010-03-28 19:51:05 +04:00
|
|
|
ULONG source_size;
|
2011-07-03 19:01:56 +04:00
|
|
|
const char *source_data;
|
2014-11-16 19:01:59 +03:00
|
|
|
struct gui_window *gw = cur_gw;
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
2010-07-20 21:20:16 +04:00
|
|
|
if((cmd->ac_ArgList[1]) && (cmd->ac_ArgList[2]))
|
2014-11-16 19:13:13 +03:00
|
|
|
gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[1], *(ULONG *)cmd->ac_ArgList[2]);
|
2009-09-29 02:17:09 +04:00
|
|
|
|
2014-11-16 19:13:13 +03:00
|
|
|
if(!gw) return;
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2014-11-16 19:01:59 +03:00
|
|
|
ami_set_pointer(gw->shared, GUI_POINTER_WAIT, false);
|
2013-01-03 23:53:20 +04:00
|
|
|
|
2014-11-09 03:37:35 +03:00
|
|
|
if((fh = FOpen((char *)cmd->ac_ArgList[0], MODE_NEWFILE, 0)))
|
2009-01-11 00:33:34 +03:00
|
|
|
{
|
2016-06-06 10:59:23 +03:00
|
|
|
struct hlcache_handle *h = browser_window_get_content(gw->bw);
|
2014-12-04 14:58:49 +03:00
|
|
|
if((source_data = content_get_source_data(h, &source_size)))
|
2010-03-28 19:51:05 +04:00
|
|
|
FWrite(fh, source_data, 1, source_size);
|
|
|
|
|
2009-01-11 00:33:34 +03:00
|
|
|
FClose(fh);
|
2014-12-04 14:59:59 +03:00
|
|
|
SetComment((char *)cmd->ac_ArgList[0], nsurl_access(browser_window_get_url(gw->bw)));
|
2009-01-11 00:33:34 +03:00
|
|
|
}
|
|
|
|
|
2014-11-16 19:01:59 +03:00
|
|
|
ami_reset_pointer(gw->shared);
|
2009-01-11 00:33:34 +03:00
|
|
|
}
|
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_quit)
|
2008-10-06 21:47:31 +04:00
|
|
|
{
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
2008-10-06 21:47:31 +04:00
|
|
|
ami_quit_netsurf();
|
|
|
|
}
|
2008-10-26 02:22:34 +03:00
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_tofront)
|
2008-10-26 02:22:34 +03:00
|
|
|
{
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
2008-10-26 02:22:34 +03:00
|
|
|
ScreenToFront(scrn);
|
|
|
|
}
|
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_geturl)
|
2008-10-26 02:22:34 +03:00
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
struct gui_window *gw = cur_gw;
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
2010-07-20 21:20:16 +04:00
|
|
|
if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1]))
|
2014-11-16 19:13:13 +03:00
|
|
|
gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2014-12-04 14:59:59 +03:00
|
|
|
if(gw && gw->bw)
|
2008-10-26 15:25:26 +03:00
|
|
|
{
|
2014-12-04 14:59:59 +03:00
|
|
|
strcpy(result, nsurl_access(browser_window_get_url(gw->bw)));
|
2008-10-26 15:25:26 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-01 16:37:32 +03:00
|
|
|
strcpy(result,"");
|
2008-10-26 15:25:26 +03:00
|
|
|
}
|
|
|
|
|
2008-10-26 02:22:34 +03:00
|
|
|
cmd->ac_Result = result;
|
|
|
|
}
|
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_gettitle)
|
2008-11-24 11:06:11 +03:00
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
struct gui_window *gw = cur_gw;
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
2010-07-20 21:20:16 +04:00
|
|
|
if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1]))
|
2014-11-16 19:13:13 +03:00
|
|
|
gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2014-11-16 19:13:13 +03:00
|
|
|
if(gw)
|
2008-11-24 11:06:11 +03:00
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
if(gw->shared->tabs > 1)
|
|
|
|
strcpy(result, gw->tabtitle);
|
2010-07-20 21:20:16 +04:00
|
|
|
else
|
2014-11-16 19:13:13 +03:00
|
|
|
strcpy(result, gw->shared->wintitle);
|
2008-11-24 11:06:11 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-01 16:37:32 +03:00
|
|
|
strcpy(result,"");
|
2008-11-24 11:06:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd->ac_Result = result;
|
|
|
|
}
|
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_version)
|
2008-11-24 11:06:11 +03:00
|
|
|
{
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
2008-11-24 11:06:11 +03:00
|
|
|
if(cmd->ac_ArgList[2])
|
|
|
|
{
|
|
|
|
if(cmd->ac_ArgList[1])
|
|
|
|
{
|
2014-11-09 03:37:35 +03:00
|
|
|
if((netsurf_version_major > *(int *)cmd->ac_ArgList[0]) || ((netsurf_version_minor >= *(int *)cmd->ac_ArgList[1]) && (netsurf_version_major == *(int *)cmd->ac_ArgList[0])))
|
2008-11-24 11:06:11 +03:00
|
|
|
{
|
|
|
|
strcpy(result,"1");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(result,"0");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(cmd->ac_ArgList[0])
|
|
|
|
{
|
2014-11-09 03:37:35 +03:00
|
|
|
if((netsurf_version_major >= *(int *)cmd->ac_ArgList[0]))
|
2008-11-24 11:06:11 +03:00
|
|
|
{
|
|
|
|
strcpy(result,"1");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(result,"0");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(result,netsurf_version);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(cmd->ac_ArgList[1])
|
|
|
|
{
|
2014-11-09 03:37:35 +03:00
|
|
|
if((netsurf_version_major > *(int *)cmd->ac_ArgList[0]) || ((atoi(wt_revid) >= *(int *)cmd->ac_ArgList[1]) && (netsurf_version_major == *(int *)cmd->ac_ArgList[0])))
|
2008-11-24 11:06:11 +03:00
|
|
|
{
|
|
|
|
strcpy(result,"1");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(result,"0");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(cmd->ac_ArgList[0])
|
|
|
|
{
|
2014-11-09 03:37:35 +03:00
|
|
|
if((netsurf_version_major >= *(int *)cmd->ac_ArgList[0]))
|
2008-11-24 11:06:11 +03:00
|
|
|
{
|
|
|
|
strcpy(result,"1");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(result,"0");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(result,verarexx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd->ac_Result = result;
|
|
|
|
}
|
2009-07-04 16:16:22 +04:00
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_pubscreen)
|
2009-07-04 16:16:22 +04:00
|
|
|
{
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
2013-06-01 02:25:05 +04:00
|
|
|
if(nsoption_charp(pubscreen_name) == NULL)
|
2009-07-04 16:16:22 +04:00
|
|
|
{
|
|
|
|
strcpy(result,"NetSurf");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-01 02:25:05 +04:00
|
|
|
strcpy(result, nsoption_charp(pubscreen_name));
|
2009-07-04 16:16:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd->ac_Result = result;
|
|
|
|
}
|
2010-07-11 19:34:35 +04:00
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_back)
|
2010-07-11 19:34:35 +04:00
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
struct gui_window *gw = cur_gw;
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
2010-07-20 21:20:16 +04:00
|
|
|
if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1]))
|
2014-11-16 19:13:13 +03:00
|
|
|
gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2014-11-16 19:13:13 +03:00
|
|
|
if(gw) ami_gui_history(gw->shared, true);
|
2010-07-11 19:34:35 +04:00
|
|
|
}
|
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_forward)
|
2010-07-11 19:34:35 +04:00
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
struct gui_window *gw = cur_gw;
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
2010-07-20 21:20:16 +04:00
|
|
|
if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1]))
|
2014-11-16 19:13:13 +03:00
|
|
|
gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2014-11-16 19:13:13 +03:00
|
|
|
if(gw) ami_gui_history(gw->shared, false);
|
2011-06-03 22:20:56 +04:00
|
|
|
|
2010-07-11 19:34:35 +04:00
|
|
|
}
|
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_home)
|
2010-07-11 19:34:35 +04:00
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
struct gui_window *gw = cur_gw;
|
2013-02-14 19:09:28 +04:00
|
|
|
nsurl *url;
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
2010-07-20 21:20:16 +04:00
|
|
|
if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1]))
|
2014-11-16 19:13:13 +03:00
|
|
|
gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2014-11-16 19:13:13 +03:00
|
|
|
if(gw == NULL) return;
|
2013-02-14 19:09:28 +04:00
|
|
|
|
|
|
|
if (nsurl_create(nsoption_charp(homepage_url), &url) != NSERROR_OK) {
|
2016-05-01 16:00:47 +03:00
|
|
|
amiga_warn_user("NoMemory", 0);
|
2013-02-14 19:09:28 +04:00
|
|
|
} else {
|
2014-11-16 19:13:13 +03:00
|
|
|
browser_window_navigate(gw->bw,
|
2013-02-14 19:09:28 +04:00
|
|
|
url,
|
|
|
|
NULL,
|
2014-02-11 02:40:04 +04:00
|
|
|
BW_NAVIGATE_HISTORY,
|
2013-02-14 19:09:28 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
2010-07-11 19:34:35 +04:00
|
|
|
}
|
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_reload)
|
2010-07-11 19:34:35 +04:00
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
struct gui_window *gw = cur_gw;
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
2010-07-20 21:20:16 +04:00
|
|
|
if((cmd->ac_ArgList[1]) && (cmd->ac_ArgList[2]))
|
2014-11-16 19:13:13 +03:00
|
|
|
gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[1], *(ULONG *)cmd->ac_ArgList[2]);
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2014-11-16 19:13:13 +03:00
|
|
|
if(gw)
|
2010-07-11 19:34:35 +04:00
|
|
|
{
|
|
|
|
if(cmd->ac_ArgList[0]) /* FORCE */
|
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
browser_window_reload(gw->bw, true);
|
2010-07-11 19:34:35 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
browser_window_reload(gw->bw, false);
|
2010-07-11 19:34:35 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_windows)
|
2010-07-20 21:20:16 +04:00
|
|
|
{
|
|
|
|
int windows = 0, tabs = 0;
|
2014-10-26 18:41:44 +03:00
|
|
|
int window = 0;
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2014-10-26 18:41:44 +03:00
|
|
|
if(cmd->ac_ArgList[0]) window = *(ULONG *)cmd->ac_ArgList[0];
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
2014-10-26 18:41:44 +03:00
|
|
|
windows = ami_gui_count_windows(window, &tabs);
|
2010-07-20 21:20:16 +04:00
|
|
|
|
2014-10-16 12:55:01 +04:00
|
|
|
if(cmd->ac_ArgList[0]) sprintf(result, "%d", tabs);
|
|
|
|
else sprintf(result, "%d", windows);
|
2010-07-20 21:20:16 +04:00
|
|
|
cmd->ac_Result = result;
|
|
|
|
}
|
2010-08-29 02:44:35 +04:00
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_active)
|
2010-08-29 02:44:35 +04:00
|
|
|
{
|
|
|
|
int window = 0, tab = 0;
|
2014-11-16 19:13:13 +03:00
|
|
|
struct gui_window *gw = cur_gw;
|
2010-08-29 02:44:35 +04:00
|
|
|
struct nsObject *node, *nnode;
|
2012-03-22 13:34:34 +04:00
|
|
|
struct gui_window_2 *gwin = NULL;
|
2010-08-29 02:44:35 +04:00
|
|
|
|
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
|
|
|
if(!IsMinListEmpty(window_list))
|
|
|
|
{
|
2014-04-05 22:56:28 +04:00
|
|
|
int windows = 0;
|
|
|
|
|
2010-08-29 02:44:35 +04:00
|
|
|
node = (struct nsObject *)GetHead((struct List *)window_list);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
nnode=(struct nsObject *)GetSucc((struct Node *)node);
|
|
|
|
|
|
|
|
gwin = node->objstruct;
|
|
|
|
|
|
|
|
if(node->Type == AMINS_WINDOW)
|
|
|
|
{
|
|
|
|
windows++;
|
2014-11-16 19:13:13 +03:00
|
|
|
if(gwin->gw == gw)
|
2010-08-29 02:44:35 +04:00
|
|
|
{
|
|
|
|
window = windows;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-11-09 03:37:35 +03:00
|
|
|
} while((node = nnode));
|
2010-08-29 02:44:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if(cmd->ac_ArgList[0])
|
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
tab = ami_find_tab_bw(gwin, gw->bw);
|
2010-08-29 02:44:35 +04:00
|
|
|
}
|
|
|
|
|
2014-10-16 12:55:01 +04:00
|
|
|
if(cmd->ac_ArgList[0]) sprintf(result, "%d", tab);
|
|
|
|
else sprintf(result, "%d", window);
|
2010-08-29 02:44:35 +04:00
|
|
|
cmd->ac_Result = result;
|
|
|
|
}
|
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_close)
|
2010-08-29 02:44:35 +04:00
|
|
|
{
|
2014-11-16 19:13:13 +03:00
|
|
|
struct gui_window *gw = cur_gw;
|
2010-08-29 02:44:35 +04:00
|
|
|
|
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
|
|
|
if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1]))
|
2014-11-16 19:13:13 +03:00
|
|
|
gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
|
2010-08-29 02:44:35 +04:00
|
|
|
else if(cmd->ac_ArgList[0])
|
|
|
|
{
|
2016-01-31 20:58:27 +03:00
|
|
|
ami_gui_close_window(gw->shared);
|
2010-08-29 02:44:35 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-16 19:13:13 +03:00
|
|
|
if(gw) browser_window_destroy(gw->bw);
|
2010-08-29 02:44:35 +04:00
|
|
|
}
|
2012-10-15 02:10:09 +04:00
|
|
|
|
2016-09-10 22:53:17 +03:00
|
|
|
RXHOOKF(rx_hotlist)
|
2012-10-15 02:10:09 +04:00
|
|
|
{
|
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
|
|
|
if(strcasecmp((char *)cmd->ac_ArgList[0], "OPEN") == 0) {
|
2017-01-07 02:56:52 +03:00
|
|
|
ami_hotlist_present();
|
2012-10-15 02:10:09 +04:00
|
|
|
} else if(strcasecmp((char *)cmd->ac_ArgList[0], "CLOSE") == 0) {
|
2017-01-07 02:56:52 +03:00
|
|
|
ami_hotlist_close();
|
2012-10-15 02:10:09 +04:00
|
|
|
}
|
|
|
|
}
|
2014-11-16 19:13:13 +03:00
|
|
|
|
2016-11-20 20:12:18 +03:00
|
|
|
RXHOOKF(rx_slabstats)
|
|
|
|
{
|
|
|
|
#ifndef __amigaos4__
|
2016-11-27 20:10:03 +03:00
|
|
|
BPTR fh = 0;
|
|
|
|
|
|
|
|
if(cmd->ac_ArgList[0] != NULL) {
|
|
|
|
fh = Open((char *)cmd->ac_ArgList[0], MODE_NEWFILE);
|
|
|
|
}
|
|
|
|
ami_memory_slab_dump(fh);
|
|
|
|
|
|
|
|
if(fh != 0) Close(fh);
|
2016-11-20 20:12:18 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|