Subversion Repositories Kolibri OS

Rev

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

Rev 3412 Rev 3413
Line 6... Line 6...
6
llist mail_list;
6
llist mail_list;
7
llist letter_view;
7
llist letter_view;
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};
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};
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};
Line -... Line 10...
-
 
10
 
-
 
11
char from[256];
-
 
12
char to[256];
-
 
13
char date[256];
-
 
14
char subj[256];
-
 
15
dword mdata;
10
 
16
 
11
struct letter_attr
17
struct letter_attr
12
{
18
{
13
   char adress[64];
19
   char adress[sizeof(to)];
14
   char header[256];
20
   char subject[sizeof(subj)];
15
   byte m_type;
21
   byte direction;
16
   int size;
22
   int size;
17
   void CreateMailsArray();
23
   void CreateArray();
-
 
24
   void SetSizes();
18
   void SetMailsSizes();
25
   void SetAtrFromCurr(int N);
-
 
26
   int  GetSize(int N);
-
 
27
   char GetDirection(int N);
-
 
28
   dword GetSubject(int N);
19
   int GetLetterSize(int N);
29
   dword GetAdress(int N);
20
};
30
};
21
letter_attr atr;
31
letter_attr atr;
Line 22... Line -...
22
dword mails_db;
-
 
23
 
-
 
24
 
-
 
25
char from[256];
-
 
26
char to[256];
-
 
27
char date[256];
-
 
28
char subj[256];
-
 
29
dword mdata;
32
dword mails_db;
30
 
33
 
Line 31... Line 34...
31
char *listbuffer;
34
char *listbuffer;
32
char *listpointer;
35
char *listpointer;
Line 262... Line 265...
262
						{
265
						{
263
							aim = SEND_RETR;
266
							aim = SEND_RETR;
264
							debug("Got mail list");
267
							debug("Got mail list");
265
							DrawMailBox();
268
							DrawMailBox();
Line 266... Line 269...
266
 
269
 
267
							atr.CreateMailsArray();
270
							atr.CreateArray();
268
							atr.SetMailsSizes();
271
							atr.SetSizes();
269
						}
272
						}
270
					} 
273
					} 
271
				}
274
				}
272
				if (aim == SEND_RETR)
275
				if (aim == SEND_RETR)
Line 278... Line 281...
278
					request_len = GetRequest("RETR", itoa(mail_list.current+1));
281
					request_len = GetRequest("RETR", itoa(mail_list.current+1));
279
					WriteSocket(socket,request_len,#request);
282
					WriteSocket(socket,request_len,#request);
280
					if (EAX == 0xffffffff) { notify("Error while trying to get letter from server"); aim=NULL; break;}
283
					if (EAX == 0xffffffff) { notify("Error while trying to get letter from server"); aim=NULL; break;}
Line 281... Line 284...
281
 
284
 
282
					mailbuffer = free(mailbuffer);
285
					mailbuffer = free(mailbuffer);
283
					letter_size = atr.GetLetterSize(mail_list.current+1) + 1024;
286
					letter_size = atr.GetSize(mail_list.current+1) + 1024;
284
					mailbuffer = malloc(letter_size);
287
					mailbuffer = malloc(letter_size);
285
					mailpointer = mailbuffer;
288
					mailpointer = mailbuffer;
286
					aim = GET_ANSWER_RETR;
289
					aim = GET_ANSWER_RETR;
287
				}
290
				}
Line 305... Line 308...
305
							letter_size += 4096;
308
							letter_size += 4096;
306
							mailbuffer = realloc(mailbuffer, letter_size);
309
							mailbuffer = realloc(mailbuffer, letter_size);
307
							if (!mailbuffer) {debug("Relloc error!"); aim=NULL; break;}
310
							if (!mailbuffer) {debug("Relloc error!"); aim=NULL; break;}
308
						}
311
						}
Line 309... Line 312...
309
 
312
 
310
						if (letter_size>5000)
313
						if (letter_size>9000)
311
						{
314
						{
312
							id = mailpointer - mailbuffer * 100 ;
315
							id = mailpointer - mailbuffer * 100 ;
313
							id /= letter_size - 1024;
316
							id /= letter_size - 1024;
314
							if (id!=cur_st_percent) SetMailBoxStatus( id , NULL);
317
							if (id!=cur_st_percent) SetMailBoxStatus( id , NULL);
Line 354... Line 357...
354
}
357
}
Line 355... Line 358...
355
 
358
 
356
 
359
 
