Rev 9246 | Rev 9597 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9246 | Rev 9287 | ||
---|---|---|---|
Line 8... | Line 8... | ||
8 | #include "const.h" |
8 | #include "const.h" |
Line 9... | Line 9... | ||
9 | 9 | ||
10 | bool exit_param = false; |
10 | bool exit_param = false; |
Line -... | Line 11... | ||
- | 11 | bool open_file = false; |
|
- | 12 | ||
11 | bool open_file = false; |
13 | dword speed; |
Line 12... | Line 14... | ||
12 | 14 | ||
Line 13... | Line 15... | ||
13 | _http http; |
15 | _http http; |
14 | 16 | ||
Line 15... | Line 17... | ||
15 | checkbox autoclose = { T_AUTOCLOSE, false }; |
17 | checkbox autoclose = { T_AUTOCLOSE, false }; |
16 | 18 | ||
17 | char uEdit[URL_SIZE]; |
19 | char uEdit[URL_SIZE]; |
Line 18... | Line 20... | ||
18 | char filepath[URL_SIZE+96]; |
20 | char filepath[URL_SIZE+96]; |
Line 49... | Line 51... | ||
49 | strcpy(#uEdit, #param); |
51 | strcpy(#uEdit, #param); |
50 | } |
52 | } |
Line 51... | Line 53... | ||
51 | 53 | ||
52 | if (streq(#param, "-test")) { |
54 | if (streq(#param, "-test")) { |
53 | strcpy(#uEdit, URL_SPEED_TEST); |
- | |
54 | RunProgram("/sys/network/netstat", NULL); |
- | |
55 | notify(SPEED_TEST_INFO_MESSAGE); |
55 | strcpy(#uEdit, URL_SPEED_TEST); |
56 | } |
56 | } |
57 | } |
57 | } |
58 | if (uEdit[0]) StartDownloading(); else { |
58 | if (uEdit[0]) StartDownloading(); else { |
59 | edit_box_set_text stdcall (#ed, "http://"); |
59 | edit_box_set_text stdcall (#ed, "http://"); |
Line 105... | Line 105... | ||
105 | { |
105 | { |
106 | DrawStandartCaptButton(GAPX+102, BUT_Y, BTN_DIR, T_OPEN_DIR); |
106 | DrawStandartCaptButton(GAPX+102, BUT_Y, BTN_DIR, T_OPEN_DIR); |
107 | DrawStandartCaptButton(GAPX+276, BUT_Y, BTN_RUN, T_RUN); |
107 | DrawStandartCaptButton(GAPX+276, BUT_Y, BTN_RUN, T_RUN); |
108 | } |
108 | } |
109 | } else { |
109 | } else { |
110 | DrawStandartCaptButton(WIN_W - 240, BUT_Y, BTN_STOP, T_CANCEL); |
110 | DrawStandartCaptButton(WIN_W - 120, BUT_Y, BTN_STOP, T_CANCEL); |
111 | DrawDownloadingProgress(); |
111 | DrawDownloadingProgress(); |
112 | } |
112 | } |
113 | //ed.offset=0; //DEL? |
113 | //ed.offset=0; //DEL? |
114 | DrawEditBox(#ed); |
114 | DrawEditBox(#ed); |
115 | } |
115 | } |
Line 116... | Line 116... | ||
116 | 116 | ||
117 | void StartDownloading() |
117 | void StartDownloading() |
118 | { |
118 | { |
119 | char get_url[URL_SIZE+33]; |
119 | char get_url[URL_SIZE+33]; |
- | 120 | if (http.transfer > 0) return; |
|
120 | if (http.transfer > 0) return; |
121 | ResetDownloadSpeed(); |
121 | filepath = '\0'; |
122 | filepath = '\0'; |
122 | if (!strncmp(#uEdit,"https:",6)) { |
123 | if (!strncmp(#uEdit,"https:",6)) { |
123 | miniprintf(#get_url, "http://gate.aspero.pro/?site=%s", #uEdit); |
124 | miniprintf(#get_url, "http://gate.aspero.pro/?site=%s", #uEdit); |
124 | //notify("'HTTPS for download is not supported, trying to download the file via HTTP' -W"); |
125 | //notify("'HTTPS for download is not supported, trying to download the file via HTTP' -W"); |
Line 144... | Line 145... | ||
144 | 145 | ||
145 | 146 | ||
146 | void DrawDownloadingProgress() |
147 | void DrawDownloadingProgress() |
- | 148 | { |
|
Line 147... | Line 149... | ||
147 | { |
149 | char bytes_received[70]; |
148 | char bytes_received[70]; |
150 | dword gotkb = http.content_received/1024; |
Line 149... | Line 151... | ||
149 | 151 | ||
150 | EDI = http.content_received / 100; |
152 | EDI = http.content_received / 100; |
151 | if (pb.value == EDI) return; |
153 | if (pb.value == EDI) return; |
- | 154 | ||
152 | 155 | pb.value = EDI; |
|
153 | pb.value = EDI; |
156 | pb.max = http.content_length / 100; |
154 | pb.max = http.content_length / 100; |
- | |
155 | progressbar_draw stdcall(#pb); |
157 | progressbar_draw stdcall(#pb); |
Line 156... | Line 158... | ||
156 | miniprintf(#bytes_received, KB_RECEIVED, ConvertSizeToKb(http.content_received) ); |
158 | CalculateDownloadSpeed(); |
157 | WriteTextWithBg(GAPX, pb.top + 22, 0xD0, sc.work_text, #bytes_received, sc.work); |
159 | sprintf(#bytes_received, KB_RECEIVED, gotkb/1024, gotkb%1024/103, speed); |
158 | //CalculateSpeed(); |
160 | WriteTextWithBg(GAPX, pb.top + 22, 0xD0, sc.work_text, #bytes_received, sc.work); |
Line 267... | Line 269... | ||
267 | chrcat(#param, '\"'); |
269 | chrcat(#param, '\"'); |
268 | RunProgram("/sys/unz", #param); |
270 | RunProgram("/sys/unz", #param); |
269 | } |
271 | } |
Line 270... | Line -... | ||
270 | - | ||
271 | 272 | ||
272 | /* |
273 | |
273 | struct TIME |
274 | struct TIME |
274 | { |
275 | { |
275 | dword old; |
276 | dword old; |
276 | dword cur; |
277 | dword cur; |
Line 277... | Line 278... | ||
277 | dword gone; |
278 | dword gone; |
278 | } time = {0,0,0}; |
- | |
Line -... | Line 279... | ||
- | 279 | } time = {0,0,0}; |
|
- | 280 | ||
- | 281 | dword netdata_received; |
|
- | 282 | ||
- | 283 | void ResetDownloadSpeed() |
|
- | 284 | { |
|
279 | 285 | time.old = 0; |
|
280 | dword netdata_received; |
286 | netdata_received = 0; |
281 | dword speed; |
287 | } |
Line 282... | Line 288... | ||
282 | 288 | ||
283 | void CalculateSpeed() |
289 | void CalculateDownloadSpeed() |
284 | { |
290 | { |
285 | time.cur = GetStartTime(); |
291 | time.cur = GetStartTime(); |
286 | - | ||
287 | if (time.old) { |
- | |
288 | time.gone = time.cur - time.old; |
292 | |
289 | if (time.gone > 200) { |
293 | if (time.old) { |
290 | speed = http.content_received - netdata_received / time.gone * 100; |
294 | time.gone = time.cur - time.old; |
- | 295 | if (time.gone >= 200) { |
|
- | 296 | speed = http.content_received - netdata_received / time.gone / 10; |
|
291 | debugval("speed", speed); |
297 | time.old = time.cur; |
292 | debugln(ConvertSizeToKb(speed) ); |
- | |
293 | time.old = time.cur; |
298 | netdata_received = http.content_received; |
294 | netdata_received = http.content_received; |
- | |
295 | } |
299 | } |