Subversion Repositories Kolibri OS

Rev

Rev 4185 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4185 Rev 4186
1
//Leency & SoUrcerer, LGPL
1
//Leency & SoUrcerer, LGPL
-
 
2
//Hidnplayer
2
 
3
 
3
#define LIST_INFO_H 59
4
#define LIST_INFO_H 59
4
int status_bar_h = 15;
5
int status_bar_h = 15;
5
 
6
 
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 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
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
 
9
 
10
 
10
 
11
 
11
char *listbuffer;
12
char *listbuffer;
12
char *listpointer;
13
char *listpointer;
13
 
14
 
14
char *mailstart;
15
char *mailstart;
15
char *mailend;
16
char *mailend;
16
int mailsize;
17
int mailsize;
17
 
18
 
18
 
19
 
19
enum {
20
enum {
20
	GET_MAIL = 20,
21
	GET_MAIL = 20,
21
	SEND_MAIL,
22
	SEND_MAIL,
22
	DELETE_LETTER,
23
	DELETE_LETTER,
23
	SAVE_LETTER,
24
	SAVE_LETTER,
24
	STOP_LOADING,
25
	STOP_LOADING,
25
	EXIT_MAIL,
26
	EXIT_MAIL,
26
	CHANGE_CHARSET,
27
	CHANGE_CHARSET,
27
	CLOSE_CHANGE_CHARSET
28
	CLOSE_CHANGE_CHARSET
28
};
29
};
29
 
30
 
30
void MailBoxNetworkProcess()
31
void MailBoxNetworkProcess()
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;
42
 
43
 
43
		case GET_ANSWER_NSTAT:
44
		case GET_ANSWER_NSTAT:
