Subversion Repositories Kolibri OS

Rev

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

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