From 8c408ccaee1b029dcff8c1b993ed354341265425 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Mon, 27 Jan 2014 19:34:00 +0000 Subject: [PATCH] HTMLv: http lib integration, part 1 (thanks hidnplayr) git-svn-id: svn://kolibrios.org@4536 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/browser/HTMLv.c | 36 +++++++++++++++++++++++++++------ programs/cmm/lib/kolibri.h | 8 +++++--- programs/cmm/lib/lib.obj/http.h | 6 ++++-- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/programs/cmm/browser/HTMLv.c b/programs/cmm/browser/HTMLv.c index 433cef6ccc..687bbea9f8 100644 --- a/programs/cmm/browser/HTMLv.c +++ b/programs/cmm/browser/HTMLv.c @@ -24,6 +24,7 @@ #include "..\lib\lib.obj\box_lib.h" #include "..\lib\lib.obj\libio_lib.h" #include "..\lib\lib.obj\libimg_lib.h" +#include "..\lib\lib.obj\http.h" //images #include "img\toolbar_icons.c" #include "img\URLgoto.txt"; @@ -73,18 +74,18 @@ void main() int scroll_used=0, show_menu; mem_Init(); - 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(libimg, #libimg_init,1)!=0) debug("Error: library doesn't exists - libimg"); - - if (!URL) strcpy(#URL, "/sys/index.htm"); 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(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio"); + if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg"); + + if (!URL) strcpy(#URL, "/sys/index.htm"); Form.width=WIN_W; Form.height=WIN_H; SetElementSizes(); OpenPage(); - SetEventMask(0x27); + SetEventMask(0xa7); loop() { WaitEventTimeout(2); @@ -164,6 +165,29 @@ void main() if (action_buf) { Scan(action_buf); action_buf=0;} Draw_Window(); 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: if (downloader_id<>0) { diff --git a/programs/cmm/lib/kolibri.h b/programs/cmm/lib/kolibri.h index 442f2ddb8d..a6fe11f8d0 100644 --- a/programs/cmm/lib/kolibri.h +++ b/programs/cmm/lib/kolibri.h @@ -20,10 +20,12 @@ char program_path[4096]; #define false 0 //Events -#define evMouse 6 -#define evButton 3 -#define evKey 2 #define evReDraw 1 +#define evKey 2 +#define evButton 3 +#define evMouse 6 +#define evNetwork 8 + //Button options #define BT_DEL 0x80000000 diff --git a/programs/cmm/lib/lib.obj/http.h b/programs/cmm/lib/lib.obj/http.h index 8e84738bc4..69c9854abc 100644 --- a/programs/cmm/lib/lib.obj/http.h +++ b/programs/cmm/lib/lib.obj/http.h @@ -28,7 +28,7 @@ char aURIunescape[9] = "unescape\0"; #define FLAG_HTTP11 1 << 0 #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_CHUNKED 1 << 4 #define FLAG_CONNECTED 1 << 5 @@ -38,6 +38,7 @@ char aURIunescape[9] = "unescape\0"; #define FLAG_NO_RAM 1 << 17 #define FLAG_SOCKET_ERROR 1 << 18 #define FLAG_TIMEOUT_ERROR 1 << 19 +#define FLAG_TRANSFER_FAILED 1 << 20 struct http_msg{ dword socket; @@ -48,7 +49,8 @@ struct http_msg{ dword timestamp; dword status; dword header_length; + dword content_ptr; dword content_length; dword content_received; - char data; + char http_header; }; \ No newline at end of file