44
				ticks = Receive(socketnum, #immbuffer, BUFFERSIZE, 0);
45
				ticks = Receive(socketnum, #immbuffer, BUFFERSIZE, 0);
45
				if ((ticks == 0xffffff) || (ticks < 2)) break;
46
				if ((ticks == 0xffffff) || (ticks < 2)) break;
46
									
47
									
47
				if (immbuffer[ticks-2]=='\n')
48
				if (immbuffer[ticks-2]=='\n')
48
				{
49
				{
49
					debug(#immbuffer);
50
					debug(#immbuffer);
50
					if (strstr(#immbuffer,"+OK"))
51
					if (strstr(#immbuffer,"+OK"))
51
					{
52
					{
52
						strcpyb(#immbuffer, #param, "+OK ", " ");
53
						strcpyb(#immbuffer, #param, "+OK ", " ");
53
						mail_list.count = atoi(#param);
54
						mail_list.count = atoi(#param);
54
						free(listbuffer);
55
						free(listbuffer);
55
						listbuffer = mem_Alloc(30*mail_list.count); //24* original
56
						listbuffer = mem_Alloc(30*mail_list.count); //24* original
56
						listpointer = listbuffer;	
57
						listpointer = listbuffer;	
57
						aim = SEND_NLIST;
58
						aim = SEND_NLIST;
58
						debug("Receiving mail list...");
59
						debug("Receiving mail list...");
59
					}
60
					}
60
					else
61
					else
61
					{
62
					{
62
						StopConnect("Sorry, can't recieve your mail");
63
						StopConnect("Sorry, can't recieve your mail");
63
					}
64
					}
64
				}
65
				}
65
				break;
66
				break;
66
 
67
 
67
		case SEND_NLIST:
68
		case SEND_NLIST:
68
				WriteText(5, Form.cheight-11, 0x80, sc.work_text, "Send LIST, awaiting answer...");
69
				WriteText(5, Form.cheight-11, 0x80, sc.work_text, "Send LIST, awaiting answer...");
69
				request_len = GetRequest("LIST", NULL);
70
				request_len = GetRequest("LIST", NULL);
70
				Send(socketnum, #request, request_len, 0);
71
				Send(socketnum, #request, request_len, 0);
71
				if (EAX == 0xffffffff) {debug("Error while sending LIST. Retry..."); break;}
72
				if (EAX == 0xffffffff) {debug("Error while sending LIST. Retry..."); break;}
72
				else aim = GET_ANSWER_NLIST;
73
				else aim = GET_ANSWER_NLIST;
73
				break;
74
				break;
74
 
75
 
75
		case GET_ANSWER_NLIST:
76
		case GET_ANSWER_NLIST:
76
				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);
77
				if (ticks == 0xffffffff) break;	
78
				if (ticks == 0xffffffff) break;	
78
				listpointer = listpointer + ticks;	
79
				listpointer = listpointer + ticks;	
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");
85
					DrawMailBox();
86
					DrawMailBox();
86
					
87
					
87
					*listpointer='\0';
88
					*listpointer='\0';
88
					atr.CreateArray();
89
					atr.CreateArray();
89
					atr.SetSizes();
90
					atr.SetSizes();
90
				}
91
				}
91
				break;
92
				break;
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
				DrawMailBox();
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
				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;
113
				aim = GET_ANSWER_RETR;
114
				aim = GET_ANSWER_RETR;
-
 
115
				debug("goto 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);
119
				ticks = Receive(socketnum, mailend, mailsize + mailstart - mailend, MSG_DONTWAIT);
117
				if (ticks == 0xffffffff) break;
120
				if (ticks == 0xffffffff) break;
118
				
-
 
119
				mailend = mailend + ticks;
121
				mailend += ticks;
120
 
-
 
121
				if (!aim) break;
-
 
122
 
-
 
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;}
127
					if (!mailstart) { StopConnect("Realloc error!"); break;}
129
				}
128
				}
130
 
-
 
131
				if (mailsize>9000)
129
				if (mailsize>9000)
132
				{
130
				{
133
					load_persent = mailend - mailstart * 100 ;
131
					load_persent = mailend - mailstart * 100 ;
134
					load_persent /= mailsize - 1024;
132
					load_persent /= mailsize - 1024;
135
					if (load_persent != cur_st_percent) SetMailBoxStatus( load_persent , NULL);
133
					if (load_persent != cur_st_percent) SetMailBoxStatus( load_persent , NULL);
136
				}
134
				}
137
				ParseMail();
135
				ParseMail();
138
	}
136
	}
139
}
137
}
140
 
138
 
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;
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;
150
	mail_list.ClearList();
148
	mail_list.ClearList();
151
	SetMailBoxStatus( NULL , NULL);
149
	SetMailBoxStatus( NULL , NULL);
152
	cur_charset = 0;
150
	cur_charset = 0;
153
	aim = SEND_NSTAT;
151
	aim = SEND_NSTAT;
154
	
152
	
155
	goto _MB_DRAW;
153
	goto _MB_DRAW;
156
 
154
 
157
	loop()	
155
	loop()	
158
	{
156
	{
159
		WaitEventTimeout(2);
157
		WaitEventTimeout(2);
160
		switch(EAX & 0xFF)
158
		switch(EAX & 0xFF)
161
		{
159
		{
162
			case evMouse:
160
			case evMouse:
163
				IF (!CheckActiveProcess(Form.ID)) break;
161
				IF (!CheckActiveProcess(Form.ID)) break;
164
				m.get();
162
				m.get();
165
				
163
				
166
				if (!m.lkm) panels_drag=0;
164
				if (!m.lkm) panels_drag=0;
167
				if (m.lkm) && (m.y>mail_list.y+mail_list.h-1) && (m.y
165
				if (m.lkm) && (m.y>mail_list.y+mail_list.h-1) && (m.y
168
				&& (!scroll1.delta2) && (!scroll2.delta2) panels_drag = 1;
166
				&& (!scroll1.delta2) && (!scroll2.delta2) panels_drag = 1;
169
				if (panels_drag)
167
				if (panels_drag)
170
				{
168
				{
171
					if (m.yForm.cheight-letter_view.min_h-status_bar_h-LIST_INFO_H) break;
169
					if (m.yForm.cheight-letter_view.min_h-status_bar_h-LIST_INFO_H) break;
172
					mail_list.h = m.y - mail_list.y-2;
170
					mail_list.h = m.y - mail_list.y-2;
173
					DrawMailBox();
171
					DrawMailBox();
174
					break;
172
					break;
175
				}
173
				}
176
 
174
 
177
				if (!mail_list.count) break;
175
				if (!mail_list.count) break;
178
				if (!panels_drag) { scrollbar_v_mouse (#scroll1); scrollbar_v_mouse (#scroll2); }
176
				if (!panels_drag) { scrollbar_v_mouse (#scroll1); scrollbar_v_mouse (#scroll2); }
179
				
177
				
180
				if (mail_list.first <> scroll1.position)
178
				if (mail_list.first <> scroll1.position)
181
				{
179
				{
182
					mail_list.first = scroll1.position;
180
					mail_list.first = scroll1.position;
183
					DrawMailList();
181
					DrawMailList();
184
					break;
182
					break;
185
				};
183
				};
186
				if (letter_view.first <> scroll2.position)
184
				if (letter_view.first <> scroll2.position)
187
				{
185
				{
188
					letter_view.first = scroll2.position;
186
					letter_view.first = scroll2.position;
189
					DrawLetter();
187
					DrawLetter();
190
					break;
188
					break;
191
				};
189
				};
192
				
190
				
193
				if (mail_list.y+mail_list.h + 10 > m.y)
191
				if (mail_list.y+mail_list.h + 10 > m.y)
194
				{
192
				{
195
					if (mail_list.MouseScroll(m.vert)) DrawMailList();
193
					if (mail_list.MouseScroll(m.vert)) DrawMailList();
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
				}
203
 
207
 
204
				break;				
208
				break;				
205
			case evButton:
209
			case evButton:
206
				id = GetButtonID(); 
210
				id = GetButtonID(); 
207
				if (id==1) SaveAndExit();
211
				if (id==1) SaveAndExit();
208
				if (id==GET_MAIL) aim = SEND_NSTAT;
212
				if (id==GET_MAIL) aim = SEND_NSTAT;
209
				if (id==SAVE_LETTER)
213
				if (id==SAVE_LETTER)
210
				{
214
				{
211
					if (!mailstart) break;
215
					if (!mailstart) break;
212
					WriteFile(strlen(mailstart), mailstart, "mail.txt");
216
					WriteFile(strlen(mailstart), mailstart, "mail.txt");
213
					pause(10);
217
					pause(10);
214
					RunProgram("tinypad", "mail.txt");
218
					RunProgram("tinypad", "mail.txt");
215
				}
219
				}
216
				if (id==STOP_LOADING) 
220
				if (id==STOP_LOADING) 
217
				{
221
				{
218
					StopLoading();
222
					StopLoading();
219
					DrawStatusBar();
223
					DrawStatusBar();
220
					DrawMailList();
224
					DrawMailList();
221
				}
225
				}
222
				if (id==EXIT_MAIL) 
226
				if (id==EXIT_MAIL) 
223
				{
227
				{
224
					StopLoading();
228
					StopLoading();
225
					Close(socketnum);
229
					Close(socketnum);
226
					LoginBoxLoop();
230
					LoginBoxLoop();
227
				}
231
				}
228
				if (id==CHANGE_CHARSET) 
232
				if (id==CHANGE_CHARSET) 
229
				{
233
				{
230
					DefineButton(0,0,Form.cwidth,Form.cheight, CLOSE_CHANGE_CHARSET+BT_HIDE+BT_NOFRAME);
234
					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);
235
					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);
236
					DrawRectangle3D(Form.cwidth-99, Form.cheight-status_bar_h- 69, 68, 80, 0xFFFfff, sc.work);
233
					for (id=0; id<5; id++)
237
					for (id=0; id<5; id++)
234
					{
238
					{
235
						if (cur_charset==id+1) { line_col=sc.work_button; text_col=sc.work_button_text; }
239
						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; }
240
						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);
241
						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,
242
						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]);
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;
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:
254
				key = GetKey();
250
				key = GetKey();
255
 
251
 
256
				if (!aim) && (mail_list.ProcessKey(key))
252
				if (!aim) && (mail_list.ProcessKey(key))
257
				{
253
				{
258
					DrawMailList();
254
					DrawMailList();
259
					aim = SEND_RETR;
255
					aim = SEND_RETR;
260
				}
256
				}
261
 
257
 
262
				break;
258
				break;
263
			case evReDraw: _MB_DRAW:
259
			case evReDraw: _MB_DRAW:
264
				if !(DefineWindow(MAILBOX_HEADER)) break;
260
				if !(DefineWindow(MAILBOX_HEADER)) break;
265
				scroll1.bckg_col = scroll2.bckg_col = 0xBBBbbb;
261
				scroll1.bckg_col = scroll2.bckg_col = 0xBBBbbb;
266
				scroll1.frnt_col = scroll2.frnt_col = sc.work;
262
				scroll1.frnt_col = scroll2.frnt_col = sc.work;
267
				scroll1.line_col = scroll2.line_col = sc.work_graph;
263
				scroll1.line_col = scroll2.line_col = sc.work_graph;
268
				DrawToolbar();
264
				DrawToolbar();
269
				DrawMailBox();
265
				DrawMailBox();
270
 
266
 
271
				break;
267
				break;
272
			default:
268
			default:
273
				MailBoxNetworkProcess();
269
				MailBoxNetworkProcess();
274
		}
270
		}
275
	}
271
	}
276
}
272
}
277
 
273
 
278
 
274
 
279
void DrawMailBox()
275
void DrawMailBox()
280
{
276
{
281
	DrawMailList();
277
	DrawMailList();
282
	DrawLetterInfo();
278
	DrawLetterInfo();
283
	DrawLetter();
279
	DrawLetter();
284
	DrawStatusBar();
280
	DrawStatusBar();
285
}
281
}
286
 
282
 
287
 
283
 
288
void DrawToolbar()
284
void DrawToolbar()
289
{
285
{
290
	#define BUT_Y 7
286
	#define BUT_Y 7
291
	#define BUT_H 22
287
	#define BUT_H 22
292
	#define BUT_W 74
288
	#define BUT_W 74
293
	int toolbar_w = BUT_Y + BUT_H + BUT_Y + 3;
289
	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);
290
	mail_list.SetSizes(0, toolbar_w, Form.cwidth - scroll1.size_x - 1, mail_list.h, 60,18);
295
 
291
 
296
	DrawBar(0,0, Form.cwidth,toolbar_w-3, sc.work);
292
	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");
293
	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");
294
	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");
295
	DrawCaptButton(Form.cwidth-BUT_W - 10, BUT_Y, BUT_W, BUT_H, EXIT_MAIL,   sc.work_button, sc.work_button_text,"< Exit");
300
 
296
 
301
	DrawBar(0, mail_list.y-3, mail_list.w,1, sc.work_graph);
297
	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);
298
	DrawBar(0, mail_list.y-2, mail_list.w,1, 0xdfdfdf);
303
	DrawBar(0, mail_list.y-1, mail_list.w,1, 0xf0f0f0);
299
	DrawBar(0, mail_list.y-1, mail_list.w,1, 0xf0f0f0);
304
}
300
}
305
 
301
 
306
void DrawMailList()
302
void DrawMailList()
307
{
303
{
308
	int i, on_y, on_x, direction;
304
	int i, on_y, on_x, direction;
309
	dword sel_col;
305
	dword sel_col;
310
	mail_list.visible = mail_list.h / mail_list.line_h;
306
	mail_list.visible = mail_list.h / mail_list.line_h;
311
 
307
 
312
	for (i=30; i<150; i++) DeleteButton(i); 
308
	for (i=30; i<150; i++) DeleteButton(i); 
313
	for (i=0; (i
309
	for (i=0; (i
314
	{
310
	{
315
		on_y = i*mail_list.line_h + mail_list.y;
311
		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;
312
		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);
313
		DrawBar(0, on_y, mail_list.w, mail_list.line_h-1, sel_col);
318
		direction = atr.GetDirection(i+mail_list.first+1);
314
		direction = atr.GetDirection(i+mail_list.first+1);
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);
330
	DrawScroller1();
325
	DrawScroller1();
331
}
326
}
332
 
327
 
333
void DrawLetterInfo()
328
void DrawLetterInfo()
334
{
329
{
335
	int lt_y = mail_list.y+mail_list.h;
330
	int lt_y = mail_list.y+mail_list.h;
336
	DrawBar(0, lt_y, mail_list.w, 1, sc.work_graph);
331
	DrawBar(0, lt_y, mail_list.w, 1, sc.work_graph);
337
	DrawBar(0, lt_y+1, Form.cwidth, 1, LBUMP);
332
	DrawBar(0, lt_y+1, Form.cwidth, 1, LBUMP);
338
	DrawBar(0, lt_y+2, Form.cwidth, LIST_INFO_H-4, sc.work);
333
	DrawBar(0, lt_y+2, Form.cwidth, LIST_INFO_H-4, sc.work);
339
	WriteText(mail_list.w-30/2, lt_y, 0x80, 0x888888, "= = =");
334
	WriteText(mail_list.w-30/2, lt_y, 0x80, 0x888888, "= = =");
340
	WriteText(mail_list.w-30/2, lt_y+1, 0x80, 0xEeeeee, "= = =");
335
	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
336
	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);
337
	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);
338
	DrawBar(0, lt_y+LIST_INFO_H  , mail_list.w, 1, 0xf0f0f0);
344
	WriteTextB(10, lt_y+8 , 0x80, sc.work_text, "From:");
339
	WriteTextB(10, lt_y+8 , 0x80, sc.work_text, "From:");
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
}
353
 
348
 
354
void DrawLetter()
349
void DrawLetter()
355
{
350
{
356
	int i=0;
351
	int i=0;
357
	dword cur_line, next_line, line_text;
352
	dword cur_line, next_line, line_text;
358
	cur_line = mdata;
353
	cur_line = mdata;
359
 
354
 
360
	letter_view.SetSizes(0, mail_list.y+mail_list.h+LIST_INFO_H+1, Form.cwidth - scroll2.size_x - 1, 
355
	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);
356
		Form.cheight - mail_list.y - mail_list.h - LIST_INFO_H - 1 - status_bar_h, 60, 12);
362
 
357
 
363
	if (mailstart) && (!aim)
358
	if (mailstart) && (!aim)
364
	{
359
	{
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);
371
			cur_line = next_line;
366
			cur_line = next_line;
372
			if (cur_line >= mailend) || (cur_line==1) break;
367
			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);
368
			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);}
369
			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
		}
370
		}
376
	}
371
	}
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);
372
	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);
373
	DrawBar(letter_view.x, letter_view.y + letter_view.h-1, letter_view.w, 1, sc.work_graph);
379
	DrawScroller2();
374
	DrawScroller2();
380
}
375
}
381
 
