Subversion Repositories Kolibri OS

Rev

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

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