Subversion Repositories Kolibri OS

Rev

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