Subversion Repositories Kolibri OS

Rev

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

Rev 6932 Rev 7038
1
//Leency & SoUrcerer, LGPL
1
//Leency & SoUrcerer, LGPL
2
 
2
 
3
//libraries
3
//libraries
4
#define MEMSIZE 0x100000
4
#define MEMSIZE 0x100000
5
#include "../lib/kolibri.h"
5
#include "../lib/kolibri.h"
6
#include "../lib/strings.h"
6
#include "../lib/strings.h"
7
#include "../lib/mem.h"
7
#include "../lib/mem.h"
8
#include "../lib/dll.h"
8
#include "../lib/dll.h"
9
#include "../lib/gui.h"
9
#include "../lib/gui.h"
10
#include "../lib/file_system.h"
10
#include "../lib/file_system.h"
11
#include "../lib/list_box.h"
11
#include "../lib/list_box.h"
12
#include "../lib/socket.h"
12
#include "../lib/socket.h"
13
#include "../lib/draw_buf.h"
13
#include "../lib/draw_buf.h"
14
#include "../lib/cursor.h"
14
#include "../lib/cursor.h"
15
#include "../lib/collection.h"
15
#include "../lib/collection.h"
16
//*.obj libraries
16
//*.obj libraries
17
#include "../lib/obj/box_lib.h"
17
#include "../lib/obj/box_lib.h"
18
#include "../lib/obj/network.h"
18
#include "../lib/obj/network.h"
19
#include "../lib/obj/libio_lib.h"
19
#include "../lib/obj/libio_lib.h"
20
#include "../lib/obj/libimg_lib.h"
20
#include "../lib/obj/libimg_lib.h"
21
#include "../lib/obj/netcode.h"
21
#include "../lib/obj/netcode.h"
22
#include "../lib/obj/iconv.h"
22
#include "../lib/obj/iconv.h"
23
//patternts
23
//patternts
24
#include "..\lib\patterns\history.h"
24
#include "..\lib\patterns\history.h"
25
//images
25
//images
26
byte letter_icons[sizeof(file "img/letter_icons.raw")] = FROM "img/letter_icons.raw";
26
byte letter_icons[sizeof(file "img/letter_icons.raw")] = FROM "img/letter_icons.raw";
27
#include "img/letter_icons.h"
27
#include "img/letter_icons.h"
28
 
28
 
29
//connection algorithm
29
//connection algorithm
30
enum {
30
enum {
31
	STOP,
31
	STOP,
32
	RESOLVE,
32
	RESOLVE,
33
	OPEN_CONNECTION,
33
	OPEN_CONNECTION,
34
	GET_ANSWER_CONNECT,
34
	GET_ANSWER_CONNECT,
35
	SEND_USER,
35
	SEND_USER,
36
	GET_ANSWER_USER,
36
	GET_ANSWER_USER,
37
	SEND_PASS,
37
	SEND_PASS,
38
	GET_ANSWER_PASS,
38
	GET_ANSWER_PASS,
39
	SEND_NLIST,
39
	SEND_NLIST,
40
	GET_ANSWER_NLIST,
40
	GET_ANSWER_NLIST,
41
	SEND_NSTAT,
41
	SEND_NSTAT,
42
	GET_ANSWER_NSTAT,
42
	GET_ANSWER_NSTAT,
43
	SEND_RETR,
43
	SEND_RETR,
44
	GET_ANSWER_RETR
44
	GET_ANSWER_RETR
45
};
45
};
46
 
46
 
47
//WindowDefinitions
47
//WindowDefinitions
48
#define WIN_W         600
48
#define WIN_W         600
49
#define WIN_H         440
49
#define WIN_H         440
50
#define WIN_MIN_W     500
50
#define WIN_MIN_W     500
51
#define WIN_MIN_H     380
51
#define WIN_MIN_H     380
52
#define LOGIN_HEADER   "Login - Email client Liza 0.9.4"
52
#define LOGIN_HEADER   "Login - Email client Liza 0.9.4"
53
#define OPTIONS_HEADER "Options - Email client Liza 0.9.4"
53
#define OPTIONS_HEADER "Options - Email client Liza 0.9.4"
54
#define MAILBOX_HEADER "Mail Box - Email client Liza 0.9.4"
54
#define MAILBOX_HEADER "Mail Box - Email client Liza 0.9.4"
55
#define BUFFERSIZE		512	
55
#define BUFFERSIZE		512	
56
proc_info Form;
56
proc_info Form;
57
#define LBUMP 0xFFFfff
57
#define LBUMP 0xFFFfff
58
 
