Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8413 → Rev 8412

/programs/cmm/browser/TWB/links.h
91,7 → 91,7
 
active_url = link.get(i);
active = i;
DrawStatusBar(active_url);
DrawStatusBar();
}
if (mouse.lkm) && (mouse.down) {
DrawRectangle(x.get(active), -list_first + y.get(active),
105,7 → 105,7
draw_underline(active, list_first, list_y, link_color_default);
active_url = 0;
active = -1;
DrawStatusBar(NULL);
DrawStatusBar();
}
return false;
}
/programs/cmm/browser/WebView.c
11,7 → 11,7
// //
//===================================================//
 
#define MEMSIZE 1024 * 130
#define MEMSIZE 1024 * 200
#include "..\lib\gui.h"
#include "..\lib\draw_buf.h"
#include "..\lib\list_box.h"
41,7 → 41,7
// DATA //
// //
//===================================================//
char version[]="WebView 3.03";
char version[]="WebView 3.01";
 
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
 
69,6 → 69,7
bool source_mode = false;
 
progress_bar prbar;
char stak[4096];
proc_info Form;
 
#include "tabs.h"
212,7 → 213,6
}
 
if (http.receive_result != 0) break;
if (debug_mode) debugval("HTTP", http.status_code);
if (http.status_code >= 300) && (http.status_code < 400)
{
// Handle redirects
229,8 → 229,7
redirect_count = 0;
http.hfree();
if (http_get_type==PAGE) {
history.add(http.cur_url);
cache.add(http.cur_url, http.content_pointer, http.content_received, 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) {
363,7 → 362,7
DrawOmnibox();
}
DrawProgress();
DrawStatusBar(NULL);
DrawStatusBar();
DrawTabsBar();
}
 
528,6 → 527,8
anchors.take_anchor_from(#new_url);
}
 
history.add(#new_url);
 
/*
There could be several possible types of addresses:
- cached page (only http/https)
540,17 → 541,11
 
if (cache.has(#new_url)) {
//CACHED PAGE
if (cache.current_type==PAGE) {
history.add(#new_url);
LoadInternalPage(cache.current_buf, cache.current_size);
}
else {
EventDownloadAndOpenImage(#new_url);
}
if (cache.current_type==PAGE) LoadInternalPage(cache.current_buf, cache.current_size);
else {EventOpenDownloader(#new_url);return;}
 
} else if (!strncmp(#new_url,"WebView:",8)) {
//INTERNAL PAGE
history.add(#new_url);
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));
else if (streq(#new_url, URL_SERVICE_HISTORY)) ShowHistory();
568,12 → 563,11
DrawOmnibox();
 
if (!http.transfer) {
history.add(#new_url);
StopLoading();
LoadInternalPage(#buildin_page_error, sizeof(buildin_page_error));
}
} else {
//LOCAL PAGE
history.add(#new_url);
if (UrlExtIs(#new_url,".docx")) {
DeleteFile("/tmp0/1/temp/word/document.xml");
CreateDir("/tmp0/1/temp");
646,6 → 640,7
 
if (http.transfer) {
StopLoading();
history.back();
}
 
if (strrchr(#new_url, '#')!=0) {
709,7 → 704,7
OpenPage(#WB1.redirect);
}
*/
DrawStatusBar(NULL);
DrawStatusBar();
DrawActiveTab();
if (source_mode) {
source_mode = false;
826,9 → 821,16
current_size = get_file_size(#program_path);
new_size = get_file_size("/tmp0/1/Downloads/WebView.com");
 
if (!new_size) || (new_size<5000) { notify(#update_download_error); return; }
if (current_size == new_size) { notify(#update_is_current); return; }
if (!new_size) || (new_size<5000) {
notify(#update_download_error);
return;
}
 
if (current_size == new_size) {
notify(#update_is_current);
return;
}
 
if (CopyFileAtOnce(new_size, "/tmp0/1/Downloads/WebView.com", #program_path)) {
notify(#update_can_not_copy);
} else {
838,15 → 840,18
}
}
 
void DrawStatusBar(dword _msg)
void DrawStatusBar()
{
dword status_y = Form.cheight - STATUSBAR_H + 4;
dword status_w = Form.cwidth - 90;
DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
if (_msg) {
ESI = math.min(status_w/6, strlen(_msg));
WriteText(10, status_y, 0, sc.work_text, _msg);
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);
}
if (http.transfer>0) && (http_get_type==IMG) {
//
}
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);
}
893,29 → 898,20
{
char content_type[64];
if (http.header_field("content-type", #content_type, sizeof(content_type))) // application || image
 
if (content_type[0] == 'i') {
EventDownloadAndOpenImage(http.cur_url);
StopLoading();
}if (content_type[0] == 'a') {
if (content_type[0] == 'a') || (content_type[0] == 'i') {
EventOpenDownloader(history.current());
StopLoading();
history.back();
EventRefreshPage();
}
}
 
void EventDownloadAndOpenImage(dword _url)
{
char image_download_url[URL_SIZE];
strcpy(#image_download_url, "-eo ");
strncat(#image_download_url, _url, URL_SIZE);
EventOpenDownloader(#image_download_url);
}
 
void HandleRedirect()
{
char redirect_url[URL_SIZE];
http.header_field("location", #redirect_url, URL_SIZE);
get_absolute_url(#redirect_url, http.cur_url);
get_absolute_url(#redirect_url, history.current());
if (http_get_type==PAGE) history.back();
http.hfree();
if (http_get_type==PAGE) OpenPage(#redirect_url);
else if (http_get_type==IMG) GetUrl(#redirect_url);
933,16 → 929,14
if (cache.has(cur_img_url)==false) {
prbar.max = WB1.img_url.count;
prbar.value = i;
if (GetUrl(cur_img_url)) {DrawStatusBar(cur_img_url); DrawProgress(); return;}
if (GetUrl(cur_img_url)) {DrawProgress(); return;}
}
}
if (_new) return;
DrawOmnibox();
DrawStatusBar(T_RENDERING);
WB1.ParseHtml(WB1.o_bufpointer, WB1.bufsize);
WB1.DrawPage();
debugln(sprintf(#param, T_DONE_IN_SEC, GetStartTime()-render_start_time/100));
DrawStatusBar(NULL);
debugln(sprintf(#param, "WebView: page rendered in %i sec", GetStartTime()-render_start_time/100));
}
 
stop:
/programs/cmm/browser/const.h
22,14 → 22,12
‘ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
char loading_text[] = "‡ £à㧪 ...";
 
char update_param[] = "-e http://builds.kolibrios.org/rus/data/programs/cmm/browser/WebView.com";
char update_param[] = "-exit http://builds.kolibrios.org/rus/data/programs/cmm/browser/WebView.com";
char update_download_error[] = "'WebView\nŽè¨¡ª  ¯à¨ ¯®«ã祭¨¨ ®¡­®¢«¥­¨©!' -tE";
char update_ok[] = "'WebView\nà ã§¥à ¡ë« ãᯥ譮 ®¡­®¢«¥­!' -tO";
char update_is_current[] = "'WebView\n‚ë 㦥 ¨á¯®«ì§ã¥â¥ ¯®á«¥¤­îî ¢¥àá¨î.' -tI";
char update_can_not_copy[] = "'WebView\n¥ ¬®£ã ¯¥à¥¬¥áâ¨âì ­®¢ãî ¢¥àá¨î ¨§ ¯ ¯ª¨ Downloads ­  Ramdisk. ‚®§¬®¦­®, ­¥ ¤®áâ â®ç­® ¬¥áâ .' -tE";
char clear_cache_ok[] = "'WebView\nŠíè ®ç¨é¥­.' -tI";
#define T_RENDERING "¥­¤¥à¨­£ áâà ­¨æë..."
#define T_DONE_IN_SEC "ƒ®â®¢®: %i ᥪ"
#else
char buildin_page_error[] = FROM "res/page_not_found_en.htm""\0";
char buildin_page_home[] = FROM "res/homepage_en.htm""\0";
53,14 → 51,12
Copy link
Download link contents";
char loading_text[] = "Loading...";
char update_param[] = "-e http://builds.kolibrios.org/eng/data/programs/cmm/browser/WebView.com";
char update_param[] = "-exit http://builds.kolibrios.org/eng/data/programs/cmm/browser/WebView.com";
char update_download_error[] = "'WebView\nError receiving an up to date information!' -tE";
char update_ok[] = "'WebView\nThe browser has been updated!' -tO";
char update_is_current[] = "'WebView\nThe browser is up to date.' -tI";
char update_can_not_copy[] = "'WebView\nError copying a new version from Downloads folder!\nProbably too litle space on Ramdisk.' -tE";
char clear_cache_ok[] = "'WebView\nThe cache has been cleared.' -tI";
#define T_RENDERING "Rendering..."
#define T_DONE_IN_SEC "Done in %i sec"
#endif
 
#define URL_SERVICE_HISTORY "WebView:history"
/programs/cmm/lib/obj/http.h
99,7 → 99,6
dword _http::get(dword _url)
{
cur_url = _url;
if (streqrp(cur_url, "http://gate.aspero.pro/?site=")) cur_url += 29;
http_get stdcall (_url, 0, 0, #accept_language);
transfer = EAX;
return EAX;
/programs/cmm/downloader/dl.c
1,4 → 1,4
#define MEMSIZE 1024 * 40
#define MEMSIZE 1024 * 100
//Copyright 2020 by Leency
#include "../lib/gui.h"
#include "../lib/random.h"
8,7 → 8,6
#include "const.h"
 
bool exit_param = false;
bool open_file = false;
 
_http http;
 
32,15 → 31,10
SetCurDir(#save_dir);
 
if (param) {
if (streqrp(#param, "-e ")) {
if (!strncmp(#param, "-exit ", 6)) {
exit_param = true;
param += 3;
param += 6;
}
if (streqrp(#param, "-eo ")) {
exit_param = true;
open_file = true;
param += 4;
}
 
if (!strncmp(#param, "-mem", 5)) {
//shared_url = memopen(#dl_shared, URL_SIZE+1, SHM_OPEN + SHM_WRITE);
58,7 → 52,7
loop() switch(@WaitEvent())
{
case evMouse: edit_box_mouse stdcall (#ed); break;
case evButton: ProcessButtonClick(@GetButtonID()); break;
case evButton: ProcessButtonClick(); break;
case evKey: ProcessKeyPress(); break;
case evReDraw: DrawWindow(); break;
default: MonitorProgress();
65,8 → 59,9
}
}
void ProcessButtonClick(int id)
void ProcessButtonClick()
{
int id = @GetButtonID();
autoclose.click(id);
if (id==BTN_EXIT) { StopDownloading(); ExitProcess(); }
if (id==BTN_START) StartDownloading();
222,7 → 217,6
}
if (!exit_param) notify(#notify_message);
if (open_file) ProcessButtonClick(BTN_RUN);
if (autoclose.checked) ExitProcess();
}