2013-03-12 20:19:10 +04:00
|
|
|
//Leency & SoUrcerer, LGPL
|
|
|
|
|
|
|
|
//libraries
|
|
|
|
#define MEMSIZE 0xA0000
|
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"
|
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-03 15:21:09 +04:00
|
|
|
#define LOGIN_HEADER "Login - Email client Liza 0.9b"
|
|
|
|
#define OPTIONS_HEADER "Options - Email client Liza 0.9b"
|
|
|
|
#define MAILBOX_HEADER "Mail Box - Email client Liza 0.9b"
|
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;
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
mem_Init();
|
|
|
|
if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("Error while loading library /rd/1/lib/box_lib.obj");
|
|
|
|
if (load_dll2(network_lib, #network_lib_init,0)!=0) notify("Error while loading library /rd/1/lib/network.obj");
|
|
|
|
if (load_dll2(netcode_lib, #base64_encode,0)!=0) notify("Error while loading library /rd/1/lib/netcode.obj");
|
|
|
|
if (load_dll2(iconv_lib, #iconv_open,0)!=0) { notify("Error while loading library /rd/1/lib/iconv.obj"); use_iconv=2; }
|
|
|
|
|
|
|
|
OpenMailDat();
|
|
|
|
SetEventMask(0x27);
|
|
|
|
LoginBoxLoop();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int DefineWindow(dword wtitle)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OpenMailDat()
|
|
|
|
{
|
|
|
|
char read_data[512], pass_b64[256];
|
|
|
|
ReadFile(0, 512, #read_data, "/sys/network/mail.dat");
|
|
|
|
if (!read_data)
|
|
|
|
{
|
2013-11-05 01:40:13 +04:00
|
|
|
strcpy(#email_text, "testliza@ya.ru"); //temporarily, for testing
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SaveAndExit()
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stop:
|
|
|
|
|