376
 
382
void DrawScroller1()
377
void DrawScroller1()
383
{
378
{
384
	scroll1.max_area = mail_list.count;
379
	scroll1.max_area = mail_list.count;
385
	scroll1.cur_area = mail_list.visible;
380
	scroll1.cur_area = mail_list.visible;
386
	scroll1.position = mail_list.first;
381
	scroll1.position = mail_list.first;
387
 
382
 
388
	scroll1.all_redraw=1;
383
	scroll1.all_redraw=1;
389
	scroll1.start_x = mail_list.x + mail_list.w;
384
	scroll1.start_x = mail_list.x + mail_list.w;
390
	scroll1.start_y = mail_list.y - 3;
385
	scroll1.start_y = mail_list.y - 3;
391
	scroll1.size_y = mail_list.h + 4;
386
	scroll1.size_y = mail_list.h + 4;
392
	scrollbar_v_draw(#scroll1);
387
	scrollbar_v_draw(#scroll1);
393
}
388
}
394
 
389
 
395
void DrawScroller2()
390
void DrawScroller2()
396
{
391
{
397
	scroll2.max_area = letter_view.count;
392
	scroll2.max_area = letter_view.count;
398
	scroll2.cur_area = letter_view.visible;
393
	scroll2.cur_area = letter_view.visible;
399
	scroll2.position = letter_view.first;
394
	scroll2.position = letter_view.first;
400
 
395
 
401
	scroll2.all_redraw=1;
396
	scroll2.all_redraw=1;
402
	scroll2.start_x = letter_view.x + letter_view.w;
397
	scroll2.start_x = letter_view.x + letter_view.w;
403
	scroll2.start_y = letter_view.y - 3;
398
	scroll2.start_y = letter_view.y - 3;
404
	scroll2.size_y = letter_view.h + 3;
399
	scroll2.size_y = letter_view.h + 3;
405
	scrollbar_v_draw(#scroll2);
400
	scrollbar_v_draw(#scroll2);
406
}
401
}
407
 
402
 
408
 
403
 
409
 
404
 
410
void DrawStatusBar()
405
void DrawStatusBar()
411
{
406
{
412
	int st_y = Form.cheight -status_bar_h;
407
	int st_y = Form.cheight -status_bar_h;
413
	DrawBar(0, st_y, Form.cwidth, status_bar_h, sc.work);
408
	DrawBar(0, st_y, Form.cwidth, status_bar_h, sc.work);
414
	if (aim) {
409
	if (aim) {
415
		SetMailBoxStatus(cur_st_percent, cur_st_text);
410
		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");
411
		DrawCaptButton(240, st_y+1, 36, status_bar_h-3, STOP_LOADING, sc.work_button, sc.work_button_text,"Stop");
417
	}
412
	}
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]);
413
	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
}
414
}
420
 
415
 
421
 
416
 
422
 
417
 
423
void SetMailBoxStatus(dword percent1, text1)
418
void SetMailBoxStatus(dword percent1, text1)
424
{
419
{
425
	DrawProgressBar(3, Form.cheight -status_bar_h + 1, 220, 12, sc.work, 0xC3C3C3, 0x54B1D6, sc.work_text, percent1, text1);
420
	DrawProgressBar(3, Form.cheight -status_bar_h + 1, 220, 12, sc.work, 0xC3C3C3, 0x54B1D6, sc.work_text, percent1, text1);
426
	cur_st_percent = percent1;
421
	cur_st_percent = percent1;
427
	cur_st_text = text1;
422
	cur_st_text = text1;
428
}
423
}
429
 
424
 
430
 
425
 
431
void StopLoading()
426
void StopLoading()
432
{
427
{
433
	aim = NULL;
428
	aim = NULL;
434
	mailstart = free(mailstart);
429
	mailstart = free(mailstart);
435
	to = from = date = subj = cur_charset = NULL;
430
	to = from = date = subj = cur_charset = NULL;
436
}
431
}
437
 
432
 
438
int GetLetterSize_(int number)
433
int GetLetterSize_(int number)
439
{
434
{
440
   char search_num[24];
435
   char search_num[24];
441
   char mailsize1[24];
436
   char mailsize1[24];
442
   strcpy(#search_num, "\x0a");       // 0x0d, 0x0a
437
   strcpy(#search_num, "\x0a");       // 0x0d, 0x0a
443
   itoa_(#search_num+1, number);
438
   itoa_(#search_num+1, number);
444
   chrcat(#search_num, ' ');
439
   chrcat(#search_num, ' ');
445
   strcpyb(listbuffer, #mailsize1, #search_num, "\x0d");
440
   strcpyb(listbuffer, #mailsize1, #search_num, "\x0d");
446
   return atoi(#mailsize1); 
441
   return atoi(#mailsize1); 
447
}
442
}
448
>
443
>