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