Rev 5709 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5709 | Rev 5714 | ||
---|---|---|---|
1 | //Leency & SoUrcerer, LGPL |
1 | //Leency & SoUrcerer, LGPL |
2 | //Hidnplayer |
2 | //Hidnplayer |
3 | 3 | ||
4 | #define LIST_INFO_H 59 |
4 | #define LIST_INFO_H 59 |
5 | int status_bar_h = 15; |
5 | int status_bar_h = 15; |
6 | 6 | ||
7 | 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}; |
7 | 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}; |
8 | 8 | ||
9 | char *listbuffer; |
9 | char *listbuffer; |
10 | char *listpointer; |
10 | char *listpointer; |
11 | 11 | ||
12 | char *mailstart; |
12 | char *mailstart; |
13 | char *mailend; |
13 | char *mailend; |
14 | int mailsize; |
14 | int mailsize; |
15 | 15 | ||
16 | 16 | ||
17 | enum { |
17 | enum { |
18 | GET_MAIL = 20, |
18 | GET_MAIL = 20, |
19 | SEND_MAIL, |
19 | SEND_MAIL, |
20 | DELETE_LETTER, |
20 | DELETE_LETTER, |
21 | SAVE_LETTER, |
21 | SAVE_LETTER, |
22 | STOP_LOADING, |
22 | STOP_LOADING, |
23 | EXIT_MAIL, |
23 | EXIT_MAIL, |
24 | CHANGE_CHARSET, |
24 | CHANGE_CHARSET, |
25 | CLOSE_CHANGE_CHARSET |
25 | CLOSE_CHANGE_CHARSET |
26 | }; |
26 | }; |
27 | 27 | ||
28 | void MailBoxNetworkProcess() { |
28 | void MailBoxNetworkProcess() { |
29 | int load_persent; |
29 | int load_persent; |
30 | if (aim) switch(aim) |
30 | if (aim) switch(aim) |
31 | { |
31 | { |
32 | case SEND_NSTAT: |
32 | case SEND_NSTAT: |
33 | SetMailBoxStatus(NULL, "Counting mail, awaiting answer..."); |
33 | SetMailBoxStatus(NULL, "Counting mail, awaiting answer..."); |
34 | request_len = GetRequest("STAT", NULL); |
34 | request_len = GetRequest("STAT", NULL); |
35 | Send(socketnum, #request, request_len, 0); |
35 | Send(socketnum, #request, request_len, 0); |
36 | if (EAX == 0xffffffff) { debugln("Error sending STAT. Retry..."w); break;} |
36 | if (EAX == 0xffffffff) { debugln("Error sending STAT. Retry..."w); break;} |
37 | aim = GET_ANSWER_NSTAT; |
37 | aim = GET_ANSWER_NSTAT; |
38 | break; |
38 | break; |
39 | 39 | ||
40 | case GET_ANSWER_NSTAT: |
40 | case GET_ANSWER_NSTAT: |
41 | ticks = Receive(socketnum, #immbuffer, BUFFERSIZE, 0); |
41 | ticks = Receive(socketnum, #immbuffer, BUFFERSIZE, 0); |
42 | if ((ticks == 0xffffff) || (ticks < 2)) break; |
42 | if ((ticks == 0xffffff) || (ticks < 2)) break; |
43 | 43 | ||
44 | if (immbuffer[ticks-2]=='\n') |
44 | if (immbuffer[ticks-2]=='\n') |
45 | { |
45 | { |
46 | debugln(#immbuffer); |
46 | debugln(#immbuffer); |
47 | if (strstr(#immbuffer,"+OK")) |
47 | if (strstr(#immbuffer,"+OK")) |
48 | { |
48 | { |
49 | strcpyb(#immbuffer, #param, "+OK ", " "); |
49 | strcpyb(#immbuffer, #param, "+OK ", " "); |
50 | mail_list.count = atoi(#param); |
50 | mail_list.count = atoi(#param); |
51 | free(listbuffer); |
51 | free(listbuffer); |
52 | listbuffer = mem_Alloc(30*mail_list.count); //24* original |
52 | listbuffer = mem_Alloc(30*mail_list.count); //24* original |
53 | listpointer = listbuffer; |
53 | listpointer = listbuffer; |
54 | aim = SEND_NLIST; |
54 | aim = SEND_NLIST; |
55 | debugln("Receiving mail list..."); |
55 | debugln("Receiving mail list..."); |
56 | } |
56 | } |
57 | else |
57 | else |
58 | { |
58 | { |
59 | StopConnect("Sorry, can't recieve your mail"); |
59 | StopConnect("Sorry, can't recieve your mail"); |
60 | } |
60 | } |
61 | } |
61 | } |
62 | break; |
62 | break; |
63 | 63 | ||
64 | case SEND_NLIST: |
64 | case SEND_NLIST: |
65 | WriteText(5, Form.cheight-11, 0x80, system.color.work_text, "Send LIST, awaiting answer..."); |
65 | WriteText(5, Form.cheight-11, 0x80, system.color.work_text, "Send LIST, awaiting answer..."); |
66 | request_len = GetRequest("LIST", NULL); |
66 | request_len = GetRequest("LIST", NULL); |
67 | Send(socketnum, #request, request_len, 0); |
67 | Send(socketnum, #request, request_len, 0); |
68 | if (EAX == 0xffffffff) {debugln("Error while sending LIST. Retry..."); break;} |
68 | if (EAX == 0xffffffff) {debugln("Error while sending LIST. Retry..."); break;} |
69 | else aim = GET_ANSWER_NLIST; |
69 | else aim = GET_ANSWER_NLIST; |
70 | break; |
70 | break; |
71 | 71 | ||
72 | case GET_ANSWER_NLIST: |
72 | case GET_ANSWER_NLIST: |
73 | ticks = Receive(socketnum, listpointer, listbuffer + 30*mail_list.count - listpointer, MSG_DONTWAIT); |
73 | ticks = Receive(socketnum, listpointer, listbuffer + 30*mail_list.count - listpointer, MSG_DONTWAIT); |
74 | if (ticks == 0xffffffff) break; |
74 | if (ticks == 0xffffffff) break; |
75 | listpointer = listpointer + ticks; |
75 | listpointer = listpointer + ticks; |
76 | 76 | ||
77 | if (listpointer - listbuffer < 5) break; |
77 | if (listpointer - listbuffer < 5) break; |
78 | if (strncmp(listpointer-5,"\n.\n",5)==0) // note that c-- assembles "\n.\n" to 0x0d, 0x0a, 0x2e, 0x0d, 0x0a |
78 | if (strncmp(listpointer-5,"\n.\n",5)==0) // note that c-- assembles "\n.\n" to 0x0d, 0x0a, 0x2e, 0x0d, 0x0a |
79 | { |
79 | { |
80 | aim = SEND_RETR; |
80 | aim = SEND_RETR; |
81 | debugln("goto SEND_RETR"); |
81 | debugln("goto SEND_RETR"); |
82 | DrawMailBox(); |
82 | DrawMailBox(); |
83 | 83 | ||
84 | *listpointer='\0'; |
84 | *listpointer='\0'; |
85 | atr.CreateArray(); |
85 | atr.CreateArray(); |
86 | atr.SetSizes(); |
86 | atr.SetSizes(); |
87 | } |
87 | } |
88 | break; |
88 | break; |
89 | 89 | ||
90 | case SEND_RETR: |
90 | case SEND_RETR: |
91 | from = to = date = subj = cur_charset = NULL; |
91 | from = to = date = subj = cur_charset = NULL; |
92 | WB1.list.ClearList(); |
92 | WB1.list.ClearList(); |
93 | DrawMailBox(); |
93 | DrawMailBox(); |
94 | request_len = GetRequest("RETR", itoa(mail_list.current+1)); |
94 | request_len = GetRequest("RETR", itoa(mail_list.current+1)); |
95 | if (Send(socketnum, #request, request_len, 0) == 0xffffffff) |
95 | if (Send(socketnum, #request, request_len, 0) == 0xffffffff) |
96 | { |
96 | { |
97 | StopConnect("Error while trying to get letter from server"); |
97 | StopConnect("Error while trying to get letter from server"); |
98 | break; |
98 | break; |
99 | } |
99 | } |
100 | mailsize = atr.GetSize(mail_list.current+1) + 1024; |
100 | mailsize = atr.GetSize(mail_list.current+1) + 1024; |
101 | free(mailstart); |
101 | free(mailstart); |
102 | mailstart = malloc(mailsize); |
102 | mailstart = malloc(mailsize); |
103 | mailend = mailstart; |
103 | mailend = mailstart; |
104 | if (!mailstart) |
104 | if (!mailstart) |
105 | { |
105 | { |
106 | debugln("alloc error!"); |
106 | debugln("alloc error!"); |
107 | aim=NULL; |
107 | aim=NULL; |
108 | break; |
108 | break; |
109 | } |
109 | } |
110 | debug("mailsize: "); debugi(mailsize); |
110 | debug("mailsize: "); debugi(mailsize); |
111 | aim = GET_ANSWER_RETR; |
111 | aim = GET_ANSWER_RETR; |
112 | debugln("goto GET_ANSWER_RETR"); |
112 | debugln("goto GET_ANSWER_RETR"); |
113 | break; |
113 | break; |
114 | 114 | ||
115 | case GET_ANSWER_RETR: |
115 | case GET_ANSWER_RETR: |
116 | debug("mailsize: "); debugi(mailsize); |
116 | debug("mailsize: "); debugi(mailsize); |
117 | debug("mailstart: "); debugi(mailstart); |
117 | debug("mailstart: "); debugi(mailstart); |
118 | debug("mailend: "); debugi(mailend); |
118 | debug("mailend: "); debugi(mailend); |
119 | ticks = Receive(socketnum, mailend, mailsize + mailstart - mailend, MSG_DONTWAIT); |
119 | ticks = Receive(socketnum, mailend, mailsize + mailstart - mailend, MSG_DONTWAIT); |
120 | if (ticks == 0xffffffff) break; |
120 | if (ticks == 0xffffffff) break; |
121 | mailend = mailend + ticks; |
121 | mailend = mailend + ticks; |
122 | if (mailsize + mailstart - mailend - 2 < 0) |
122 | if (mailsize + mailstart - mailend - 2 < 0) |
123 | { |
123 | { |
124 | debugln("Resizing buffer"); |
124 | debugln("Resizing buffer"); |
125 | mailsize += 4096; |
125 | mailsize += 4096; |
126 | mailstart = realloc(mailstart, mailsize); |
126 | mailstart = realloc(mailstart, mailsize); |
127 | if (!mailstart) { StopConnect("Realloc error!"); break;} |
127 | if (!mailstart) { StopConnect("Realloc error!"); break;} |
128 | } |
128 | } |
129 | /* |
129 | /* |
130 | if (mailsize>9000) |
130 | if (mailsize>9000) |
131 | { |
131 | { |
132 | load_persent = mailend - mailstart * 100 ; |
132 | load_persent = mailend - mailstart * 100 ; |
133 | load_persent /= mailsize - 1024; |
133 | load_persent /= mailsize - 1024; |
134 | if (load_persent != cur_st_percent) SetMailBoxStatus( load_persent , NULL); |
134 | if (load_persent != cur_st_percent) SetMailBoxStatus( load_persent , NULL); |
135 | } |
135 | } |
136 | */ |
136 | */ |
137 | //ParseMail(); |
137 | //ParseMail(); |
138 | } |
138 | } |
139 | } |
139 | } |
140 | 140 | ||
141 | 141 | ||
142 | void MailBoxLoop() { |
142 | void MailBoxLoop() { |
143 | int key, id; |
143 | int id; |
144 | int panels_drag=0, clicked_list=0; |
144 | int panels_drag=0, clicked_list=0; |
145 | dword line_col, text_col; |
145 | dword line_col, text_col; |
146 | 146 | ||
147 | mail_list.h = Form.cheight/4; |
147 | mail_list.h = Form.cheight/4; |
148 | mail_list.ClearList(); |
148 | mail_list.ClearList(); |
149 | SetMailBoxStatus( NULL , NULL); |
149 | SetMailBoxStatus( NULL , NULL); |
150 | cur_charset = 0; |
150 | cur_charset = 0; |
151 | aim = SEND_NSTAT; |
151 | aim = SEND_NSTAT; |
152 | 152 | ||
153 | goto _MB_DRAW; |
153 | goto _MB_DRAW; |
154 | 154 | ||
155 | loop() |
155 | loop() |
156 | { |
156 | { |
157 | WaitEventTimeout(2); |
157 | WaitEventTimeout(2); |
158 | switch(EAX & 0xFF) |
158 | switch(EAX & 0xFF) |
159 | { |
159 | { |
160 | case evMouse: |
160 | case evMouse: |
161 | IF (!CheckActiveProcess(Form.ID)) break; |
161 | IF (!CheckActiveProcess(Form.ID)) break; |
162 | mouse.get(); |
162 | mouse.get(); |
163 | 163 | ||
164 | if (!mouse.lkm) panels_drag=0; |
164 | if (!mouse.lkm) panels_drag=0; |
165 | if (mouse.lkm) && (mouse.y>mail_list.y+mail_list.h-1) && (mouse.y |
165 | if (mouse.lkm) && (mouse.y>mail_list.y+mail_list.h-1) && (mouse.y |
166 | && (!scroll1.delta2) && (!scroll_wv.delta2) panels_drag = 1; |
166 | && (!scroll1.delta2) && (!scroll_wv.delta2) panels_drag = 1; |
167 | if (panels_drag) |
167 | if (panels_drag) |
168 | { |
168 | { |
169 | if (mouse.y |
169 | if (mouse.y |
170 | mail_list.h = mouse.y - mail_list.y-2; |
170 | mail_list.h = mouse.y - mail_list.y-2; |
171 | DrawMailBox(); |
171 | DrawMailBox(); |
172 | break; |
172 | break; |
173 | } |
173 | } |
174 | 174 | ||
175 | PageLinks.Hover(mouse.x, mouse.y, link_color_inactive, link_color_active, bg_color); |
175 | PageLinks.Hover(mouse.x, mouse.y, link_color_inactive, link_color_active, bg_color); |
176 | 176 | ||
177 | if (!mail_list.count) break; |
177 | if (!mail_list.count) break; |
178 | if (!panels_drag) { scrollbar_v_mouse (#scroll1); scrollbar_v_mouse (#scroll_wv); } |
178 | if (!panels_drag) { scrollbar_v_mouse (#scroll1); scrollbar_v_mouse (#scroll_wv); } |
179 | 179 | ||
180 | if (mail_list.first <> scroll1.position) |
180 | if (mail_list.first <> scroll1.position) |
181 | { |
181 | { |
182 | mail_list.first = scroll1.position; |
182 | mail_list.first = scroll1.position; |
183 | DrawMailList(); |
183 | DrawMailList(); |
184 | break; |
184 | break; |
185 | }; |
185 | }; |
186 | if (WB1.list.first <> scroll_wv.position) |
186 | if (WB1.list.first <> scroll_wv.position) |
187 | { |
187 | { |
188 | WB1.list.first = scroll_wv.position; |
188 | WB1.list.first = scroll_wv.position; |
189 | DrawLetter(); |
189 | DrawLetter(); |
190 | break; |
190 | break; |
191 | }; |
191 | }; |
192 | 192 | ||
193 | if (mail_list.y+mail_list.h + 10 > mouse.y) |
193 | if (mail_list.y+mail_list.h + 10 > mouse.y) |
194 | { |
194 | { |
195 | if (mail_list.MouseScroll(mouse.vert)) DrawMailList(); |
195 | if (mail_list.MouseScroll(mouse.vert)) DrawMailList(); |
196 | } |
196 | } |
197 | else |
197 | else |
198 | { |
198 | { |
199 | if (WB1.list.MouseScroll(mouse.vert)) DrawLetter(); |
199 | if (WB1.list.MouseScroll(mouse.vert)) DrawLetter(); |
200 | } |
200 | } |
201 | if (mouse.lkm) && (mail_list.MouseOver(mouse.x, mouse.y)) && (!clicked_list) clicked_list=1; |
201 | if (mouse.lkm) && (mail_list.MouseOver(mouse.x, mouse.y)) && (!clicked_list) clicked_list=1; |
202 | if (!mouse.lkm) && (clicked_list) if (mail_list.ProcessMouse(mouse.x, mouse.y)) |
202 | if (!mouse.lkm) && (clicked_list) if (mail_list.ProcessMouse(mouse.x, mouse.y)) |
203 | { |
203 | { |
204 | clicked_list = 0; |
204 | clicked_list = 0; |
205 | if (aim) break; |
205 | if (aim) break; |
206 | DrawMailList(); |
206 | DrawMailList(); |
207 | aim = SEND_RETR; |
207 | aim = SEND_RETR; |
208 | } |
208 | } |
209 | 209 | ||
210 | break; |
210 | break; |
211 | case evButton: |
211 | case evButton: |
212 | id = GetButtonID(); |
212 | id = GetButtonID(); |
213 | if (id==1) SaveAndExit(); |
213 | if (id==1) SaveAndExit(); |
214 | if (id==GET_MAIL) aim = SEND_NSTAT; |
214 | if (id==GET_MAIL) aim = SEND_NSTAT; |
215 | if (id==SAVE_LETTER) |
215 | if (id==SAVE_LETTER) |
216 | { |
216 | { |
217 | if (!mailstart) break; |
217 | if (!mailstart) break; |
218 | WriteFile(strlen(mailstart), mailstart, "mail.txt"); |
218 | WriteFile(strlen(mailstart), mailstart, "mail.txt"); |
219 | pause(10); |
219 | pause(10); |
220 | RunProgram("tinypad", "mail.txt"); |
220 | RunProgram("tinypad", "mail.txt"); |
221 | } |
221 | } |
222 | if (id==STOP_LOADING) |
222 | if (id==STOP_LOADING) |
223 | { |
223 | { |
224 | StopLoading(); |
224 | StopLoading(); |
225 | DrawStatusBar(); |
225 | DrawStatusBar(); |
226 | DrawMailList(); |
226 | DrawMailList(); |
227 | } |
227 | } |
228 | if (id==EXIT_MAIL) |
228 | if (id==EXIT_MAIL) |
229 | { |
229 | { |
230 | StopLoading(); |
230 | StopLoading(); |
231 | Close(socketnum); |
231 | Close(socketnum); |
232 | LoginBoxLoop(); |
232 | LoginBoxLoop(); |
233 | } |
233 | } |
234 | if (id==CHANGE_CHARSET) |
234 | if (id==CHANGE_CHARSET) |
235 | { |
235 | { |
236 | DefineButton(0,0,Form.cwidth,Form.cheight, CLOSE_CHANGE_CHARSET+BT_HIDE+BT_NOFRAME); |
236 | DefineButton(0,0,Form.cwidth,Form.cheight, CLOSE_CHANGE_CHARSET+BT_HIDE+BT_NOFRAME); |
237 | DrawRectangle(Form.cwidth-100, Form.cheight-status_bar_h- 70, 70, 82, system.color.work_graph); |
237 | DrawRectangle(Form.cwidth-100, Form.cheight-status_bar_h- 70, 70, 82, system.color.work_graph); |
238 | DrawRectangle3D(Form.cwidth-99, Form.cheight-status_bar_h- 69, 68, 80, 0xFFFfff, system.color.work); |
238 | DrawRectangle3D(Form.cwidth-99, Form.cheight-status_bar_h- 69, 68, 80, 0xFFFfff, system.color.work); |
239 | for (id=0; id<5; id++) |
239 | for (id=0; id<5; id++) |
240 | { |
240 | { |
241 | if (cur_charset==id+1) { line_col=system.color.work_button; text_col=system.color.work_button_text; } |
241 | if (cur_charset==id+1) { line_col=system.color.work_button; text_col=system.color.work_button_text; } |
242 | else { line_col=system.color.work; text_col=system.color.work_text; } |
242 | else { line_col=system.color.work; text_col=system.color.work_text; } |
243 | DrawBar(Form.cwidth-98, id*16+Form.cheight-status_bar_h- 68, 67, 16, line_col); |
243 | DrawBar(Form.cwidth-98, id*16+Form.cheight-status_bar_h- 68, 67, 16, line_col); |
244 | DrawCaptButton(Form.cwidth-100, id*16+Form.cheight-status_bar_h- 68, 70,16, 10+id+BT_HIDE, |
244 | DrawCaptButton(Form.cwidth-100, id*16+Form.cheight-status_bar_h- 68, 70,16, 10+id+BT_HIDE, |
245 | 0, text_col, charsets[id+1]); |
245 | 0, text_col, charsets[id+1]); |
246 | } |
246 | } |
247 | } |
247 | } |
248 | if (id==CLOSE_CHANGE_CHARSET) goto _MB_DRAW; |
248 | if (id==CLOSE_CHANGE_CHARSET) goto _MB_DRAW; |
249 | 249 | ||
250 | break; |
250 | break; |
251 | case evKey: |
251 | case evKey: |
252 | key = GetKey(); |
252 | GetKeys(); |
253 | 253 | ||
254 | if (!aim) && (mail_list.ProcessKey(key)) |
254 | if (!aim) && (mail_list.ProcessKey(key_scancode)) |
255 | { |
255 | { |
256 | DrawMailList(); |
256 | DrawMailList(); |
257 | aim = SEND_RETR; |
257 | aim = SEND_RETR; |
258 | } |
258 | } |
259 | 259 | ||
260 | break; |
260 | break; |
261 | case evReDraw: _MB_DRAW: |
261 | case evReDraw: _MB_DRAW: |
262 | if !(DefineWindow(MAILBOX_HEADER)) break; |
262 | if !(DefineWindow(MAILBOX_HEADER)) break; |
263 | scroll1.bckg_col = scroll_wv.bckg_col = 0xBBBbbb; |
263 | scroll1.bckg_col = scroll_wv.bckg_col = 0xBBBbbb; |
264 | scroll1.frnt_col = scroll_wv.frnt_col = system.color.work; |
264 | scroll1.frnt_col = scroll_wv.frnt_col = system.color.work; |
265 | scroll1.line_col = scroll_wv.line_col = system.color.work_graph; |
265 | scroll1.line_col = scroll_wv.line_col = system.color.work_graph; |
266 | DrawToolbar(); |
266 | DrawToolbar(); |
267 | DrawMailBox(); |
267 | DrawMailBox(); |
268 | 268 | ||
269 | break; |
269 | break; |
270 | default: |
270 | default: |
271 | MailBoxNetworkProcess(); |
271 | MailBoxNetworkProcess(); |
272 | } |
272 | } |
273 | } |
273 | } |
274 | } |
274 | } |
275 | 275 | ||
276 | 276 | ||
277 | void DrawMailBox() |
277 | void DrawMailBox() |
278 | { |
278 | { |
279 | DrawMailList(); |
279 | DrawMailList(); |
280 | DrawLetterInfo(); |
280 | DrawLetterInfo(); |
281 | InitTWB(); |
281 | InitTWB(); |
282 | DrawLetter(); |
282 | DrawLetter(); |
283 | DrawStatusBar(); |
283 | DrawStatusBar(); |
284 | } |
284 | } |
285 | 285 | ||
286 | 286 | ||
287 | void DrawToolbar() { |
287 | void DrawToolbar() { |
288 | #define BUT_Y 7 |
288 | #define BUT_Y 7 |
289 | #define BUT_H 22 |
289 | #define BUT_H 22 |
290 | #define BUT_W 74 |
290 | #define BUT_W 74 |
291 | int toolbar_w = BUT_Y + BUT_H + BUT_Y + 3; |
291 | int toolbar_w = BUT_Y + BUT_H + BUT_Y + 3; |
292 | mail_list.SetSizes(0, toolbar_w, Form.cwidth - scroll1.size_x - 1, mail_list.h, 18); |
292 | mail_list.SetSizes(0, toolbar_w, Form.cwidth - scroll1.size_x - 1, mail_list.h, 18); |
293 | 293 | ||
294 | DrawBar(0,0, Form.cwidth,toolbar_w-3, system.color.work); |
294 | DrawBar(0,0, Form.cwidth,toolbar_w-3, system.color.work); |
295 | DrawCaptButton(10 , BUT_Y, BUT_W, BUT_H, GET_MAIL, system.color.work_button, system.color.work_button_text,"Get mail"); |
295 | DrawCaptButton(10 , BUT_Y, BUT_W, BUT_H, GET_MAIL, system.color.work_button, system.color.work_button_text,"Get mail"); |
296 | DrawCaptButton(BUT_W+ 20, BUT_Y, BUT_W+10, BUT_H, SAVE_LETTER, system.color.work_button, system.color.work_button_text,"Save letter"); |
296 | DrawCaptButton(BUT_W+ 20, BUT_Y, BUT_W+10, BUT_H, SAVE_LETTER, system.color.work_button, system.color.work_button_text,"Save letter"); |
297 | DrawCaptButton(Form.cwidth-BUT_W - 10, BUT_Y, BUT_W, BUT_H, EXIT_MAIL, system.color.work_button, system.color.work_button_text,"< Exit"); |
297 | DrawCaptButton(Form.cwidth-BUT_W - 10, BUT_Y, BUT_W, BUT_H, EXIT_MAIL, system.color.work_button, system.color.work_button_text,"< Exit"); |
298 | 298 | ||
299 | DrawBar(0, mail_list.y-3, mail_list.w,1, system.color.work_graph); |
299 | DrawBar(0, mail_list.y-3, mail_list.w,1, system.color.work_graph); |
300 | DrawBar(0, mail_list.y-2, mail_list.w,1, 0xdfdfdf); |
300 | DrawBar(0, mail_list.y-2, mail_list.w,1, 0xdfdfdf); |
301 | DrawBar(0, mail_list.y-1, mail_list.w,1, 0xf0f0f0); |
301 | DrawBar(0, mail_list.y-1, mail_list.w,1, 0xf0f0f0); |
302 | } |
302 | } |
303 | 303 | ||
304 | void DrawMailList() { |
304 | void DrawMailList() { |
305 | int i, on_y, on_x, direction; |
305 | int i, on_y, on_x, direction; |
306 | dword sel_col; |
306 | dword sel_col; |
307 | mail_list.visible = mail_list.h / mail_list.line_h; |
307 | mail_list.visible = mail_list.h / mail_list.line_h; |
308 | 308 | ||
309 | for (i=30; i<150; i++) DeleteButton(i); |
309 | for (i=30; i<150; i++) DeleteButton(i); |
310 | for (i=0; (i |
310 | for (i=0; (i |
311 | { |
311 | { |
312 | on_y = i*mail_list.line_h + mail_list.y; |
312 | on_y = i*mail_list.line_h + mail_list.y; |
313 | if (mail_list.current==mail_list.first+i) sel_col=0xEEEeee; else sel_col=0xFFFfff; |
313 | if (mail_list.current==mail_list.first+i) sel_col=0xEEEeee; else sel_col=0xFFFfff; |
314 | DrawBar(0, on_y, mail_list.w, mail_list.line_h-1, sel_col); |
314 | DrawBar(0, on_y, mail_list.w, mail_list.line_h-1, sel_col); |
315 | direction = atr.GetDirection(i+mail_list.first+1); |
315 | direction = atr.GetDirection(i+mail_list.first+1); |
316 | on_x = strlen(itoa(i+mail_list.first+1))*6; |
316 | on_x = strlen(itoa(i+mail_list.first+1))*6; |
317 | letter_icons_pal[0]=sel_col; |
317 | letter_icons_pal[0]=sel_col; |
318 | PutPaletteImage(sizeof(letter_icons)/3*direction + #letter_icons, 18,12, on_x+18, |
318 | PutPaletteImage(sizeof(letter_icons)/3*direction + #letter_icons, 18,12, on_x+18, |
319 | mail_list.line_h-12/2+ on_y, 8, #letter_icons_pal); |
319 | mail_list.line_h-12/2+ on_y, 8, #letter_icons_pal); |
320 | WriteText(on_x + 42, on_y+5, 0x80, 0, atr.GetSubject(i+mail_list.first+1)); |
320 | WriteText(on_x + 42, on_y+5, 0x80, 0, atr.GetSubject(i+mail_list.first+1)); |
321 | DrawBar(0, on_y + mail_list.line_h-1, mail_list.w, 1, 0xCCCccc); |
321 | DrawBar(0, on_y + mail_list.line_h-1, mail_list.w, 1, 0xCCCccc); |
322 | WriteText(10, on_y+5, 0x80, 0, itoa(i+mail_list.first+1)); |
322 | WriteText(10, on_y+5, 0x80, 0, itoa(i+mail_list.first+1)); |
323 | WriteText(mail_list.w - 40, on_y+5, 0x80, 0, ConvertSize(atr.GetSize(i+mail_list.first+1))); |
323 | WriteText(mail_list.w - 40, on_y+5, 0x80, 0, ConvertSize(atr.GetSize(i+mail_list.first+1))); |
324 | } |
324 | } |
325 | DrawBar(0, i*mail_list.line_h + mail_list.y, mail_list.w, -i*mail_list.line_h+mail_list.h, 0xFFFfff); |
325 | DrawBar(0, i*mail_list.line_h + mail_list.y, mail_list.w, -i*mail_list.line_h+mail_list.h, 0xFFFfff); |
326 | DrawScroller1(); |
326 | DrawScroller1(); |
327 | } |
327 | } |
328 | 328 | ||
329 | void DrawLetterInfo() { |
329 | void DrawLetterInfo() { |
330 | int lt_y = mail_list.y+mail_list.h; |
330 | int lt_y = mail_list.y+mail_list.h; |
331 | DrawBar(0, lt_y, mail_list.w, 1, system.color.work_graph); |
331 | DrawBar(0, lt_y, mail_list.w, 1, system.color.work_graph); |
332 | DrawBar(0, lt_y+1, Form.cwidth, 1, LBUMP); |
332 | DrawBar(0, lt_y+1, Form.cwidth, 1, LBUMP); |
333 | DrawBar(0, lt_y+2, Form.cwidth, LIST_INFO_H-4, system.color.work); |
333 | DrawBar(0, lt_y+2, Form.cwidth, LIST_INFO_H-4, system.color.work); |
334 | WriteText(mail_list.w-30/2, lt_y, 0x80, 0x888888, "= = ="); |
334 | WriteText(mail_list.w-30/2, lt_y, 0x80, 0x888888, "= = ="); |
335 | WriteText(mail_list.w-30/2, lt_y+1, 0x80, 0xEeeeee, "= = ="); |
335 | WriteText(mail_list.w-30/2, lt_y+1, 0x80, 0xEeeeee, "= = ="); |
336 | DrawBar(0, lt_y+LIST_INFO_H-2, Form.cwidth, 1, system.color.work_graph); //bottom |
336 | DrawBar(0, lt_y+LIST_INFO_H-2, Form.cwidth, 1, system.color.work_graph); //bottom |
337 | DrawBar(0, lt_y+LIST_INFO_H-1, Form.cwidth, 1, 0xdfdfdf); |
337 | DrawBar(0, lt_y+LIST_INFO_H-1, Form.cwidth, 1, 0xdfdfdf); |
338 | DrawBar(0, lt_y+LIST_INFO_H , Form.cwidth, 1, 0xf0f0f0); |
338 | DrawBar(0, lt_y+LIST_INFO_H , Form.cwidth, 1, 0xf0f0f0); |
339 | WriteTextB(10, lt_y+8 , 0x80, system.color.work_text, "From:"); |
339 | WriteTextB(10, lt_y+8 , 0x80, system.color.work_text, "From:"); |
340 | WriteText (45, lt_y+8 , 0x80, system.color.work_text, #from); |
340 | WriteText (45, lt_y+8 , 0x80, system.color.work_text, #from); |
341 | WriteTextB(10, lt_y+20, 0x80, system.color.work_text, "To:"); |
341 | WriteTextB(10, lt_y+20, 0x80, system.color.work_text, "To:"); |
342 | WriteText (45, lt_y+20, 0x80, system.color.work_text, #to); |
342 | WriteText (45, lt_y+20, 0x80, system.color.work_text, #to); |
343 | WriteTextB(10, lt_y+32, 0x80, system.color.work_text, "Date:"); |
343 | WriteTextB(10, lt_y+32, 0x80, system.color.work_text, "Date:"); |
344 | WriteText (45, lt_y+32, 0x80, system.color.work_text, #date); |
344 | WriteText (45, lt_y+32, 0x80, system.color.work_text, #date); |
345 | WriteTextB(10, lt_y+44, 0x80, system.color.work_text, "Subj:"); |
345 | WriteTextB(10, lt_y+44, 0x80, system.color.work_text, "Subj:"); |
346 | WriteText (45, lt_y+44, 0x80, system.color.work_text, #subj); |
346 | WriteText (45, lt_y+44, 0x80, system.color.work_text, #subj); |
347 | } |
347 | } |
348 | 348 | ||
349 | 349 | ||
350 | void InitTWB() { |
350 | void InitTWB() { |
351 | WB1.list.SetSizes(0, mail_list.y+mail_list.h+LIST_INFO_H+1, Form.cwidth - scroll_wv.size_x - 1, |
351 | WB1.list.SetSizes(0, mail_list.y+mail_list.h+LIST_INFO_H+1, Form.cwidth - scroll_wv.size_x - 1, |
352 | Form.cheight - mail_list.y - mail_list.h - LIST_INFO_H - 1 - status_bar_h, 12); |
352 | Form.cheight - mail_list.y - mail_list.h - LIST_INFO_H - 1 - status_bar_h, 12); |
353 | WB1.list.column_max = WB1.list.w - 30 / 6; |
353 | WB1.list.column_max = WB1.list.w - 30 / 6; |
354 | WB1.list.visible = WB1.list.h / WB1.list.line_h; |
354 | WB1.list.visible = WB1.list.h / WB1.list.line_h; |
355 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h); |
355 | WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.h); |
356 | 356 | ||
357 | strcpy(#header, #version); |
357 | strcpy(#header, #version); |
358 | pre_text = 0; |
358 | pre_text = 0; |
359 | WB1.list.first = WB1.list.count = 0; |
359 | WB1.list.first = WB1.list.count = 0; |
360 | } |
360 | } |
361 | 361 | ||
362 | void DrawLetter() { |
362 | void DrawLetter() { |
363 | pre_text = 2; |
363 | pre_text = 2; |
364 | bufsize = strlen(mdata); |
364 | bufsize = strlen(mdata); |
365 | WB1.Prepare(bufsize, mdata); |
365 | WB1.Prepare(bufsize, mdata); |
366 | if (bufsize) WB1.Parse(); |
366 | if (bufsize) WB1.Parse(); |
367 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, 0xFFFfff); |
367 | DrawRectangle(scroll_wv.start_x, scroll_wv.start_y, scroll_wv.size_x, scroll_wv.size_y-1, 0xFFFfff); |
368 | } |
368 | } |
369 | 369 | ||
370 | 370 | ||
371 | void DrawScroller1() { |
371 | void DrawScroller1() { |
372 | scroll1.max_area = mail_list.count; |
372 | scroll1.max_area = mail_list.count; |
373 | scroll1.cur_area = mail_list.visible; |
373 | scroll1.cur_area = mail_list.visible; |
374 | scroll1.position = mail_list.first; |
374 | scroll1.position = mail_list.first; |
375 | scroll1.all_redraw=1; |
375 | scroll1.all_redraw=1; |
376 | scroll1.start_x = mail_list.x + mail_list.w; |
376 | scroll1.start_x = mail_list.x + mail_list.w; |
377 | scroll1.start_y = mail_list.y - 3; |
377 | scroll1.start_y = mail_list.y - 3; |
378 | scroll1.size_y = mail_list.h + 4; |
378 | scroll1.size_y = mail_list.h + 4; |
379 | scrollbar_v_draw(#scroll1); |
379 | scrollbar_v_draw(#scroll1); |
380 | } |
380 | } |
381 | 381 | ||
382 | 382 | ||
383 | 383 | ||
384 | void DrawStatusBar() { |
384 | void DrawStatusBar() { |
385 | int st_y = Form.cheight -status_bar_h; |
385 | int st_y = Form.cheight -status_bar_h; |
386 | DrawBar(0, st_y, Form.cwidth, status_bar_h, system.color.work); |
386 | DrawBar(0, st_y, Form.cwidth, status_bar_h, system.color.work); |
387 | if (aim) { |
387 | if (aim) { |
388 | SetMailBoxStatus(cur_st_percent, cur_st_text); |
388 | SetMailBoxStatus(cur_st_percent, cur_st_text); |
389 | DrawCaptButton(240, st_y+1, 36, status_bar_h-3, STOP_LOADING, system.color.work_button, system.color.work_button_text,"Stop"); |
389 | DrawCaptButton(240, st_y+1, 36, status_bar_h-3, STOP_LOADING, system.color.work_button, system.color.work_button_text,"Stop"); |
390 | } |
390 | } |
391 | DrawCaptButton(Form.cwidth - 100, st_y+1, 70, status_bar_h-2, CHANGE_CHARSET+BT_HIDE, system.color.work, system.color.work_text,charsets[cur_charset]); |
391 | DrawCaptButton(Form.cwidth - 100, st_y+1, 70, status_bar_h-2, CHANGE_CHARSET+BT_HIDE, system.color.work, system.color.work_text,charsets[cur_charset]); |
392 | } |
392 | } |
393 | 393 | ||
394 | 394 | ||
395 | 395 | ||
396 | void SetMailBoxStatus(dword percent1, text1) { |
396 | void SetMailBoxStatus(dword percent1, text1) { |
397 | DrawProgressBar(3, Form.cheight -status_bar_h + 1, 220, 12, system.color.work, 0xC3C3C3, 0x54B1D6, system.color.work_text, percent1); |
397 | DrawProgressBar(3, Form.cheight -status_bar_h + 1, 220, 12, system.color.work, 0xC3C3C3, 0x54B1D6, system.color.work_text, percent1); |
398 | WriteText(3, Form.cheight -status_bar_h + 1, 0x80, system.color.work_text, text1); |
398 | WriteText(3, Form.cheight -status_bar_h + 1, 0x80, system.color.work_text, text1); |
399 | cur_st_percent = percent1; |
399 | cur_st_percent = percent1; |
400 | cur_st_text = text1; |
400 | cur_st_text = text1; |
401 | } |
401 | } |
402 | 402 | ||
403 | 403 | ||
404 | void StopLoading() { |
404 | void StopLoading() { |
405 | aim = NULL; |
405 | aim = NULL; |
406 | mailstart = free(mailstart); |
406 | mailstart = free(mailstart); |
407 | to = from = date = subj = cur_charset = NULL; |
407 | to = from = date = subj = cur_charset = NULL; |
408 | } |
408 | } |
409 | 409 | ||
410 | int GetLetterSize_(int number) { |
410 | int GetLetterSize_(int number) { |
411 | char search_num[24]; |
411 | char search_num[24]; |
412 | char mailsize1[24]; |
412 | char mailsize1[24]; |
413 | strcpy(#search_num, "\x0a"); // 0x0d, 0x0a |
413 | strcpy(#search_num, "\x0a"); // 0x0d, 0x0a |
414 | itoa_(#search_num+1, number); |
414 | itoa_(#search_num+1, number); |
415 | chrcat(#search_num, ' '); |
415 | chrcat(#search_num, ' '); |
416 | strcpyb(listbuffer, #mailsize1, #search_num, "\x0d"); |
416 | strcpyb(listbuffer, #mailsize1, #search_num, "\x0d"); |
417 | return atoi(#mailsize1); |
417 | return atoi(#mailsize1); |
418 | }150;>>5;>>> |
418 | }150;>>5;>>> |
419 | >>>> |
419 | >>>> |