Subversion Repositories Kolibri OS

Rev

Rev 4152 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4152 Rev 4164
Line 1... Line 1...
1
//Leency & SoUrcerer, LGPL
1
//Leency & SoUrcerer, LGPL
Line 2... Line 2...
2
 
2
 
3
#define LIST_INFO_H 59
3
#define LIST_INFO_H 59
Line 4... Line -...
4
int status_bar_h = 15;
-
 
5
 
-
 
6
llist mail_list;
4
int status_bar_h = 15;
7
llist letter_view;
5
 
Line 8... Line -...
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};
-
 
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};
-
 
10
 
-
 
11
char from[256];
-
 
12
char to[256];
-
 
13
char date[256];
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};
14
char subj[256];
-
 
15
dword mdata;
-
 
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);
-
 
Line 30... Line 7...
30
};
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};
31
letter_attr atr;
8
 
Line 32... Line 9...
32
dword mails_db;
9
 
Line 61... Line 38...
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);
-
 
42
	cur_charset = 0;
Line 65... Line 43...
65
	cur_charset = 0;
43
	aim=SEND_NSTAT;
Line 66... Line 44...
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
		{
Line 74... Line 52...
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();
Line 108... Line 86...
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();
Line 113... Line 93...
113
 
93
 
114
				break;				
94
				break;				
115
			case evButton:
95
			case evButton:
116
				id = GetButtonID(); 
96
				id = GetButtonID(); 
Line 180... Line 160...
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;
Line 194... Line 174...
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;
Line 196... Line 176...
196
										
176
										
197
					if (immbuffer[ticks-2]=='\n')
177
					if (immbuffer[ticks-2]=='\n')
198
					{
-
 
199
						debug("GOT::");
178
					{
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();
Line 209... Line 188...
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
				}
Line 219... Line 197...
219
 
197
 
Line 250... Line 228...
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
				}
Line 266... Line 249...
266
				
249
				
267
				if (aim == GET_ANSWER_RETR)
250
				if (aim == GET_ANSWER_RETR)
-
 
251
				{
-
 
252
					aim=NULL;
268
				{
253
					break;
269
					ticks = Receive(socketnum, mailpointer, letter_size + mailbuffer - mailpointer , MSG_DONTWAIT);
-
 
270
					debugi(ticks);
254
					ticks = Receive(socketnum, mailpointer, letter_size + mailbuffer - mailpointer , MSG_DONTWAIT);
271
					if (ticks == 0xffffffff) break;		
-
 
Line 272... Line 255...
272
					//debugi(EAX);
255
					if (ticks == 0xffffffff) break;		
273
					
-
 
274
					mailpointer = mailpointer + ticks;
-
 
Line 275... Line 256...
275
					//*mailpointer='\0';
256
					
Line 276... Line 257...
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");
Line 283... Line 264...
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;}
Line 479... Line 460...
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
}
Line 482... Line -...
482
 
-
 
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;
-
 
Line 515... Line -...
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]; }
-