WebView 2.25: add check for updates function

git-svn-id: svn://kolibrios.org@7765 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-04-05 18:28:02 +00:00
parent 6aa36595f5
commit 7bac0abad3
7 changed files with 136 additions and 52 deletions

View File

@ -30,6 +30,7 @@
#include "..\lib\patterns\toolbar_button.h"
#include "show_src.h"
bool download_and_exit = false;
#include "download_manager.h"
_history history;
#include "history.h"
@ -72,6 +73,7 @@ enum {
NEW_WINDOW,
VIEW_HISTORY,
DOWNLOAD_MANAGER,
UPDATE_BROWSER,
COPY_LINK_URL,
DOWNLOAD_LINK_CONTENTS,
};
@ -98,13 +100,19 @@ void LoadLibraries()
void HandleParam()
{
if (param) {
if (!strncmp(#param, "-d ", 3)) {
strcpy(#downloader_edit, #param+3);
CreateThread(#Downloader,#downloader_stak+4092);
if (!strncmp(#param, "-download_and_exit ", 19)) {
download_and_exit = true;
strcpy(#downloader_edit, #param+19);
Downloader();
ExitProcess();
} else if (!strncmp(#param, "-s ", 3)) {
} else if (!strncmp(#param, "-download ", 10)) {
strcpy(#downloader_edit, #param+10);
//CreateThread(#Downloader,#downloader_stak+4092);
Downloader();
ExitProcess();
} else if (!strncmp(#param, "-source ", 8)) {
source_mode = true;
history.add(#param + 3);
history.add(#param + 8);
} else {
history.add(#param);
}
@ -359,6 +367,9 @@ void ProcessEvent(dword id__)
CreateThread(#Downloader,#downloader_stak+4092);
}
return;
case UPDATE_BROWSER:
EventUpdateBrowser();
return;
case COPY_LINK_URL:
Clipboard__CopyText(PageLinks.GetURL(PageLinks.active));
notify("'URL copied to clipboard'O");
@ -673,11 +684,58 @@ void EventOpenDialog()
void EventViewSource()
{
char source_view_param[URL_SIZE+1];
strcpy(#source_view_param, "-s ");
strcpy(#source_view_param, "-source ");
strncat(#source_view_param, history.current(), URL_SIZE);
RunProgram(#program_path, #source_view_param);
}
dword GetFileSize(dword _path)
{
BDVK bdvk;
if (GetFileInfo(_path, #bdvk)!=0) {
return 0;
} else {
return bdvk.sizelo;
}
}
void EventUpdateBrowser()
{
dword downloader_id, slot_n;
dword current_size;
dword new_size;
int error;
draw_window();
downloader_id = RunProgram(#program_path, #update_param);
do {
slot_n = GetProcessSlot(downloader_id);
pause(10);
} while (slot_n!=0);
current_size = GetFileSize(#program_path);
new_size = GetFileSize("/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 (error = CopyFileAtOnce(new_size, "/tmp0/1/Downloads/WebView.com", #program_path)) {
notify(#update_can_not_copy);
} else {
notify(#update_ok);
RunProgram(#program_path, history.current());
ExitProcess();
}
}
void DrawStatusBar(dword _status_text)
{
status_text.font_color = system.color.work_text;

View File

@ -89,6 +89,7 @@ void Downloader()
if (downloader.state == STATE_COMPLETED)
{
SaveDownloadedFile();
if (download_and_exit) ExitProcess();
StopDownloading();
DL_Draw_Window();
break;
@ -145,6 +146,7 @@ void StartDownloading()
return;
}
if (!downloader.Start(#downloader_edit)) {
if (download_and_exit) ExitProcess();
notify("'Error while starting download process.\nPlease, check entered path and internet connection.' -E");
StopDownloading();
return;
@ -217,10 +219,11 @@ void SaveDownloadedFile()
for (i=0; i<strlen(#filepath); i++) if(filepath[i]==':')||(filepath[i]=='?')filepath[i]='-';
if (CreateFile(downloader.httpd.content_received, downloader.bufpointer, #filepath)==0)
if (CreateFile(downloader.httpd.content_received, downloader.bufpointer, #filepath)==0) {
sprintf(#notify_message, "%s%s%s",FILE_SAVED_AS,#filepath,"' -Dt");
else
} else {
sprintf(#notify_message, "%s%s%s","'Download manager\nError! Can\96t save file as ",#filepath,"' -Et");
notify(#notify_message);
}
if (!download_and_exit) notify(#notify_message);
}

View File

@ -4,6 +4,9 @@
<title>‘¯à ¢ª  WebView</title>
</head>
<body><pre><h1>‘¯à ¢ª  WebView</h1>
<b>┼╚═╒╗Х╗ ║КАБЮ╝ё╝ ╒К╖╝╒═</b>
<font bg="#C7CEE4">[CTRL + N ¨«¨ CTRL + T]</font> <20>®¢®¥ ®ª­®
<font bg="#C7CEE4">[CTRL + R ¨«¨ F5]</font> <20>¥à¥§ £à㧨âì áâà ­¨æã
<font bg="#C7CEE4">[CTRL + O]</font> ‚맢 âì ¤¨ «®£ ¢ë¡®à  ä ©« 

View File

@ -8,8 +8,11 @@
2. <a href="http://kolibri-n.org" id="hodor">KolibriN homepage</a>
3. <a href="http://store.kolibri-n.org">Kolibri Stuff</a>
<font color="#555555">Hint: to run a web search, type a text in the adress box
and press Ctrl+Enter. You can also use other <a href="WebView://help"><font color="#555555">Hotkeys</font></a>.</font>
<font bg=#F8F15B>By the way,</font>
<font color="#555555">&bull; You can check for browser updates from the main menu.
&bull; To run a web search, type a text in the adress box and press Ctrl+Enter.
&bull; You can also use other <a href="WebView:help"><font color="#555555">Hotkeys</font></a>.
</font>
</pre>

View File

@ -8,9 +8,11 @@
2. <a href="http://kolibri-n.org" id="hodor">KolibriN10</a>
3. <a href="http://store.kolibri-n.org">Kolibri Store</a>
<font color="#555555">„«ï ¯®¨áª  ¢ Google ­ ¡¥à¨â¥ â¥áâ ¢  ¤à¥á­®© áâப¥
¨ ­ ¦¬¨â¥ Ctrl+Enter. …áâì â ª¦¥ ¤à㣨¥ <a href="WebView:help"><font color="#555555">ƒ®àï稥 ª« ¢¨è¨</font></a>.</font>
<font bg=#F8F15B>Šáâ â¨,</font>
<font color="#555555">&bull; ˆ§ £« ¢­®£® ¬¥­î ¬®¦­® ¯à®¢¥à¨âì ­ «¨ç¨¥ ®¡­®¢«¥­¨©
&bull; „«ï ¯®¨áª  ¢ Google ­ ¡¥à¨â¥ â¥áâ ¢  ¤à¥á­®© áâப¥ ¨ ­ ¦¬¨â¥ Ctrl+Enter
&bull; …áâì â ª¦¥ ¤à㣨¥ <a href="WebView:help"><font color="#555555">ƒ®àï稥 ª« ¢¨è¨</font></a>.
</font>
</pre>
</body>

View File

@ -1,4 +1,4 @@
char version[]="WebView 2.2";
char version[]="WebView 2.25";
#ifdef LANG_RUS
char page_not_found[] = FROM "html\\page_not_found_ru.htm""\0";
@ -12,11 +12,18 @@ char main_menu[] =
"Žâªàëâì ä ©«
<EFBFBD>®¢®¥ ®ª­®
ˆáâ®à¨ï
Œ¥­¥¤¦¥à § £à㧮ª";
Œ¥­¥¤¦¥à § £à㧮ª
Ž¡­®¢¨âì ¡à ã§¥à";
char link_menu[] =
"Š®¯¨à®¢ âì áá뫪ã
ª ç âì ᮤ¥à¦¨¬®¥ áá뫪¨";
char loading_text[] = "‡ £à㧪 ...";
char update_param[] = "-download_and_exit http://builds.kolibrios.org/rus/data/programs/cmm/browser/WebView.com";
char update_download_error[] = "'WebView\nŽè¨¡ª  ¯à¨ ¯®«ã祭¨¨ ®¡­®¢«¥­¨©!' -tE";
char update_ok[] = "'WebView\n<EFBFBD>à ã§¥à ¡ë« ãᯥ譮 ®¡­®¢«¥­!' -tO";
char update_is_current[] = "'WebView\n‚ë 㦥 ¨á¯®«ì§ã¥â¥ ¯®á«¥¤­îî ¢¥àá¨î.' -I";
char update_can_not_copy[] = "'WebView\n<EFBFBD>¥ ¬®£ã ¯¥à¥¬¥áâ¨âì ­®¢ãî ¢¥àá¨î ¨§ ¯ ¯ª¨ Downloads ­  Ramdisk. ‚®§¬®¦­®, ­¥ ¤®áâ â®ç­® ¬¥áâ .' -E";
#else
char page_not_found[] = FROM "html\\page_not_found_en.htm""\0";
char homepage[] = FROM "html\\homepage_en.htm""\0";
@ -29,11 +36,17 @@ char main_menu[] =
"Open local file
New window
History
Download Manager";
Download Manager
Update browser";
char link_menu[] =
"Copy link
Download link contents";
char loading_text[] = "Loading...";
char update_param[] = "-download_and_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.' -I";
char update_can_not_copy[] = "'WebView\nError copying a new version from Downloads folder!\nProbably too litle space on Ramdisk.' -E";
#endif
#define URL_SERVICE_HISTORY "WebView:history"

View File

@ -339,6 +339,40 @@ void DrawPixieTitle(dword _t)
theme.color_top_panel_folder_name, list.font_type, #title);
}
void DrawAboutWindow()
{
proc_info pop_up;
loop() switch(WaitEvent())
{
case evButton:
ExitProcess();
break;
case evKey:
GetKeys();
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
break;
case evReDraw:
DefineDragableWindow(150, 200, 400, 400);
GetProcessInfo(#pop_up, SelfInfo);
DrawBar(0, 0, pop_up.width, pop_up.height, theme.color_top_panel_bg);
DrawRectangle(0, 0, pop_up.width, pop_up.height, theme.color_list_border);
DefineHiddenButton(pop_up.width - 27, 1, 26, 15, BUTTON_WINDOW_CLOSE);
//img_draw stdcall(skin.image, pop_up.width-28, 0, 28, 18, skin.w - 29, 0);
DrawCaptButton(pop_up.width-10-80, pop_up.height - 34, 80, 24, 2,
0x171717, 0xF5EFB3, "Cool");
WriteText(131,16, 0x81, 0x8E7C61, "Pixie Player");
WriteText(130,15, 0x81, 0xF5EFB3, "Pixie Player");
WriteTextLines(10, 40, 0x90, theme.color_top_panel_song_name, ABOUT_MESSAGE, 19);
DrawIcon32(45, 15, theme.color_top_panel_bg, 65);
DrawIcon32(pop_up.width-32-45, 15, theme.color_top_panel_bg, 65);
}
}
//===================================================//
// //
// EVENTS //
@ -408,7 +442,9 @@ void EventStartPlaying()
current_filename[strrchr(#current_filename, '.')-1] = '\0';
DrawPlayList();
DrawTopPanel();
//start_playing_time =
player_run_id = RunProgram("/sys/media/ac97snd", #item_path);
//player_run_id = RunProgram("/kolibrios/media/minimp3", #item_path);
sprintf(#notify_message,"'Now playing:\n%s' -St",#current_filename);
if (!repeat) && (window_mode==WINDOW_MODE_SMALL)
{
@ -538,41 +574,7 @@ void EventPermanentlyDeleteFile()
void EventShowAbout()
{
CreateThread(#ShowAboutThread,#menu_stak+4092);
}
void ShowAboutThread()
{
proc_info pop_up;
loop() switch(WaitEvent())
{
case evButton:
ExitProcess();
break;
case evKey:
GetKeys();
if (key_scancode == SCAN_CODE_ESC) ExitProcess();
break;
case evReDraw:
DefineDragableWindow(150, 200, 400, 400);
GetProcessInfo(#pop_up, SelfInfo);
DrawBar(0, 0, pop_up.width, pop_up.height, theme.color_top_panel_bg);
DrawRectangle(0, 0, pop_up.width, pop_up.height, theme.color_list_border);
DefineHiddenButton(pop_up.width - 27, 1, 26, 15, BUTTON_WINDOW_CLOSE);
//img_draw stdcall(skin.image, pop_up.width-28, 0, 28, 18, skin.w - 29, 0);
DrawCaptButton(pop_up.width-10-80, pop_up.height - 34, 80, 24, 2,
0x171717, 0xF5EFB3, "Cool");
WriteText(131,16, 0x81, 0x8E7C61, "Pixie Player");
WriteText(130,15, 0x81, 0xF5EFB3, "Pixie Player");
WriteTextLines(10, 40, 0x90, theme.color_top_panel_song_name, ABOUT_MESSAGE, 19);
DrawIcon32(45, 15, theme.color_top_panel_bg, 65);
DrawIcon32(pop_up.width-32-45, 15, theme.color_top_panel_bg, 65);
}
CreateThread(#DrawAboutWindow,#menu_stak+4092);
}
/*