Subversion Repositories Kolibri OS

Rev

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

Rev 4164 Rev 4166
Line 9... Line 9...
9
 
9
 
10
 
10
 
Line 11... Line 11...
11
char *listbuffer;
11
char *listbuffer;
12
char *listpointer;
12
char *listpointer;
-
 
13
 
Line 13... Line 14...
13
 
14
char *mailstart;
14
char *mailbuffer;
15
char *mailend;
15
char *mailpointer;
16
int mailsize;
Line 30... Line 31...
30
void MailBoxLoop()
31
void MailBoxLoop()
31
{
32
{
32
	int key, id;
33
	int key, id;
33
	mouse m;
34
	mouse m;
34
	int panels_drag = 0;
35
	int panels_drag = 0;
35
	char socket_char;
-
 
36
	int letter_size;
-
 
37
	dword line_col, text_col;
36
	dword line_col, text_col;
Line 38... Line 37...
38
 
37
 
39
	mail_list.h = Form.cheight/4;
38
	mail_list.h = Form.cheight/4;
40
	mail_list.ClearList();
39
	mail_list.ClearList();
Line 96... Line 95...
96
				id = GetButtonID(); 
95
				id = GetButtonID(); 
97
				if (id==1) SaveAndExit();
96
				if (id==1) SaveAndExit();
98
				if (id==GET_MAIL) aim = SEND_NSTAT;
97
				if (id==GET_MAIL) aim = SEND_NSTAT;
99
				if (id==SAVE_LETTER)
98
				if (id==SAVE_LETTER)
100
				{
99
				{
101
					if (!mailbuffer) break;
100
					if (!mailstart) break;
102
					WriteFile(strlen(mailbuffer), mailbuffer, "mail.txt");
101
					WriteFile(strlen(mailstart), mailstart, "mail.txt");
103
					pause(10);
102
					pause(10);
104
					RunProgram("tinypad", "mail.txt");
103
					RunProgram("tinypad", "mail.txt");
105
				}
104
				}
106
				if (id==STOP_LOADING) 
105
				if (id==STOP_LOADING) 
107
				{
106
				{
Line 178... Line 177...
178
					{
177
					{
179
						debug(#immbuffer);
178
						debug(#immbuffer);
180
						if (strstr(#immbuffer,"+OK"))
179
						if (strstr(#immbuffer,"+OK"))
181
						{
180
						{
182
							mail_list.count = GetMailCount();
181
							mail_list.count = GetMailCount();
183
							debug("Letters:");
-
 
184
							debug(itoa(mail_list.count));
-
 
185
							free(listbuffer);
182
							free(listbuffer);
186
							listbuffer = mem_Alloc(30*mail_list.count); //24* original
183
							listbuffer = mem_Alloc(30*mail_list.count); //24* original
187
							listpointer = listbuffer;	
184
							listpointer = listbuffer;	
188
							aim = SEND_NLIST;
185
							aim = SEND_NLIST;
189
							debug("Receiving mail list...");
186
							debug("Receiving mail list...");
Line 233... Line 230...
233
					if (Send(socketnum, #request, request_len, 0) == 0xffffffff)
230
					if (Send(socketnum, #request, request_len, 0) == 0xffffffff)
234
					{
231
					{
235
						StopConnect("Error while trying to get letter from server");
232
						StopConnect("Error while trying to get letter from server");
236
						break;
233
						break;
237
					}
234
					}
238
					letter_size = atr.GetSize(mail_list.current+1) + 1024;
235
					mailsize = atr.GetSize(mail_list.current+1) + 1024;
239
					free(mailbuffer);
236
					free(mailstart);
240
					if (!mailbuffer = malloc(letter_size))
237
					if (!mailstart = malloc(mailsize))
241
					{
238
					{
242
						debug("alloc error!");
239
						debug("alloc error!");
243
						aim=NULL;
240
						aim=NULL;
244
						break;
241
						break;
245
					}
242
					}
246
					mailpointer = mailbuffer;
243
					mailend = mailstart;
247
					aim = GET_ANSWER_RETR;
244
					aim = GET_ANSWER_RETR;
248
				}
245
				}
Line 249... Line 246...
249
				
246
				
250
				if (aim == GET_ANSWER_RETR)
247
				if (aim == GET_ANSWER_RETR)
251
				{
-
 
252
					aim=NULL;
-
 
253
					break;
248
				{
254
					ticks = Receive(socketnum, mailpointer, letter_size + mailbuffer - mailpointer , MSG_DONTWAIT);
249
					ticks = Receive(socketnum, mailend, mailsize + mailstart - mailend, MSG_DONTWAIT);
Line 255... Line 250...
255
					if (ticks == 0xffffffff) break;		
250
					if (ticks == 0xffffffff) break;
Line 256... Line 251...
256
					
251
					
Line 257... Line 252...
257
					mailpointer = mailpointer + ticks;
252
					mailend = mailend + ticks;
258
 
253
 
259
					if (!aim) break;
254
					if (!aim) break;
260
 
255
 
261
					if (letter_size + mailbuffer - mailpointer - 2 < 0)
256
					if (mailsize + mailstart - mailend - 2 < 0)
262
					{
257
					{
263
						debug("Resizing buffer");
258
						debug("Resizing buffer");
Line 264... Line 259...
264
						letter_size += 4096;
259
						mailsize += 4096;
265
						mailbuffer = realloc(mailbuffer, letter_size);
260
						mailstart = realloc(mailstart, mailsize);
266
						if (!mailbuffer) { StopConnect("Realloc error!"); break;}
261
						if (!mailstart) { StopConnect("Realloc error!"); break;}
267
					}
262
					}
268
 
263
 
269
					if (letter_size>9000)
264
					if (mailsize>9000)
Line -... Line 265...
-
 
265
					{
-
 
266
						id = mailend - mailstart * 100 ;
-
 
267
						id /= mailsize - 1024;
270
					{
268
						if (id!=cur_st_percent) SetMailBoxStatus( id , NULL);
271
						id = mailpointer - mailbuffer * 100 ;
269
					}
Line 272... Line 270...
272
						id /= letter_size - 1024;
270
 
273
						if (id!=cur_st_percent) SetMailBoxStatus( id , NULL);
271
					//debug(mailstart);
Line 366... Line 364...
366
	cur_line = mdata;
364
	cur_line = mdata;
Line 367... Line 365...
367
 
365
 
368
	letter_view.SetSizes(0, mail_list.y+mail_list.h+LIST_INFO_H+1, Form.cwidth - scroll2.size_x - 1, 
366
	letter_view.SetSizes(0, mail_list.y+mail_list.h+LIST_INFO_H+1, Form.cwidth - scroll2.size_x - 1, 
Line 369... Line 367...
369
		Form.cheight - mail_list.y - mail_list.h - LIST_INFO_H - 1 - status_bar_h, 60, 12);
367
		Form.cheight - mail_list.y - mail_list.h - LIST_INFO_H - 1 - status_bar_h, 60, 12);
370
 
368
 
371
	if (mailbuffer) && (!aim)
369
	if (mailstart) && (!aim)
Line 372... Line 370...
372
	{
370
	{
373
		for ( ; i < letter_view.first; i++) cur_line = GetNextLine(cur_line);
371
		for ( ; i < letter_view.first; i++) cur_line = GetNextLine(cur_line);
374
 
372
 
375
		for (i=0; i < letter_view.h / letter_view.line_h; i++)
373
		for (i=0; i < letter_view.h / letter_view.line_h; i++)
376
		{
374
		{
377
			next_line = GetNextLine(cur_line);
375
			next_line = GetNextLine(cur_line);
378
			line_text = CopyBetweenOffsets(cur_line, next_line);
376
			line_text = CopyBetweenOffsets(cur_line, next_line);
379
			cur_line = next_line;
377
			cur_line = next_line;
380
			if (cur_line >= mailpointer) || (cur_line==1) break;
378
			if (cur_line >= mailend) || (cur_line==1) break;
381
			DrawBar(letter_view.x, i*letter_view.line_h + letter_view.y, letter_view.w, letter_view.line_h, 0xFFFfff);
379
			DrawBar(letter_view.x, i*letter_view.line_h + letter_view.y, letter_view.w, letter_view.line_h, 0xFFFfff);
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);}
380
			if (line_text) { WriteText(letter_view.x+5, i*letter_view.line_h+letter_view.y+3, 0x80, 0, line_text); free(line_text);}
Line 428... Line 426...
428
 
426
 
429
 
427
 
430
 
428
 
431
void SetMailBoxStatus(dword percent1, text1)
-
 
432
{
429
void SetMailBoxStatus(dword percent1, text1)
433
	DrawProgressBar(3, Form.cheight -status_bar_h + 1, 220, 12, sc.work, 0xC3C3C3, 0x54B1D6, sc.work_text, percent1, text1);
430
{
Line 434... Line 431...
434
	cur_st_percent = percent1;
431
	if (text1) WriteText(3, Form.cheight -status_bar_h + 3, 0x80, sc.work_text, text1);
435
	cur_st_text = text1;
432
	cur_st_text = text1;
436
}
433
}
437
 
434
 
438
 
435
 
439
void StopLoading()
436
void StopLoading()
Line 440... Line 437...
440
{
437
{
441
	aim = NULL;
438
	aim = NULL;
442
	mailbuffer = free(mailbuffer);
439
	mailstart = free(mailstart);
443
	to = from = date = subj = cur_charset = NULL;
440
	to = from = date = subj = cur_charset = NULL;
444
}
441
}
Line 445... Line -...
445
 
-
 
446
int GetMailCount(){
-
 
447
	char tmpbuf4[512];
442
 
-
 
443
int GetMailCount(){
448
	strcpyb(#immbuffer, #tmpbuf4, "+OK ", " ");
444
	char tmpbuf4[512];
449
	return atoi(#tmpbuf4);
445
	strcpyb(#immbuffer, #tmpbuf4, "+OK ", " ");
450
}
446
	return atoi(#tmpbuf4);
451
 
447
}
452
 
448
 
453
 
449
int GetLetterSize_(int number)
454
int GetLetterSize_(int number){
450
{
455
	char search_num[24];
451
   char search_num[24];