Rev 4185 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4185 | Rev 4186 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | //Leency & SoUrcerer, LGPL |
1 | //Leency & SoUrcerer, LGPL |
- | 2 | //Hidnplayer |
|
Line 2... | Line 3... | ||
2 | 3 | ||
3 | #define LIST_INFO_H 59 |
4 | #define LIST_INFO_H 59 |
Line 4... | Line 5... | ||
4 | int status_bar_h = 15; |
5 | int status_bar_h = 15; |
Line 31... | Line 32... | ||
31 | { |
32 | { |
32 | int load_persent; |
33 | int load_persent; |
33 | if (aim) switch(aim) |
34 | if (aim) switch(aim) |
34 | { |
35 | { |
35 | case SEND_NSTAT: |
36 | case SEND_NSTAT: |
36 | SetLoginStatus("Counting mail, awaiting answer..."); |
37 | SetMailBoxStatus(NULL, "Counting mail, awaiting answer..."); |
37 | request_len = GetRequest("STAT", NULL); |
38 | request_len = GetRequest("STAT", NULL); |
38 | Send(socketnum, #request, request_len, 0); |
39 | Send(socketnum, #request, request_len, 0); |
39 | if (EAX == 0xffffffff) { debug("Error sending STAT. Retry..."w); break;} |
40 | if (EAX == 0xffffffff) { debug("Error sending STAT. Retry..."w); break;} |
40 | aim = GET_ANSWER_NSTAT; |
41 | aim = GET_ANSWER_NSTAT; |
41 | break; |
42 | break; |
Line 79... | Line 80... | ||
79 | 80 | ||
80 | if (listpointer - listbuffer < 5) break; |
81 | 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 |
82 | if (strncmp(listpointer-5,"\n.\n",5)==0) // note that c-- assembles "\n.\n" to 0x0d, 0x0a, 0x2e, 0x0d, 0x0a |
82 | { |
83 | { |
83 | aim = SEND_RETR; |
84 | aim = SEND_RETR; |
84 | debug("Got mail list"); |
85 | debug("goto SEND_RETR"); |
Line 85... | Line 86... | ||
85 | DrawMailBox(); |
86 | DrawMailBox(); |
86 | 87 | ||
87 | *listpointer='\0'; |
88 | *listpointer='\0'; |
Line 92... | Line 93... | ||
92 | 93 | ||
93 | case SEND_RETR: |
94 | case SEND_RETR: |
94 | from = to = date = subj = cur_charset = NULL; |
95 | from = to = date = subj = cur_charset = NULL; |
95 | letter_view.ClearList(); |
96 | letter_view.ClearList(); |
96 | DrawMailBox(); |
- | |
97 | debug("Send RETR, awaiting answer..."); |
97 | DrawMailBox(); |
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 | mailstart = malloc(mailsize); |
|
106 | if (!mailstart = malloc(mailsize)) |
107 | if (!mailstart) |
107 | { |
108 | { |
108 | debug("alloc error!"); |
109 | debug("alloc error!"); |
109 | aim=NULL; |
110 | aim=NULL; |
110 | break; |
111 | break; |
111 | } |
112 | } |
112 | mailend = mailstart; |
113 | mailend = mailstart; |
- | 114 | aim = GET_ANSWER_RETR; |
|
- | 115 | debug("goto GET_ANSWER_RETR"); |
|
Line 113... | Line 116... | ||
113 | aim = GET_ANSWER_RETR; |
116 | break; |
114 | 117 | ||
115 | case GET_ANSWER_RETR: |
118 | case GET_ANSWER_RETR: |
116 | ticks = Receive(socketnum, mailend, mailsize + mailstart - mailend, MSG_DONTWAIT); |
- | |
117 | if (ticks == 0xffffffff) break; |
119 | ticks = Receive(socketnum, mailend, mailsize + mailstart - mailend, MSG_DONTWAIT); |
118 | - | ||
119 | mailend = mailend + ticks; |
- | |
120 | - | ||
121 | if (!aim) break; |
120 | if (ticks == 0xffffffff) break; |
122 | 121 | mailend += ticks; |
|
123 | if (mailsize + mailstart - mailend - 2 < 0) |
122 | if (mailsize + mailstart - mailend - 2 < 0) |
124 | { |
123 | { |
125 | debug("Resizing buffer"); |
124 | debug("Resizing buffer"); |
126 | mailsize += 4096; |
125 | mailsize += 4096; |
127 | mailstart = realloc(mailstart, mailsize); |
126 | mailstart = realloc(mailstart, mailsize); |
128 | if (!mailstart) { StopConnect("Realloc error!"); break;} |
- | |
129 | } |
127 | if (!mailstart) { StopConnect("Realloc error!"); break;} |
130 | 128 | } |
|
131 | if (mailsize>9000) |
129 | if (mailsize>9000) |
132 | { |
130 | { |
133 | load_persent = mailend - mailstart * 100 ; |
131 | load_persent = mailend - mailstart * 100 ; |
Line 141... | Line 139... | ||
141 | 139 | ||
142 | void MailBoxLoop() |
140 | void MailBoxLoop() |
143 | { |
141 | { |
144 | int key, id; |
142 | int key, id; |
145 | mouse m; |
143 | mouse m; |
146 | int panels_drag = 0; |
144 | int panels_drag=0, clicked_list=0; |
Line 147... | Line 145... | ||
147 | dword line_col, text_col; |
145 | dword line_col, text_col; |
148 | 146 | ||
149 | mail_list.h = Form.cheight/4; |
147 | mail_list.h = Form.cheight/4; |
Line 196... | Line 194... | ||
196 | } |
194 | } |
197 | else |
195 | else |
198 | { |
196 | { |
199 | if (letter_view.MouseScroll(m.vert)) DrawLetter(); |
197 | if (letter_view.MouseScroll(m.vert)) DrawLetter(); |
200 | } |
198 | } |
201 | //if (!m.lkm) && (menu.ProcessMouse(mm.x, mm.y)) && |
199 | if (m.lkm) && (mail_list.MouseOver(m.x, m.y)) && (!clicked_list) clicked_list=1; |
202 | //if (!m.lkm) && if (menu.ProcessMouse(mm.x, mm.y)) DrawMenuList(); |
200 | if (!m.lkm) && (clicked_list) if (mail_list.ProcessMouse(m.x, m.y)) |
- | 201 | { |
|
- | 202 | clicked_list = 0; |
|
- | 203 | if (aim) break; |
|
- | 204 | DrawMailList(); |
|
- | 205 | aim = SEND_RETR; |
|
- | 206 | } |
|
Line 203... | Line 207... | ||
203 | 207 | ||
204 | break; |
208 | break; |
205 | case evButton: |
209 | case evButton: |
206 | id = GetButtonID(); |
210 | id = GetButtonID(); |
Line 239... | Line 243... | ||
239 | 0, text_col, charsets[id+1]); |
243 | 0, text_col, charsets[id+1]); |
240 | } |
244 | } |
241 | } |
245 | } |
242 | if (id==CLOSE_CHANGE_CHARSET) goto _MB_DRAW; |
246 | if (id==CLOSE_CHANGE_CHARSET) goto _MB_DRAW; |
Line 243... | Line -... | ||
243 | - | ||
244 | if (id>=30) |
- | |
245 | { |
- | |
246 | if (aim) break; |
- | |
247 | mail_list.current = mail_list.first + id - 30; |
- | |
248 | DrawMailList(); |
- | |
249 | aim = SEND_RETR; |
- | |
250 | } |
- | |
251 | 247 | ||
252 | break; |
248 | break; |
253 | case evKey: |
249 | case evKey: |
Line 254... | Line 250... | ||
254 | key = GetKey(); |
250 | key = GetKey(); |
Line 319... | Line 315... | ||
319 | on_x = strlen(itoa(i+mail_list.first+1))*6; |
315 | on_x = strlen(itoa(i+mail_list.first+1))*6; |
320 | letter_icons_pal[0]=sel_col; |
316 | letter_icons_pal[0]=sel_col; |
321 | PutPaletteImage(sizeof(letter_icons)/3*direction + #letter_icons, 18,12, on_x+18, |
317 | 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); |
318 | 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)); |
319 | 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); |
- | |
325 | DrawBar(0, on_y + mail_list.line_h-1, mail_list.w, 1, 0xCCCccc); |
320 | 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)); |
321 | 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))); |
322 | WriteText(mail_list.w - 40, on_y+5, 0x80, 0, ConvertMemSize(atr.GetSize(i+mail_list.first+1))); |
328 | } |
323 | } |
329 | DrawBar(0, i*mail_list.line_h + mail_list.y, mail_list.w, -i*mail_list.line_h+mail_list.h, 0xFFFfff); |
324 | DrawBar(0, i*mail_list.line_h + mail_list.y, mail_list.w, -i*mail_list.line_h+mail_list.h, 0xFFFfff); |
Line 345... | Line 340... | ||
345 | WriteText (45, lt_y+8 , 0x80, sc.work_text, #from); |
340 | WriteText (45, lt_y+8 , 0x80, sc.work_text, #from); |
346 | WriteTextB(10, lt_y+20, 0x80, sc.work_text, "To:"); |
341 | WriteTextB(10, lt_y+20, 0x80, sc.work_text, "To:"); |
347 | WriteText (45, lt_y+20, 0x80, sc.work_text, #to); |
342 | WriteText (45, lt_y+20, 0x80, sc.work_text, #to); |
348 | WriteTextB(10, lt_y+32, 0x80, sc.work_text, "Date:"); |
343 | WriteTextB(10, lt_y+32, 0x80, sc.work_text, "Date:"); |
349 | WriteText (45, lt_y+32, 0x80, sc.work_text, #date); |
344 | WriteText (45, lt_y+32, 0x80, sc.work_text, #date); |
350 | WriteTextB(10, lt_y+44, 0x80, sc.work_text, "Subject:"); |
345 | WriteTextB(10, lt_y+44, 0x80, sc.work_text, "Subj:"); |
351 | WriteText (66, lt_y+44, 0x80, sc.work_text, #subj); |
346 | WriteText (45, lt_y+44, 0x80, sc.work_text, #subj); |
352 | } |
347 | } |
Line 353... | Line 348... | ||
353 | 348 | ||
354 | void DrawLetter() |
349 | void DrawLetter() |
355 | { |
350 | { |
Line 362... | Line 357... | ||
362 | 357 | ||
363 | if (mailstart) && (!aim) |
358 | if (mailstart) && (!aim) |
364 | { |
359 | { |
Line 365... | Line 360... | ||
365 | for ( ; i < letter_view.first; i++) cur_line = GetNextLine(cur_line); |
360 | for ( ; i < letter_view.first; i++) cur_line = GetNextLine(cur_line); |
366 | 361 | ||
367 | for (i=0; i < letter_view.h / letter_view.line_h; i++) |
362 | for (i=0; i < letter_view.visible; i++) |
368 | { |
363 | { |
369 | next_line = GetNextLine(cur_line); |
364 | next_line = GetNextLine(cur_line); |
370 | line_text = CopyBetweenOffsets(cur_line, next_line); |
365 | line_text = CopyBetweenOffsets(cur_line, next_line); |