2020-03-20 04:28:59 +03:00
|
|
|
//Copyright 2007-2020 by Veliant & Leency
|
2017-09-17 04:32:09 +03:00
|
|
|
//Asper, lev, Lrz, Barsuk, Nable, hidnplayr...
|
2012-11-26 19:26:15 +04:00
|
|
|
|
2013-10-25 01:45:17 +04:00
|
|
|
#ifndef AUTOBUILD
|
|
|
|
#include "lang.h--"
|
|
|
|
#endif
|
|
|
|
|
2020-12-06 15:03:16 +03:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// LIB //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
2020-04-10 19:19:52 +03:00
|
|
|
#define MEMSIZE 1024 * 1000
|
2015-03-05 23:55:28 +03:00
|
|
|
#include "..\lib\gui.h"
|
2014-01-22 04:08:47 +04:00
|
|
|
#include "..\lib\draw_buf.h"
|
|
|
|
#include "..\lib\list_box.h"
|
|
|
|
#include "..\lib\cursor.h"
|
2015-12-17 01:44:42 +03:00
|
|
|
#include "..\lib\collection.h"
|
2016-12-14 01:08:14 +03:00
|
|
|
#include "..\lib\random.h"
|
2017-10-01 14:57:00 +03:00
|
|
|
#include "..\lib\clipboard.h"
|
2015-12-17 22:15:49 +03:00
|
|
|
|
2015-03-05 23:55:28 +03:00
|
|
|
#include "..\lib\obj\box_lib.h"
|
2017-10-05 01:59:57 +03:00
|
|
|
#include "..\lib\obj\libimg.h"
|
2015-03-05 23:55:28 +03:00
|
|
|
#include "..\lib\obj\http.h"
|
2015-08-07 01:37:34 +03:00
|
|
|
#include "..\lib\obj\iconv.h"
|
2020-03-23 04:11:31 +03:00
|
|
|
#include "..\lib\obj\proc_lib.h"
|
2020-12-06 02:22:38 +03:00
|
|
|
#include "..\lib\obj\netcode.h"
|
2020-03-29 13:57:14 +03:00
|
|
|
|
2015-12-17 01:44:42 +03:00
|
|
|
#include "..\lib\patterns\history.h"
|
2020-03-23 04:11:31 +03:00
|
|
|
#include "..\lib\patterns\simple_open_dialog.h"
|
2020-04-04 02:17:28 +03:00
|
|
|
#include "..\lib\patterns\toolbar_button.h"
|
2020-05-12 02:02:41 +03:00
|
|
|
#include "..\lib\patterns\restart_process.h"
|
2015-02-15 13:18:26 +03:00
|
|
|
|
2020-12-07 21:19:13 +03:00
|
|
|
#include "const.h"
|
|
|
|
#include "cache.h"
|
|
|
|
#include "show_src.h"
|
|
|
|
|
2020-12-06 15:03:16 +03:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// DATA //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
2020-12-11 06:05:01 +03:00
|
|
|
char version[]="WebView 2.8 BETA 5";
|
2020-11-29 22:08:52 +03:00
|
|
|
|
2020-12-07 21:19:13 +03:00
|
|
|
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
|
2020-04-10 19:19:52 +03:00
|
|
|
|
2020-03-29 13:57:14 +03:00
|
|
|
bool debug_mode = false;
|
2020-12-06 02:22:38 +03:00
|
|
|
bool show_images = false;
|
2020-04-10 19:19:52 +03:00
|
|
|
|
2020-06-02 01:18:26 +03:00
|
|
|
_history history;
|
|
|
|
|
2020-05-23 00:39:04 +03:00
|
|
|
enum { TARGET_SAME_TAB, TARGET_NEW_WINDOW, TARGET_NEW_TAB };
|
|
|
|
|
2020-12-06 02:22:38 +03:00
|
|
|
#include "TWB\TWB.c" //HTML Parser, a core component
|
2020-03-29 13:57:14 +03:00
|
|
|
|
2020-04-04 02:17:28 +03:00
|
|
|
TWebBrowser WB1;
|
|
|
|
|
2020-04-10 19:19:52 +03:00
|
|
|
#include "history.h"
|
2020-03-26 03:12:32 +03:00
|
|
|
|
2020-03-31 00:29:52 +03:00
|
|
|
#define PADDING 9
|
|
|
|
#define TSZE 25
|
2020-04-10 19:19:52 +03:00
|
|
|
#define STATUSBAR_H 15
|
|
|
|
#define TAB_H 20
|
2020-03-31 00:29:52 +03:00
|
|
|
dword TOOLBAR_H = PADDING+TSZE+PADDING+2;
|
2020-04-10 19:19:52 +03:00
|
|
|
|
2020-04-04 02:17:28 +03:00
|
|
|
_http http = 0;
|
2020-03-31 00:29:52 +03:00
|
|
|
|
2020-03-25 03:18:19 +03:00
|
|
|
bool source_mode = false;
|
2018-05-20 16:40:58 +03:00
|
|
|
|
2020-12-06 02:22:38 +03:00
|
|
|
progress_bar prbar;
|
2020-03-25 03:18:19 +03:00
|
|
|
char stak[4096];
|
|
|
|
proc_info Form;
|
2014-03-22 14:29:29 +04:00
|
|
|
|
2020-04-10 19:19:52 +03:00
|
|
|
#include "tabs.h"
|
|
|
|
|
2020-12-07 21:19:13 +03:00
|
|
|
dword cur_img_url;
|
|
|
|
dword shared_url;
|
|
|
|
dword http_get_type;
|
2020-12-11 16:33:32 +03:00
|
|
|
dword render_start_time;
|
2020-12-07 21:19:13 +03:00
|
|
|
int menu_id=NULL;
|
|
|
|
|
2020-03-23 04:11:31 +03:00
|
|
|
char default_dir[] = "/rd/1";
|
2020-04-14 19:03:24 +03:00
|
|
|
od_filter filter2 = { 22, "TXT\0HTM\0HTML\0DOCX\0\0" };
|
2020-03-23 04:11:31 +03:00
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
char editURL[URL_SIZE+1];
|
2020-12-06 15:03:16 +03:00
|
|
|
edit_box omnibox_edit = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff,
|
2020-03-31 00:29:52 +03:00
|
|
|
0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19};
|
2014-01-27 06:16:25 +04:00
|
|
|
|
2020-12-06 15:03:16 +03:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// CODE //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
2020-03-23 04:11:31 +03:00
|
|
|
void LoadLibraries()
|
|
|
|
{
|
2020-12-06 02:22:38 +03:00
|
|
|
load_dll(boxlib, #box_lib_init,0);
|
|
|
|
load_dll(libimg, #libimg_init,1);
|
|
|
|
load_dll(libHTTP, #http_lib_init,1);
|
|
|
|
load_dll(iconv_lib, #iconv_open,0);
|
|
|
|
load_dll(netcode_lib, #base64_encode,0);
|
|
|
|
load_dll(Proc_lib, #OpenDialog_init,0);
|
2020-03-23 04:11:31 +03:00
|
|
|
OpenDialog_init stdcall (#o_dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HandleParam()
|
|
|
|
{
|
2020-11-29 22:08:52 +03:00
|
|
|
if (!param) {
|
2020-12-07 21:19:13 +03:00
|
|
|
history.add(DEFAULT_URL);
|
2020-11-29 22:08:52 +03:00
|
|
|
} else {
|
|
|
|
if (!strncmp(#param, "-source ", 8)) {
|
2020-03-25 03:18:19 +03:00
|
|
|
source_mode = true;
|
2020-04-05 21:28:02 +03:00
|
|
|
history.add(#param + 8);
|
2020-05-17 14:35:02 +03:00
|
|
|
} else if (!strncmp(#param, "-new ", 5)) {
|
|
|
|
history.add(#param + 5);
|
2020-03-23 04:11:31 +03:00
|
|
|
} else {
|
2020-05-12 02:02:41 +03:00
|
|
|
if (GetProcessesCount("WEBVIEW") == 1) {
|
|
|
|
history.add(#param);
|
|
|
|
} else {
|
|
|
|
shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_OPEN + SHM_WRITE);
|
|
|
|
strncpy(shared_url, #param, URL_SIZE);
|
|
|
|
ExitProcess();
|
|
|
|
}
|
2020-03-23 04:11:31 +03:00
|
|
|
}
|
|
|
|
}
|
2020-05-12 02:02:41 +03:00
|
|
|
shared_url = memopen(#webview_shared, URL_SIZE+1, SHM_CREATE + SHM_WRITE);
|
2020-05-15 11:09:03 +03:00
|
|
|
ESDWORD[shared_url] = '\0';
|
2020-03-23 04:11:31 +03:00
|
|
|
}
|
|
|
|
|
2012-11-26 19:26:15 +04:00
|
|
|
void main()
|
|
|
|
{
|
2020-12-06 15:03:16 +03:00
|
|
|
int redirect_count=0;
|
2020-03-23 04:11:31 +03:00
|
|
|
LoadLibraries();
|
|
|
|
HandleParam();
|
2016-01-08 05:19:41 +03:00
|
|
|
WB1.list.SetFont(8, 14, 10011000b);
|
2015-08-29 23:14:17 +03:00
|
|
|
WB1.list.no_selection = true;
|
2020-04-04 02:17:28 +03:00
|
|
|
WB1.custom_encoding = -1;
|
2020-12-06 15:03:16 +03:00
|
|
|
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
|
2020-05-12 02:02:41 +03:00
|
|
|
loop() switch(@WaitEventTimeout(30))
|
2017-09-17 04:32:09 +03:00
|
|
|
{
|
|
|
|
case evMouse:
|
2020-12-06 15:03:16 +03:00
|
|
|
edit_box_mouse stdcall (#omnibox_edit);
|
2017-09-17 04:32:09 +03:00
|
|
|
mouse.get();
|
2020-05-23 00:39:04 +03:00
|
|
|
|
2018-05-20 16:40:58 +03:00
|
|
|
if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
|
2020-05-23 00:39:04 +03:00
|
|
|
|
2017-09-17 04:32:09 +03:00
|
|
|
scrollbar_v_mouse (#scroll_wv);
|
2020-12-06 02:22:38 +03:00
|
|
|
if (scroll_wv.delta2) {
|
2017-09-17 04:32:09 +03:00
|
|
|
WB1.list.first = scroll_wv.position;
|
|
|
|
WB1.DrawPage();
|
2012-11-26 19:26:15 +04:00
|
|
|
break;
|
2017-09-17 04:32:09 +03:00
|
|
|
}
|
2020-05-23 00:39:04 +03:00
|
|
|
|
|
|
|
if (links.hover(WB1.list.y, WB1.list.first))
|
2020-03-31 00:29:52 +03:00
|
|
|
{
|
2020-12-06 02:22:38 +03:00
|
|
|
if (mouse.key&MOUSE_MIDDLE) && (mouse.up) {
|
2020-05-23 00:39:04 +03:00
|
|
|
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
|
|
|
|
EventClickLink(TARGET_NEW_WINDOW);
|
|
|
|
} else {
|
|
|
|
EventClickLink(TARGET_NEW_TAB);
|
|
|
|
}
|
|
|
|
}
|
2020-12-06 02:22:38 +03:00
|
|
|
if (mouse.key&MOUSE_LEFT) && (mouse.up) {
|
2020-05-23 00:39:04 +03:00
|
|
|
CursorPointer.Restore();
|
|
|
|
EventClickLink(TARGET_SAME_TAB);
|
|
|
|
}
|
2020-12-06 02:22:38 +03:00
|
|
|
if (mouse.key&MOUSE_RIGHT) && (mouse.up) {
|
2020-05-23 00:39:04 +03:00
|
|
|
CursorPointer.Restore();
|
|
|
|
EventShowLinkMenu();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
CursorPointer.Restore();
|
2020-12-06 02:22:38 +03:00
|
|
|
if (mouse.key&MOUSE_RIGHT) && (mouse.up) && (WB1.list.MouseOver(mouse.x, mouse.y)) {
|
2020-05-23 00:39:04 +03:00
|
|
|
EventShowPageMenu();
|
|
|
|
}
|
2020-03-31 00:29:52 +03:00
|
|
|
}
|
2017-09-17 04:32:09 +03:00
|
|
|
break;
|
2015-08-10 18:08:16 +03:00
|
|
|
|
2017-09-17 04:32:09 +03:00
|
|
|
case evButton:
|
2020-12-06 15:03:16 +03:00
|
|
|
ProcessButtonClick( @GetButtonID() );
|
2017-09-17 04:32:09 +03:00
|
|
|
break;
|
2015-08-10 18:08:16 +03:00
|
|
|
|
2017-09-17 04:32:09 +03:00
|
|
|
case evKey:
|
2020-12-06 15:03:16 +03:00
|
|
|
@GetKeys();
|
|
|
|
edit_box_key stdcall(#omnibox_edit);
|
|
|
|
ProcessKeyEvent();
|
2017-09-17 04:32:09 +03:00
|
|
|
break;
|
2015-03-18 22:40:42 +03:00
|
|
|
|
2017-09-17 04:32:09 +03:00
|
|
|
case evReDraw:
|
2020-12-06 15:03:16 +03:00
|
|
|
DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),
|
2020-03-27 13:38:54 +03:00
|
|
|
GetScreenHeight()-700/2-random(80),800,700,0x73,0,0,0);
|
2017-09-17 04:32:09 +03:00
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
2020-04-13 14:51:56 +03:00
|
|
|
ProcessMenuClick();
|
2020-04-18 02:52:24 +03:00
|
|
|
sc.get();
|
2020-04-04 02:17:28 +03:00
|
|
|
if (Form.status_window>2) break;
|
2017-09-17 04:32:09 +03:00
|
|
|
if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; }
|
|
|
|
if (Form.width<280) { MoveSize(OLD,OLD,280,OLD); break; }
|
2020-03-23 04:11:31 +03:00
|
|
|
draw_window();
|
2017-09-17 04:32:09 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case evNetwork:
|
2020-03-31 00:29:52 +03:00
|
|
|
if (http.transfer <= 0) break;
|
|
|
|
http.receive();
|
2020-12-07 21:19:13 +03:00
|
|
|
|
|
|
|
if (http_get_type==PAGE) {
|
|
|
|
CheckContentType();
|
|
|
|
prbar.max = http.content_length;
|
|
|
|
if (prbar.value != http.content_received) {
|
|
|
|
prbar.value = http.content_received;
|
|
|
|
DrawProgress();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-31 00:29:52 +03:00
|
|
|
if (http.receive_result != 0) break;
|
|
|
|
if (http.status_code >= 300) && (http.status_code < 400)
|
|
|
|
{
|
|
|
|
// Handle redirects
|
|
|
|
if (redirect_count<=5) {
|
|
|
|
redirect_count++;
|
2020-12-03 05:56:54 +03:00
|
|
|
HandleRedirect();
|
2020-03-31 00:29:52 +03:00
|
|
|
} else {
|
|
|
|
notify("'Too many redirects.' -E");
|
|
|
|
StopLoading();
|
2020-04-14 20:38:31 +03:00
|
|
|
redirect_count = 0;
|
2014-01-27 23:34:00 +04:00
|
|
|
}
|
2020-03-31 00:29:52 +03:00
|
|
|
} else {
|
|
|
|
// Loading the page is complete, free resources
|
|
|
|
redirect_count = 0;
|
2020-12-01 20:37:47 +03:00
|
|
|
http.hfree();
|
2020-06-02 01:18:26 +03:00
|
|
|
if (http_get_type==PAGE) {
|
|
|
|
cache.add(history.current(), http.content_pointer, http.content_received, PAGE);
|
|
|
|
LoadInternalPage(http.content_pointer, http.content_received);
|
|
|
|
}
|
|
|
|
else if (http_get_type==IMG) {
|
2020-12-07 21:19:13 +03:00
|
|
|
cache.add(cur_img_url, http.content_pointer, http.content_received, IMG);
|
|
|
|
GetImg(false);
|
2020-06-02 01:18:26 +03:00
|
|
|
}
|
2017-09-17 04:32:09 +03:00
|
|
|
}
|
2020-05-12 02:02:41 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (ESDWORD[shared_url] != '\0') {
|
|
|
|
EventOpenNewTab(shared_url);
|
|
|
|
ESDWORD[shared_url] = '\0';
|
|
|
|
ActivateWindow(GetProcessSlot(Form.ID));
|
|
|
|
}
|
2017-09-17 04:32:09 +03:00
|
|
|
}
|
2012-11-26 19:26:15 +04:00
|
|
|
}
|
|
|
|
|
2020-12-06 15:03:16 +03:00
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// EVENTS //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
void ProcessButtonClick(dword id__)
|
|
|
|
{
|
|
|
|
switch (id__)
|
|
|
|
{
|
|
|
|
case 1: ExitProcess();
|
|
|
|
case TAB_CLOSE_ID...TAB_CLOSE_ID+TABS_MAX: EventTabClose(id__ - TAB_CLOSE_ID); return;
|
|
|
|
case TAB_ID...TAB_ID+TABS_MAX: EventAllTabsClick(id__ - TAB_ID); return;
|
|
|
|
case ENCODINGS...ENCODINGS+6: EventChangeEncodingAndLoadPage(id__-ENCODINGS); return;
|
|
|
|
case NEW_WINDOW: RunProgram(#program_path, NULL); return;
|
|
|
|
case NEW_TAB: if (!http.transfer) EventOpenNewTab(URL_SERVICE_HOMEPAGE); return;
|
|
|
|
case SCAN_CODE_BS:
|
|
|
|
case BACK_BUTTON: if (history.back()) OpenPage(history.current()); return;
|
|
|
|
case FORWARD_BUTTON: if (history.forward()) OpenPage(history.current()); return;
|
|
|
|
case GOTOURL_BUTTON: EventSubmitOmnibox(); return;
|
|
|
|
case REFRESH_BUTTON: EventRefreshPage(); return;
|
|
|
|
case CHANGE_ENCODING: EventShowEncodingsList(); return;
|
|
|
|
case SANDWICH_BUTTON: EventShowMainMenu(); return;
|
|
|
|
case VIEW_SOURCE: EventViewSource(); return;
|
|
|
|
case EDIT_SOURCE: EventEditSource(); return;
|
|
|
|
case VIEW_HISTORY: OpenPage(URL_SERVICE_HISTORY); return;
|
|
|
|
case DOWNLOAD_MANAGER: EventOpenDownloader(""); return;
|
|
|
|
case UPDATE_BROWSER: EventUpdateBrowser(); return;
|
|
|
|
case CLEAR_CACHE: EventClearCache(); return;
|
|
|
|
case IN_NEW_TAB: EventClickLink(TARGET_NEW_TAB); return;
|
|
|
|
case IN_NEW_WINDOW: EventClickLink(TARGET_NEW_WINDOW); return;
|
|
|
|
case COPY_LINK_URL: EventCopyLinkToClipboard(); return;
|
|
|
|
case DOWNLOAD_LINK_CT: EventOpenDownloader( GetAbsoluteActiveURL() ); return;
|
|
|
|
case OPEN_FILE: EventOpenDialog(); return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ProcessKeyEvent()
|
2020-04-10 19:37:34 +03:00
|
|
|
{
|
2020-12-06 15:03:16 +03:00
|
|
|
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT)
|
|
|
|
{
|
|
|
|
if (key_scancode == SCAN_CODE_TAB) {EventActivatePreviousTab();return;}
|
|
|
|
}
|
|
|
|
|
2020-04-10 19:37:34 +03:00
|
|
|
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) switch(key_scancode)
|
|
|
|
{
|
2020-06-02 01:18:26 +03:00
|
|
|
case SCAN_CODE_KEY_O: EventOpenDialog(); return true;
|
2020-12-06 15:03:16 +03:00
|
|
|
case SCAN_CODE_KEY_H: ProcessButtonClick(VIEW_HISTORY); return true;
|
2020-06-02 01:18:26 +03:00
|
|
|
case SCAN_CODE_KEY_U: EventViewSource(); return true;
|
|
|
|
case SCAN_CODE_KEY_T: EventOpenNewTab(URL_SERVICE_HOMEPAGE); return true;
|
|
|
|
case SCAN_CODE_KEY_N: RunProgram(#program_path, NULL); return true;
|
2020-12-06 15:03:16 +03:00
|
|
|
case SCAN_CODE_KEY_J: ProcessButtonClick(DOWNLOAD_MANAGER); return true;
|
|
|
|
case SCAN_CODE_KEY_R: ProcessButtonClick(REFRESH_BUTTON); return true;
|
2020-06-02 01:18:26 +03:00
|
|
|
case SCAN_CODE_ENTER: EventSeachWeb(); return true;
|
2020-12-06 15:03:16 +03:00
|
|
|
case SCAN_CODE_LEFT: ProcessButtonClick(BACK_BUTTON); return true;
|
|
|
|
case SCAN_CODE_RIGHT: ProcessButtonClick(FORWARD_BUTTON); return true;
|
2020-06-02 01:18:26 +03:00
|
|
|
case SCAN_CODE_KEY_W: EventCloseActiveTab(); return true;
|
|
|
|
case SCAN_CODE_TAB: EventActivateNextTab(); return true;
|
2020-12-07 21:19:13 +03:00
|
|
|
case SCAN_CODE_F5: EventClearCache(); return;
|
2020-06-02 01:18:26 +03:00
|
|
|
default: return false;
|
2020-04-10 19:37:34 +03:00
|
|
|
}
|
2020-12-06 15:03:16 +03:00
|
|
|
|
|
|
|
switch(key_scancode)
|
|
|
|
{
|
|
|
|
case SCAN_CODE_UP: EventScrollUpAndDown(SCAN_CODE_UP); return;
|
|
|
|
case SCAN_CODE_DOWN: EventScrollUpAndDown(SCAN_CODE_DOWN); return;
|
|
|
|
case SCAN_CODE_F6: {omnibox_edit.flags=ed_focus; DrawOmnibox();} return;
|
|
|
|
case SCAN_CODE_F5: EventRefreshPage(); return;
|
|
|
|
case SCAN_CODE_ENTER: if (omnibox_edit.flags & ed_focus) EventSubmitOmnibox(); return;
|
|
|
|
case SCAN_CODE_F12: EventToggleDebugMode(); return;
|
|
|
|
case SCAN_CODE_F11: show_images^=1; EventClearCache(); return;
|
|
|
|
default: if (WB1.list.ProcessKey(key_scancode)) WB1.DrawPage(); return;
|
|
|
|
}
|
2020-04-10 19:37:34 +03:00
|
|
|
}
|
|
|
|
|
2012-11-26 19:26:15 +04:00
|
|
|
void SetElementSizes()
|
|
|
|
{
|
2020-12-06 15:03:16 +03:00
|
|
|
omnibox_edit.width = Form.cwidth - omnibox_edit.left - 52 - 16;
|
2020-04-10 19:19:52 +03:00
|
|
|
WB1.list.SetSizes(0, TOOLBAR_H+TAB_H, Form.width - 10 - scroll_wv.size_x,
|
|
|
|
Form.cheight - TOOLBAR_H - STATUSBAR_H - TAB_H, BASIC_LINE_H);
|
2020-04-04 02:17:28 +03:00
|
|
|
WB1.list.wheel_size = 7 * BASIC_LINE_H;
|
2020-03-22 22:50:16 +03:00
|
|
|
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w + 1;
|
2016-12-12 01:58:11 +03:00
|
|
|
WB1.list.visible = WB1.list.h;
|
2012-11-26 19:26:15 +04:00
|
|
|
}
|
|
|
|
|
2015-12-17 22:19:36 +03:00
|
|
|
|
2020-03-23 04:11:31 +03:00
|
|
|
void draw_window()
|
2012-11-26 19:26:15 +04:00
|
|
|
{
|
2020-05-11 10:32:44 +03:00
|
|
|
bool burger_active = false;
|
|
|
|
if (menu_id == OPEN_FILE) burger_active = true;
|
|
|
|
|
2012-11-26 19:26:15 +04:00
|
|
|
SetElementSizes();
|
2020-03-31 00:29:52 +03:00
|
|
|
|
2020-04-18 02:52:24 +03:00
|
|
|
DrawBar(0,0, Form.cwidth,PADDING, sc.work);
|
|
|
|
DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, sc.work);
|
|
|
|
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(sc.work_dark, sc.work, 180));
|
|
|
|
DrawBar(0,TOOLBAR_H-1, Form.cwidth,1, sc.work_graph);
|
2020-12-06 15:03:16 +03:00
|
|
|
DrawBar(0, PADDING, omnibox_edit.left-2, TSZE+1, sc.work);
|
|
|
|
DrawBar(omnibox_edit.left+omnibox_edit.width+18, PADDING, Form.cwidth-omnibox_edit.left-omnibox_edit.width-18, TSZE+1, sc.work);
|
2020-03-31 00:29:52 +03:00
|
|
|
|
2020-05-11 10:32:44 +03:00
|
|
|
DrawTopPanelButton(BACK_BUTTON, PADDING-1, PADDING, 30, false);
|
|
|
|
DrawTopPanelButton(FORWARD_BUTTON, PADDING+TSZE+PADDING-2, PADDING, 31, false);
|
|
|
|
DrawTopPanelButton(SANDWICH_BUTTON, Form.cwidth-PADDING-TSZE-3, PADDING, -1, burger_active); //burger menu
|
2020-03-31 00:29:52 +03:00
|
|
|
|
2020-04-18 02:52:24 +03:00
|
|
|
DrawBar(0,Form.cheight - STATUSBAR_H, Form.cwidth,1, sc.work_graph);
|
2020-03-31 00:29:52 +03:00
|
|
|
|
|
|
|
DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x,
|
|
|
|
WB1.list.h-1, scroll_wv.bckg_col);
|
|
|
|
|
2020-04-10 19:19:52 +03:00
|
|
|
if (!BrowserWidthChanged()) {
|
|
|
|
WB1.DrawPage();
|
|
|
|
DrawOmnibox();
|
|
|
|
}
|
|
|
|
DrawProgress();
|
2020-05-23 00:39:04 +03:00
|
|
|
DrawStatusBar();
|
2020-04-10 19:19:52 +03:00
|
|
|
DrawTabsBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserWidthChanged()
|
|
|
|
{
|
|
|
|
dword source_mode_holder;
|
|
|
|
if (WB1.list.w!=DrawBuf.bufw) {
|
|
|
|
DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 400*20);
|
2020-03-31 00:29:52 +03:00
|
|
|
if (!strncmp(history.current(),"http",4)) {
|
2020-04-04 02:17:28 +03:00
|
|
|
//nihuya ne izyashnoe reshenie, no pust' poka butet tak
|
2020-04-10 19:19:52 +03:00
|
|
|
source_mode_holder = source_mode;
|
2020-03-31 00:29:52 +03:00
|
|
|
LoadInternalPage(#loading_text, sizeof(loading_text));
|
2020-04-10 19:19:52 +03:00
|
|
|
source_mode = source_mode_holder;
|
2020-03-31 00:29:52 +03:00
|
|
|
}
|
|
|
|
OpenPage(history.current());
|
2020-04-10 19:19:52 +03:00
|
|
|
return true;
|
2018-05-20 16:40:58 +03:00
|
|
|
}
|
2020-04-10 19:19:52 +03:00
|
|
|
return false;
|
2020-04-04 02:17:28 +03:00
|
|
|
}
|
|
|
|
|
2020-04-10 19:19:52 +03:00
|
|
|
|
2020-04-04 02:17:28 +03:00
|
|
|
void EventChangeEncodingAndLoadPage(int _new_encoding)
|
|
|
|
{
|
|
|
|
dword newbuf, newsize;
|
|
|
|
WB1.custom_encoding = _new_encoding;
|
|
|
|
newsize = strlen(WB1.o_bufpointer);
|
|
|
|
newbuf = malloc(newsize);
|
|
|
|
memmov(newbuf, WB1.o_bufpointer, newsize);
|
|
|
|
LoadInternalPage(newbuf, newsize);
|
|
|
|
free(newbuf);
|
2012-11-26 19:26:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-06 15:03:16 +03:00
|
|
|
void EventScrollUpAndDown(int _direction)
|
2013-12-27 04:33:12 +04:00
|
|
|
{
|
2020-12-06 15:03:16 +03:00
|
|
|
int i;
|
|
|
|
for (i=0;i<WB1.list.item_h*2;i++) {
|
|
|
|
if (_direction == SCAN_CODE_UP) WB1.list.KeyUp();
|
|
|
|
if (_direction == SCAN_CODE_DOWN) WB1.list.KeyDown();
|
|
|
|
}
|
|
|
|
WB1.DrawPage();
|
2013-12-27 04:33:12 +04:00
|
|
|
}
|
|
|
|
|
2020-12-03 05:56:54 +03:00
|
|
|
void EventToggleDebugMode()
|
2014-03-13 02:56:28 +04:00
|
|
|
{
|
2020-12-03 05:56:54 +03:00
|
|
|
debug_mode ^= 1;
|
|
|
|
if (debug_mode) notify("'Debug mode ON'-I");
|
|
|
|
else notify("'Debug mode OFF'-I");
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventAllTabsClick(dword _n)
|
|
|
|
{
|
|
|
|
if (http.transfer) return;
|
|
|
|
if (mouse.mkm) {
|
|
|
|
EventTabClose(_n);
|
|
|
|
} else {
|
|
|
|
EventTabClick(_n);
|
2020-12-09 23:26:53 +03:00
|
|
|
}
|
2020-12-03 05:56:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventEditSource()
|
|
|
|
{
|
|
|
|
if (check_is_the_adress_local(history.current())) {
|
2020-12-06 02:22:38 +03:00
|
|
|
RunProgram("/rd/1/quark", history.current());
|
2020-12-03 05:56:54 +03:00
|
|
|
} else {
|
|
|
|
CreateFile(WB1.bufsize, WB1.bufpointer, "/tmp0/1/WebView_tmp.htm");
|
2020-12-06 02:22:38 +03:00
|
|
|
if (!EAX) RunProgram("/rd/1/quark", "/tmp0/1/WebView_tmp.htm");
|
2014-03-15 14:34:28 +04:00
|
|
|
}
|
2020-12-03 05:56:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventClearCache()
|
|
|
|
{
|
|
|
|
cache.clear();
|
|
|
|
notify(#clear_cache_ok);
|
|
|
|
EventRefreshPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventCopyLinkToClipboard()
|
|
|
|
{
|
|
|
|
Clipboard__CopyText(GetAbsoluteActiveURL());
|
|
|
|
notify("'URL copied to clipboard'O");
|
|
|
|
}
|
|
|
|
|
|
|
|
void StopLoading()
|
|
|
|
{
|
|
|
|
if (http.stop()) pause(10);
|
2020-12-06 02:22:38 +03:00
|
|
|
prbar.value = 0;
|
2014-03-14 23:06:48 +04:00
|
|
|
}
|
|
|
|
|
2020-03-27 23:18:44 +03:00
|
|
|
//rewrite into
|
2020-03-29 13:57:14 +03:00
|
|
|
//bool strrpl(dword dst, from, into, dst_len);
|
|
|
|
bool ReplaceSpaceInUrl(dword url, size) {
|
2020-03-27 23:18:44 +03:00
|
|
|
unsigned int i, j;
|
2020-03-29 13:57:14 +03:00
|
|
|
bool was_changed=false;
|
|
|
|
for (i=url+size-3; i>url; i--)
|
2020-02-10 22:53:38 +03:00
|
|
|
{
|
2020-03-27 23:18:44 +03:00
|
|
|
if (ESBYTE[i]!=' ') continue;
|
2020-03-29 13:57:14 +03:00
|
|
|
for (j=url+size-3; j>=i; j--) {
|
|
|
|
ESBYTE[j+3]=ESBYTE[j+2];
|
2020-03-27 23:18:44 +03:00
|
|
|
ESBYTE[j+2]=ESBYTE[j+1];
|
|
|
|
ESBYTE[j+1]=ESBYTE[j];
|
|
|
|
}
|
|
|
|
ESBYTE[i] = '%';
|
|
|
|
ESBYTE[i+1] = '2';
|
|
|
|
ESBYTE[i+2] = '0';
|
2020-03-29 13:57:14 +03:00
|
|
|
was_changed = true;
|
2020-02-10 22:53:38 +03:00
|
|
|
}
|
2020-03-29 13:57:14 +03:00
|
|
|
return was_changed;
|
2020-02-10 22:53:38 +03:00
|
|
|
}
|
|
|
|
|
2020-04-16 18:40:08 +03:00
|
|
|
bool HandleUrlFiles(dword _path, _data)
|
|
|
|
{
|
|
|
|
dword url_from_file;
|
|
|
|
if (!UrlExtIs(_path, "url")) return false;
|
2020-05-18 13:03:45 +03:00
|
|
|
if (! url_from_file = strstri(_data, "URL=")) return false;
|
2020-04-16 18:40:08 +03:00
|
|
|
replace_char(url_from_file, '\n', '\0', strlen(url_from_file));
|
2020-05-18 13:03:45 +03:00
|
|
|
OpenPage(url_from_file);
|
|
|
|
return true;
|
2020-04-16 18:40:08 +03:00
|
|
|
}
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
bool GetLocalFileData(dword _path)
|
2013-12-27 16:30:42 +04:00
|
|
|
{
|
2020-04-16 18:40:08 +03:00
|
|
|
dword data, size;
|
2020-12-13 15:31:53 +03:00
|
|
|
read_file(_path, #data, #size);
|
2020-04-16 18:40:08 +03:00
|
|
|
if (!HandleUrlFiles(_path, data)) {
|
|
|
|
LoadInternalPage(data, size);
|
2014-03-24 02:49:49 +04:00
|
|
|
}
|
2020-04-16 18:40:08 +03:00
|
|
|
free(data);
|
|
|
|
return true;
|
2020-03-27 13:38:54 +03:00
|
|
|
}
|
|
|
|
|
2020-12-07 21:19:13 +03:00
|
|
|
bool GetUrl(dword _http_url)
|
2020-12-06 02:22:38 +03:00
|
|
|
{
|
|
|
|
char new_url_full[URL_SIZE+1];
|
|
|
|
|
|
|
|
if (!strncmp(_http_url,"http:",5)) {
|
|
|
|
http.get(_http_url);
|
2020-12-07 21:19:13 +03:00
|
|
|
return true;
|
2020-12-06 02:22:38 +03:00
|
|
|
} else if (!strncmp(_http_url,"https://",8)) {
|
|
|
|
strcpy(#new_url_full, "http://gate.aspero.pro/?site=");
|
|
|
|
strncat(#new_url_full, _http_url, URL_SIZE);
|
|
|
|
http.get(#new_url_full);
|
2020-12-07 21:19:13 +03:00
|
|
|
return true;
|
2020-12-06 02:22:38 +03:00
|
|
|
}
|
2020-12-07 21:19:13 +03:00
|
|
|
return false;
|
2020-12-06 02:22:38 +03:00
|
|
|
}
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
void OpenPage(dword _open_URL)
|
|
|
|
{
|
|
|
|
char new_url[URL_SIZE+1];
|
2020-04-14 19:03:24 +03:00
|
|
|
int unz_id;
|
2020-03-27 13:38:54 +03:00
|
|
|
|
|
|
|
StopLoading();
|
|
|
|
|
2020-04-10 19:19:52 +03:00
|
|
|
SetOmniboxText(_open_URL);
|
2020-03-26 03:12:32 +03:00
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
strncpy(#new_url, _open_URL, URL_SIZE);
|
|
|
|
|
|
|
|
//Exclude # from the URL to the load page
|
|
|
|
//We will bring it back when we get the buffer
|
2020-05-23 00:39:04 +03:00
|
|
|
if (strrchr(#new_url, '#')) {
|
|
|
|
anchors.take_anchor_from(#new_url);
|
|
|
|
}
|
2020-03-27 13:38:54 +03:00
|
|
|
|
|
|
|
history.add(#new_url);
|
|
|
|
|
2020-05-24 03:50:02 +03:00
|
|
|
/*
|
|
|
|
There could be several possible types of addresses:
|
|
|
|
- cached page (only http/https)
|
|
|
|
- internal page
|
|
|
|
- web page
|
|
|
|
- local file
|
|
|
|
So we need to detect what incoming address is
|
|
|
|
and then halndle it in the propper way.
|
|
|
|
*/
|
|
|
|
|
2020-06-02 01:18:26 +03:00
|
|
|
if (cache.has(#new_url)) {
|
2020-04-05 10:33:55 +03:00
|
|
|
//CACHED PAGE
|
2020-12-07 21:19:13 +03:00
|
|
|
if (cache.current_type==PAGE) LoadInternalPage(cache.current_buf, cache.current_size);
|
|
|
|
else {EventOpenDownloader(#new_url);return;}
|
2020-04-05 10:33:55 +03:00
|
|
|
|
|
|
|
} else if (!strncmp(#new_url,"WebView:",8)) {
|
2020-03-27 13:38:54 +03:00
|
|
|
//INTERNAL PAGE
|
2020-11-29 22:08:52 +03:00
|
|
|
if (streq(#new_url, URL_SERVICE_HOMEPAGE)) LoadInternalPage(#buildin_page_home, sizeof(buildin_page_home));
|
|
|
|
else if (streq(#new_url, URL_SERVICE_HELP)) LoadInternalPage(#buildin_page_help, sizeof(buildin_page_help));
|
2020-05-24 03:50:02 +03:00
|
|
|
else if (streq(#new_url, URL_SERVICE_HISTORY)) ShowHistory();
|
2020-11-29 22:08:52 +03:00
|
|
|
else LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
|
2020-04-16 17:04:21 +03:00
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
} else if (!strncmp(#new_url,"http:",5)) || (!strncmp(#new_url,"https:",6)) {
|
|
|
|
//WEB PAGE
|
2020-03-29 13:57:14 +03:00
|
|
|
if (ReplaceSpaceInUrl(#new_url, URL_SIZE)) {
|
|
|
|
strcpy(#editURL, #new_url);
|
|
|
|
}
|
|
|
|
|
2020-06-02 01:18:26 +03:00
|
|
|
http_get_type = PAGE;
|
2020-12-06 02:22:38 +03:00
|
|
|
GetUrl(#new_url);
|
2020-03-31 00:29:52 +03:00
|
|
|
|
|
|
|
DrawOmnibox();
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
if (!http.transfer) {
|
2014-03-15 14:23:06 +04:00
|
|
|
StopLoading();
|
2020-11-29 22:08:52 +03:00
|
|
|
LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
|
2014-03-15 14:23:06 +04:00
|
|
|
}
|
2020-03-27 13:38:54 +03:00
|
|
|
} else {
|
|
|
|
//LOCAL PAGE
|
2020-04-14 19:03:24 +03:00
|
|
|
if (UrlExtIs(#new_url,".docx")) {
|
|
|
|
DeleteFile("/tmp0/1/temp/word/document.xml");
|
|
|
|
CreateDir("/tmp0/1/temp");
|
|
|
|
unz_id = RunProgram("/sys/unz", sprintf(#param, "-o \"/tmp0/1/temp\" -h \"%s\"", #new_url));
|
|
|
|
while (GetProcessSlot(unz_id)) pause(2);
|
|
|
|
strcpy(#new_url, "/tmp0/1/temp/word/document.xml");
|
|
|
|
}
|
2020-03-27 13:38:54 +03:00
|
|
|
if (!GetLocalFileData(#new_url)) {
|
2020-11-29 22:08:52 +03:00
|
|
|
LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
|
2014-03-15 19:16:08 +04:00
|
|
|
}
|
2014-03-13 02:56:28 +04:00
|
|
|
}
|
2013-12-27 16:30:42 +04:00
|
|
|
}
|
2013-12-27 15:15:17 +04:00
|
|
|
|
2020-11-29 22:08:52 +03:00
|
|
|
dword EventOpenDownloader(dword _url)
|
|
|
|
{
|
|
|
|
//char download_params[URL_SIZE+50];
|
|
|
|
return RunProgram("/sys/network/dl", _url);
|
|
|
|
}
|
2020-05-23 00:39:04 +03:00
|
|
|
|
|
|
|
bool EventClickAnchor()
|
|
|
|
{
|
|
|
|
dword aURL = links.active_url;
|
|
|
|
|
|
|
|
if (anchors.get_pos_by_name(aURL+1)!=-1) {
|
|
|
|
WB1.list.first = anchors.get_pos_by_name(aURL+1);
|
|
|
|
//WB1.list.CheckDoesValuesOkey();
|
|
|
|
strcpy(#editURL, history.current());
|
|
|
|
strcat(#editURL, aURL);
|
|
|
|
DrawOmnibox();
|
|
|
|
WB1.DrawPage();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventClickLink(dword _target)
|
2014-01-22 04:08:47 +04:00
|
|
|
{
|
2020-03-27 23:18:44 +03:00
|
|
|
char new_url[URL_SIZE+1];
|
2020-05-17 14:35:02 +03:00
|
|
|
char new_url_full[URL_SIZE+1];
|
2020-05-23 00:39:04 +03:00
|
|
|
dword aURL = GetAbsoluteActiveURL();
|
|
|
|
if (!aURL) return;
|
2020-03-21 17:33:54 +03:00
|
|
|
|
2020-05-23 00:39:04 +03:00
|
|
|
strcpy(#new_url, aURL);
|
|
|
|
|
|
|
|
if (ESBYTE[aURL]=='#') {
|
|
|
|
if (_target == TARGET_SAME_TAB) {
|
|
|
|
EventClickAnchor();
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
strcpy(#new_url, history.current());
|
|
|
|
strcat(#new_url, aURL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_target == TARGET_NEW_TAB) {
|
|
|
|
EventOpenNewTab(#new_url);
|
2020-03-31 00:29:52 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-23 00:39:04 +03:00
|
|
|
if (_target == TARGET_NEW_WINDOW) {
|
|
|
|
strcpy(#new_url_full, "-new ");
|
|
|
|
strncat(#new_url_full, #new_url, URL_SIZE);
|
|
|
|
RunProgram(#program_path, #new_url_full);
|
2020-03-27 13:38:54 +03:00
|
|
|
return;
|
2020-03-21 17:33:54 +03:00
|
|
|
}
|
2015-03-02 00:36:17 +03:00
|
|
|
|
2020-05-23 00:39:04 +03:00
|
|
|
if (!strncmp(#new_url,"mailto:", 7)) || (!strncmp(#new_url,"tel:", 4)) {
|
|
|
|
notify(#new_url);
|
2020-03-27 13:38:54 +03:00
|
|
|
return;
|
|
|
|
}
|
2015-08-19 15:48:31 +03:00
|
|
|
|
2020-04-10 19:19:52 +03:00
|
|
|
if (http.transfer) {
|
2015-08-27 02:55:33 +03:00
|
|
|
StopLoading();
|
2016-01-01 19:51:53 +03:00
|
|
|
history.back();
|
2015-08-27 02:55:33 +03:00
|
|
|
}
|
2016-11-20 14:10:10 +03:00
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
if (strrchr(#new_url, '#')!=0) {
|
|
|
|
anchors.take_anchor_from(#new_url);
|
|
|
|
OpenPage(#new_url);
|
2015-08-27 02:55:33 +03:00
|
|
|
return;
|
|
|
|
}
|
2016-11-20 14:10:10 +03:00
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
if (!strncmp(#new_url,"WebView:",8)) {
|
|
|
|
OpenPage(#new_url);
|
2020-03-21 17:33:54 +03:00
|
|
|
return;
|
|
|
|
}
|
2016-11-20 14:10:10 +03:00
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
if (strncmp(#new_url,"http://",7)!=0) && (strncmp(#new_url,"https://",8)!=0)
|
2016-11-20 14:10:10 +03:00
|
|
|
{
|
2020-03-27 13:38:54 +03:00
|
|
|
if (UrlExtIs(#new_url,".htm")!=true) && (UrlExtIs(#new_url,".html")!=true)
|
2016-11-20 14:10:10 +03:00
|
|
|
{
|
2020-03-27 13:38:54 +03:00
|
|
|
if (strchr(#new_url, '|')) {
|
|
|
|
ESBYTE[strchr(#new_url, '|')] = NULL;
|
|
|
|
RunProgram(#new_url, strlen(#new_url)+1+#new_url);
|
|
|
|
} else {
|
|
|
|
RunProgram("/sys/@open", #new_url);
|
2018-10-01 19:41:14 +03:00
|
|
|
}
|
2016-11-20 14:10:10 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-03-27 13:38:54 +03:00
|
|
|
OpenPage(#new_url);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventSubmitOmnibox()
|
|
|
|
{
|
|
|
|
char new_url[URL_SIZE+1];
|
|
|
|
if (!editURL[0]) return;
|
|
|
|
if (!strncmp(#editURL,"http:",5)) || (editURL[0]=='/')
|
|
|
|
|| (!strncmp(#editURL,"https:",6)) || (!strncmp(#editURL,"WebView:",8)) {
|
|
|
|
OpenPage(#editURL);
|
|
|
|
} else {
|
|
|
|
strcpy(#new_url, "http://");
|
2020-05-23 00:39:04 +03:00
|
|
|
strncat(#new_url, #editURL, URL_SIZE-1);
|
2020-03-27 13:38:54 +03:00
|
|
|
OpenPage(#new_url);
|
2017-07-05 13:33:54 +03:00
|
|
|
}
|
2015-08-27 02:55:33 +03:00
|
|
|
}
|
|
|
|
|
2020-03-27 13:38:54 +03:00
|
|
|
void LoadInternalPage(dword _bufdata, _in_bufsize){
|
|
|
|
if (!_bufdata) || (!_in_bufsize) {
|
2020-11-29 22:08:52 +03:00
|
|
|
LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
|
2020-03-27 13:38:54 +03:00
|
|
|
} else {
|
|
|
|
WB1.list.first = 0; //scroll page to the top
|
|
|
|
DrawOmnibox();
|
|
|
|
if(!strrchr(#editURL, '#')) {
|
|
|
|
strcat(#editURL, #anchors.current);
|
|
|
|
DrawOmnibox();
|
|
|
|
}
|
2020-12-11 16:33:32 +03:00
|
|
|
render_start_time = GetStartTime();
|
2020-04-04 02:17:28 +03:00
|
|
|
WB1.ParseHtml(_bufdata, _in_bufsize);
|
2020-12-02 17:21:06 +03:00
|
|
|
// REJECTED. Reason: infinite redirect at Google Results.
|
|
|
|
/*
|
|
|
|
if (WB1.redirect) { //<meta http-equiv="refresh" content="0; url=http://site.com">
|
|
|
|
get_absolute_url(#WB1.redirect, history.current());
|
|
|
|
history.back();
|
|
|
|
OpenPage(#WB1.redirect);
|
|
|
|
}
|
|
|
|
*/
|
2020-05-23 00:39:04 +03:00
|
|
|
DrawStatusBar();
|
2020-04-10 19:19:52 +03:00
|
|
|
DrawActiveTab();
|
2020-03-27 23:18:44 +03:00
|
|
|
if (source_mode) {
|
|
|
|
source_mode = false;
|
2020-04-16 09:39:58 +03:00
|
|
|
WB1.custom_encoding = CH_CP866;
|
2020-04-04 02:17:28 +03:00
|
|
|
ShowSource(WB1.bufpointer, _in_bufsize);
|
2020-03-29 13:57:14 +03:00
|
|
|
} else {
|
2020-06-02 01:18:26 +03:00
|
|
|
WB1.DrawPage();
|
2020-03-27 23:18:44 +03:00
|
|
|
}
|
2020-12-07 21:19:13 +03:00
|
|
|
GetImg(true);
|
2020-03-21 17:33:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-16 09:39:58 +03:00
|
|
|
bool UrlExtIs(dword base, ext)
|
2020-03-21 17:33:54 +03:00
|
|
|
{
|
2020-03-27 13:38:54 +03:00
|
|
|
if (!strcmpi(base + strlen(base) - strlen(ext), ext)) return true;
|
2020-03-21 17:33:54 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawProgress()
|
|
|
|
{
|
2020-12-06 02:22:38 +03:00
|
|
|
dword pct;
|
|
|
|
if (!http.transfer) return;
|
|
|
|
if (http_get_type==PAGE) && (prbar.max) pct = prbar.value*30/prbar.max; else pct = 10;
|
2020-12-07 21:19:13 +03:00
|
|
|
if (http_get_type==IMG) pct = prbar.value * 70 / prbar.max + 30;
|
2020-12-06 15:03:16 +03:00
|
|
|
DrawBar(omnibox_edit.left-1, omnibox_edit.top+20, pct*omnibox_edit.width+16/100, 2, 0x72B7EB);
|
2020-03-21 17:33:54 +03:00
|
|
|
}
|
|
|
|
|
2020-04-06 22:54:05 +03:00
|
|
|
void EventShowPageMenu()
|
2016-12-04 19:50:34 +03:00
|
|
|
{
|
2020-06-04 01:21:39 +03:00
|
|
|
open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #rmb_menu);
|
2020-04-13 14:51:56 +03:00
|
|
|
menu_id = VIEW_SOURCE;
|
2016-12-04 19:50:34 +03:00
|
|
|
}
|
|
|
|
|
2020-04-06 22:54:05 +03:00
|
|
|
void EventShowLinkMenu()
|
2020-04-04 02:17:28 +03:00
|
|
|
{
|
2020-06-04 01:21:39 +03:00
|
|
|
open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #link_menu);
|
2020-04-14 19:33:17 +03:00
|
|
|
menu_id = IN_NEW_TAB;
|
2020-04-13 14:51:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventShowMainMenu()
|
|
|
|
{
|
2020-06-04 01:21:39 +03:00
|
|
|
open_lmenu(Form.cwidth - PADDING -4, PADDING + TSZE + 3,
|
|
|
|
MENU_TOP_RIGHT, NULL, #main_menu);
|
2020-04-13 14:51:56 +03:00
|
|
|
menu_id = OPEN_FILE;
|
2020-04-04 02:17:28 +03:00
|
|
|
}
|
|
|
|
|
2020-04-06 22:54:05 +03:00
|
|
|
void EventShowEncodingsList()
|
2020-03-31 00:29:52 +03:00
|
|
|
{
|
2020-06-04 01:21:39 +03:00
|
|
|
open_lmenu(Form.cwidth-4, Form.cheight - STATUSBAR_H + 12,
|
|
|
|
MENU_BOT_RIGHT, WB1.cur_encoding + 1,
|
|
|
|
"UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866");
|
2020-04-13 14:51:56 +03:00
|
|
|
menu_id = ENCODINGS;
|
2020-03-31 00:29:52 +03:00
|
|
|
}
|
|
|
|
|
2020-04-13 14:51:56 +03:00
|
|
|
void ProcessMenuClick()
|
2016-12-14 01:08:14 +03:00
|
|
|
{
|
2020-04-13 14:51:56 +03:00
|
|
|
int click_id;
|
2020-05-11 10:32:44 +03:00
|
|
|
if (menu_id) {
|
|
|
|
if (click_id = get_menu_click()) {
|
|
|
|
click_id += menu_id - 1;
|
2020-12-06 15:03:16 +03:00
|
|
|
ProcessButtonClick(click_id);
|
2020-05-11 10:32:44 +03:00
|
|
|
}
|
|
|
|
if (!menu_process_id) menu_id = NULL;
|
2020-04-13 14:51:56 +03:00
|
|
|
}
|
2016-12-14 01:08:14 +03:00
|
|
|
}
|
|
|
|
|
2020-03-21 21:49:45 +03:00
|
|
|
void EventSeachWeb()
|
|
|
|
{
|
2020-03-27 13:38:54 +03:00
|
|
|
char new_url[URL_SIZE+1];
|
|
|
|
replace_char(#editURL, ' ', '_', URL_SIZE);
|
|
|
|
strcpy(#new_url, "https://www.google.com/search?q=");
|
|
|
|
strncat(#new_url, #editURL, URL_SIZE);
|
|
|
|
OpenPage(#new_url);
|
2020-03-21 21:49:45 +03:00
|
|
|
}
|
|
|
|
|
2020-03-23 04:11:31 +03:00
|
|
|
void EventOpenDialog()
|
|
|
|
{
|
|
|
|
OpenDialog_start stdcall (#o_dialog);
|
|
|
|
if (o_dialog.status) {
|
2020-03-27 13:38:54 +03:00
|
|
|
OpenPage(#openfile_path);
|
2020-03-23 04:11:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-25 03:18:19 +03:00
|
|
|
void EventViewSource()
|
|
|
|
{
|
2020-04-10 19:19:52 +03:00
|
|
|
source_mode = true;
|
|
|
|
EventOpenNewTab(history.current());
|
2020-03-25 03:18:19 +03:00
|
|
|
}
|
|
|
|
|
2020-05-08 00:13:43 +03:00
|
|
|
void EventRefreshPage()
|
|
|
|
{
|
|
|
|
if (http.transfer) {
|
|
|
|
StopLoading();
|
|
|
|
draw_window();
|
|
|
|
} else {
|
|
|
|
OpenPage(history.current());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-05 21:28:02 +03:00
|
|
|
void EventUpdateBrowser()
|
|
|
|
{
|
|
|
|
dword downloader_id, slot_n;
|
|
|
|
dword current_size;
|
|
|
|
dword new_size;
|
|
|
|
|
|
|
|
draw_window();
|
|
|
|
|
2020-11-29 22:08:52 +03:00
|
|
|
downloader_id = EventOpenDownloader(#update_param);
|
2020-04-05 21:28:02 +03:00
|
|
|
do {
|
|
|
|
slot_n = GetProcessSlot(downloader_id);
|
|
|
|
pause(10);
|
|
|
|
} while (slot_n!=0);
|
|
|
|
|
2020-12-13 15:31:53 +03:00
|
|
|
current_size = get_file_size(#program_path);
|
|
|
|
new_size = get_file_size("/tmp0/1/Downloads/WebView.com");
|
2020-04-05 21:28:02 +03:00
|
|
|
|
|
|
|
if (!new_size) || (new_size<5000) {
|
|
|
|
notify(#update_download_error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (current_size == new_size) {
|
|
|
|
notify(#update_is_current);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-12-06 15:03:16 +03:00
|
|
|
if (CopyFileAtOnce(new_size, "/tmp0/1/Downloads/WebView.com", #program_path)) {
|
2020-04-05 21:28:02 +03:00
|
|
|
notify(#update_can_not_copy);
|
|
|
|
} else {
|
|
|
|
notify(#update_ok);
|
|
|
|
RunProgram(#program_path, history.current());
|
|
|
|
ExitProcess();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-23 00:39:04 +03:00
|
|
|
void DrawStatusBar()
|
2016-12-14 01:08:14 +03:00
|
|
|
{
|
2020-05-23 00:39:04 +03:00
|
|
|
dword status_y = Form.cheight - STATUSBAR_H + 4;
|
|
|
|
dword status_w = Form.cwidth - 90;
|
2020-04-18 02:52:24 +03:00
|
|
|
DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
|
2020-05-23 00:39:04 +03:00
|
|
|
if (links.active_url) {
|
|
|
|
ESI = math.min(status_w/6, strlen(links.active_url));
|
|
|
|
WriteText(10, status_y, 0, sc.work_text, links.active_url);
|
2020-03-31 00:29:52 +03:00
|
|
|
}
|
2020-06-02 01:18:26 +03:00
|
|
|
if (http.transfer>0) && (http_get_type==IMG) {
|
|
|
|
//
|
|
|
|
}
|
2020-05-23 00:39:04 +03:00
|
|
|
DefineHiddenButton(status_w+20, status_y-3, 60, 12, CHANGE_ENCODING);
|
|
|
|
WriteTextCenter(status_w+20, status_y, 60, sc.work_text, WB1.cur_encoding*10+#charsets);
|
2020-03-31 00:29:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawOmnibox()
|
|
|
|
{
|
2020-04-14 02:11:07 +03:00
|
|
|
int imgxoff;
|
2020-03-31 00:29:52 +03:00
|
|
|
|
2020-12-06 15:03:16 +03:00
|
|
|
DrawOvalBorder(omnibox_edit.left-2, omnibox_edit.top-3, omnibox_edit.width+18, 24, sc.work_graph,
|
2020-04-18 02:52:24 +03:00
|
|
|
sc.work_graph, sc.work_graph, sc.work_dark);
|
2020-12-06 15:03:16 +03:00
|
|
|
DrawBar(omnibox_edit.left-1, omnibox_edit.top-2, omnibox_edit.width+18, 1, 0xD8DCD8);
|
|
|
|
DrawBar(omnibox_edit.left-1, omnibox_edit.top-1, omnibox_edit.width+18, 1, omnibox_edit.color);
|
|
|
|
DrawBar(omnibox_edit.left-1, omnibox_edit.top, 1, 22, omnibox_edit.color);
|
2020-03-31 00:29:52 +03:00
|
|
|
|
2020-12-06 15:03:16 +03:00
|
|
|
if (omnibox_edit.flags & ed_focus) omnibox_edit.flags = ed_focus; else omnibox_edit.flags = 0;
|
|
|
|
EditBox_UpdateText(#omnibox_edit, omnibox_edit.flags);
|
|
|
|
edit_box_draw stdcall(#omnibox_edit);
|
2020-04-14 02:11:07 +03:00
|
|
|
if (http.transfer) imgxoff = 16*23*3; else imgxoff = 0;
|
2020-12-06 15:03:16 +03:00
|
|
|
_PutImage(omnibox_edit.left+omnibox_edit.width+1, omnibox_edit.top-1, 16, 23, imgxoff + #editbox_icons);
|
|
|
|
DefineHiddenButton(omnibox_edit.left+omnibox_edit.width-1, omnibox_edit.top-2, 17, 23, REFRESH_BUTTON);
|
2020-03-31 00:29:52 +03:00
|
|
|
|
|
|
|
DrawProgress();
|
|
|
|
}
|
|
|
|
|
2020-04-10 19:19:52 +03:00
|
|
|
void SetOmniboxText(dword _text)
|
|
|
|
{
|
2020-12-07 21:19:13 +03:00
|
|
|
edit_box_set_text stdcall (#omnibox_edit, _text);
|
2020-12-09 23:26:53 +03:00
|
|
|
omnibox_edit.pos = omnibox_edit.flags = 0;
|
|
|
|
DrawOmnibox();
|
2020-04-10 19:19:52 +03:00
|
|
|
}
|
|
|
|
|
2020-05-23 00:39:04 +03:00
|
|
|
dword GetAbsoluteActiveURL()
|
|
|
|
{
|
|
|
|
char abs_url[URL_SIZE];
|
|
|
|
if (links.active_url) {
|
|
|
|
strncpy(#abs_url, links.active_url, URL_SIZE);
|
2020-12-01 20:37:47 +03:00
|
|
|
get_absolute_url(#abs_url, history.current());
|
2020-05-23 00:39:04 +03:00
|
|
|
return #abs_url;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2020-03-31 00:29:52 +03:00
|
|
|
|
2020-12-03 05:56:54 +03:00
|
|
|
void CheckContentType()
|
|
|
|
{
|
|
|
|
char content_type[64];
|
2020-12-04 14:58:20 +03:00
|
|
|
if (http.header_field("content-type", #content_type, sizeof(content_type))) // application || image
|
2020-12-03 05:56:54 +03:00
|
|
|
if (content_type[0] == 'a') || (content_type[0] == 'i') {
|
|
|
|
EventOpenDownloader(history.current());
|
|
|
|
StopLoading();
|
|
|
|
history.back();
|
|
|
|
EventRefreshPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void HandleRedirect()
|
|
|
|
{
|
|
|
|
char redirect_url[URL_SIZE];
|
2020-12-04 14:58:20 +03:00
|
|
|
http.header_field("location", #redirect_url, URL_SIZE);
|
2020-12-03 05:56:54 +03:00
|
|
|
get_absolute_url(#redirect_url, history.current());
|
2020-12-06 02:22:38 +03:00
|
|
|
if (http_get_type==PAGE) history.back();
|
2020-12-03 05:56:54 +03:00
|
|
|
http.hfree();
|
|
|
|
if (http_get_type==PAGE) OpenPage(#redirect_url);
|
2020-12-06 02:22:38 +03:00
|
|
|
else if (http_get_type==IMG) GetUrl(#redirect_url);
|
2020-12-03 05:56:54 +03:00
|
|
|
}
|
|
|
|
|
2020-12-07 21:19:13 +03:00
|
|
|
dword GetImg(bool _new)
|
2020-06-02 01:18:26 +03:00
|
|
|
{
|
2020-12-07 21:19:13 +03:00
|
|
|
int i;
|
2020-12-06 02:22:38 +03:00
|
|
|
if (!show_images) return;
|
2020-12-07 21:19:13 +03:00
|
|
|
http_get_type = IMG;
|
|
|
|
|
|
|
|
for (i = 0; i < WB1.img.url.count; i++)
|
|
|
|
{
|
|
|
|
cur_img_url = WB1.img.url.get(i);
|
|
|
|
if (cache.has(cur_img_url)==false) {
|
|
|
|
prbar.max = WB1.img.url.count;
|
|
|
|
prbar.value = i;
|
|
|
|
if (GetUrl(cur_img_url)) {DrawProgress(); return;}
|
|
|
|
}
|
2020-06-02 01:18:26 +03:00
|
|
|
}
|
2020-12-07 21:19:13 +03:00
|
|
|
if (_new) return;
|
2020-06-02 01:18:26 +03:00
|
|
|
DrawOmnibox();
|
2020-12-06 02:22:38 +03:00
|
|
|
WB1.ParseHtml(WB1.o_bufpointer, WB1.bufsize);
|
2020-06-02 01:18:26 +03:00
|
|
|
WB1.DrawPage();
|
2020-12-11 16:33:32 +03:00
|
|
|
debugln(sprintf(#param, "WebView: page rendered in %i sec", GetStartTime()-render_start_time/100));
|
2020-06-02 01:18:26 +03:00
|
|
|
}
|
|
|
|
|
2015-07-30 18:49:09 +03:00
|
|
|
stop:
|