Subversion Repositories Kolibri OS

Rev

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