357
void DrawMailList()
360
void DrawMailList()
358
{
361
{
Line 359... Line 362...
359
	int i, on_y;
362
	int i, on_y, on_x, direction;
360
	mail_list.visible = mail_list.h / mail_list.line_h;
363
	mail_list.visible = mail_list.h / mail_list.line_h;
361
 
364
 
362
	for (i=30; i<150; i++) DeleteButton(i); 
365
	for (i=30; i<150; i++) DeleteButton(i); 
363
	for (i=0; (i
366
	for (i=0; (i
364
	{
367
	{
365
		on_y = i*mail_list.line_h + mail_list.y;
368
		on_y = i*mail_list.line_h + mail_list.y;
366
		if (mail_list.current==mail_list.first+i)
-
 
367
		{
-
 
368
			DrawBar(0, on_y, mail_list.w, mail_list.line_h-1, 0xEEEeee);
369
		if (mail_list.current==mail_list.first+i)
369
			WriteText(strlen(itoa(i+mail_list.first+1))*6 + 42, on_y+5, 0x80, 0, #subj);
370
		{
370
			PutMailDirectionImage(strlen(itoa(i+mail_list.first+1))*6 + 18, mail_list.line_h-12/2+ on_y, #to, #from);
371
			DrawBar(0, on_y, mail_list.w, mail_list.line_h-1, 0xEEEeee);
371
		}
372
		}
372
		else
-
 
373
		{
373
		else
-
 
374
		{
-
 
375
			DrawBar(0, on_y, mail_list.w, mail_list.line_h-1, 0xFFFfff);
-
 
376
		}
-
 
377
		direction = atr.GetDirection(i+mail_list.first+1);
374
			DrawBar(0, on_y, mail_list.w, mail_list.line_h-1, 0xFFFfff);
378
		on_x = strlen(itoa(i+mail_list.first+1))*6;
375
			PutMailDirectionImage(strlen(itoa(i+mail_list.first+1))*6 + 18, mail_list.line_h-12/2+ on_y, NULL, NULL);
379
		_PutImage(on_x + 18, mail_list.line_h-12/2+ on_y, 18,12, sizeof(in_out_mail)/3*direction + #in_out_mail);
376
		}
380
		WriteText(on_x + 42, on_y+5, 0x80, 0, atr.GetSubject(i+mail_list.first+1));
377
		DefineButton(0, on_y, mail_list.w-1, mail_list.line_h, 30+i+BT_HIDE+BT_NOFRAME);
381
		DefineButton(0, on_y, mail_list.w-1, mail_list.line_h, 30+i+BT_HIDE+BT_NOFRAME);
378
		DrawBar(0, on_y + mail_list.line_h-1, mail_list.w, 1, 0xCCCccc);
382
		DrawBar(0, on_y + mail_list.line_h-1, mail_list.w, 1, 0xCCCccc);
379
		WriteText(10, on_y+5, 0x80, 0, itoa(i+mail_list.first+1));
383
		WriteText(10, on_y+5, 0x80, 0, itoa(i+mail_list.first+1));
380
		WriteText(mail_list.w - 40, on_y+5, 0x80, 0, ConvertMemSize(atr.GetLetterSize(i+mail_list.first+1)));
384
		WriteText(mail_list.w - 40, on_y+5, 0x80, 0, ConvertMemSize(atr.GetSize(i+mail_list.first+1)));
381
	}
385
	}
Line 382... Line -...
382
	DrawBar(0, i*mail_list.line_h + mail_list.y, mail_list.w, -i*mail_list.line_h+mail_list.h, 0xFFFfff);
-
 
383
	DrawScroller1();
-
 
384
}
-
 
385
 
-
 
386
 
-
 
387
void PutMailDirectionImage(int x,y, to_str, from_str)
-
 
388
{
-
 
389
	char mail_direction=0;
-
 
390
	if (strstri(to_str, #email_text)) mail_direction = 1;
-
 
391
	if (strstri(from_str, #email_text)) mail_direction = 2;
-
 
392
	_PutImage(x, y, 18,12, sizeof(in_out_mail)/3*mail_direction + #in_out_mail);
386
	DrawBar(0, i*mail_list.line_h + mail_list.y, mail_list.w, -i*mail_list.line_h+mail_list.h, 0xFFFfff);
393
}
387
	DrawScroller1();
394
 
388
}
395
 
-
 
396
void DrawLetterInfo()
389
 
397
{
390
void DrawLetterInfo()
398
	int lt_y = mail_list.y+mail_list.h;
391
{
399
 
392
	int lt_y = mail_list.y+mail_list.h;
400
	DrawBar(0, lt_y, mail_list.w, 1, sc.work_graph);
393
	DrawBar(0, lt_y, mail_list.w, 1, sc.work_graph);
401
	DrawBar(0, lt_y+1, Form.cwidth, 1, LBUMP);
394
	DrawBar(0, lt_y+1, Form.cwidth, 1, LBUMP);
402
	DrawBar(0, lt_y+2, Form.cwidth, LIST_INFO_H-4, sc.work);
395
	DrawBar(0, lt_y+2, Form.cwidth, LIST_INFO_H-4, sc.work);
403
	WriteText(mail_list.w-30/2, lt_y, 0x80, 0x888888, "= = =");
396
	WriteText(mail_list.w-30/2, lt_y, 0x80, 0x888888, "= = =");
404
	WriteText(mail_list.w-30/2, lt_y+1, 0x80, 0xEeeeee, "= = =");
-
 
405
	DrawBar(0, lt_y+LIST_INFO_H-2, mail_list.w, 1, sc.work_graph); //bottom
397
	WriteText(mail_list.w-30/2, lt_y+1, 0x80, 0xEeeeee, "= = =");
406
	DrawBar(0, lt_y+LIST_INFO_H-1, mail_list.w, 1, 0xdfdfdf);
398
	DrawBar(0, lt_y+LIST_INFO_H-2, mail_list.w, 1, sc.work_graph); //bottom
407
	DrawBar(0, lt_y+LIST_INFO_H  , mail_list.w, 1, 0xf0f0f0);
-
 
408
 
399
	DrawBar(0, lt_y+LIST_INFO_H-1, mail_list.w, 1, 0xdfdfdf);
409
	WriteTextB(10, lt_y+8 , 0x80, sc.work_text, "From:");
400
	DrawBar(0, lt_y+LIST_INFO_H  , mail_list.w, 1, 0xf0f0f0);
410
	WriteText(45, lt_y+8 , 0x80, sc.work_text, #from);
-
 
411
 
401
	WriteTextB(10, lt_y+8 , 0x80, sc.work_text, "From:");
412
	WriteTextB(10, lt_y+20 , 0x80, sc.work_text, "To:");
402
	WriteText (45, lt_y+8 , 0x80, sc.work_text, #from);
413
	WriteText(45, lt_y+20 , 0x80, sc.work_text, #to);
-
 
414
	
403
	WriteTextB(10, lt_y+20, 0x80, sc.work_text, "To:");
415
	WriteTextB(10, lt_y+32, 0x80, sc.work_text, "Date:");
404
	WriteText (45, lt_y+20, 0x80, sc.work_text, #to);
416
	WriteText(45, lt_y+32, 0x80, sc.work_text, #date);
405
	WriteTextB(10, lt_y+32, 0x80, sc.work_text, "Date:");
Line 417... Line 406...
417
 
406
	WriteText (45, lt_y+32, 0x80, sc.work_text, #date);
Line 524... Line 513...
524
}
513
}
Line 525... Line 514...
525
 
514
 
526
int GetLetterSize_(int number){
515
int GetLetterSize_(int number){
527
	char serch_num[24];
516
	char serch_num[24];
528
	char letter_size1[24];
-
 
529
	
517
	char letter_size1[24];
530
	strcpy(#serch_num, "\n");
518
	strcpy(#serch_num, "\n");
531
	strcat(#serch_num, itoa(number));
519
	strcat(#serch_num, itoa(number));
532
	strcat(#serch_num, " ");
520
	strcat(#serch_num, " ");
533
	strcpyb(listbuffer, #letter_size1, #serch_num, "\n");
521
	strcpyb(listbuffer, #letter_size1, #serch_num, "\n");
534
	return atoi(#letter_size1); 
522
	return atoi(#letter_size1); 
Line 535... Line 523...
535
}
523
}
536
 
524
 
537
 
525
 
538
 
526
 
539
 
527
 
Line 540... Line 528...
540
void letter_attr::CreateMailsArray()
528
void letter_attr::CreateArray()
541
{
529
{
542
	mails_db = free(mails_db);
530
	mails_db = free(mails_db);
543
	mails_db = malloc( mail_list.count * sizeof(atr) );
531
	mails_db = malloc( mail_list.count * sizeof(atr) );
544
}
532
}
545
 
533
 
-
 
534
void letter_attr::SetSizes()
-
 
535
{
546
void letter_attr::SetMailsSizes()
536
	int i;
547
{
537
	for (i=0; i < mail_list.count; i++)
Line 548... Line 538...
548
	int i, off;
538
	{
-
 
539
		ESDWORD[sizeof(atr)*i+#mails_db+#atr.size-#atr] = GetLetterSize_(i);
-
 
540
		ESDWORD[sizeof(atr)*i+#mails_db+#atr.subject-#atr] = ' ';
-
 
541
		ESDWORD[sizeof(atr)*i+#mails_db+#atr.subject-#atr+1] = '\0';
-
 
542
	}
-
 
543
}
-
 
544
 
-
 
545
void letter_attr::SetAtrFromCurr(int N)
-
 
546
{
549
	for (i=0; i < mail_list.count; i++)
547
	byte mail_direction=0;
-
 
548
	if (strstri(#to, #email_text))
550
	{
549
	{
551
		ESDWORD[sizeof(atr)*i+#mails_db+#atr.size-#atr] = GetLetterSize_(i);
550
		mail_direction = 1;
552
	}
551
		strcpy(sizeof(atr)*N+#mails_db+#atr.adress-#atr, #from);
-
 
552
	}
-
 
553
	if (strstri(#from, #email_text))
-
 
554
	{
-
 
555
		mail_direction = 2;
-
 
556
		strcpy(sizeof(atr)*N+#mails_db+#atr.adress-#atr, #to);
-
 
557
	}
-
 
558
	ESBYTE[sizeof(atr)*N+#mails_db+#atr.direction-#atr] = mail_direction;
-
 
559
	strcpy(sizeof(atr)*N+#mails_db+#atr.subject-#atr, #subj);
-
 
560
}