58
 
59
//progress_bar definitions
59
//progress_bar definitions
60
char cur_st_percent;
60
char cur_st_percent;
61
dword cur_st_text;
61
dword cur_st_text;
62
 
62
 
63
//connection data
63
//connection data
64
#define DEFAULT_POP_PORT 110;
64
#define DEFAULT_POP_PORT 110;
65
char POP_server_path[128];
65
char POP_server_path[128];
66
dword POP_server_port;
66
dword POP_server_port;
67
char login[128];
67
char login[128];
68
char request[256+22];
68
char request[256+22];
69
int request_len;
69
int request_len;
70
char connection_status;
70
char connection_status;
71
dword socketnum;
71
dword socketnum;
72
 
72
 
73
sockaddr_in sockaddr;
73
sockaddr_in sockaddr;
74
 
74
 
75
int aim;
75
int aim;
76
int ticks;
76
int ticks;
77
 
77
 
78
char immbuffer[BUFFERSIZE];
78
char immbuffer[BUFFERSIZE];
79
 
79
 
80
llist mail_list;
80
llist mail_list;
81
llist letter_view;
81
llist letter_view;
82
 
82
 
83
dword TAB_H = false; //19;
83
dword TAB_H = false; //19;
84
dword TAB_W = 150;
84
dword TAB_W = 150;
85
dword TOOLBAR_H = 31; //50;
85
dword TOOLBAR_H = 31; //50;
86
dword STATUSBAR_H =15;
86
dword STATUSBAR_H =15;
87
dword col_bg;
87
dword col_bg;
88
dword panel_color;
88
dword panel_color;
89
dword border_color;
89
dword border_color;
90
 
90
 
91
bool open_in_a_new_window = false;
91
bool open_in_a_new_window = false;
92
 
92
 
93
progress_bar wv_progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F};
93
progress_bar wv_progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F};
94
 
94
 
95
int http_transfer;
95
int http_transfer;
96
char version[]=" WebView 0.1";
96
char version[]=" WebView 0.1";
97
#include "..\TWB\TWB.c"
97
#include "..\TWB\TWB.c"
98
 
98
 
99
#include "settings.c"
99
#include "settings.c"
100
#include "login.c"
100
#include "login.c"
101
#include "letter_attr.c"
101
#include "letter_attr.c"
102
#include "mail_box.c"
102
#include "mail_box.c"
103
#include "parselist.c"
103
#include "parselist.c"
104
 
104
 
