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