Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3368 | leency | 1 | //Leency & SoUrcerer, LGPL |
2 | |||
3 | #define LIST_INFO_H 59 |
||
4 | int status_bar_h = 15; |
||
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}; |
||
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 | |||
9 | |||
10 | llist mail_list; |
||
11 | llist letter_view; |
||
12 | |||
13 | char from[256]; |
||
14 | char to[256]; |
||
15 | char date[256]; |
||
16 | char subj[256]; |
||
17 | dword mdata; |
||
18 | |||
19 | char *listbuffer; |
||
20 | char *listpointer; |
||
21 | |||
22 | char *mailbuffer; |
||
23 | char *mailpointer; |
||
24 | |||
25 | |||
26 | enum { |
||
27 | GET_MAIL = 20, |
||
28 | SEND_MAIL, |
||
29 | DELETE_LETTER, |
||
30 | SAVE_LETTER, |
||
31 | STOP_LOADING, |
||
32 | EXIT_MAIL, |
||
33 | CHANGE_CHARSET, |
||
34 | CLOSE_CHANGE_CHARSET |
||
35 | }; |
||
36 | |||
37 | |||
38 | void MailBoxLoop() |
||
39 | { |
||
40 | int key, id; |
||
41 | mouse m; |
||
42 | int panels_drag = 0; |
||
43 | char socket_char; |
||
44 | int letter_size; |
||
45 | dword line_col, text_col; |
||
46 | |||
47 | mail_list.h = Form.cheight/4; |
||
48 | mail_list.ClearList(); |
||
49 | SetMailBoxStatus( NULL , NULL); |
||
50 | cur_charset = 0; |
||
51 | |||
52 | goto _MB_DRAW; |
||
53 | |||
54 | loop() |
||
55 | { |
||
56 | WaitEventTimeout(2); |
||
57 | switch(EAX & 0xFF) |
||
58 | { |
||
59 | case evMouse: |
||
60 | IF (GetProcessSlot(Form.ID)-GetActiveProcess()!=0) break; |
||
61 | m.get(); |
||
62 | |||
63 | if (!m.lkm) panels_drag=0; |
||
64 | if (m.lkm) && (m.y>mail_list.y+mail_list.h-1) && (m.y |
||
65 | && (!scroll1.delta2) && (!scroll2.delta2) panels_drag = 1; |
||
66 | if (panels_drag) |
||
67 | { |
||
68 | if (m.y |
||
69 | mail_list.h = m.y - mail_list.y-2; |
||
70 | DrawMailBox(); |
||
71 | break; |
||
72 | } |
||
73 | |||
74 | if (!mail_list.count) break; |
||
75 | if (!panels_drag) { scrollbar_v_mouse (#scroll1); scrollbar_v_mouse (#scroll2); } |
||
76 | |||
77 | if (mail_list.first <> scroll1.position) |
||
78 | { |
||
79 | mail_list.first = scroll1.position; |
||
80 | DrawMailList(); |
||
81 | break; |
||
82 | }; |
||
83 | if (letter_view.first <> scroll2.position) |
||
84 | { |
||
85 | letter_view.first = scroll2.position; |
||
86 | DrawLetter(); |
||
87 | break; |
||
88 | }; |
||
89 | |||
90 | if (mail_list.y+mail_list.h + 10 > m.y) |
||
91 | { |
||
92 | if (mail_list.MouseScroll(m.vert)) DrawMailList(); |
||
93 | } |
||
94 | else |
||
95 | { |
||
96 | if (letter_view.MouseScroll(m.vert)) DrawLetter(); |
||
97 | } |
||
98 | |||
99 | break; |
||
100 | case evButton: |
||
101 | id = GetButtonID(); |
||
102 | if (id==1) SaveAndExit(); |
||
103 | if (id==GET_MAIL) aim = SEND_NSTAT; |
||
104 | if (id==SAVE_LETTER) |
||
105 | { |
||
106 | if (!mailbuffer) break; |
||
107 | WriteFile(strlen(mailbuffer), mailbuffer, "mail.txt"); |
||
108 | pause(10); |
||
109 | RunProgram("tinypad", "mail.txt"); |
||
110 | } |
||
111 | if (id==STOP_LOADING) |
||
112 | { |
||
113 | StopLoading(); |
||
114 | DrawStatusBar(); |
||
115 | DrawMailList(); |
||
116 | } |
||
117 | if (id==EXIT_MAIL) |
||
118 | { |
||
119 | StopLoading(); |
||
120 | LoginBoxLoop(); |
||
121 | } |
||
122 | if (id==CHANGE_CHARSET) |
||
123 | { |
||
124 | DefineButton(0,0,Form.cwidth,Form.cheight, CLOSE_CHANGE_CHARSET+BT_HIDE+BT_NOFRAME); |
||
125 | DrawRectangle(Form.cwidth-100, Form.cheight-status_bar_h- 70, 70, 82, sc.work_graph); |
||
126 | DrawRectangle3D(Form.cwidth-99, Form.cheight-status_bar_h- 69, 68, 80, 0xFFFfff, sc.work); |
||
127 | for (id=0; id<5; id++) |
||
128 | { |
||
129 | if (cur_charset==id+1) { line_col=sc.work_button; text_col=sc.work_button_text; } |
||
130 | else { line_col=sc.work; text_col=sc.work_text; } |
||
131 | DrawBar(Form.cwidth-98, id*16+Form.cheight-status_bar_h- 68, 67, 16, line_col); |
||
132 | DrawCaptButton(Form.cwidth-100, id*16+Form.cheight-status_bar_h- 68, 70,16, 10+id+BT_HIDE, |
||
133 | 0, text_col, charsets[id+1]); |
||
134 | } |
||
135 | } |
||
136 | if (id==CLOSE_CHANGE_CHARSET) goto _MB_DRAW; |
||
137 | |||
138 | if (id>=30) |
||
139 | { |
||
140 | if (aim) break; |
||
141 | mail_list.current = mail_list.first + id - 30; |
||
142 | DrawMailList(); |
||
143 | aim = SEND_RETR; |
||
144 | } |
||
145 | |||
146 | break; |
||
147 | case evKey: |
||
148 | key = GetKey(); |
||
149 | |||
150 | if (key == 177){ //down |
||
151 | if (aim) break; |
||
152 | if (mail_list.current >= mail_list.count-1) break; |
||
153 | mail_list.current++ ; |
||
154 | if (mail_list.current >= mail_list.first + mail_list.visible) mail_list.first++ ; |
||
155 | DrawMailList(); |
||
156 | aim = SEND_RETR; |
||
157 | } |
||
158 | if (key == 178){ //up |
||
159 | if (aim) break; |
||
160 | if (mail_list.current<=0) break; |
||
161 | mail_list.current-- ; |
||
162 | if (mail_list.current < mail_list.first) mail_list.first-- ; |
||
163 | DrawMailList(); |
||
164 | aim = SEND_RETR; |
||
165 | } |
||
166 | if (key == 180){ //home |
||
167 | if (aim) break; |
||
168 | mail_list.first = mail_list.current = 0; |
||
169 | DrawMailList(); |
||
170 | aim = SEND_RETR; |
||
171 | } |
||
172 | if (key == 181){ //end |
||
173 | if (aim) break; |
||
174 | mail_list.first = mail_list.count - mail_list.visible; |
||
175 | mail_list.current = mail_list.count - 1; |
||
176 | DrawMailList(); |
||
177 | aim = SEND_RETR; |
||
178 | } |
||
179 | |||
180 | break; |
||
181 | case evReDraw: _MB_DRAW: |
||
182 | if !(DefineWindow(MAILBOX_HEADER)) break; |
||
183 | scroll1.bckg_col = scroll2.bckg_col = 0xBBBbbb; |
||
184 | scroll1.frnt_col = scroll2.frnt_col = sc.work; |
||
185 | scroll1.line_col = scroll2.line_col = sc.work_graph; |
||
186 | DrawToolbar(); |
||
187 | DrawMailBox(); |
||
188 | |||
189 | break; |
||
190 | default: |
||
191 | if (aim == SEND_NSTAT) |
||
192 | { |
||
193 | debug("Counting mail, awaiting answer..."); |
||
194 | request_len = GetRequest("STAT", NULL); |
||
195 | WriteSocket(socket,request_len,#request); |
||
196 | if (EAX == 0xffffffff) { debug("Error sending STAT. Retry..."w); break;} |
||
197 | aim = GET_ANSWER_NSTAT; |
||
198 | } |
||
199 | |||
200 | if (aim == GET_ANSWER_NSTAT) |
||
201 | { |
||
202 | if (!PollSocket(socket)) break; |
||
203 | socket_char=ReadSocket(socket); |
||
204 | immputc(socket_char); |
||
205 | |||
206 | if (socket_char=='\n') |
||
207 | { |
||
208 | debug("GOT::"); |
||
209 | debug(#immbuffer); |
||
210 | if (strstr(#immbuffer,"+OK")) |
||
211 | { |
||
212 | mail_list.count = GetMailCount(); |
||
213 | debug("Letters:"); |
||
214 | debug(itoa(mail_list.count)); |
||
215 | listbuffer = free(listbuffer); |
||
216 | listbuffer = mem_Alloc(30*mail_list.count); //24* original |
||
217 | listpointer = listbuffer; |
||
218 | aim = SEND_NLIST; |
||
219 | debug("Recieving mail list..."); |
||
220 | immfree(); |
||
221 | } |
||
222 | else |
||
223 | { |
||
224 | notify("Sorry, can't recieve your mail"); |
||
225 | immfree(); |
||
226 | aim=NULL; //aim = SEND_NLIST; |
||
227 | } |
||
228 | } |
||
229 | } |
||
230 | |||
231 | if (aim == SEND_NLIST) |
||
232 | { |
||
233 | WriteText(5, Form.cheight-11, 0x80, sc.work_text, "Send LIST, awaiting answer..."); |
||
234 | request_len = GetRequest("LIST", NULL); |
||
235 | WriteSocket(socket,request_len,#request); |
||
236 | if (EAX == 0xffffffff) {debug("Error while sending LIST. Retry..."); break;} |
||
237 | aim = GET_ANSWER_NLIST; |
||
238 | } |
||
239 | |||
240 | if (aim == GET_ANSWER_NLIST) |
||
241 | { |
||
242 | ticks = PollSocket(socket); |
||
243 | if (!ticks) break; |
||
244 | for (;ticks>0;ticks--) |
||
245 | { |
||
246 | socket_char=ReadSocket(socket); |
||
247 | listputc(socket_char); |
||
248 | |||
249 | if (socket_char=='.') //this way of checking end of message IS BAD |
||
250 | { |
||
251 | aim = SEND_RETR; |
||
252 | debug("Got mail list"); |
||
253 | DrawMailBox(); |
||
254 | |||
255 | CreateMailsArray(); |
||
256 | SetMailsSizes(); |
||
257 | } |
||
258 | } |
||
259 | } |
||
260 | if (aim == SEND_RETR) |
||
261 | { |
||
262 | from = to = date = subj = cur_charset = NULL; |
||
263 | letter_view.ClearList(); |
||
264 | DrawMailBox(); |
||
265 | debug("Send RETR, awaiting answer..."); |
||
266 | request_len = GetRequest("RETR", itoa(mail_list.current+1)); |
||
267 | WriteSocket(socket,request_len,#request); |
||
268 | if (EAX == 0xffffffff) { notify("Error while trying to get letter from server"); aim=NULL; break;} |
||
269 | |||
270 | mailbuffer = free(mailbuffer); |
||
271 | letter_size = GetLetterSize(mail_list.current+1) + 1024; |
||
272 | mailbuffer = malloc(letter_size); |
||
273 | mailpointer = mailbuffer; |
||
274 | aim = GET_ANSWER_RETR; |
||
275 | } |
||
276 | if (aim == GET_ANSWER_RETR) |
||
277 | { |
||
278 | ticks=PollSocket(socket); |
||
279 | if (!ticks) break; |
||
280 | |||
281 | for (;ticks>0;ticks--) |
||
282 | { |
||
283 | socket_char=ReadSocket(socket); |
||
284 | //debugch(socket_char); |
||
285 | *mailpointer=socket_char; |
||
286 | mailpointer++; |
||
287 | *mailpointer='\0'; |
||
288 | if (!aim) continue; |
||
289 | |||
290 | if (letter_size + mailbuffer - mailpointer - 2 < 0) |
||
291 | { |
||
292 | debug("Buffer overflow!!1 Realloc..."w); |
||
293 | letter_size += 4096; |
||
294 | mailbuffer = realloc(mailbuffer, letter_size); |
||
295 | if (!mailbuffer) {debug("Relloc error!"); aim=NULL; break;} |
||
296 | } |
||
297 | |||
298 | if (letter_size>5000) |
||
299 | { |
||
300 | id = mailpointer - mailbuffer * 100 ; |
||
301 | id /= letter_size - 1024; |
||
302 | if (id!=cur_st_percent) SetMailBoxStatus( id , NULL); |
||
303 | } |
||
304 | |||
305 | ParceMail(); |
||
306 | } |
||
307 | } |
||
308 | |||
309 | } |
||
310 | } |
||
311 | } |
||
312 | |||
313 | |||
314 | void DrawMailBox() |
||
315 | { |
||
316 | DrawMailList(); |
||
317 | DrawLetterInfo(); |
||
318 | DrawLetter(); |
||
319 | DrawStatusBar(); |
||
320 | } |
||
321 | |||
322 | |||
323 | void DrawToolbar() |
||
324 | { |
||
325 | #define BUT_Y 7 |
||
326 | #define BUT_H 22 |
||
327 | #define BUT_W 74 |
||
328 | #define BUT_SPACE 11 |
||
329 | int toolbar_w = BUT_Y + BUT_H + BUT_Y + 3; |
||
330 | mail_list.SetSizes(0, toolbar_w, Form.cwidth - scroll1.size_x - 1, mail_list.h, 60,18); |
||
331 | |||
332 | DrawBar(0,0, Form.cwidth,toolbar_w-3, sc.work); |
||
333 | DrawCaptButton(10 , BUT_Y, BUT_W, BUT_H, GET_MAIL, sc.work_button, sc.work_button_text,"Get mail"); |
||
334 | DrawCaptButton(BUT_W+BUT_SPACE + 10, BUT_Y, BUT_W, BUT_H, SEND_MAIL, sc.work_button, sc.work_button_text,"Send Email"); |
||
335 | DrawCaptButton(BUT_W+BUT_SPACE*2 + 10, BUT_Y, BUT_W, BUT_H, DELETE_LETTER, sc.work_button, sc.work_button_text,"Delete"); |
||
336 | DrawCaptButton(BUT_W+BUT_SPACE*3 + 10, BUT_Y, BUT_W, BUT_H, SAVE_LETTER, sc.work_button, sc.work_button_text,"Save"); |
||
337 | DrawCaptButton(Form.cwidth-BUT_W - 10, BUT_Y, BUT_W, BUT_H, EXIT_MAIL, sc.work_button, sc.work_button_text,"< Exit"); |
||
338 | |||
339 | DrawBar(0, mail_list.y-3, mail_list.w,1, sc.work_graph); |
||
340 | DrawBar(0, mail_list.y-2, mail_list.w,1, 0xdfdfdf); |
||
341 | DrawBar(0, mail_list.y-1, mail_list.w,1, 0xf0f0f0); |
||
342 | } |
||
343 | |||
344 | |||
345 | void DrawMailList() |
||
346 | { |
||
347 | int i, on_y; |
||
348 | mail_list.visible = mail_list.h / mail_list.line_h; |
||
349 | |||
350 | for (i=30; i<150; i++) DeleteButton(i); |
||
351 | for (i=0; (i |
||
352 | { |
||
353 | on_y = i*mail_list.line_h + mail_list.y; |
||
354 | if (mail_list.current==mail_list.first+i) |
||
355 | { |
||
356 | DrawBar(0, on_y, mail_list.w, mail_list.line_h-1, 0xEEEeee); |
||
357 | WriteText(strlen(itoa(i+mail_list.first+1))*6 + 42, on_y+5, 0x80, 0, #subj); |
||
358 | PutMailDirectionImage(strlen(itoa(i+mail_list.first+1))*6 + 18, mail_list.line_h-12/2+ on_y, #to, #from); |
||
359 | } |
||
360 | else |
||
361 | { |
||
362 | DrawBar(0, on_y, mail_list.w, mail_list.line_h-1, 0xFFFfff); |
||
363 | PutMailDirectionImage(strlen(itoa(i+mail_list.first+1))*6 + 18, mail_list.line_h-12/2+ on_y, NULL, NULL); |
||
364 | } |
||
365 | DefineButton(0, on_y, mail_list.w-1, mail_list.line_h, 30+i+BT_HIDE+BT_NOFRAME); |
||
366 | DrawBar(0, on_y + mail_list.line_h-1, mail_list.w, 1, 0xCCCccc); |
||
367 | WriteText(10, on_y+5, 0x80, 0, itoa(i+mail_list.first+1)); |
||
368 | //WriteText(mail_list.w - 40, on_y+5, 0x80, 0, itoa(GetLetterSize(i+mail_list.first+1))); |
||
369 | WriteText(mail_list.w - 40, on_y+5, 0x80, 0, ConvertSize(GetLetterSize(i+mail_list.first+1))); |
||
370 | } |
||
371 | DrawBar(0, i*mail_list.line_h + mail_list.y, mail_list.w, -i*mail_list.line_h+mail_list.h, 0xFFFfff); |
||
372 | DrawScroller1(); |
||
373 | } |
||
374 | |||
375 | |||
376 | void PutMailDirectionImage(int x,y, to_str, from_str) |
||
377 | { |
||
378 | char mail_direction=0; |
||
379 | if (strstri(to_str, #email_text)) mail_direction = 1; |
||
380 | if (strstri(from_str, #email_text)) mail_direction = 2; |
||
381 | _PutImage(x, y, 18,12, sizeof(in_out_mail)/3*mail_direction + #in_out_mail); |
||
382 | } |
||
383 | |||
384 | |||
385 | dword ConvertSize(unsigned int bytes) |
||
386 | { |
||
387 | unsigned char size_prefix[8], size_nm[4]; |
||
388 | if (bytes>=1073741824) strcpy(#size_nm, " Gb"); |
||
389 | else if (bytes>=1048576) strcpy(#size_nm, " Mb"); |
||
390 | else if (bytes>=1024) strcpy(#size_nm, " Kb"); |
||
391 | else strcpy(#size_nm, " b "); |
||
392 | while (bytes>1023) bytes/=1024; |
||
393 | strcpy(#size_prefix, itoa(bytes)); |
||
394 | strcat(#size_prefix, #size_nm); |
||
395 | return #size_prefix; |
||
396 | } |
||
397 | |||
398 | |||
399 | void DrawLetterInfo() |
||
400 | { |
||
401 | int lt_y = mail_list.y+mail_list.h; |
||
402 | |||
403 | DrawBar(0, lt_y, mail_list.w, 1, sc.work_graph); |
||
404 | DrawBar(0, lt_y+1, Form.cwidth, 1, LBUMP); |
||
405 | DrawBar(0, lt_y+2, Form.cwidth, LIST_INFO_H-4, sc.work); |
||
406 | WriteText(mail_list.w-30/2, lt_y, 0x80, 0x888888, "= = ="); |
||
407 | WriteText(mail_list.w-30/2, lt_y+1, 0x80, 0xEeeeee, "= = ="); |
||
408 | DrawBar(0, lt_y+LIST_INFO_H-2, mail_list.w, 1, sc.work_graph); //bottom |
||
409 | DrawBar(0, lt_y+LIST_INFO_H-1, mail_list.w, 1, 0xdfdfdf); |
||
410 | DrawBar(0, lt_y+LIST_INFO_H , mail_list.w, 1, 0xf0f0f0); |
||
411 | |||
412 | WriteTextB(10, lt_y+8 , 0x80, sc.work_text, "From:"); |
||
413 | WriteText(45, lt_y+8 , 0x80, sc.work_text, #from); |
||
414 | |||
415 | WriteTextB(10, lt_y+20 , 0x80, sc.work_text, "To:"); |
||
416 | WriteText(45, lt_y+20 , 0x80, sc.work_text, #to); |
||
417 | |||
418 | WriteTextB(10, lt_y+32, 0x80, sc.work_text, "Date:"); |
||
419 | WriteText(45, lt_y+32, 0x80, sc.work_text, #date); |
||
420 | |||
421 | WriteTextB(10, lt_y+44, 0x80, sc.work_text, "Subject:"); |
||
422 | WriteText(66, lt_y+44, 0x80, sc.work_text, #subj); |
||
423 | } |
||
424 | |||
425 | void DrawLetter() |
||
426 | { |
||
427 | int i=0; |
||
428 | dword cur_line, next_line, line_text; |
||
429 | cur_line = mdata; |
||
430 | |||
431 | letter_view.SetSizes(0, mail_list.y+mail_list.h+LIST_INFO_H+1, Form.cwidth - scroll2.size_x - 1, |
||
432 | Form.cheight - mail_list.y - mail_list.h - LIST_INFO_H - 1 - status_bar_h, 60, 12); |
||
433 | |||
434 | if (mailbuffer) && (!aim) |
||
435 | { |
||
436 | for ( ; i < letter_view.first; i++) cur_line = GetNextLine(cur_line); |
||
437 | |||
438 | for (i=0; i < letter_view.h / letter_view.line_h; i++) |
||
439 | { |
||
440 | next_line = GetNextLine(cur_line); |
||
441 | line_text = CopyBetweenOffsets(cur_line, next_line); |
||
442 | cur_line = next_line; |
||
443 | if (cur_line >= mailpointer) || (cur_line==1) break; |
||
444 | DrawBar(letter_view.x, i*letter_view.line_h + letter_view.y, letter_view.w, letter_view.line_h, 0xFFFfff); |
||
445 | if (line_text) { WriteText(letter_view.x+5, i*letter_view.line_h+letter_view.y+3, 0x80, 0, line_text); free(line_text);} |
||
446 | } |
||
447 | } |
||
448 | 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); |
||
449 | DrawBar(letter_view.x, letter_view.y + letter_view.h-1, letter_view.w, 1, sc.work_graph); |
||
450 | DrawScroller2(); |
||
451 | } |
||
452 | |||
453 | void DrawScroller1() |
||
454 | { |
||
455 | scroll1.max_area = mail_list.count; |
||
456 | scroll1.cur_area = mail_list.visible; |
||
457 | scroll1.position = mail_list.first; |
||
458 | |||
459 | scroll1.all_redraw=1; |
||
460 | scroll1.start_x = mail_list.x + mail_list.w; |
||
461 | scroll1.start_y = mail_list.y - 3; |
||
462 | scroll1.size_y = mail_list.h + 4; |
||
463 | scrollbar_v_draw(#scroll1); |
||
464 | } |
||
465 | |||
466 | void DrawScroller2() |
||
467 | { |
||
468 | scroll2.max_area = letter_view.count; |
||
469 | scroll2.cur_area = letter_view.visible; |
||
470 | scroll2.position = letter_view.first; |
||
471 | |||
472 | scroll2.all_redraw=1; |
||
473 | scroll2.start_x = letter_view.x + letter_view.w; |
||
474 | scroll2.start_y = letter_view.y - 3; |
||
475 | scroll2.size_y = letter_view.h + 3; |
||
476 | scrollbar_v_draw(#scroll2); |
||
477 | } |
||
478 | |||
479 | |||
480 | |||
481 | void DrawStatusBar() |
||
482 | { |
||
483 | int st_y = Form.cheight -status_bar_h; |
||
484 | DrawBar(0, st_y, Form.cwidth, status_bar_h, sc.work); |
||
485 | if (aim) { |
||
486 | SetMailBoxStatus(cur_st_percent, cur_st_text); |
||
487 | DrawCaptButton(240, st_y+1, 36, status_bar_h-3, STOP_LOADING, sc.work_button, sc.work_button_text,"Stop"); |
||
488 | } |
||
489 | DrawCaptButton(Form.cwidth - 100, st_y+1, 70, status_bar_h-2, CHANGE_CHARSET+BT_HIDE, sc.work, sc.work_text,charsets[cur_charset]); |
||
490 | } |
||
491 | |||
492 | |||
493 | |||
494 | void SetMailBoxStatus(dword percent1, text1) |
||
495 | { |
||
496 | DrawProgressBar(3, Form.cheight -status_bar_h + 1, 220, 12, sc.work, 0xC3C3C3, 0x54B1D6, sc.work_text, percent1, text1); |
||
497 | cur_st_percent = percent1; |
||
498 | cur_st_text = text1; |
||
499 | } |
||
500 | |||
501 | |||
502 | void StopLoading() |
||
503 | { |
||
504 | aim = NULL; |
||
505 | mailbuffer = free(mailbuffer); |
||
506 | to = from = date = subj = cur_charset = NULL; |
||
507 | while (PollSocket(socket)) ReadSocket(socket); |
||
508 | } |
||
509 | |||
510 | int GetMailCount(){ |
||
511 | char tmpbuf4[512]; |
||
512 | strcpyb(#immbuffer, #tmpbuf4, "+OK ", " "); |
||
513 | return atoi(#tmpbuf4); |
||
514 | } |
||
515 | |||
516 | |||
517 | |||
518 | |||
519 | |||
520 | |||
521 | |||
522 | |||
523 | |||
524 | |||
525 | |||
526 | |||
527 | |||
528 | |||
529 | |||
530 | |||
531 | |||
532 | void listputc(char agot_char){ |
||
533 | *listpointer=agot_char; |
||
534 | listpointer++; |
||
535 | *listpointer='\0'; |
||
536 | } |
||
537 | |||
538 | int GetLetterSize_(int number){ |
||
539 | char serch_num[24]; |
||
540 | char letter_size1[24]; |
||
541 | |||
542 | strcpy(#serch_num, "\n"); |
||
543 | strcat(#serch_num, itoa(number)); |
||
544 | strcat(#serch_num, " "); |
||
545 | strcpyb(listbuffer, #letter_size1, #serch_num, "\n"); |
||
546 | return atoi(#letter_size1); |
||
547 | } |
||
548 | |||
549 | |||
550 | struct line_element |
||
551 | { |
||
552 | byte m_type; |
||
553 | char adress[64]; |
||
554 | char header[256]; |
||
555 | int size; |
||
556 | }; |
||
557 | dword mails_db; |
||
558 | |||
559 | void CreateMailsArray() |
||
560 | { |
||
561 | mails_db = free(mails_db); |
||
562 | mails_db = malloc( mail_list.count * sizeof(line_element) ); |
||
563 | } |
||
564 | |||
565 | dword GetCurrentElement(int el_N) |
||
566 | { |
||
567 | return sizeof(line_element)*el_N + #mails_db; |
||
568 | } |
||
569 | |||
570 | void SetMailsSizes() |
||
571 | { |
||
572 | int i, temp; |
||
573 | for (i=0; i < mail_list.count; i++) |
||
574 | { |
||
575 | temp = GetLetterSize_(i); |
||
576 | EBX = GetCurrentElement(i); //в регистр EBX суём адрес блока памяти со смещением к элементу N с котрым мы хотим работать |
||
577 | EBX.line_element.size = temp;//работаем с m_type N-ного элемента структуры отраженной на блок памяти |
||
578 | } |
||
579 | } |
||
580 | |||
581 | int GetLetterSize(int el_N) |
||
582 | { |
||
583 | EBX = GetCurrentElement(el_N); |
||
584 | return EBX.line_element.size; |
||
585 | }>>>150;>>>>=0)>5;>>> |