105
void main() {
105
void main() {
106
 
106
 
107
	CursorPointer.Load(#CursorFile);
107
	CursorPointer.Load(#CursorFile);
108
	load_dll(boxlib, #box_lib_init,0);
108
	load_dll(boxlib, #box_lib_init,0);
109
	load_dll(network_lib, #network_lib_init,0);
109
	load_dll(network_lib, #network_lib_init,0);
110
	load_dll(netcode_lib, #base64_encode,0);
110
	load_dll(netcode_lib, #base64_encode,0);
111
	load_dll(libio, #libio_init,1);
111
	load_dll(libio, #libio_init,1);
112
	load_dll(libimg, #libimg_init,1);
112
	load_dll(libimg, #libimg_init,1);
113
	load_dll(iconv_lib, #iconv_open,0);
113
	load_dll(iconv_lib, #iconv_open,0);
114
	OpenMailDat();
114
	OpenMailDat();
115
	SetEventMask(0x27);
115
	SetEventMask(0x27);
116
	LoginBoxLoop();
116
	LoginBoxLoop();
117
}
117
}
118
 
118
 
119
 
119
 
120
int DefineWindow(dword wtitle) {
120
int DefineWindow(dword wtitle) {
121
	system.color.get();
121
	system.color.get();
122
	DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2, WIN_W, WIN_H, 0x73,system.color.work, 0,0); 
122
	DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2, WIN_W, WIN_H, 0x73,system.color.work, 0,0); 
123
	DrawTitle(wtitle);
123
	DrawTitle(wtitle);
124
	GetProcessInfo(#Form, SelfInfo);
124
	GetProcessInfo(#Form, SelfInfo);
125
	if (Form.status_window>2) return 0; //rolled_up
125
	if (Form.status_window>2) return 0; //rolled_up
126
	if (Form.width < WIN_MIN_W) MoveSize(OLD,OLD,WIN_MIN_W,OLD);
126
	if (Form.width < WIN_MIN_W) MoveSize(OLD,OLD,WIN_MIN_W,OLD);
127
	if (Form.height < WIN_MIN_H) MoveSize(OLD,OLD,OLD,WIN_MIN_H);
127
	if (Form.height < WIN_MIN_H) MoveSize(OLD,OLD,OLD,WIN_MIN_H);
128
	return 1;
128
	return 1;
129
}
129
}
130
 
130
 
131
 
131
 
132
void OpenMailDat() {
132
void OpenMailDat() {
133
	char read_data[512], pass_b64[256];
133
	char read_data[512], pass_b64[256];
134
	ReadFile(0, 512, #read_data, "/sys/network/mail.dat");
134
	ReadFile(0, 512, #read_data, "/sys/network/mail.dat");
135
	if (!read_data)
135
	if (!read_data)
136
	{
136
	{
137
		strcpy(#email_text, "testliza@ya.ru"); 
137
		strcpy(#email_text, "testliza@ya.ru"); 
138
		strcpy(#pass_text, "kolibri");
138
		strcpy(#pass_text, "kolibri");
139
	}
139
	}
140
	else
140
	else
141
	{
141
	{
142
		strcpy(#pass_b64, strchr(#read_data, '\n'));
142
		strcpy(#pass_b64, strchr(#read_data, '\n'));
143
		base64_decode stdcall (#pass_b64, #pass_text, strlen(#pass_b64));
143
		base64_decode stdcall (#pass_b64, #pass_text, strlen(#pass_b64));
144
		ESBYTE[strchr(#read_data, '\n')] = NULL;
144
		ESBYTE[strchr(#read_data, '\n')] = NULL;
145
		strcpy(#email_text, #read_data);
145
		strcpy(#email_text, #read_data);
146
	}
146
	}
147
	pass_box.size = pass_box.pos = strlen(#pass_text);
147
	pass_box.size = pass_box.pos = strlen(#pass_text);
148
	login_box.size = login_box.pos = strlen(#email_text);
148
	login_box.size = login_box.pos = strlen(#email_text);
149
}
149
}
150
 
150
 
151
void SaveAndExit() {
151
void SaveAndExit() {
152
	char write_data[512], pass_b64[256];
152
	char write_data[512], pass_b64[256];
153
	Close(socketnum);
153
	Close(socketnum);
154
	strcpy(#write_data, #email_text);
154
	strcpy(#write_data, #email_text);
155
	chrcat(#write_data, '\n');
155
	chrcat(#write_data, '\n');
156
	base64_encode stdcall (#pass_text, #pass_b64, strlen(#pass_text));
156
	base64_encode stdcall (#pass_text, #pass_b64, strlen(#pass_text));
157
	strcat(#write_data, #pass_b64);
157
	strcat(#write_data, #pass_b64);
158
	WriteFile(strlen(#write_data)+1, #write_data, "/sys/network/mail.dat");
158
	WriteFile(strlen(#write_data)+1, #write_data, "/sys/network/mail.dat");
159
	ExitProcess();
159
	ExitProcess();
160
}
160
}
161
 
161
 
162
 
162
 
163
int GetRequest(dword command, text) {
163
int GetRequest(dword command, text) {
164
	strcpy(#request, command);
164
	strcpy(#request, command);
165
	if (text)
165
	if (text)
166
	{
166
	{
167
		chrcat(#request, ' ');
167
		chrcat(#request, ' ');
168
		strcat(#request, text);
168
		strcat(#request, text);
169
	}
169
	}
170
	strcat(#request, "\n");
170
	strcat(#request, "\n");
171
	return strlen(#request);
171
	return strlen(#request);
172
}
172
}
173
 
173
 
174
void StopConnect(dword message) {
174
void StopConnect(dword message) {
175
	if (message) notify(message);
175
	if (message) notify(message);
176
	aim = STOP;
176
	aim = STOP;
177
	Close(socketnum);
177
	Close(socketnum);
178
}
178
}
-
 
179
 
-
 
180
void EventShowLinkMenu(dword _left, _top)
-
 
181
{
-
 
182
	//do nothing, stub
-
 
183
	return;
-
 
184
}
179
 
185
 
180
stop:
186
stop: