Subversion Repositories Kolibri OS

Rev

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

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