HTMLv: http lib integration, part 1 (thanks hidnplayr)

git-svn-id: svn://kolibrios.org@4536 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2014-01-27 19:34:00 +00:00
parent bd53b16a76
commit 8c408ccaee
3 changed files with 39 additions and 11 deletions

View File

@ -24,6 +24,7 @@
#include "..\lib\lib.obj\box_lib.h" #include "..\lib\lib.obj\box_lib.h"
#include "..\lib\lib.obj\libio_lib.h" #include "..\lib\lib.obj\libio_lib.h"
#include "..\lib\lib.obj\libimg_lib.h" #include "..\lib\lib.obj\libimg_lib.h"
#include "..\lib\lib.obj\http.h"
//images //images
#include "img\toolbar_icons.c" #include "img\toolbar_icons.c"
#include "img\URLgoto.txt"; #include "img\URLgoto.txt";
@ -73,18 +74,18 @@ void main()
int scroll_used=0, show_menu; int scroll_used=0, show_menu;
mem_Init(); mem_Init();
CursorPointer.Load(#CursorFile);
if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();} if (load_dll2(boxlib, #box_lib_init,0)!=0) {notify("System Error: library doesn't exists /rd/1/lib/box_lib.obj"); ExitProcess();}
if (load_dll2(libio, #libio_init,1)!=0) debug("Error: library doesn't exists - libio"); if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
if (load_dll2(libimg, #libimg_init,1)!=0) debug("Error: library doesn't exists - libimg"); if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
if (!URL) strcpy(#URL, "/sys/index.htm"); if (!URL) strcpy(#URL, "/sys/index.htm");
CursorPointer.Load(#CursorFile);
Form.width=WIN_W; Form.width=WIN_W;
Form.height=WIN_H; Form.height=WIN_H;
SetElementSizes(); SetElementSizes();
OpenPage(); OpenPage();
SetEventMask(0x27); SetEventMask(0xa7);
loop() loop()
{ {
WaitEventTimeout(2); WaitEventTimeout(2);
@ -164,6 +165,29 @@ void main()
if (action_buf) { Scan(action_buf); action_buf=0;} if (action_buf) { Scan(action_buf); action_buf=0;}
Draw_Window(); Draw_Window();
break; break;
case evNetwork:
return;
//open page
http_get stdcall (#URL, 0);
http_transfer = EAX;
IF (http_transfer<0) notify("Error from HTTP lib");
//
if (http_transfer != 0) {
http_process stdcall (http_transfer);
$push EAX
ESI = http_transfer;
if (!ESI.http_msg.content_received) break;
buf = ESI.http_msg.content_ptr;
debug(buf);
filesize = ESI.http_msg.content_received;
debugi(filesize);
WB1.ParseHTML(buf);
$pop EAX
if (EAX == 0) {
http_free stdcall (http_transfer);
http_transfer=0;
}
}
default: default:
if (downloader_id<>0) if (downloader_id<>0)
{ {

View File

@ -20,10 +20,12 @@ char program_path[4096];
#define false 0 #define false 0
//Events //Events
#define evMouse 6
#define evButton 3
#define evKey 2
#define evReDraw 1 #define evReDraw 1
#define evKey 2
#define evButton 3
#define evMouse 6
#define evNetwork 8
//Button options //Button options
#define BT_DEL 0x80000000 #define BT_DEL 0x80000000

View File

@ -28,7 +28,7 @@ char aURIunescape[9] = "unescape\0";
#define FLAG_HTTP11 1 << 0 #define FLAG_HTTP11 1 << 0
#define FLAG_GOT_HEADER 1 << 1 #define FLAG_GOT_HEADER 1 << 1
#define FLAG_GOT_DATA 1 << 2 #define FLAG_GOT_ALL_DATA 1 << 2
#define FLAG_CONTENT_LENGTH 1 << 3 #define FLAG_CONTENT_LENGTH 1 << 3
#define FLAG_CHUNKED 1 << 4 #define FLAG_CHUNKED 1 << 4
#define FLAG_CONNECTED 1 << 5 #define FLAG_CONNECTED 1 << 5
@ -38,6 +38,7 @@ char aURIunescape[9] = "unescape\0";
#define FLAG_NO_RAM 1 << 17 #define FLAG_NO_RAM 1 << 17
#define FLAG_SOCKET_ERROR 1 << 18 #define FLAG_SOCKET_ERROR 1 << 18
#define FLAG_TIMEOUT_ERROR 1 << 19 #define FLAG_TIMEOUT_ERROR 1 << 19
#define FLAG_TRANSFER_FAILED 1 << 20
struct http_msg{ struct http_msg{
dword socket; dword socket;
@ -48,7 +49,8 @@ struct http_msg{
dword timestamp; dword timestamp;
dword status; dword status;
dword header_length; dword header_length;
dword content_ptr;
dword content_length; dword content_length;
dword content_received; dword content_received;
char data; char http_header;
}; };