C-- downloader: show download speed and size in Mb

git-svn-id: svn://kolibrios.org@9287 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2021-11-17 23:43:09 +00:00
parent 0dc168b130
commit 1a964f239f
4 changed files with 108 additions and 123 deletions

View File

@ -1,4 +1,4 @@
//Copyright 2020 by Leency //Copyright 2021 by Leency
#ifdef LANG_RUS #ifdef LANG_RUS
#define DL_WINDOW_HEADER "Œ¥­¥¤¦¥à § £à㧮ª" #define DL_WINDOW_HEADER "Œ¥­¥¤¦¥à § £à㧮ª"
@ -9,10 +9,9 @@
#define T_SPEED_TEST "’¥áâ ᪮à®áâ¨" #define T_SPEED_TEST "’¥áâ ᪮à®áâ¨"
#define FILE_SAVED_AS "'Œ¥­¥¤¦¥à § £à㧮ª\n” ©« á®åà ­¥­ ª ª %s' -Dt" #define FILE_SAVED_AS "'Œ¥­¥¤¦¥à § £à㧮ª\n” ©« á®åà ­¥­ ª ª %s' -Dt"
#define FILE_NOT_SAVED "'Œ¥­¥¤¦¥à § £à㧮ª\nŽè¨¡ª ! ” ©« ­¥ ¬®¦¥â ¡ëâì á®åà ­¥­ ª ª\n%s' -Et" #define FILE_NOT_SAVED "'Œ¥­¥¤¦¥à § £à㧮ª\nŽè¨¡ª ! ” ©« ­¥ ¬®¦¥â ¡ëâì á®åà ­¥­ ª ª\n%s' -Et"
#define KB_RECEIVED "ˆ¤¥â ᪠稢 ­¨¥... %s ¯®«ã祭®" #define KB_RECEIVED "ế乒 嶊删芍<E588A0>言: %i.%i Mb 祚怒蟡陋 (%i Kb/s) "
#define T_ERROR_STARTING_DOWNLOAD "'<27>¥¢®§¬®¦­® ­ ç âì ᪠稢 ­¨¥.\n<>஢¥àì⥠¢¢¥¤¥­­ë© ¯ãâì ¨ ᮥ¤¨­¥­¨¥ á ˆ­â¥à­¥â®¬.' -E" #define T_ERROR_STARTING_DOWNLOAD "'<27>¥¢®§¬®¦­® ­ ç âì ᪠稢 ­¨¥.\n<>஢¥àì⥠¢¢¥¤¥­­ë© ¯ãâì ¨ ᮥ¤¨­¥­¨¥ á ˆ­â¥à­¥â®¬.' -E"
#define T_AUTOCLOSE "€¢â®§ ªàë⨥" #define T_AUTOCLOSE "€¢â®§ ªàë⨥"
#define SPEED_TEST_INFO_MESSAGE "'‘ª®à®áâì § £à㧪¨ ®â®¡à ¦ ¥âáï ¢ ¯®«¥ Download ¯à®£à ¬¬ë Network status.'-Id"
char accept_language[]= "Accept-Language: ru\n"; char accept_language[]= "Accept-Language: ru\n";
#else #else
#define DL_WINDOW_HEADER "Download Manager" #define DL_WINDOW_HEADER "Download Manager"
@ -23,15 +22,14 @@
#define T_SPEED_TEST "Speed test" #define T_SPEED_TEST "Speed test"
#define FILE_SAVED_AS "'Download manager\nFile saved as %s' -Dt" #define FILE_SAVED_AS "'Download manager\nFile saved as %s' -Dt"
#define FILE_NOT_SAVED "'Download manager\nError! Can\96t save file as %s' -Et" #define FILE_NOT_SAVED "'Download manager\nError! Can\96t save file as %s' -Et"
#define KB_RECEIVED "Downloading... %s received" #define KB_RECEIVED "Downloading: %i.%i Mb received (%i Kb/s) "
#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"
#define T_AUTOCLOSE "Autoclose" #define T_AUTOCLOSE "Autoclose"
#define SPEED_TEST_INFO_MESSAGE "'Download speed is shown after `Download`\nlabel in the Network status program.'-Id"
char accept_language[]= "Accept-Language: en\n"; char accept_language[]= "Accept-Language: en\n";
#endif #endif
#define GAPX 15 #define GAPX 15
#define WIN_W 580 #define WIN_W 540
#define WIN_H 100 #define WIN_H 100
char save_dir[] = "/tmp0/1/Downloads"; char save_dir[] = "/tmp0/1/Downloads";

