2013-03-12 20:19:10 +04:00
|
|
|
//Leency & SoUrcerer, LGPL
|
|
|
|
|
|
|
|
//libraries
|
2014-01-22 04:28:22 +04:00
|
|
|
#define MEMSIZE 0x100000
|
2013-11-03 15:21:09 +04:00
|
|
|
#include "../lib/kolibri.h"
|
|
|
|
#include "../lib/strings.h"
|
|
|
|
#include "../lib/mem.h"
|
|
|
|
#include "../lib/dll.h"
|
|
|
|
#include "../lib/encoding.h"
|
|
|
|
#include "../lib/figures.h"
|
|
|
|
#include "../lib/file_system.h"
|
|
|
|
#include "../lib/list_box.h"
|
|
|
|
#include "../lib/socket_new.h"
|
2014-01-22 04:28:22 +04:00
|
|
|
#include "../lib/draw_buf.h"
|
|
|
|
#include "../lib/cursor.h"
|
2013-03-12 20:19:10 +04:00
|
|
|
//*.obj libraries
|
2013-11-03 15:21:09 +04:00
|
|
|
#include "../lib/lib.obj/box_lib.h"
|
|
|
|
#include "../lib/lib.obj/network.h"
|
|
|
|
#include "../lib/lib.obj/libio_lib.h"
|
|
|
|
#include "../lib/lib.obj/libimg_lib.h"
|
|
|
|
#include "../lib/lib.obj/netcode.h"
|
|
|
|
#include "../lib/lib.obj/iconv.h"
|
2013-03-12 20:19:10 +04:00
|
|
|
//images
|
2013-11-03 15:21:09 +04:00
|
|
|
byte letter_icons[sizeof(file "img/letter_icons.raw")] = FROM "img/letter_icons.raw";
|
|
|
|
#include "img/letter_icons.h"
|
2013-03-12 20:19:10 +04:00
|
|
|
|
|
|
|
//connection algorithm
|
|
|
|
enum {
|
|
|
|
STOP,
|
2013-10-31 22:40:41 +04:00
|
|
|
RESOLVE,
|
|
|
|
OPEN_CONNECTION,
|
2013-03-12 20:19:10 +04:00
|
|
|
GET_ANSWER_CONNECT,
|
|
|
|
SEND_USER,
|
|
|
|
GET_ANSWER_USER,
|
|
|
|
SEND_PASS,
|
|
|
|
GET_ANSWER_PASS,
|
|
|
|
SEND_NLIST,
|
|
|
|
GET_ANSWER_NLIST,
|
|
|
|
SEND_NSTAT,
|
|
|
|
GET_ANSWER_NSTAT,
|
|
|
|
SEND_RETR,
|
2013-11-05 01:40:13 +04:00
|
|
|
GET_ANSWER_RETR
|
2013-03-12 20:19:10 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
//WindowDefinitions
|
|
|
|
#define WIN_W 600
|
|
|
|
#define WIN_H 440
|
|
|
|
#define WIN_MIN_W 500
|
|
|
|
#define WIN_MIN_H 380
|
2013-11-06 22:50:58 +04:00
|
|
|
#define LOGIN_HEADER "Login - Email client Liza 0.9.3"
|
|
|
|
#define OPTIONS_HEADER "Options - Email client Liza 0.9.3"
|
|
|
|
#define MAILBOX_HEADER "Mail Box - Email client Liza 0.9.3"
|
2013-10-31 22:40:41 +04:00
|
|
|
#define BUFFERSIZE 512
|
2013-03-12 20:19:10 +04:00
|
|
|
proc_info Form;
|
|
|
|
system_colors sc;
|
|
|
|
#define LBUMP 0xFFFfff
|
|
|
|
|
|
|
|
//progress_bar definitions
|
|
|
|
char cur_st_percent;
|
|
|
|
dword cur_st_text;
|
|
|
|
|
|
|
|
//connection data
|
|
|
|
#define DEFAULT_POP_PORT 110;
|
|
|
|
char POP_server_path[128];
|
|
|
|
dword POP_server_port;
|
|
|
|
char login[128];
|
|
|
|
char request[256+22];
|
|
|
|
int request_len;
|
|
|
|
char connection_status;
|
2013-10-31 22:40:41 +04:00
|
|
|
dword socketnum;
|
|
|
|
|
|
|
|
sockaddr_in sockaddr;
|
2013-03-12 20:19:10 +04:00
|
|
|
|
|
|
|
int aim;
|
|
|
|
int ticks;
|
|
|
|
|
2013-10-31 22:40:41 +04:00
|
|
|
char immbuffer[BUFFERSIZE];
|
2013-03-12 20:19:10 +04:00
|
|
|
|
2013-11-05 01:40:13 +04:00
|
|
|
llist mail_list;
|
|
|
|
llist letter_view;
|
|
|
|
|
2014-01-22 04:28:22 +04:00
|
|
|
char version[]=" WebView 0.1";
|
|
|
|
#include "..\TWB\TWB.c"
|
|
|
|
|
2013-03-12 20:19:10 +04:00
|
|
|
#include "settings.c"
|
|
|
|
#include "login.c"
|
2013-11-05 01:40:13 +04:00
|
|
|
#include "letter_attr.c"
|
2013-03-12 20:19:10 +04:00
|
|
|
#include "mail_box.c"
|
|
|
|
#include "parselist.c"
|
|
|
|
|
2014-01-22 04:28:22 +04:00
|
|
|
void main() {
|
2013-03-12 20:19:10 +04:00
|
|
|
mem_Init();
|
2014-01-22 04:28:22 +04:00
|
|
|
CursorPointer.Load(#CursorFile);
|
|
|
|
if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("Error while loading library - box_lib.obj");
|
|
|
|
if (load_dll2(network_lib, #network_lib_init,0)!=0) notify("Error while loading library - network.obj");
|
|
|
|
if (load_dll2(netcode_lib, #base64_encode,0)!=0) notify("Error while loading library - netcode.obj");
|
|
|
|
if (load_dll2(iconv_lib, #iconv_open,0)!=0) { notify("Error while loading library - iconv.obj"); use_iconv=2; }
|
|
|
|
if (load_dll2(libio, #libio_init,1)!=0) notify("Error while loading library - libio.obj");
|
|
|
|
if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error while loading library - libimg.obj");
|
2013-03-12 20:19:10 +04:00
|
|
|
OpenMailDat();
|
|
|
|
SetEventMask(0x27);
|
|
|
|
LoginBoxLoop();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-22 04:28:22 +04:00
|
|
|
int DefineWindow(dword wtitle) {
|
2013-03-12 20:19:10 +04:00
|
|
|
sc.get();
|
|
|
|
DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2, WIN_W, WIN_H, 0x73,sc.work);
|
|
|
|
DrawTitle(wtitle);
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
|
|
|
if (Form.status_window>2) return 0; //rolled_up
|
|
|
|
if (Form.width < WIN_MIN_W) MoveSize(OLD,OLD,WIN_MIN_W,OLD);
|
|
|
|
if (Form.height < WIN_MIN_H) MoveSize(OLD,OLD,OLD,WIN_MIN_H);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-22 04:28:22 +04:00
|
|
|
void OpenMailDat() {
|
2013-03-12 20:19:10 +04:00
|
|
|
char read_data[512], pass_b64[256];
|
|
|
|
ReadFile(0, 512, #read_data, "/sys/network/mail.dat");
|
|
|
|
if (!read_data)
|
|
|
|
{
|
2013-11-05 23:38:16 +04:00
|
|
|
strcpy(#email_text, "testliza@ya.ru");
|
2013-11-05 01:40:13 +04:00
|
|
|
strcpy(#pass_text, "kolibri");
|
2013-03-12 20:19:10 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(#pass_b64, #read_data+strchr(#read_data, '\n')+1);
|
|
|
|
base64_decode stdcall (#pass_b64, #pass_text, strlen(#pass_b64));
|
|
|
|
read_data[strchr(#read_data, '\n')-1] = NULL;
|
|
|
|
strcpy(#email_text, #read_data);
|
|
|
|
}
|
|
|
|
pass_box.size = pass_box.pos = strlen(#pass_text);
|
|
|
|
login_box.size = login_box.pos = strlen(#email_text);
|
|
|
|
}
|
|
|
|
|
2014-01-22 04:28:22 +04:00
|
|
|
void SaveAndExit() {
|
2013-03-12 20:19:10 +04:00
|
|
|
char write_data[512], pass_b64[256];
|
2013-10-31 22:40:41 +04:00
|
|
|
Close(socketnum);
|
2013-03-12 20:19:10 +04:00
|
|
|
strcpy(#write_data, #email_text);
|
2013-11-03 17:42:47 +04:00
|
|
|
chrcat(#write_data, '\n');
|
2013-03-12 20:19:10 +04:00
|
|
|
base64_encode stdcall (#pass_text, #pass_b64, strlen(#pass_text));
|
|
|
|
strcat(#write_data, #pass_b64);
|
|
|
|
WriteFile(strlen(#write_data)+1, #write_data, "/sys/network/mail.dat");
|
|
|
|
ExitProcess();
|
|
|
|
}
|
|
|
|
|
2013-11-05 23:38:16 +04:00
|
|
|
|
2014-01-22 04:28:22 +04:00
|
|
|
int GetRequest(dword command, text) {
|
2013-11-05 03:27:39 +04:00
|
|
|
strcpy(#request, command);
|
|
|
|
if (text)
|
|
|
|
{
|
|
|
|
chrcat(#request, ' ');
|
|
|
|
strcat(#request, text);
|
|
|
|
}
|
|
|
|
strcat(#request, "\n");
|
|
|
|
return strlen(#request);
|
|
|
|
}
|
|
|
|
|
2014-01-22 04:28:22 +04:00
|
|
|
void StopConnect(dword message) {
|
2013-11-05 03:27:39 +04:00
|
|
|
if (message) notify(message);
|
|
|
|
aim = STOP;
|
2013-11-05 23:38:16 +04:00
|
|
|
Close(socketnum);
|
2013-11-05 03:27:39 +04:00
|
|
|
}
|
2013-03-12 20:19:10 +04:00
|
|
|
|
|
|
|
stop:
|
|
|
|
|