401 authentication/login support.
svn path=/trunk/netsurf/; revision=5222
This commit is contained in:
parent
277262bf46
commit
a9867f0b7f
101
amiga/gui.c
101
amiga/gui.c
|
@ -80,7 +80,6 @@ struct browser_window *curbw;
|
|||
char *default_stylesheet_url;
|
||||
char *adblock_stylesheet_url;
|
||||
struct gui_window *search_current_window = NULL;
|
||||
struct MinList *window_list;
|
||||
|
||||
struct MsgPort *msgport;
|
||||
struct timerequest *tioreq;
|
||||
|
@ -89,12 +88,10 @@ struct TimerIFace *ITimer;
|
|||
struct Library *PopupMenuBase = NULL;
|
||||
struct PopupMenuIFace *IPopupMenu = NULL;
|
||||
|
||||
struct Screen *scrn;
|
||||
bool win_destroyed = false;
|
||||
static struct RastPort dummyrp;
|
||||
struct FileRequester *filereq;
|
||||
struct IFFHandle *iffh = NULL;
|
||||
STRPTR nsscreentitle = NULL;
|
||||
struct tree *hotlist;
|
||||
|
||||
void ami_update_buttons(struct gui_window *);
|
||||
|
@ -261,11 +258,11 @@ void gui_init2(int argc, char** argv)
|
|||
BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED,
|
||||
NULL,RGBFB_A8R8G8B8);
|
||||
|
||||
if(!dummyrp.BitMap) die(messages_get("NoMemory"));
|
||||
|
||||
if ((!option_homepage_url) || (option_homepage_url[0] == '\0'))
|
||||
option_homepage_url = strdup(NETSURF_HOMEPAGE);
|
||||
|
||||
/* need some bestmodeid() in here, or grab modeid from options file */
|
||||
|
||||
if(option_modeid)
|
||||
{
|
||||
id = option_modeid;
|
||||
|
@ -442,6 +439,19 @@ void ami_get_msg(void)
|
|||
ami_update_buttons(gwin);
|
||||
break;
|
||||
|
||||
case GID_LOGIN:
|
||||
ami_401login_login((struct gui_login_window *)gwin);
|
||||
win_destroyed = true;
|
||||
break;
|
||||
|
||||
case GID_CANCEL:
|
||||
if(gwin->node->Type == AMINS_LOGINWINDOW)
|
||||
{
|
||||
ami_401login_close((struct gui_login_window *)gwin);
|
||||
win_destroyed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("GADGET: %ld\n",(result & WMHI_GADGETMASK));
|
||||
break;
|
||||
|
@ -752,26 +762,28 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
|||
struct gui_window *gwin = NULL;
|
||||
bool closegadg=TRUE;
|
||||
|
||||
/*
|
||||
if(bw->browser_window_type == BROWSER_WINDOW_IFRAME)
|
||||
{
|
||||
if(option_no_iframes) return NULL;
|
||||
/*
|
||||
gwin = bw->parent->window;
|
||||
printf("%lx\n",gwin);
|
||||
return gwin;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
gwin = AllocVec(sizeof(struct gui_window),MEMF_CLEAR);
|
||||
|
||||
gwin->scrollerhook.h_Entry = ami_scroller_hook;
|
||||
gwin->scrollerhook.h_Data = gwin;
|
||||
|
||||
if(!gwin)
|
||||
{
|
||||
printf(messages_get("NoMemory"));
|
||||
return 0;
|
||||
warn_user("NoMemory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gwin->scrollerhook.h_Entry = ami_scroller_hook;
|
||||
gwin->scrollerhook.h_Data = gwin;
|
||||
|
||||
menu = ami_create_menu(bw->browser_window_type);
|
||||
|
||||
switch(bw->browser_window_type)
|
||||
|
@ -944,17 +956,28 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
|||
|
||||
gwin->win = (struct Window *)RA_OpenWindow(gwin->objects[OID_MAIN]);
|
||||
|
||||
if(!gwin->win)
|
||||
{
|
||||
warn_user("NoMemory");
|
||||
FreeVec(gwin);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gwin->bw = bw;
|
||||
// curwin = gwin; //test
|
||||
/* not needed - no rendering takes place here. */
|
||||
currp = &gwin->rp; // WINDOW.CLASS: &gwin->rp; //gwin->win->RPort;
|
||||
|
||||
/* below needs to be allocated as big as the screen */
|
||||
gwin->bm = p96AllocBitMap(scrn->Width,scrn->Height,32,
|
||||
BMF_CLEAR | BMF_DISPLAYABLE | BMF_INTERLEAVED,
|
||||
gwin->win->RPort->BitMap,
|
||||
RGBFB_A8R8G8B8);
|
||||
|
||||
if(!gwin->bm)
|
||||
{
|
||||
warn_user("NoMemory");
|
||||
browser_window_destroy(bw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
InitRastPort(&gwin->rp);
|
||||
gwin->rp.BitMap = gwin->bm;
|
||||
SetDrMd(currp,BGBACKFILL);
|
||||
|
@ -964,9 +987,25 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
|||
|
||||
gwin->areabuf = AllocVec(100,MEMF_CLEAR);
|
||||
gwin->rp.AreaInfo = AllocVec(sizeof(struct AreaInfo),MEMF_CLEAR);
|
||||
|
||||
if((!gwin->areabuf) || (!gwin->rp.AreaInfo))
|
||||
{
|
||||
warn_user("NoMemory");
|
||||
browser_window_destroy(bw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
InitArea(gwin->rp.AreaInfo,gwin->areabuf,100/5);
|
||||
gwin->rp.TmpRas = AllocVec(sizeof(struct TmpRas),MEMF_CLEAR);
|
||||
gwin->tmprasbuf = AllocVec(scrn->Width*scrn->Height,MEMF_CLEAR);
|
||||
|
||||
if((!gwin->tmprasbuf) || (!gwin->rp.TmpRas))
|
||||
{
|
||||
warn_user("NoMemory");
|
||||
browser_window_destroy(bw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
InitTmpRas(gwin->rp.TmpRas,gwin->tmprasbuf,scrn->Width*scrn->Height);
|
||||
|
||||
GetRPAttrs(&gwin->rp,RPTAG_Font,&origrpfont,TAG_DONE);
|
||||
|
@ -976,19 +1015,11 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
|||
|
||||
|
||||
RefreshSetGadgetAttrs((APTR)gwin->objects[OID_VSCROLL],gwin->win,NULL,
|
||||
/*
|
||||
GA_RelVerify,TRUE,
|
||||
GA_Immediate,TRUE,
|
||||
*/
|
||||
GA_ID,OID_VSCROLL,
|
||||
ICA_TARGET,ICTARGET_IDCMP,
|
||||
TAG_DONE);
|
||||
|
||||
RefreshSetGadgetAttrs((APTR)gwin->objects[OID_HSCROLL],gwin->win,NULL,
|
||||
/*
|
||||
GA_RelVerify,TRUE,
|
||||
GA_Immediate,TRUE,
|
||||
*/
|
||||
GA_ID,OID_HSCROLL,
|
||||
ICA_TARGET,ICTARGET_IDCMP,
|
||||
TAG_DONE);
|
||||
|
@ -1001,6 +1032,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
|||
|
||||
void gui_window_destroy(struct gui_window *g)
|
||||
{
|
||||
if(!g) return;
|
||||
|
||||
DisposeObject(g->objects[OID_MAIN]);
|
||||
DeleteLayer(0,g->rp.Layer);
|
||||
DisposeLayerInfo(g->layerinfo);
|
||||
|
@ -1023,6 +1056,7 @@ void gui_window_destroy(struct gui_window *g)
|
|||
|
||||
void gui_window_set_title(struct gui_window *g, const char *title)
|
||||
{
|
||||
if(!g) return;
|
||||
if(g->win->Title) ami_utf8_free(g->win->Title);
|
||||
SetWindowTitles(g->win,ami_utf8_easy(title),nsscreentitle);
|
||||
}
|
||||
|
@ -1034,6 +1068,8 @@ void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1)
|
|||
|
||||
void gui_window_redraw_window(struct gui_window *g)
|
||||
{
|
||||
if(!g) return;
|
||||
|
||||
g->redraw_required = true;
|
||||
g->redraw_data = NULL;
|
||||
}
|
||||
|
@ -1045,6 +1081,8 @@ void gui_window_update_box(struct gui_window *g,
|
|||
ULONG hcurrent,vcurrent,xoffset,yoffset,width=800,height=600;
|
||||
struct IBox *bbox;
|
||||
|
||||
if(!g) return;
|
||||
|
||||
GetAttr(SPACE_AreaBox,g->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
GetAttr(SCROLLER_Top,g->objects[OID_HSCROLL],&hcurrent);
|
||||
GetAttr(SCROLLER_Top,g->objects[OID_VSCROLL],&vcurrent);
|
||||
|
@ -1191,6 +1229,8 @@ bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
|
|||
|
||||
void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
|
||||
{
|
||||
if(!g) return;
|
||||
|
||||
RefreshSetGadgetAttrs((APTR)g->objects[OID_VSCROLL],g->win,NULL,
|
||||
SCROLLER_Top,sy,
|
||||
TAG_DONE);
|
||||
|
@ -1212,6 +1252,7 @@ void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
|
|||
void gui_window_position_frame(struct gui_window *g, int x0, int y0,
|
||||
int x1, int y1)
|
||||
{
|
||||
if(!g) return;
|
||||
ChangeWindowBox(g->win,x0,y0,x1-x0,y1-y0);
|
||||
}
|
||||
|
||||
|
@ -1219,6 +1260,7 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
|
|||
bool scaled)
|
||||
{
|
||||
struct IBox *bbox;
|
||||
if(!g) return;
|
||||
|
||||
GetAttr(SPACE_AreaBox,g->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
|
||||
|
@ -1238,6 +1280,8 @@ void gui_window_update_extent(struct gui_window *g)
|
|||
{
|
||||
struct IBox *bbox;
|
||||
|
||||
if(!g) return;
|
||||
|
||||
GetAttr(SPACE_AreaBox,g->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
|
||||
/*
|
||||
|
@ -1286,6 +1330,8 @@ void gui_window_hide_pointer(struct gui_window *g)
|
|||
|
||||
void gui_window_set_url(struct gui_window *g, const char *url)
|
||||
{
|
||||
if(!g) return;
|
||||
|
||||
RefreshSetGadgetAttrs(g->gadgets[GID_URL],g->win,NULL,STRINGA_TextVal,url,TAG_DONE);
|
||||
}
|
||||
|
||||
|
@ -1301,6 +1347,8 @@ void gui_window_place_caret(struct gui_window *g, int x, int y, int height)
|
|||
{
|
||||
struct IBox *bbox;
|
||||
|
||||
if(!g) return;
|
||||
|
||||
GetAttr(SPACE_AreaBox,g->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
|
||||
SetAPen(g->win->RPort,3);
|
||||
|
@ -1315,6 +1363,8 @@ void gui_window_remove_caret(struct gui_window *g)
|
|||
{
|
||||
struct IBox *bbox;
|
||||
|
||||
if(!g) return;
|
||||
|
||||
GetAttr(SPACE_AreaBox,g->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
|
||||
BltBitMapRastPort(g->bm,g->c_x,g->c_y,g->win->RPort,bbox->Left+g->c_x,bbox->Top+g->c_y,2,g->c_h,0x0C0);
|
||||
|
@ -1395,6 +1445,7 @@ struct gui_download_window *gui_download_window_create(const char *url,
|
|||
WA_SizeGadget, TRUE,
|
||||
WA_CustomScreen,scrn,
|
||||
WINDOW_IconifyGadget, TRUE,
|
||||
WINDOW_LockHeight,TRUE,
|
||||
WINDOW_Position, WPOS_CENTERSCREEN,
|
||||
WINDOW_ParentGroup, dw->gadgets[GID_MAIN] = VGroupObject,
|
||||
LAYOUT_AddChild, dw->gadgets[GID_STATUS] = FuelGaugeObject,
|
||||
|
@ -1432,8 +1483,8 @@ void gui_download_window_data(struct gui_download_window *dw, const char *data,
|
|||
|
||||
dw->downloaded = dw->downloaded + size;
|
||||
|
||||
va[0] = dw->downloaded;
|
||||
va[1] = dw->size;
|
||||
va[0] = (APTR)dw->downloaded;
|
||||
va[1] = (APTR)dw->size;
|
||||
va[2] = 0;
|
||||
|
||||
if(dw->size)
|
||||
|
|
|
@ -38,6 +38,10 @@ enum
|
|||
GID_BACK,
|
||||
GID_FORWARD,
|
||||
GID_THROBBER,
|
||||
GID_USER,
|
||||
GID_PASS,
|
||||
GID_LOGIN,
|
||||
GID_CANCEL,
|
||||
GID_LAST
|
||||
};
|
||||
|
||||
|
@ -86,4 +90,7 @@ struct gui_window {
|
|||
|
||||
struct RastPort *currp;
|
||||
struct TextFont *origrpfont;
|
||||
struct MinList *window_list;
|
||||
struct Screen *scrn;
|
||||
STRPTR nsscreentitle;
|
||||
#endif
|
||||
|
|
122
amiga/login.c
122
amiga/login.c
|
@ -17,8 +17,130 @@
|
|||
*/
|
||||
|
||||
#include "desktop/401login.h"
|
||||
#include "amiga/gui.h"
|
||||
#include "amiga/object.h"
|
||||
#include "amiga/login.h"
|
||||
#include <proto/exec.h>
|
||||
#include <proto/intuition.h>
|
||||
#include <proto/utility.h>
|
||||
#include "utils/url.h"
|
||||
#include "content/urldb.h"
|
||||
#include "utils/messages.h"
|
||||
|
||||
#include <proto/window.h>
|
||||
#include <proto/layout.h>
|
||||
#include <proto/string.h>
|
||||
#include <proto/button.h>
|
||||
#include <proto/label.h>
|
||||
#include <classes/window.h>
|
||||
#include <gadgets/layout.h>
|
||||
#include <gadgets/string.h>
|
||||
#include <gadgets/button.h>
|
||||
#include <images/label.h>
|
||||
#include <reaction/reaction_macros.h>
|
||||
|
||||
void gui_401login_open(struct browser_window *bw, struct content *c,
|
||||
const char *realm)
|
||||
{
|
||||
struct gui_login_window *lw = AllocVec(sizeof(struct gui_login_window),MEMF_CLEAR);
|
||||
char *host;
|
||||
|
||||
url_host(c->url, &host);
|
||||
lw->host = host;
|
||||
lw->url = c->url;
|
||||
lw->realm = (char *)realm;
|
||||
lw->bw = bw;
|
||||
|
||||
lw->objects[OID_MAIN] = WindowObject,
|
||||
WA_ScreenTitle,nsscreentitle,
|
||||
WA_Title,lw->url,
|
||||
WA_Activate, TRUE,
|
||||
WA_DepthGadget, TRUE,
|
||||
WA_DragBar, TRUE,
|
||||
WA_CloseGadget, FALSE,
|
||||
WA_SizeGadget, TRUE,
|
||||
WA_CustomScreen,scrn,
|
||||
WINDOW_IconifyGadget, FALSE,
|
||||
WINDOW_LockHeight,TRUE,
|
||||
WINDOW_Position, WPOS_CENTERSCREEN,
|
||||
WINDOW_ParentGroup, lw->gadgets[GID_MAIN] = VGroupObject,
|
||||
LAYOUT_AddChild, StringObject,
|
||||
STRINGA_TextVal,lw->host,
|
||||
GA_ReadOnly,TRUE,
|
||||
StringEnd,
|
||||
CHILD_Label, LabelObject,
|
||||
LABEL_Text,messages_get("Host"),
|
||||
LabelEnd,
|
||||
CHILD_WeightedHeight,0,
|
||||
LAYOUT_AddChild, StringObject,
|
||||
STRINGA_TextVal,lw->realm,
|
||||
GA_ReadOnly,TRUE,
|
||||
StringEnd,
|
||||
CHILD_Label, LabelObject,
|
||||
LABEL_Text,messages_get("Realm"),
|
||||
LabelEnd,
|
||||
CHILD_WeightedHeight,0,
|
||||
LAYOUT_AddChild, lw->gadgets[GID_USER] = StringObject,
|
||||
GA_ID,GID_USER,
|
||||
GA_TabCycle,TRUE,
|
||||
StringEnd,
|
||||
CHILD_Label, LabelObject,
|
||||
LABEL_Text,messages_get("Username"),
|
||||
LabelEnd,
|
||||
CHILD_WeightedHeight,0,
|
||||
LAYOUT_AddChild, lw->gadgets[GID_PASS] = StringObject,
|
||||
GA_ID,GID_PASS,
|
||||
STRINGA_HookType,SHK_PASSWORD,
|
||||
GA_TabCycle,TRUE,
|
||||
StringEnd,
|
||||
CHILD_Label, LabelObject,
|
||||
LABEL_Text,messages_get("Password"),
|
||||
LabelEnd,
|
||||
CHILD_WeightedHeight,0,
|
||||
LAYOUT_AddChild, HGroupObject,
|
||||
LAYOUT_AddChild, lw->gadgets[GID_LOGIN] = ButtonObject,
|
||||
GA_ID,GID_LOGIN,
|
||||
GA_RelVerify,TRUE,
|
||||
GA_Text,messages_get("Login"),
|
||||
GA_TabCycle,TRUE,
|
||||
ButtonEnd,
|
||||
CHILD_WeightedHeight,0,
|
||||
LAYOUT_AddChild, lw->gadgets[GID_CANCEL] = ButtonObject,
|
||||
GA_ID,GID_CANCEL,
|
||||
GA_RelVerify,TRUE,
|
||||
GA_Text,messages_get("Cancel"),
|
||||
GA_TabCycle,TRUE,
|
||||
ButtonEnd,
|
||||
LayoutEnd,
|
||||
CHILD_WeightedHeight,0,
|
||||
EndGroup,
|
||||
EndWindow;
|
||||
|
||||
lw->win = (struct Window *)RA_OpenWindow(lw->objects[OID_MAIN]);
|
||||
|
||||
lw->node = AddObject(window_list,AMINS_LOGINWINDOW);
|
||||
lw->node->objstruct = lw;
|
||||
}
|
||||
|
||||
void ami_401login_close(struct gui_login_window *lw)
|
||||
{
|
||||
DisposeObject(lw->objects[OID_MAIN]);
|
||||
free(lw->host);
|
||||
DelObject(lw->node);
|
||||
}
|
||||
|
||||
void ami_401login_login(struct gui_login_window *lw)
|
||||
{
|
||||
ULONG *user,*pass;
|
||||
STRPTR userpass;
|
||||
|
||||
GetAttr(STRINGA_TextVal,lw->gadgets[GID_USER],(ULONG *)&user);
|
||||
GetAttr(STRINGA_TextVal,lw->gadgets[GID_PASS],(ULONG *)&pass);
|
||||
|
||||
userpass = ASPrintf("%s:%s",user,pass);
|
||||
urldb_set_auth_details(lw->url,lw->realm,userpass);
|
||||
FreeVec(userpass);
|
||||
browser_window_go(lw->bw,lw->url,0,true);
|
||||
|
||||
ami_401login_close(lw);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2008 Chris Young <chris@unsatisfactorysoftware.co.uk>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef AMIGA_LOGIN_H
|
||||
#define AMIGA_LOGIN_H
|
||||
struct gui_login_window {
|
||||
struct Window *win;
|
||||
Object *objects[OID_LAST];
|
||||
struct Gadget *gadgets[GID_LAST];
|
||||
struct nsObject *node;
|
||||
ULONG pad[2];
|
||||
struct browser_window *bw;
|
||||
char *url;
|
||||
char *realm;
|
||||
char *host;
|
||||
};
|
||||
|
||||
void ami_401login_close(struct gui_login_window *lw);
|
||||
void ami_401login_login(struct gui_login_window *lw);
|
||||
#endif
|
|
@ -25,6 +25,7 @@
|
|||
#define AMINS_WINDOW 1
|
||||
#define AMINS_FRAME 2
|
||||
#define AMINS_DLWINDOW 3
|
||||
#define AMINS_LOGINWINDOW 3
|
||||
|
||||
struct nsObject
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue