2008-09-29 23:35:30 +04:00
|
|
|
/*
|
2010-07-20 21:20:16 +04:00
|
|
|
* Copyright 2008-2010 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/utils.h"
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "utils/nsoption.h"
|
|
|
|
#include "utils/nsurl.h"
|
|
|
|
#include "content/hlcache.h"
|
2014-12-04 15:02:13 +03:00
|
|
|
#include "desktop/browser.h"
|
2014-10-16 12:55:01 +04:00
|
|
|
#include "desktop/gui_window.h"
|
|
|
|
#include "desktop/version.h"
|
|
|
|
|
|
|
|
#include "amiga/arexx.h"
|
|
|
|
#include "amiga/download.h"
|
|
|
|
#include "amiga/gui.h"
|
|
|
|
#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"
|
|
|
|
|
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,
|
|
|
|
RX_HOTLIST
|
2008-09-29 23:35:30 +04:00
|
|
|
};
|
|
|
|
|
2008-10-26 02:22:34 +03:00
|
|
|
STATIC char result[100];
|
|
|
|
|
2008-09-29 23:35:30 +04:00
|
|
|
STATIC VOID rx_open(struct ARexxCmd *, struct RexxMsg *);
|
2008-10-06 21:47:31 +04:00
|
|
|
STATIC VOID rx_quit(struct ARexxCmd *, struct RexxMsg *);
|
2008-10-26 02:22:34 +03:00
|
|
|
STATIC VOID rx_tofront(struct ARexxCmd *, struct RexxMsg *);
|
|
|
|
STATIC VOID rx_geturl(struct ARexxCmd *, struct RexxMsg *);
|
2008-11-24 11:06:11 +03:00
|
|
|
STATIC VOID rx_gettitle(struct ARexxCmd *, struct RexxMsg *);
|
|
|
|
STATIC VOID rx_version(struct ARexxCmd *, struct RexxMsg *);
|
2009-01-11 00:33:34 +03:00
|
|
|
STATIC VOID rx_save(struct ARexxCmd *, struct RexxMsg *);
|
2009-07-04 16:16:22 +04:00
|
|
|
STATIC VOID rx_pubscreen(struct ARexxCmd *, struct RexxMsg *);
|
2010-07-11 19:34:35 +04:00
|
|
|
STATIC VOID rx_back(struct ARexxCmd *, struct RexxMsg *);
|
|
|
|
STATIC VOID rx_forward(struct ARexxCmd *, struct RexxMsg *);
|
|
|
|
STATIC VOID rx_home(struct ARexxCmd *, struct RexxMsg *);
|
|
|
|
STATIC VOID rx_reload(struct ARexxCmd *, struct RexxMsg *);
|
2010-07-20 21:20:16 +04:00
|
|
|
STATIC VOID rx_windows(struct ARexxCmd *, struct RexxMsg *);
|
2010-08-29 02:44:35 +04:00
|
|
|
STATIC VOID rx_active(struct ARexxCmd *, struct RexxMsg *);
|
|
|
|
STATIC VOID rx_close(struct ARexxCmd *, struct RexxMsg *);
|
2012-10-15 02:10:09 +04:00
|
|
|
STATIC VOID rx_hotlist(struct ARexxCmd *, struct RexxMsg *);
|
2008-09-29 23:35:30 +04:00
|
|
|
|
|
|
|
STATIC struct ARexxCmd Commands[] =
|
|
|
|
{
|
2010-08-29 03:48:33 +04:00
|
|
|
{"OPEN",RX_OPEN,rx_open,"URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,W=WINDOW/K/N,T=TAB/K/N", 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 },
|
2008-09-29 23:35:30 +04:00
|
|
|
{ NULL, 0, NULL, NULL, 0, NULL, 0, 0, NULL }
|
|
|
|
};
|
|
|
|
|
2008-11-16 17:42:40 +03:00
|
|
|
BOOL ami_arexx_init(void)
|
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
|
|
|
{
|
|
|
|
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;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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);
|
2015-05-28 18:08:46 +03:00
|
|
|
LOG("Executing script: %s", full_script_path);
|
2015-02-21 15:21:14 +03:00
|
|
|
IDoMethod(arexx_obj, AM_EXECUTE, full_script_path, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2008-09-29 23:35:30 +04:00
|
|
|
STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
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
|
|
|
|
2015-01-11 02:10:05 +03:00
|
|
|
dln = ami_misc_allocvec_clear(sizeof(struct dlnode), 0);
|
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])
|
|
|
|
{
|
2014-02-10 18:08:45 +04:00
|
|
|
browser_window_create(BW_CREATE_HISTORY |
|
|
|
|
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);
|
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
|
|
|
|
2009-01-11 00:33:34 +03:00
|
|
|
STATIC VOID rx_save(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2014-12-04 14:58:49 +03:00
|
|
|
hlcache_handle *h = browser_window_get_content(gw->bw);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2008-10-06 21:47:31 +04:00
|
|
|
STATIC VOID rx_quit(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
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
|
|
|
|
|
|
|
STATIC VOID rx_tofront(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
2010-07-23 21:59:46 +04:00
|
|
|
cmd->ac_RC = 0;
|
2008-10-26 02:22:34 +03:00
|
|
|
ScreenToFront(scrn);
|
|
|
|
}
|
|
|
|
|
|
|
|
STATIC VOID rx_geturl(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2008-11-24 11:06:11 +03:00
|
|
|
STATIC VOID rx_gettitle(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
STATIC VOID rx_version(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
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
|
|
|
|
|
|
|
STATIC VOID rx_pubscreen(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
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
|
|
|
|
|
|
|
STATIC VOID rx_back(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
STATIC VOID rx_forward(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
STATIC VOID rx_home(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
STATIC VOID rx_reload(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
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
|
|
|
|
|
|
|
STATIC VOID rx_windows(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
STATIC VOID rx_active(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
STATIC VOID rx_close(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
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
|
|
|
|
|
|
|
STATIC VOID rx_hotlist(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
|
|
|
if(strcasecmp((char *)cmd->ac_ArgList[0], "OPEN") == 0) {
|
|
|
|
ami_tree_open(hotlist_window, AMI_TREE_HOTLIST);
|
|
|
|
} else if(strcasecmp((char *)cmd->ac_ArgList[0], "CLOSE") == 0) {
|
|
|
|
ami_tree_close(hotlist_window);
|
|
|
|
}
|
|
|
|
}
|
2014-11-16 19:13:13 +03:00
|
|
|
|