Rev 7758 | Rev 7762 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7739 | leency | 1 | //Copyright 2007-2020 by Veliant & Leency |
6978 | leency | 2 | //Asper, lev, Lrz, Barsuk, Nable, hidnplayr... |
3067 | leency | 3 | |
4085 | leency | 4 | #ifndef AUTOBUILD |
5 | #include "lang.h--" |
||
6 | #endif |
||
7 | |||
3107 | leency | 8 | //libraries |
7755 | leency | 9 | #define MEMSIZE 1024 * 850 |
5499 | leency | 10 | #include "..\lib\gui.h" |
4508 | leency | 11 | #include "..\lib\draw_buf.h" |
12 | #include "..\lib\list_box.h" |
||
13 | #include "..\lib\cursor.h" |
||
5978 | leency | 14 | #include "..\lib\collection.h" |
6795 | leency | 15 | #include "..\lib\random.h" |
7037 | leency | 16 | #include "..\lib\clipboard.h" |
5981 | leency | 17 | |
7437 | leency | 18 | // *.obj libraries |
5499 | leency | 19 | #include "..\lib\obj\box_lib.h" |
7049 | leency | 20 | #include "..\lib\obj\libio.h" |
21 | #include "..\lib\obj\libimg.h" |
||
5499 | leency | 22 | #include "..\lib\obj\http.h" |
5690 | leency | 23 | #include "..\lib\obj\iconv.h" |
7748 | leency | 24 | #include "..\lib\obj\proc_lib.h" |
7757 | leency | 25 | |
5408 | leency | 26 | //useful patterns |
5978 | leency | 27 | #include "..\lib\patterns\history.h" |
6058 | leency | 28 | #include "..\lib\patterns\http_downloader.h" |
7748 | leency | 29 | #include "..\lib\patterns\simple_open_dialog.h" |
7759 | leency | 30 | #include "..\lib\patterns\toolbar_button.h" |
5408 | leency | 31 | |
7757 | leency | 32 | #include "show_src.h" |
33 | #include "download_manager.h" |
||
34 | _history history; |
||
35 | #include "history.h" |
||
36 | bool debug_mode = false; |
||
7759 | leency | 37 | #include "..\TWB\TWB.c" //HTML Parser, a core component |
7757 | leency | 38 | |
7759 | leency | 39 | TWebBrowser WB1; |
7758 | leency | 40 | |
7759 | leency | 41 | char version[]="WebView 2.1"; |
42 | |||
4026 | leency | 43 | #ifdef LANG_RUS |
6698 | leency | 44 | char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0"; |
7743 | leency | 45 | char homepage[] = FROM "html\\homepage_ru.htm""\0"; |
46 | char help[] = FROM "html\\help_ru.htm""\0"; |
||
6045 | leency | 47 | char accept_language[]= "Accept-Language: ru\n"; |
48 | char rmb_menu[] = |
||
49 | "Посмотреть исходник |
||
7758 | leency | 50 | Редактировать исходник"; |
51 | char main_menu[] = |
||
52 | "Открыть файл |
||
53 | Новое окно |
||
6045 | leency | 54 | История |
55 | Менеджер загрузок"; |
||
7037 | leency | 56 | char link_menu[] = |
7208 | leency | 57 | "Копировать ссылку |
58 | Скачать содержимое ссылки"; |
||
7758 | leency | 59 | char loading_text[] = "Загрузка..."; |
4026 | leency | 60 | #else |
6698 | leency | 61 | char page_not_found[] = FROM "html\\page_not_found_en.htm""\0"; |
7743 | leency | 62 | char homepage[] = FROM "html\\homepage_en.htm""\0"; |
63 | char help[] = FROM "html\\help_en.htm""\0"; |
||
6045 | leency | 64 | char accept_language[]= "Accept-Language: en\n"; |
65 | char rmb_menu[] = |
||
66 | "View source |
||
7758 | leency | 67 | Edit source"; |
68 | char main_menu[] = |
||
69 | "Open local file |
||
70 | New window |
||
6045 | leency | 71 | History |
72 | Download Manager"; |
||
7037 | leency | 73 | char link_menu[] = |
7208 | leency | 74 | "Copy link |
75 | Download link contents"; |
||
7758 | leency | 76 | char loading_text[] = "Loading..."; |
4026 | leency | 77 | #endif |
78 | |||
7756 | leency | 79 | #define URL_SIZE 4000 |
7752 | leency | 80 | |
7750 | leency | 81 | #define URL_SERVICE_HISTORY "WebView:history" |
82 | #define URL_SERVICE_HOMEPAGE "WebView:home" |
||
83 | #define URL_SERVICE_HELP "WebView:help" |
||
4026 | leency | 84 | |
7758 | leency | 85 | #define PADDING 9 |
86 | #define SKIN_Y 24 |
||
87 | #define TSZE 25 |
||
88 | dword TOOLBAR_H = PADDING+TSZE+PADDING+2; |
||
5519 | leency | 89 | dword STATUSBAR_H = 15; |
4677 | leency | 90 | |
7750 | leency | 91 | int action_buf; |
7425 | leency | 92 | |
7759 | leency | 93 | _http http = 0; |
7758 | leency | 94 | |
7750 | leency | 95 | bool source_mode = false; |
7282 | leency | 96 | |
5718 | leency | 97 | progress_bar wv_progress_bar; |
7750 | leency | 98 | char stak[4096]; |
99 | proc_info Form; |
||
7748 | leency | 100 | |
5718 | leency | 101 | enum { |
7759 | leency | 102 | ENCODINGS=900, |
5718 | leency | 103 | BACK_BUTTON=1000, |
104 | FORWARD_BUTTON, |
||
105 | REFRESH_BUTTON, |
||
106 | GOTOURL_BUTTON, |
||
7759 | leency | 107 | CHANGE_ENCODING, |
6795 | leency | 108 | SANDWICH_BUTTON, |
7750 | leency | 109 | VIEW_SOURCE, |
5718 | leency | 110 | EDIT_SOURCE, |
7758 | leency | 111 | OPEN_FILE, |
112 | NEW_WINDOW, |
||
5718 | leency | 113 | VIEW_HISTORY, |
6795 | leency | 114 | DOWNLOAD_MANAGER, |
7750 | leency | 115 | COPY_LINK_URL, |
7208 | leency | 116 | DOWNLOAD_LINK_CONTENTS, |
5718 | leency | 117 | }; |
118 | |||
7748 | leency | 119 | char default_dir[] = "/rd/1"; |
120 | od_filter filter2 = { 16, "TXT\0HTM\0HTML\0\0" }; |
||
121 | |||
7755 | leency | 122 | char editURL[URL_SIZE+1]; |
7758 | leency | 123 | edit_box address_box = {, PADDING+TSZE*2+PADDING+6, PADDING+3, 0xffffff, |
124 | 0x94AECE, 0xffffff, 0xffffff,0x10000000,URL_SIZE-2,#editURL,0,,19,19}; |
||
4534 | leency | 125 | |
126 | |||
7748 | leency | 127 | void LoadLibraries() |
128 | { |
||
129 | load_dll(boxlib, #box_lib_init,0); |
||
130 | load_dll(libio, #libio_init,1); |
||
131 | load_dll(libimg, #libimg_init,1); |
||
132 | load_dll(libHTTP, #http_lib_init,1); |
||
133 | load_dll(iconv_lib, #iconv_open,0); |
||
134 | load_dll(Proc_lib, #OpenDialog_init,0); |
||
135 | OpenDialog_init stdcall (#o_dialog); |
||
136 | } |
||
137 | |||
138 | void HandleParam() |
||
139 | { |
||
140 | if (param) { |
||
7750 | leency | 141 | if (!strncmp(#param, "-d ", 3)) { |
7748 | leency | 142 | strcpy(#downloader_edit, #param+3); |
143 | CreateThread(#Downloader,#downloader_stak+4092); |
||
144 | ExitProcess(); |
||
7750 | leency | 145 | } else if (!strncmp(#param, "-s ", 3)) { |
146 | source_mode = true; |
||
7755 | leency | 147 | history.add(#param + 3); |
7748 | leency | 148 | } else { |
7755 | leency | 149 | history.add(#param); |
7748 | leency | 150 | } |
151 | } else { |
||
7755 | leency | 152 | history.add(URL_SERVICE_HOMEPAGE); |
7748 | leency | 153 | } |
154 | } |
||
155 | |||
3067 | leency | 156 | void main() |
157 | { |
||
7758 | leency | 158 | int i, btn, redirect_count=0; |
7748 | leency | 159 | LoadLibraries(); |
160 | CreateDir("/tmp0/1/downloads"); |
||
7428 | leency | 161 | Libimg_LoadImage(#skin, "/sys/toolbar.png"); |
7748 | leency | 162 | HandleParam(); |
7437 | leency | 163 | skin.h = 26; |
6045 | leency | 164 | WB1.list.SetFont(8, 14, 10011000b); |
5779 | leency | 165 | WB1.list.no_selection = true; |
7759 | leency | 166 | WB1.custom_encoding = -1; |
6978 | leency | 167 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); |
168 | loop() switch(WaitEvent()) |
||
169 | { |
||
170 | case evMouse: |
||
171 | edit_box_mouse stdcall (#address_box); |
||
172 | mouse.get(); |
||
7757 | leency | 173 | if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y, WB1.list.y, WB1.list.first)) |
7755 | leency | 174 | && (mouse.pkm) && (mouse.up) { |
7282 | leency | 175 | if (WB1.list.MouseOver(mouse.x, mouse.y)) EventShowPageMenu(mouse.x, mouse.y); |
176 | break; |
||
6978 | leency | 177 | } |
7282 | leency | 178 | if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage(); |
6978 | leency | 179 | scrollbar_v_mouse (#scroll_wv); |
180 | if (WB1.list.first != scroll_wv.position) |
||
181 | { |
||
182 | WB1.list.first = scroll_wv.position; |
||
183 | WB1.DrawPage(); |
||
3067 | leency | 184 | break; |
6978 | leency |