Subversion Repositories Kolibri OS

Rev

Rev 8389 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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