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/>.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
2014-10-16 12:55:01 +04:00
|
|
|
#include "utils/nsoption.h"
|
|
|
|
#include "desktop/browser_private.h"
|
|
|
|
#include "desktop/gui_window.h"
|
|
|
|
#include "desktop/version.h"
|
|
|
|
|
|
|
|
#include "amiga/os3support.h"
|
|
|
|
#include "amiga/arexx.h"
|
|
|
|
#include "amiga/download.h"
|
|
|
|
#include "amiga/gui.h"
|
|
|
|
#include "amiga/hotlist.h"
|
|
|
|
#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
|
|
|
{
|
2014-10-16 12:55:01 +04:00
|
|
|
if((arexx_obj = ARexxObject,
|
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 */
|
|
|
|
arexx_obj = ARexxObject,
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
IDoMethod(arexx_obj, AM_EXECUTE, script, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ami_arexx_cleanup(void)
|
2008-09-29 23:35:30 +04:00
|
|
|
{
|
|
|
|
if(arexx_obj) DisposeObject(arexx_obj);
|
|
|
|
}
|
|
|
|
|
2014-10-16 12:55:01 +04:00
|
|
|
static struct browser_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;
|
|
|
|
struct browser_window *bw;
|
|
|
|
|
2014-11-16 17:47:26 +03:00
|
|
|
if((tab == 0) || (gwin->tabs == 0)) return gwin->gw->bw;
|
2010-07-20 21:20:16 +04:00
|
|
|
|
|
|
|
ctab = GetHead(&gwin->tab_list);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
tabs++;
|
|
|
|
ntab=GetSucc(ctab);
|
|
|
|
GetClickTabNodeAttrs(ctab,
|
|
|
|
TNA_UserData, &bw,
|
|
|
|
TAG_DONE);
|
|
|
|
if(tabs == tab) return bw;
|
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;
|
|
|
|
struct browser_window *tbw = NULL;
|
|
|
|
|
|
|
|
if((bw == NULL) || (gwin->tabs == 0)) return 1;
|
|
|
|
|
|
|
|
ctab = GetHead(&gwin->tab_list);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
tabs++;
|
|
|
|
ntab=GetSucc(ctab);
|
|
|
|
GetClickTabNodeAttrs(ctab,
|
|
|
|
TNA_UserData, &tbw,
|
|
|
|
TAG_DONE);
|
|
|
|
if(tbw == 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-10-16 12:55:01 +04:00
|
|
|
static struct browser_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;
|
2010-07-20 21:20:16 +04:00
|
|
|
struct browser_window *bw = curbw;
|
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]))
|
|
|
|
bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[4], *(ULONG *)cmd->ac_ArgList[5]);
|
|
|
|
|
2013-02-14 19:09:28 +04:00
|
|
|
if (nsurl_create((char *)cmd->ac_ArgList[0], &url) != NSERROR_OK) {
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-07-20 21:20:16 +04:00
|
|
|
if(cmd->ac_ArgList[3])
|
2009-02-01 02:45:25 +03:00
|
|
|
{
|
2010-07-20 21:20:16 +04:00
|
|
|
if(!bw) return;
|
2009-04-14 22:51:10 +04:00
|
|
|
|
2013-10-12 16:11:13 +04:00
|
|
|
dln = AllocVecTags(sizeof(struct dlnode), AVT_ClearWithValue, 0, TAG_DONE);
|
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;
|
2011-07-03 19:01:56 +04:00
|
|
|
AddTail(&bw->window->dllist, (struct Node *)dln);
|
2013-02-14 19:09:28 +04:00
|
|
|
if(!bw->download) {
|
|
|
|
browser_window_navigate(curbw,
|
|
|
|
url,
|
|
|
|
NULL,
|
2014-02-11 02:40:04 +04:00
|
|
|
BW_NAVIGATE_DOWNLOAD,
|
2013-02-14 19:09:28 +04:00
|
|
|
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,
|
2013-06-18 23:13:59 +04:00
|
|
|
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
|
|
|
|
{
|
2010-07-20 21:20:16 +04:00
|
|
|
if(bw)
|
2009-09-29 02:17:09 +04:00
|
|
|
{
|
2013-02-14 19:09:28 +04:00
|
|
|
browser_window_navigate(bw,
|
|
|
|
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;
|
2010-07-20 21:20:16 +04:00
|
|
|
struct browser_window *bw = curbw;
|
|
|
|
|
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]))
|
|
|
|
bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[1], *(ULONG *)cmd->ac_ArgList[2]);
|
2009-09-29 02:17:09 +04:00
|
|
|
|
2010-07-20 21:20:16 +04:00
|
|
|
if(!bw) return;
|
|
|
|
|
2013-01-06 04:21:15 +04:00
|
|
|
ami_set_pointer(bw->window->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-11-09 03:37:35 +03:00
|
|
|
if((source_data = content_get_source_data(bw->current_content, &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);
|
2011-12-04 18:55:23 +04:00
|
|
|
SetComment((char *)cmd->ac_ArgList[0], nsurl_access(hlcache_handle_get_url(bw->current_content)));
|
2009-01-11 00:33:34 +03:00
|
|
|
}
|
|
|
|
|
2013-01-06 04:21:15 +04:00
|
|
|
ami_reset_pointer(bw->window->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)))
|
|
|
|
{
|
2010-07-20 21:20:16 +04:00
|
|
|
struct browser_window *bw = curbw;
|
|
|
|
|
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]))
|
|
|
|
bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
|
|
|
|
|
|
|
|
if(bw && bw->current_content)
|
2008-10-26 15:25:26 +03:00
|
|
|
{
|
2011-12-04 18:55:23 +04:00
|
|
|
strcpy(result, nsurl_access(hlcache_handle_get_url(bw->current_content)));
|
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)))
|
|
|
|
{
|
2010-07-20 21:20:16 +04:00
|
|
|
struct browser_window *bw = curbw;
|
|
|
|
|
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]))
|
|
|
|
bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
|
|
|
|
|
|
|
|
if(bw)
|
2008-11-24 11:06:11 +03:00
|
|
|
{
|
2011-07-03 19:01:56 +04:00
|
|
|
if(bw->window->shared->tabs > 1)
|
|
|
|
strcpy(result, bw->window->tabtitle);
|
2010-07-20 21:20:16 +04:00
|
|
|
else
|
2011-07-03 19:01:56 +04:00
|
|
|
strcpy(result, bw->window->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)))
|
|
|
|
{
|
2010-07-20 21:20:16 +04:00
|
|
|
struct browser_window *bw = curbw;
|
|
|
|
|
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]))
|
|
|
|
bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
|
|
|
|
|
2011-06-03 22:20:56 +04:00
|
|
|
if(bw) ami_gui_history(bw->window->shared, true);
|
2010-07-11 19:34:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
STATIC VOID rx_forward(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
2010-07-20 21:20:16 +04:00
|
|
|
struct browser_window *bw = curbw;
|
|
|
|
|
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]))
|
|
|
|
bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
|
|
|
|
|
2011-06-03 22:20:56 +04:00
|
|
|
if(bw) ami_gui_history(bw->window->shared, false);
|
|
|
|
|
2010-07-11 19:34:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
STATIC VOID rx_home(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
|
|
|
|
{
|
2010-07-20 21:20:16 +04:00
|
|
|
struct browser_window *bw = curbw;
|
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]))
|
|
|
|
bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
|
|
|
|
|
2013-02-14 19:09:28 +04:00
|
|
|
if(bw == NULL) return;
|
|
|
|
|
|
|
|
if (nsurl_create(nsoption_charp(homepage_url), &url) != NSERROR_OK) {
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
} else {
|
|
|
|
browser_window_navigate(bw,
|
|
|
|
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)))
|
|
|
|
{
|
2010-07-20 21:20:16 +04:00
|
|
|
struct browser_window *bw = curbw;
|
|
|
|
|
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]))
|
|
|
|
bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[1], *(ULONG *)cmd->ac_ArgList[2]);
|
|
|
|
|
|
|
|
if(bw)
|
2010-07-11 19:34:35 +04:00
|
|
|
{
|
|
|
|
if(cmd->ac_ArgList[0]) /* FORCE */
|
|
|
|
{
|
2010-07-20 21:20:16 +04:00
|
|
|
browser_window_reload(bw, true);
|
2010-07-11 19:34:35 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-20 21:20:16 +04:00
|
|
|
browser_window_reload(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;
|
|
|
|
struct browser_window *bw = curbw;
|
|
|
|
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 17:47:26 +03:00
|
|
|
if(gwin->gw->bw == bw)
|
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])
|
|
|
|
{
|
|
|
|
tab = ami_find_tab_bw(gwin, bw);
|
|
|
|
}
|
|
|
|
|
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)))
|
|
|
|
{
|
|
|
|
struct browser_window *bw = curbw;
|
|
|
|
|
|
|
|
cmd->ac_RC = 0;
|
|
|
|
|
|
|
|
if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1]))
|
|
|
|
bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
|
|
|
|
else if(cmd->ac_ArgList[0])
|
|
|
|
{
|
|
|
|
ami_close_all_tabs(bw->window->shared);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(bw) browser_window_destroy(bw);
|
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
}
|