Apps: Fix webview and downloader issue #22
- Fix #22 in both webview and downloader; - Get rid of app mode in webview; - Fix update link for webview.
This commit is contained in:
@@ -10,11 +10,9 @@ void TWebBrowser::RenderLine(dword _line)
|
|||||||
if (style.title)
|
if (style.title)
|
||||||
{
|
{
|
||||||
strncpy(#header, _line, sizeof(TWebBrowser.header)-1);
|
strncpy(#header, _line, sizeof(TWebBrowser.header)-1);
|
||||||
if (!application_mode) {
|
|
||||||
strncat(#header, " - ", sizeof(TWebBrowser.header)-1);
|
strncat(#header, " - ", sizeof(TWebBrowser.header)-1);
|
||||||
strncat(#header, #version, sizeof(TWebBrowser.header)-1);
|
strncat(#header, #version, sizeof(TWebBrowser.header)-1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (t_html) && (!t_body) {
|
else if (t_html) && (!t_body) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
@@ -56,10 +56,6 @@ void TWebBrowser::SetStyle()
|
|||||||
if (tag.is("tr")) { tag_table(); return; }
|
if (tag.is("tr")) { tag_table(); return; }
|
||||||
if (tag.is("th")) { tag_table(); return; }
|
if (tag.is("th")) { tag_table(); return; }
|
||||||
if (tag.is("td")) { tag_table(); return; }
|
if (tag.is("td")) { tag_table(); return; }
|
||||||
|
|
||||||
if (application_mode) {
|
|
||||||
if (tag.is("exit")) { ExitProcess(); return; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TWebBrowser::tag_p()
|
void TWebBrowser::tag_p()
|
||||||
@@ -148,22 +144,6 @@ void TWebBrowser::tag_meta_xml()
|
|||||||
if (streq(tag.get_value_of("http-equiv"), "refresh")) && (tag.get_value_of("content")) {
|
if (streq(tag.get_value_of("http-equiv"), "refresh")) && (tag.get_value_of("content")) {
|
||||||
if (tag.value = strstri(tag.value, "url")) strcpy(#redirect, tag.value);
|
if (tag.value = strstri(tag.value, "url")) strcpy(#redirect, tag.value);
|
||||||
}
|
}
|
||||||
if (streq(tag.get_value_of("name"), "application")) {
|
|
||||||
if (application_mode) {
|
|
||||||
if (tag.get_number_of("left")) {
|
|
||||||
MoveSize(tag.number,-1,-1,-1);
|
|
||||||
}
|
|
||||||
if (tag.get_number_of("top")) {
|
|
||||||
MoveSize(-1,tag.number,-1,-1);
|
|
||||||
}
|
|
||||||
if (tag.get_number_of("width")) {
|
|
||||||
MoveSize(-1,-1,tag.number,-1);
|
|
||||||
}
|
|
||||||
if (tag.get_number_of("height")) {
|
|
||||||
MoveSize(-1,-1,-1,tag.number);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
signed int get_encoding_type_by_name(dword name)
|
signed int get_encoding_type_by_name(dword name)
|
||||||
|
@@ -45,7 +45,6 @@
|
|||||||
bool debug_mode = false;
|
bool debug_mode = false;
|
||||||
bool show_images = true;
|
bool show_images = true;
|
||||||
bool source_mode = false;
|
bool source_mode = false;
|
||||||
bool application_mode = false;
|
|
||||||
|
|
||||||
_history history;
|
_history history;
|
||||||
|
|
||||||
@@ -110,9 +109,6 @@ void HandleParam()
|
|||||||
history.add(#param + 8);
|
history.add(#param + 8);
|
||||||
} else if (!strncmp(#param, "-new ", 5)) {
|
} else if (!strncmp(#param, "-new ", 5)) {
|
||||||
history.add(#param + 5);
|
history.add(#param + 5);
|
||||||
} else if (!strncmp(#param, "-app ", 5)) {
|
|
||||||
history.add(#param + 5);
|
|
||||||
application_mode = true;
|
|
||||||
} else {
|
} else {
|
||||||
if (GetProcessesCount("WEBVIEW") == 1) {
|
if (GetProcessesCount("WEBVIEW") == 1) {
|
||||||
history.add(#param);
|
history.add(#param);
|
||||||
@@ -136,14 +132,6 @@ void main()
|
|||||||
LoadLibraries();
|
LoadLibraries();
|
||||||
HandleParam();
|
HandleParam();
|
||||||
|
|
||||||
if (application_mode) {
|
|
||||||
TOOLBAR_H = 0;
|
|
||||||
PADDING = 0;
|
|
||||||
TSZE = 0;
|
|
||||||
STATUSBAR_H = 0;
|
|
||||||
TAB_H = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
omnibox_edit.left = PADDING+TSZE*2+PADDING+6;
|
omnibox_edit.left = PADDING+TSZE*2+PADDING+6;
|
||||||
omnibox_edit.top = PADDING+3;
|
omnibox_edit.top = PADDING+3;
|
||||||
|
|
||||||
@@ -221,15 +209,6 @@ void main()
|
|||||||
if (http.transfer <= 0) break;
|
if (http.transfer <= 0) break;
|
||||||
http.receive();
|
http.receive();
|
||||||
|
|
||||||
if (http_get_type==PAGE) {
|
|
||||||
CheckContentType();
|
|
||||||
prbar.max = http.content_length;
|
|
||||||
if (prbar.value != http.content_received) {
|
|
||||||
prbar.value = http.content_received;
|
|
||||||
DrawProgress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (http.receive_result != 0) break;
|
if (http.receive_result != 0) break;
|
||||||
if (debug_mode) {
|
if (debug_mode) {
|
||||||
EAX = http.transfer;
|
EAX = http.transfer;
|
||||||
@@ -248,6 +227,15 @@ void main()
|
|||||||
notify("'Too many redirects.' -E");
|
notify("'Too many redirects.' -E");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (http_get_type==PAGE) {
|
||||||
|
CheckContentType();
|
||||||
|
prbar.max = http.content_length;
|
||||||
|
if (prbar.value != http.content_received) {
|
||||||
|
prbar.value = http.content_received;
|
||||||
|
DrawProgress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Loading the page is complete, free resources
|
// Loading the page is complete, free resources
|
||||||
redirect_count = 0;
|
redirect_count = 0;
|
||||||
if (http_get_type==PAGE) {
|
if (http_get_type==PAGE) {
|
||||||
@@ -382,7 +370,6 @@ void draw_window()
|
|||||||
|
|
||||||
SetElementSizes();
|
SetElementSizes();
|
||||||
|
|
||||||
if (!application_mode) {
|
|
||||||
DrawBar(0,0, Form.cwidth,PADDING, sc.work);
|
DrawBar(0,0, Form.cwidth,PADDING, sc.work);
|
||||||
DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, sc.work);
|
DrawBar(0,PADDING+TSZE+1, Form.cwidth,PADDING-1, sc.work);
|
||||||
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(sc.dark, sc.work, 180));
|
DrawBar(0,TOOLBAR_H-2, Form.cwidth,1, MixColors(sc.dark, sc.work, 180));
|
||||||
@@ -398,7 +385,6 @@ void draw_window()
|
|||||||
|
|
||||||
DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x,
|
DrawRectangle(WB1.list.x + WB1.list.w, WB1.list.y, scroll_wv.size_x,
|
||||||
WB1.list.h-1, scroll_wv.bckg_col);
|
WB1.list.h-1, scroll_wv.bckg_col);
|
||||||
}
|
|
||||||
|
|
||||||
if (!canvas.bufw) {
|
if (!canvas.bufw) {
|
||||||
EventOpenFirstPage();
|
EventOpenFirstPage();
|
||||||
@@ -406,12 +392,9 @@ void draw_window()
|
|||||||
WB1.DrawPage();
|
WB1.DrawPage();
|
||||||
DrawOmnibox();
|
DrawOmnibox();
|
||||||
}
|
}
|
||||||
if (!application_mode) {
|
|
||||||
DrawProgress();
|
DrawProgress();
|
||||||
DrawStatusBar(NULL);
|
DrawStatusBar(NULL);
|
||||||
DrawTabsBar();
|
DrawTabsBar();
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventOpenFirstPage()
|
void EventOpenFirstPage()
|
||||||
@@ -770,7 +753,6 @@ bool UrlExtIs(dword base, ext)
|
|||||||
void DrawProgress()
|
void DrawProgress()
|
||||||
{
|
{
|
||||||
dword pct;
|
dword pct;
|
||||||
if (application_mode) return;
|
|
||||||
if (!http.transfer) return;
|
if (!http.transfer) return;
|
||||||
if (http_get_type==PAGE) && (prbar.max) pct = prbar.value*30/prbar.max; else pct = 10;
|
if (http_get_type==PAGE) && (prbar.max) pct = prbar.value*30/prbar.max; else pct = 10;
|
||||||
if (http_get_type==IMG) pct = prbar.value * 70 / prbar.max + 30;
|
if (http_get_type==IMG) pct = prbar.value * 70 / prbar.max + 30;
|
||||||
@@ -779,21 +761,18 @@ void DrawProgress()
|
|||||||
|
|
||||||
void EventShowPageMenu()
|
void EventShowPageMenu()
|
||||||
{
|
{
|
||||||
if (application_mode) return;
|
|
||||||
open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #rmb_menu);
|
open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #rmb_menu);
|
||||||
menu_id = VIEW_SOURCE;
|
menu_id = VIEW_SOURCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventShowLinkMenu()
|
void EventShowLinkMenu()
|
||||||
{
|
{
|
||||||
if (application_mode) return;
|
|
||||||
open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #link_menu);
|
open_lmenu(mouse.x, mouse.y, MENU_TOP_LEFT, NULL, #link_menu);
|
||||||
menu_id = IN_NEW_TAB;
|
menu_id = IN_NEW_TAB;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventShowMainMenu()
|
void EventShowMainMenu()
|
||||||
{
|
{
|
||||||
if (application_mode) return;
|
|
||||||
open_lmenu(Form.cwidth - PADDING -4, PADDING + TSZE + 3,
|
open_lmenu(Form.cwidth - PADDING -4, PADDING + TSZE + 3,
|
||||||
MENU_TOP_RIGHT, NULL, #main_menu);
|
MENU_TOP_RIGHT, NULL, #main_menu);
|
||||||
menu_id = OPEN_FILE;
|
menu_id = OPEN_FILE;
|
||||||
@@ -801,7 +780,6 @@ void EventShowMainMenu()
|
|||||||
|
|
||||||
void EventShowEncodingsList()
|
void EventShowEncodingsList()
|
||||||
{
|
{
|
||||||
if (application_mode) return;
|
|
||||||
open_lmenu(Form.cwidth-4, Form.cheight - STATUSBAR_H + 12,
|
open_lmenu(Form.cwidth-4, Form.cheight - STATUSBAR_H + 12,
|
||||||
MENU_BOT_RIGHT, WB1.cur_encoding + 1,
|
MENU_BOT_RIGHT, WB1.cur_encoding + 1,
|
||||||
"UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866");
|
"UTF-8\nKOI8-RU\nCP1251\nCP1252\nISO8859-5\nCP866");
|
||||||
@@ -886,7 +864,6 @@ void DrawStatusBar(dword _msg)
|
|||||||
{
|
{
|
||||||
dword status_y = Form.cheight - STATUSBAR_H + 4;
|
dword status_y = Form.cheight - STATUSBAR_H + 4;
|
||||||
dword status_w = Form.cwidth - 90;
|
dword status_w = Form.cwidth - 90;
|
||||||
if (application_mode) return;
|
|
||||||
if (Form.status_window>2) return;
|
if (Form.status_window>2) return;
|
||||||
DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
|
DrawBar(0,Form.cheight - STATUSBAR_H+1, Form.cwidth,STATUSBAR_H-1, sc.work);
|
||||||
if (_msg) {
|
if (_msg) {
|
||||||
@@ -900,7 +877,6 @@ void DrawStatusBar(dword _msg)
|
|||||||
void DrawOmnibox()
|
void DrawOmnibox()
|
||||||
{
|
{
|
||||||
int imgxoff;
|
int imgxoff;
|
||||||
if (application_mode) return;
|
|
||||||
DrawOvalBorder(omnibox_edit.left-2, omnibox_edit.top-3, omnibox_edit.width+18, 24, sc.line,
|
DrawOvalBorder(omnibox_edit.left-2, omnibox_edit.top-3, omnibox_edit.width+18, 24, sc.line,
|
||||||
sc.line, sc.line, sc.dark);
|
sc.line, sc.line, sc.dark);
|
||||||
DrawBar(omnibox_edit.left-1, omnibox_edit.top-2, omnibox_edit.width+18, 1, 0xD8DCD8);
|
DrawBar(omnibox_edit.left-1, omnibox_edit.top-2, omnibox_edit.width+18, 1, 0xD8DCD8);
|
||||||
@@ -919,7 +895,6 @@ void DrawOmnibox()
|
|||||||
|
|
||||||
void SetOmniboxText(dword _text)
|
void SetOmniboxText(dword _text)
|
||||||
{
|
{
|
||||||
if (application_mode) return;
|
|
||||||
edit_box_set_text stdcall (#omnibox_edit, _text);
|
edit_box_set_text stdcall (#omnibox_edit, _text);
|
||||||
omnibox_edit.pos = omnibox_edit.flags = 0;
|
omnibox_edit.pos = omnibox_edit.flags = 0;
|
||||||
DrawOmnibox();
|
DrawOmnibox();
|
||||||
|
@@ -27,7 +27,7 @@ char link_menu[] =
|
|||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᮤ<EFBFBD>ন<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>뫪<EFBFBD>";
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᮤ<EFBFBD>ন<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>뫪<EFBFBD>";
|
||||||
char loading_text[] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>㧪<EFBFBD>...";
|
char loading_text[] = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>㧪<EFBFBD>...";
|
||||||
|
|
||||||
char update_param[] = "-e http://builds.kolibrios.org/rus/data/programs/cmm/browser/WebView.com";
|
char update_param[] = "-e http://builds.kolibrios.org/ru_RU/data/programs/cmm/browser/WebView.com";
|
||||||
char update_download_error[] = "'WebView\n<EFBFBD>訡<EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>祭<EFBFBD><E7A5AD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!' -tE";
|
char update_download_error[] = "'WebView\n<EFBFBD>訡<EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>祭<EFBFBD><E7A5AD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!' -tE";
|
||||||
char update_ok[] = "'WebView\n<EFBFBD><EFBFBD><EFBFBD>㧥<EFBFBD> <20><><EFBFBD> <20>ᯥ譮 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!' -tO";
|
char update_ok[] = "'WebView\n<EFBFBD><EFBFBD><EFBFBD>㧥<EFBFBD> <20><><EFBFBD> <20>ᯥ譮 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!' -tO";
|
||||||
char update_is_current[] = "'WebView\n<EFBFBD><EFBFBD> 㦥 <20>ᯮ<EFBFBD><E1AFAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.' -tI";
|
char update_is_current[] = "'WebView\n<EFBFBD><EFBFBD> 㦥 <20>ᯮ<EFBFBD><E1AFAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><E1ABA5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.' -tI";
|
||||||
@@ -63,7 +63,7 @@ Open in new window
|
|||||||
Copy link
|
Copy link
|
||||||
Download link contents";
|
Download link contents";
|
||||||
char loading_text[] = "Loading...";
|
char loading_text[] = "Loading...";
|
||||||
char update_param[] = "-e http://builds.kolibrios.org/eng/data/programs/cmm/browser/WebView.com";
|
char update_param[] = "-e http://builds.kolibrios.org/en_US/data/programs/cmm/browser/WebView.com";
|
||||||
char update_download_error[] = "'WebView\nError receiving an up to date information!' -tE";
|
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_ok[] = "'WebView\nThe browser has been updated!' -tO";
|
||||||
char update_is_current[] = "'WebView\nThe browser is up to date.' -tI";
|
char update_is_current[] = "'WebView\nThe browser is up to date.' -tI";
|
||||||
|
@@ -17,8 +17,10 @@
|
|||||||
#define T_STATUS_DL_P2 " M<> <20><><EFBFBD><EFBFBD>祭<EFBFBD> ("
|
#define T_STATUS_DL_P2 " M<> <20><><EFBFBD><EFBFBD>祭<EFBFBD> ("
|
||||||
#define T_STATUS_DL_P3 " K<>/<EFBFBD>) "
|
#define T_STATUS_DL_P3 " K<>/<EFBFBD>) "
|
||||||
|
|
||||||
#define FILE_SAVED_AS "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㧮<EFBFBD>\n<><6E><EFBFBD><EFBFBD> <20><><EFBFBD>࠭<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> %s' -Dt"
|
#define T_ERROR_TOO_MANY_REDIRECTS "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㧮<EFBFBD>\n<><6E><EFBFBD>誮<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> ।<EFBFBD>४⮢ (HTTP 3XX)' -Et"
|
||||||
#define FILE_NOT_SAVED "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㧮<EFBFBD>\n<>訡<EFBFBD><E8A8A1>! <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>࠭<EFBFBD><E0A0AD> <20><><EFBFBD>\n%s' -Et"
|
|
||||||
|
#define T_FILE_SAVED_AS "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㧮<EFBFBD>\n<><6E><EFBFBD><EFBFBD> <20><><EFBFBD>࠭<EFBFBD><E0A0AD> <20><><EFBFBD> %s' -Dt"
|
||||||
|
#define T_FILE_NOT_SAVED "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㧮<EFBFBD>\n<>訡<EFBFBD><E8A8A1>! <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>࠭<EFBFBD><E0A0AD> <20><><EFBFBD>\n%s' -Et"
|
||||||
#define T_ERROR_STARTING_DOWNLOAD "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᪠稢<E1AAA0><E7A8A2><EFBFBD><EFBFBD>.\n<><EFBFBD><E0AEA2><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> ᮥ<><E1AEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>⮬.' -E"
|
#define T_ERROR_STARTING_DOWNLOAD "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᪠稢<E1AAA0><E7A8A2><EFBFBD><EFBFBD>.\n<><EFBFBD><E0AEA2><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> ᮥ<><E1AEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>⮬.' -E"
|
||||||
char accept_language[]= "Accept-Language: ru\n";
|
char accept_language[]= "Accept-Language: ru\n";
|
||||||
#else
|
#else
|
||||||
@@ -38,8 +40,10 @@
|
|||||||
#define T_STATUS_DL_P2 " MB received ("
|
#define T_STATUS_DL_P2 " MB received ("
|
||||||
#define T_STATUS_DL_P3 " KB/s) "
|
#define T_STATUS_DL_P3 " KB/s) "
|
||||||
|
|
||||||
#define FILE_SAVED_AS "'Download manager\nFile saved as %s' -Dt"
|
#define T_ERROR_TOO_MANY_REDIRECTS "'Download manager\nToo many redirects' -Et"
|
||||||
#define FILE_NOT_SAVED "'Download manager\nError! Can\96t save file as %s' -Et"
|
|
||||||
|
#define T_FILE_SAVED_AS "'Download manager\nFile saved as %s' -Dt"
|
||||||
|
#define T_FILE_NOT_SAVED "'Download manager\nError! Can\96t save file as %s' -Et"
|
||||||
#define T_ERROR_STARTING_DOWNLOAD "'Error while starting download process.\nCheck entered path and Internet connection.' -E"
|
#define T_ERROR_STARTING_DOWNLOAD "'Error while starting download process.\nCheck entered path and Internet connection.' -E"
|
||||||
char accept_language[]= "Accept-Language: en\n";
|
char accept_language[]= "Accept-Language: en\n";
|
||||||
#endif
|
#endif
|
||||||
|
@@ -11,6 +11,8 @@ bool open_file = false;
|
|||||||
|
|
||||||
dword speed;
|
dword speed;
|
||||||
|
|
||||||
|
int redirect_count;
|
||||||
|
|
||||||
_http http;
|
_http http;
|
||||||
|
|
||||||
checkbox autoclose = { T_AUTOCLOSE, false };
|
checkbox autoclose = { T_AUTOCLOSE, false };
|
||||||
@@ -228,6 +230,7 @@ void InitDownload()
|
|||||||
pb.progress_color = PB_COL_PROGRESS;
|
pb.progress_color = PB_COL_PROGRESS;
|
||||||
filepath = '\0';
|
filepath = '\0';
|
||||||
active_status = T_STATUS_READY;
|
active_status = T_STATUS_READY;
|
||||||
|
redirect_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MonitorProgress()
|
void MonitorProgress()
|
||||||
@@ -241,6 +244,13 @@ void MonitorProgress()
|
|||||||
DrawDownloadingProgress();
|
DrawDownloadingProgress();
|
||||||
} else {
|
} else {
|
||||||
if (http.status_code >= 300) && (http.status_code < 400) {
|
if (http.status_code >= 300) && (http.status_code < 400) {
|
||||||
|
redirect_count++;
|
||||||
|
if (redirect_count >= 5) {
|
||||||
|
notify(T_ERROR_TOO_MANY_REDIRECTS);
|
||||||
|
ProcessButtonClick(BTN_STOP);
|
||||||
|
EditBox_UpdateText(#ed, ed_focus + ed_always_focus);
|
||||||
|
return;
|
||||||
|
}
|
||||||
http.header_field("location", #redirect_url, URL_SIZE);
|
http.header_field("location", #redirect_url, URL_SIZE);
|
||||||
get_absolute_url(#redirect_url, #uEdit);
|
get_absolute_url(#redirect_url, #uEdit);
|
||||||
edit_box_set_text stdcall (#ed, #redirect_url);
|
edit_box_set_text stdcall (#ed, #redirect_url);
|
||||||
@@ -307,9 +317,9 @@ void SaveFile(int attempt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CreateFile(http.content_received, http.content_pointer, #filepath)==0) {
|
if (CreateFile(http.content_received, http.content_pointer, #filepath)==0) {
|
||||||
miniprintf(#notify_message, FILE_SAVED_AS, #filepath);
|
miniprintf(#notify_message, T_FILE_SAVED_AS, #filepath);
|
||||||
} else {
|
} else {
|
||||||
miniprintf(#notify_message, FILE_NOT_SAVED, #filepath);
|
miniprintf(#notify_message, T_FILE_NOT_SAVED, #filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!autoclose.checked) notify(#notify_message);
|
if (!autoclose.checked) notify(#notify_message);
|
||||||
|
@@ -70,17 +70,17 @@ char aURIunescape[] = "unescape";
|
|||||||
#define FLAG_TRANSFER_FAILED 1 << 20
|
#define FLAG_TRANSFER_FAILED 1 << 20
|
||||||
|
|
||||||
struct http_msg{
|
struct http_msg{
|
||||||
dword socket;
|
dword socket; //socket on which the actual transfer happens
|
||||||
dword flags;
|
dword flags; //flags, reflects status of the transfer using bitflags
|
||||||
dword write_ptr;
|
dword write_ptr; //internal use only (where to write new data in buffer)
|
||||||
dword buffer_length;
|
dword buffer_length; //internal use only (number of available bytes in buffer)
|
||||||
dword chunk_ptr;
|
dword chunk_ptr; //internal use only (where the next chunk begins)
|
||||||
dword timestamp;
|
dword timestamp; //internal use only (when last data was received)
|
||||||
dword status;
|
dword status; //HTTP status
|
||||||
dword header_length;
|
dword header_length; //length of HTTP header
|
||||||
dword content_ptr;
|
dword content_ptr; //ptr to content
|
||||||
dword content_length;
|
dword content_length; //total length of HTTP content
|
||||||
dword content_received;
|
dword content_received; //number of currently received content bytes
|
||||||
char http_header;
|
char http_header;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user