Rev 7227 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7227 | Rev 7281 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | char save_to[4096] = "/tmp0/1/Downloads"; |
18 | char save_to[4096] = "/tmp0/1/Downloads"; |
Line 19... | Line 19... | ||
19 | 19 | ||
20 | proc_info DL_Form; |
20 | proc_info DL_Form; |
21 | char downloader_edit[10000]; |
21 | char downloader_edit[10000]; |
22 | char filepath[4096]; |
- | |
23 | int mouse_twbi; |
22 | char filepath[4096]; |
24 | edit_box ed = {250,20,20,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(downloader_edit),#downloader_edit,#mouse_twbi,2,19,19}; |
23 | edit_box ed = {NULL,57,20,0xffffff,0x94AECE,0xffffff,0xffffff,0x10000000,sizeof(downloader_edit),#downloader_edit,0,2,19,19}; |
25 | progress_bar pb = {0, 20, 58, 350, 17, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F}; |
24 | progress_bar pb = {0, 20, 58, 350, 17, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F}; |
26 | //progress_bar pb = {0, 180, 55, 225, 12, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F}; |
25 | //progress_bar pb = {0, 180, 55, 225, 12, 0, 0, 100, 0xFFFfff, 0x74DA00, 0x9F9F9F}; |
Line 27... | Line 26... | ||
27 | //progress_bar: value, left, top, width, height, style, min, max, back_color, progress_color, frame_color; |
26 | //progress_bar: value, left, top, width, height, style, min, max, back_color, progress_color, frame_color; |
28 | 27 | ||
29 | - | ||
30 | byte downloader_opened; |
- | |
Line 31... | Line 28... | ||
31 | char downloader_stak[4096]; |
28 | |
32 | char str[2048]; |
29 | bool downloader_opened; |
33 | char aux[2048]; |
- | |
34 | 30 | char downloader_stak[4096]; |
|
35 | 31 | ||
36 | 32 | ||
Line 37... | Line 33... | ||
37 | void Downloader() |
33 | |
38 | { |
34 | void Downloader() |
Line 51... | Line 47... | ||
51 | ed.size = ed.pos = ed.shift = ed.shift_old = strlen(#downloader_edit); |
47 | ed.size = ed.pos = ed.shift = ed.shift_old = strlen(#downloader_edit); |
Line 52... | Line 48... | ||
52 | 48 | ||
53 | loop() switch(WaitEvent()) |
49 | loop() switch(WaitEvent()) |
54 | { |
50 | { |
55 | case evMouse: |
- | |
56 | if (!CheckActiveProcess(DL_Form.ID)) break; |
51 | case evMouse: |
57 | edit_box_mouse stdcall (#ed); |
52 | edit_box_mouse stdcall (#ed); |
Line 58... | Line 53... | ||
58 | break; |
53 | break; |
59 | 54 | ||
Line 85... | Line 80... | ||
85 | progressbar_draw stdcall(#pb); |
80 | progressbar_draw stdcall(#pb); |
86 | DrawDownloading(); |
81 | DrawDownloading(); |
87 | } |
82 | } |
88 | if (downloader.state == STATE_COMPLETED) |
83 | if (downloader.state == STATE_COMPLETED) |
89 | { |
84 | { |
90 | if (!dir_exists(#save_to)) CreateDir(#save_to); |
- | |
91 | strcpy(#filepath, #save_to); |
- | |
92 | chrcat(#filepath, '/'); |
- | |
93 | // Clean all slashes at the end |
- | |
94 | strcpy(#aux, #downloader_edit); |
85 | SaveDownloadedFile(); |
95 | while (aux[strlen(#aux)-1] == '/') { |
- | |
96 | aux[strlen(#aux)-1] = 0; |
- | |
97 | } |
- | |
98 | strcat(#filepath, #aux+strrchr(#aux, '/')); |
- | |
99 | - | ||
100 | for (i=0; i |
- | |
101 | - | ||
102 | if (CreateFile(downloader.data_downloaded_size, downloader.bufpointer, #filepath)==0) |
- | |
103 | sprintf(#notify_message, "%s%s%s",FILE_SAVED_AS,#filepath,"' -Dt"); |
- | |
104 | else |
- | |
105 | sprintf(#notify_message, "%s%s%s","'Download manager\nError! Can\96t save file as ",#filepath,"' -Et"); |
- | |
106 | - | ||
107 | notify(#notify_message); |
- | |
108 | StopDownloading(); |
86 | StopDownloading(); |
109 | DL_Draw_Window(); |
87 | DL_Draw_Window(); |
110 | break; |
88 | break; |
111 | } |
89 | } |
112 | } |
90 | } |
113 | } |
91 | } |
Line 114... | Line 92... | ||
114 | 92 | ||
115 | void Key_Scan(int id) |
93 | void Key_Scan(int id) |
116 | { |
94 | { |
117 | if (id==001) { downloader_opened=0; StopDownloading(); ExitProcess(); } |
95 | if (id==001) { downloader_opened=false; StopDownloading(); ExitProcess(); } |
118 | if (id==301) && (downloader.http_transfer <= 0) StartDownloading(); |
96 | if (id==301) && (downloader.httpd.transfer <= 0) StartDownloading(); |
119 | if (id==302) StopDownloading(); |
97 | if (id==302) StopDownloading(); |
- | 98 | if (id==305) RunProgram("/sys/File managers/Eolite", #save_to); |
|
- | 99 | if (id==306) { |
|
120 | if (id==305) RunProgram("/sys/File managers/Eolite", #save_to); |
100 | SetCurDir(#save_to); |
- | 101 | RunProgram("/sys/@open", #filepath); |
|
121 | if (id==306) RunProgram("/sys/@open", #filepath); |
102 | } |
Line 122... | Line 103... | ||
122 | } |
103 | } |
123 | 104 | ||
124 | void DL_Draw_Window() |
105 | void DL_Draw_Window() |
125 | { |
106 | { |
126 | int cleft = 15; |
107 | int cleft = 15; |
127 | int but_x = 0; |
108 | int but_x = 0; |
- | 109 | int but_y = 58; |
|
- | 110 | DrawBar(0,0, DL_Form.cwidth, DL_Form.cheight, system.color.work); |
|
128 | int but_y = 58; |
111 | DeleteButton(301); |
129 | DrawBar(0,0, DL_Form.cwidth, DL_Form.cheight, system.color.work); |
112 | DeleteButton(302); |
130 | DeleteButton(305); |
113 | DeleteButton(305); |
131 | DeleteButton(306); |
114 | DeleteButton(306); |
132 | if (downloader.state == STATE_NOT_STARTED) || (downloader.state == STATE_COMPLETED) |
115 | if (downloader.state == STATE_NOT_STARTED) || (downloader.state == STATE_COMPLETED) |
Line 138... | Line 121... | ||
138 | DrawStandartCaptButton(but_x, but_y, 306, OPEN_FILE_TEXT); |
121 | DrawStandartCaptButton(but_x, but_y, 306, OPEN_FILE_TEXT); |
139 | } |
122 | } |
140 | } |
123 | } |
141 | if (downloader.state == STATE_IN_PROGRESS) |
124 | if (downloader.state == STATE_IN_PROGRESS) |
142 | { |
125 | { |
143 | DrawCaptButton(DL_Form.width - 190, but_y, 167, 26, 302, system.color.work_button, system.color.work_button_text, STOP_DOWNLOADING); |
126 | DrawStandartCaptButton(DL_Form.width - 190, but_y, 302, STOP_DOWNLOADING); |
144 | DrawDownloading(); |
127 | DrawDownloading(); |
145 | } |
128 | } |
146 | WriteText(cleft, ed.top + 4, 0x90, system.color.work_text, "URL:"); |
129 | WriteText(cleft, ed.top + 4, 0x90, system.color.work_text, "URL:"); |
147 | ed.left = strlen("URL:")*8 + 10 + cleft; |
- | |
148 | ed.width = DL_Form.cwidth - ed.left - cleft - 3; |
130 | ed.width = DL_Form.cwidth - ed.left - cleft - 3; |
149 | ed.offset=0; |
131 | ed.offset=0; |
150 | DrawEditBox(#ed); |
132 | DrawEditBox(#ed); |
151 | } |
133 | } |
Line 182... | Line 164... | ||
182 | downloader.Stop(); |
164 | downloader.Stop(); |
183 | ed.blur_border_color = 0xFFFfff; |
165 | ed.blur_border_color = 0xFFFfff; |
184 | ed.flags = 10b; |
166 | ed.flags = 10b; |
185 | DL_Draw_Window(); |
167 | DL_Draw_Window(); |
186 | }=>280)>120)> |
168 | } |
187 | 169 | ||
- | 170 | void SaveDownloadedFile() |
|
- | 171 | { |
|
- | 172 | int i; |
|
- | 173 | char aux[2048]; |
|
- | 174 | char notify_message[4296]; |
|
- | 175 | ||
- | 176 | // Clean all slashes at the end |
|
- | 177 | strcpy(#aux, #downloader_edit); |
|
- | 178 | while (aux[strlen(#aux)-1] == '/') { |
|
- | 179 | aux[strlen(#aux)-1] = 0; |
|
- | 180 | } |
|
- | 181 | sprintf(#filepath, "%s/%s", #save_to, #aux+strrchr(#aux, '/')); |
|
- | 182 | ||
- | 183 | for (i=0; i |
|
- | 184 | ||
- | 185 | if (CreateFile(downloader.data_downloaded_size, downloader.bufpointer, #filepath)==0) |
|
- | 186 | sprintf(#notify_message, "%s%s%s",FILE_SAVED_AS,#filepath,"' -Dt"); |
|
- | 187 | else |
|
- | 188 | sprintf(#notify_message, "%s%s%s","'Download manager\nError! Can\96t save file as ",#filepath,"' -Et"); |
|
- | 189 | ||
- | 190 | notify(#notify_message); |
|
- | 191 | }=>280)>120)> |
|
- | 192 | ||
188 | 193 |