View File

@ -10,6 +10,8 @@
bool exit_param = false; bool exit_param = false;
bool open_file = false; bool open_file = false;
dword speed;
_http http; _http http;
checkbox autoclose = { T_AUTOCLOSE, false }; checkbox autoclose = { T_AUTOCLOSE, false };
@ -17,7 +19,7 @@ checkbox autoclose = { T_AUTOCLOSE, false };
char uEdit[URL_SIZE]; char uEdit[URL_SIZE];
char filepath[URL_SIZE+96]; char filepath[URL_SIZE+96];
progress_bar pb = {0, GAPX, 58, 315, 17, 0, NULL, NULL, 0xFFFfff, 0x74DA00, NULL}; progress_bar pb = {0, GAPX, 58, 380, 17, 0, NULL, NULL, 0xFFFfff, 0x74DA00, NULL};
edit_box ed = {WIN_W-GAPX-GAPX,GAPX,20,0xffffff,0x94AECE,0xffffff,0xffffff, edit_box ed = {WIN_W-GAPX-GAPX,GAPX,20,0xffffff,0x94AECE,0xffffff,0xffffff,
0x10000000, sizeof(uEdit)-2,#uEdit,0,ed_focus,19,19}; 0x10000000, sizeof(uEdit)-2,#uEdit,0,ed_focus,19,19};
@ -51,8 +53,6 @@ void main()
if (streq(#param, "-test")) { if (streq(#param, "-test")) {
strcpy(#uEdit, URL_SPEED_TEST); strcpy(#uEdit, URL_SPEED_TEST);
RunProgram("/sys/network/netstat", NULL);
notify(SPEED_TEST_INFO_MESSAGE);
} }
} }
if (uEdit[0]) StartDownloading(); else { if (uEdit[0]) StartDownloading(); else {
@ -107,7 +107,7 @@ void DrawWindow()
DrawStandartCaptButton(GAPX+276, BUT_Y, BTN_RUN, T_RUN); DrawStandartCaptButton(GAPX+276, BUT_Y, BTN_RUN, T_RUN);
} }
} else { } else {
DrawStandartCaptButton(WIN_W - 240, BUT_Y, BTN_STOP, T_CANCEL); DrawStandartCaptButton(WIN_W - 120, BUT_Y, BTN_STOP, T_CANCEL);
DrawDownloadingProgress(); DrawDownloadingProgress();
} }
//ed.offset=0; //DEL? //ed.offset=0; //DEL?
@ -118,6 +118,7 @@ void StartDownloading()
{ {
char get_url[URL_SIZE+33]; char get_url[URL_SIZE+33];
if (http.transfer > 0) return; if (http.transfer > 0) return;
ResetDownloadSpeed();
filepath = '\0'; filepath = '\0';
if (!strncmp(#uEdit,"https:",6)) { if (!strncmp(#uEdit,"https:",6)) {
miniprintf(#get_url, "http://gate.aspero.pro/?site=%s", #uEdit); miniprintf(#get_url, "http://gate.aspero.pro/?site=%s", #uEdit);
@ -146,6 +147,7 @@ void StartDownloading()
void DrawDownloadingProgress() void DrawDownloadingProgress()
{ {
char bytes_received[70]; char bytes_received[70];
dword gotkb = http.content_received/1024;
EDI = http.content_received / 100; EDI = http.content_received / 100;
if (pb.value == EDI) return; if (pb.value == EDI) return;
@ -153,9 +155,9 @@ void DrawDownloadingProgress()
pb.value = EDI; pb.value = EDI;
pb.max = http.content_length / 100; pb.max = http.content_length / 100;
progressbar_draw stdcall(#pb); progressbar_draw stdcall(#pb);
miniprintf(#bytes_received, KB_RECEIVED, ConvertSizeToKb(http.content_received) ); CalculateDownloadSpeed();
sprintf(#bytes_received, KB_RECEIVED, gotkb/1024, gotkb%1024/103, speed);
WriteTextWithBg(GAPX, pb.top + 22, 0xD0, sc.work_text, #bytes_received, sc.work); WriteTextWithBg(GAPX, pb.top + 22, 0xD0, sc.work_text, #bytes_received, sc.work);
//CalculateSpeed();
} }
void StopDownloading() void StopDownloading()
@ -269,7 +271,6 @@ void Unarchive(dword _arc)
} }
/*
struct TIME struct TIME
{ {
dword old; dword old;
@ -278,22 +279,25 @@ struct TIME
} time = {0,0,0}; } time = {0,0,0};
dword netdata_received; dword netdata_received;
dword speed;
void CalculateSpeed() void ResetDownloadSpeed()
{
time.old = 0;
netdata_received = 0;
}
void CalculateDownloadSpeed()
{ {
time.cur = GetStartTime(); time.cur = GetStartTime();
if (time.old) { if (time.old) {
time.gone = time.cur - time.old; time.gone = time.cur - time.old;
if (time.gone > 200) { if (time.gone >= 200) {
speed = http.content_received - netdata_received / time.gone * 100; speed = http.content_received - netdata_received / time.gone / 10;
debugval("speed", speed);
debugln(ConvertSizeToKb(speed) );
time.old = time.cur; time.old = time.cur;
netdata_received = http.content_received; netdata_received = http.content_received;
} }
} else {
time.old = time.cur;
} }
else time.old = time.cur; }
}
*/

View File

@ -9,99 +9,94 @@
#define SOCK_STREAM 1 #define SOCK_STREAM 1
#define SOCK_DGRAM 2 #define SOCK_DGRAM 2
#define AF_INET4 2 #define AF_INET4 2
#define MSG_PEEK 0x02 #define MSG_PEEK 0x02
#define MSG_DONTWAIT 0x40 #define MSG_DONTWAIT 0x40
dword errorcode; struct SockAddr
struct sockaddr_in
{ {
word sin_family; word sin_family;
word sin_port; char data[14];
dword sin_addr; };
char padding[8];
};
inline fastcall dword Socket(ECX, EDX, ESI) // ecx = domain
// edx = type
// esi = protocol
inline fastcall dword socket_open(ECX, EDX, ESI)
{ {
$push ebx
$mov eax, 75 $mov eax, 75
$mov ebx, 0 $mov bl, 0
$int 0x40 $int 0x40
errorcode = EBX;
$pop ebx
}
inline fastcall dword Close(ECX)
{
$push ebx
$mov eax, 75
$mov ebx, 1
$int 0x40
errorcode = EBX;
$pop ebx
} }
inline fastcall dword Bind(ECX, EDX, ESI) // ecx = socket number
inline fastcall dword socket_close(ECX)
{ {
$push ebx
$mov eax, 75 $mov eax, 75
$mov ebx, 2 $mov bl, 1
$int 0x40 $int 0x40
errorcode = EBX;
$pop ebx
} }
inline fastcall dword Listen(ECX, EDX) // ecx = socket number
// edx = pointer to sockaddr structure
// esi = length of sockaddr structure
inline fastcall dword socket_bind(ECX, EDX, ESI)
{ {
$push ebx
$mov eax, 75 $mov eax, 75
$mov ebx, 3 $mov bl, 2
$int 0x40 $int 0x40
errorcode = EBX;
$pop ebx
} }
inline fastcall dword Connect(ECX, EDX, ESI) // ecx = socket number
// edx = backlog
inline fastcall dword socket_listen(ECX, EDX)
{ {
$push ebx
$mov eax, 75 $mov eax, 75
$mov ebx, 4 $mov bl, 3
$int 0x40 $int 0x40
errorcode = EBX;
$pop ebx
} }
inline fastcall dword Accept(ECX, EDX, ESI) // ecx = socket number
// edx = pointer to sockaddr structure
// esi = length of sockaddr structure
inline fastcall dword socket_connect(ECX, EDX, ESI)
{ {
$push ebx
$mov eax, 75 $mov eax, 75
$mov ebx, 5 $mov bl, 4
$int 0x40 $int 0x40
errorcode = EBX;
$pop ebx
} }
inline fastcall dword Send(ECX, EDX, ESI, EDI) // ecx = socket number
// edx = pointer to sockaddr structure
// esi = length of sockaddr structure
inline fastcall dword socket_accept(ECX, EDX, ESI)
{ {
$push ebx
$mov eax, 75 $mov eax, 75
$mov ebx, 6 $mov bl, 5
$int 0x40 $int 0x40
errorcode = EBX;
$pop ebx
} }
inline fastcall dword Receive(ECX, EDX, ESI, EDI) // ecx = socket number
// edx = pointer to buffer
// esi = length of buffer
// edi = flags
inline fastcall dword socket_send(ECX, EDX, ESI, EDI)
{ {
$push ebx
$mov eax, 75 $mov eax, 75
$mov ebx, 7 $mov bl, 6
$int 0x40
}
// ecx = socket number
// edx = pointer to buffer
// esi = length of buffer
// edi = flags
inline fastcall dword socket_receive(ECX, EDX, ESI, EDI)
{
$mov eax, 75
$mov bl, 7
$int 0x40 $int 0x40
errorcode = EBX;
$pop ebx
} }
#endif #endif

View File

@ -1,12 +1,11 @@
//Leency & SoUrcerer, LGPL //Leency & SoUrcerer, LGPL
//Hidnplayer //Hidnplayer
TWebBrowser WB1;
#define LIST_INFO_H 59 #define LIST_INFO_H 59
int status_bar_h = 15; int status_bar_h = 15;
scroll_bar scroll1 = { 17,200,210, LIST_INFO_H-3,18,0,115,15,0,0xCCCccc,0xD2CED0,0x555555,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; scroll_bar scroll1 = { 17,200,210, LIST_INFO_H-3,18,0,115,15,0,0xCCCccc,0xD2CED0,0x555555,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
scroll_bar scroll_wv;
char *listbuffer; char *listbuffer;
char *listpointer; char *listpointer;
@ -17,6 +16,7 @@ int mailsize;
int cur_charset; int cur_charset;
llist list;
enum { enum {
GET_MAIL = 20, GET_MAIL = 20,
@ -34,7 +34,7 @@ void MailBoxNetworkProcess() {
if (aim) switch(aim) if (aim) switch(aim)
{ {
case SEND_NSTAT: case SEND_NSTAT:
SetMailBoxStatus(NULL, "Counting mail, awaiting answer..."); SetMailBoxStatus(NULL, "Counting mail, awaiting answer...");
request_len = GetRequest("STAT", NULL); request_len = GetRequest("STAT", NULL);
Send(socketnum, #request, request_len, 0); Send(socketnum, #request, request_len, 0);
if (EAX == 0xffffffff) { debugln("Error sending STAT. Retry..."w); break;} if (EAX == 0xffffffff) { debugln("Error sending STAT. Retry..."w); break;}
@ -44,7 +44,7 @@ void MailBoxNetworkProcess() {
case GET_ANSWER_NSTAT: case GET_ANSWER_NSTAT:
ticks = Receive(socketnum, #immbuffer, BUFFERSIZE, 0); ticks = Receive(socketnum, #immbuffer, BUFFERSIZE, 0);
if ((ticks == 0xffffff) || (ticks < 2)) break; if ((ticks == 0xffffff) || (ticks < 2)) break;
if (immbuffer[ticks-2]=='\n') if (immbuffer[ticks-2]=='\n')
{ {
debugln(#immbuffer); debugln(#immbuffer);
@ -54,7 +54,7 @@ void MailBoxNetworkProcess() {
mail_list.count = atoi(#param); mail_list.count = atoi(#param);
free(listbuffer); free(listbuffer);
listbuffer = mem_Alloc(30*mail_list.count); //24* original listbuffer = mem_Alloc(30*mail_list.count); //24* original
listpointer = listbuffer; listpointer = listbuffer;
aim = SEND_NLIST; aim = SEND_NLIST;
debugln("Receiving mail list..."); debugln("Receiving mail list...");
} }
@ -75,16 +75,16 @@ void MailBoxNetworkProcess() {
case GET_ANSWER_NLIST: case GET_ANSWER_NLIST:
ticks = Receive(socketnum, listpointer, listbuffer + 30*mail_list.count - listpointer, MSG_DONTWAIT); ticks = Receive(socketnum, listpointer, listbuffer + 30*mail_list.count - listpointer, MSG_DONTWAIT);
if (ticks == 0xffffffff) break; if (ticks == 0xffffffff) break;
listpointer = listpointer + ticks; listpointer = listpointer + ticks;
if (listpointer - listbuffer < 5) break; if (listpointer - listbuffer < 5) break;
if (strncmp(listpointer-5,"\n.\n",5)==0) // note that c-- assembles "\n.\n" to 0x0d, 0x0a, 0x2e, 0x0d, 0x0a if (strncmp(listpointer-5,"\n.\n",5)==0) // note that c-- assembles "\n.\n" to 0x0d, 0x0a, 0x2e, 0x0d, 0x0a
{ {
aim = SEND_RETR; aim = SEND_RETR;
debugln("goto SEND_RETR"); debugln("goto SEND_RETR");
DrawMailBox(); DrawMailBox();
*listpointer='\0'; *listpointer='\0';
atr.CreateArray(); atr.CreateArray();
atr.SetSizes(); atr.SetSizes();
@ -93,7 +93,6 @@ void MailBoxNetworkProcess() {
case SEND_RETR: case SEND_RETR:
from = to = date = subj = cur_charset = NULL; from = to = date = subj = cur_charset = NULL;
WB1.list.ClearList();
DrawMailBox(); DrawMailBox();
request_len = GetRequest("RETR", itoa(mail_list.cur_y+1)); request_len = GetRequest("RETR", itoa(mail_list.cur_y+1));
if (Send(socketnum, #request, request_len, 0) == 0xffffffff) if (Send(socketnum, #request, request_len, 0) == 0xffffffff)
@ -115,7 +114,7 @@ void MailBoxNetworkProcess() {
aim = GET_ANSWER_RETR; aim = GET_ANSWER_RETR;
debugln("goto GET_ANSWER_RETR"); debugln("goto GET_ANSWER_RETR");
break; break;
case GET_ANSWER_RETR: case GET_ANSWER_RETR:
debugval("mailsize", mailsize); debugval("mailsize", mailsize);
debugval("mailstart", mailstart); debugval("mailstart", mailstart);
@ -150,21 +149,20 @@ void MailBoxLoop() {
mail_list.h = Form.cheight/4; mail_list.h = Form.cheight/4;
mail_list.ClearList(); mail_list.ClearList();
WB1.list.no_selection = true;
SetMailBoxStatus( NULL , NULL); SetMailBoxStatus( NULL , NULL);
cur_charset = 0; cur_charset = 0;
aim = SEND_NSTAT; aim = SEND_NSTAT;
goto _MB_DRAW; goto _MB_DRAW;
loop() loop()
{ {
WaitEventTimeout(2); WaitEventTimeout(2);
switch(EAX & 0xFF) switch(EAX & 0xFF)
{ {
case evMouse: case evMouse:
mouse.get(); mouse.get();
if (!mouse.lkm) panels_drag=0; if (!mouse.lkm) panels_drag=0;
if (mouse.lkm) && (mouse.y>mail_list.y+mail_list.h-1) && (mouse.y<mail_list.y+mail_list.h+6) if (mouse.lkm) && (mouse.y>mail_list.y+mail_list.h-1) && (mouse.y<mail_list.y+mail_list.h+6)
&& (!scroll1.delta2) && (!scroll_wv.delta2) panels_drag = 1; && (!scroll1.delta2) && (!scroll_wv.delta2) panels_drag = 1;
@ -176,34 +174,34 @@ void MailBoxLoop() {
break; break;
} }
links.hover(mouse.x, mouse.y); //links.hover(mouse.x, mouse.y);
if (!mail_list.count) break; if (!mail_list.count) break;
if (!panels_drag) { scrollbar_v_mouse (#scroll1); scrollbar_v_mouse (#scroll_wv); } if (!panels_drag) { scrollbar_v_mouse (#scroll1); scrollbar_v_mouse (#scroll_wv); }
if (mail_list.first <> scroll1.position) if (mail_list.first <> scroll1.position)
{ {
mail_list.first = scroll1.position; mail_list.first = scroll1.position;
DrawMailList(); DrawMailList();
break; break;
}; };
if (WB1.list.first <> scroll_wv.position) if (list.first <> scroll_wv.position)
{ {
WB1.list.first = scroll_wv.position; list.first = scroll_wv.position;
DrawLetter(); DrawLetter();
break; break;
}; };
if (mail_list.y+mail_list.h + 10 > mouse.y) if (mail_list.y+mail_list.h + 10 > mouse.y)
{ {
if (mail_list.MouseScroll(mouse.vert)) DrawMailList(); if (mail_list.MouseScroll(mouse.vert)) DrawMailList();
} }
else else
{ {
if (WB1.list.MouseScroll(mouse.vert)) DrawLetter(); if (list.MouseScroll(mouse.vert)) DrawLetter();
} }
if (mouse.lkm) && (mail_list.MouseOver(mouse.x, mouse.y)) && (!clicked_list) clicked_list=1; if (mouse.lkm) && (mail_list.MouseOver(mouse.x, mouse.y)) && (!clicked_list) clicked_list=1;
if (!mouse.lkm) && (clicked_list) if (mail_list.ProcessMouse(mouse.x, mouse.y)) if (!mouse.lkm) && (clicked_list) if (mail_list.ProcessMouse(mouse.x, mouse.y))
{ {
clicked_list = 0; clicked_list = 0;
if (aim) break; if (aim) break;
@ -211,9 +209,9 @@ void MailBoxLoop() {
aim = SEND_RETR; aim = SEND_RETR;
} }
break; break;
case evButton: case evButton:
id = GetButtonID(); id = GetButtonID();
if (id==1) SaveAndExit(); if (id==1) SaveAndExit();
if (id==GET_MAIL) aim = SEND_NSTAT; if (id==GET_MAIL) aim = SEND_NSTAT;
if (id==SAVE_LETTER) if (id==SAVE_LETTER)
@ -223,19 +221,19 @@ void MailBoxLoop() {
pause(10); pause(10);
RunProgram("/sys/tinypad", "mail.txt"); RunProgram("/sys/tinypad", "mail.txt");
} }
if (id==STOP_LOADING) if (id==STOP_LOADING)
{ {
StopLoading(); StopLoading();
DrawStatusBar(); DrawStatusBar();
DrawMailList(); DrawMailList();
} }
if (id==EXIT_MAIL) if (id==EXIT_MAIL)
{ {
StopLoading(); StopLoading();
Close(socketnum); Close(socketnum);
LoginBoxLoop(); LoginBoxLoop();
} }
if (id==CHANGE_CHARSET) if (id==CHANGE_CHARSET)
{ {
DefineButton(0,0,Form.cwidth,Form.cheight, CLOSE_CHANGE_CHARSET+BT_HIDE+BT_NOFRAME); DefineButton(0,0,Form.cwidth,Form.cheight, CLOSE_CHANGE_CHARSET+BT_HIDE+BT_NOFRAME);
DrawRectangle(Form.cwidth-100, Form.cheight-status_bar_h- 70, 70, 82, sc.work_graph); DrawRectangle(Form.cwidth-100, Form.cheight-status_bar_h- 70, 70, 82, sc.work_graph);
@ -251,7 +249,7 @@ void MailBoxLoop() {
} }
if (id==CLOSE_CHANGE_CHARSET) goto _MB_DRAW; if (id==CLOSE_CHANGE_CHARSET) goto _MB_DRAW;
break; break;
case evKey: case evKey:
GetKeys(); GetKeys();
@ -282,7 +280,6 @@ void DrawMailBox()
{ {
DrawMailList(); DrawMailList();
DrawLetterInfo(); DrawLetterInfo();
InitTWB();
DrawLetter(); DrawLetter();
DrawStatusBar(); DrawStatusBar();
} }
@ -310,7 +307,7 @@ void DrawMailList() {
dword sel_col; dword sel_col;
mail_list.visible = mail_list.h / mail_list.item_h; mail_list.visible = mail_list.h / mail_list.item_h;
for (i=30; i<150; i++) DeleteButton(i); for (i=30; i<150; i++) DeleteButton(i);
for (i=0; (i<mail_list.visible) && (i+mail_list.first<mail_list.count); i++) for (i=0; (i<mail_list.visible) && (i+mail_list.first<mail_list.count); i++)
{ {
on_y = i*mail_list.item_h + mail_list.y; on_y = i*mail_list.item_h + mail_list.y;
@ -351,19 +348,8 @@ void DrawLetterInfo() {
} }
void InitTWB() {
WB1.list.SetSizes(0, mail_list.y+mail_list.h+LIST_INFO_H+1, Form.cwidth - scroll_wv.size_x - 1,
Form.cheight - mail_list.y - mail_list.h - LIST_INFO_H - 1 - status_bar_h, 12);
WB1.list.column_max = WB1.list.w - 30 / 6;
WB1.list.visible = WB1.list.h / WB1.list.item_h;
DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h);
WB1.list.first = WB1.list.count = 0;
}
void DrawLetter() { void DrawLetter() {
WB1.ParseHtml(mdata, strlen(mdata)); //DrawTextLines();
WB1.DrawPage();
DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, 0xFFFfff); DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, 0xFFFfff);
} }
@ -387,7 +373,7 @@ void DrawStatusBar() {
SetMailBoxStatus(cur_st_percent, cur_st_text); SetMailBoxStatus(cur_st_percent, cur_st_text);
DrawCaptButton(240, st_y+1, 36, status_bar_h-3, STOP_LOADING, sc.button, sc.button_text,"Stop"); DrawCaptButton(240, st_y+1, 36, status_bar_h-3, STOP_LOADING, sc.button, sc.button_text,"Stop");
} }
DrawCaptButton(Form.cwidth - 100, st_y+1, 70, status_bar_h-2, CHANGE_CHARSET+BT_HIDE, DrawCaptButton(Form.cwidth - 100, st_y+1, 70, status_bar_h-2, CHANGE_CHARSET+BT_HIDE,
sc.work, sc.work_text,cur_charset*10+#charsets); sc.work, sc.work_text,cur_charset*10+#charsets);
} }
@ -414,10 +400,12 @@ int GetLetterSize_(int number) {
itoa_(#search_num+1, number); itoa_(#search_num+1, number);
chrcat(#search_num, ' '); chrcat(#search_num, ' ');
strcpyb(listbuffer, #mailsize1, #search_num, "\x0d"); strcpyb(listbuffer, #mailsize1, #search_num, "\x0d");
return atoi(#mailsize1); return atoi(#mailsize1);
} }
/*
void EventClickLink() { void EventClickLink() {
RunProgram("/sys/network/WebView", links.active_url); RunProgram("/sys/network/WebView", links.active_url);
} }
*/