Subversion Repositories Kolibri OS

Rev

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