2013-03-12 17:19:10 +01:00
|
|
|
//Leency & SoUrcerer, LGPL
|
|
|
|
|
|
|
|
//libraries
|
2014-01-22 01:28:22 +01:00
|
|
|
#define MEMSIZE 0x100000
|
2013-11-03 12:21:09 +01:00
|
|
|
#include "../lib/kolibri.h"
|
|
|
|
#include "../lib/strings.h"
|
|
|
|
#include "../lib/mem.h"
|
|
|
|
#include "../lib/dll.h"
|
2015-03-05 21:55:28 +01:00
|
|
|
#include "../lib/gui.h"
|
2018-04-03 15:57:56 +02:00
|
|
|
#include "../lib/fs.h"
|
2013-11-03 12:21:09 +01:00
|
|
|
#include "../lib/list_box.h"
|
2015-03-05 21:55:28 +01:00
|
|
|
#include "../lib/socket.h"
|
2014-01-22 01:28:22 +01:00
|
|
|
#include "../lib/draw_buf.h"
|
|
|
|
#include "../lib/cursor.h"
|
2015-12-16 23:48:58 +01:00
|
|
|
#include "../lib/collection.h"
|
2013-03-12 17:19:10 +01:00
|
|
|
//*.obj libraries
|
2015-03-05 21:55:28 +01:00
|
|
|
#include "../lib/obj/box_lib.h"
|
|
|
|
#include "../lib/obj/network.h"
|
2018-05-20 15:54:35 +02:00
|
|
|
#include "../lib/obj/http.h"
|
2017-10-05 00:59:57 +02:00
|
|
|
#include "../lib/obj/libio.h"
|
|
|
|
#include "../lib/obj/libimg.h"
|
2015-03-05 21:55:28 +01:00
|
|
|
#include "../lib/obj/netcode.h"
|
|
|
|
#include "../lib/obj/iconv.h"
|
2018-10-29 12:39:31 +01:00
|
|
|
//patterns
|
2018-05-20 15:54:35 +02:00
|
|
|
#include "../lib/patterns/http_downloader.h"
|
2013-03-12 17:19:10 +01:00
|
|
|
//images
|
2013-11-03 12:21:09 +01:00
|
|
|
byte letter_icons[sizeof(file "img/letter_icons.raw")] = FROM "img/letter_icons.raw";
|
|
|
|
#include "img/letter_icons.h"
|
2013-03-12 17:19:10 +01:00
|
|
|
|
2018-05-20 15:54:35 +02:00
|
|
|
_http http = {0};
|
|
|
|
bool debug_mode = false;
|
|
|
|
char accept_language[]= "Accept-Language: ru\n";
|
2018-05-18 22:18:10 +02:00
|
|
|
|
2013-03-12 17:19:10 +01:00
|
|
|
//connection algorithm
|
|
|
|
enum {
|
|
|
|
STOP,
|
2013-10-31 19:40:41 +01:00
|
|
|
RESOLVE,
|
|
|
|
OPEN_CONNECTION,
|
2013-03-12 17:19:10 +01: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-04 22:40:13 +01:00
|
|
|
GET_ANSWER_RETR
|
2013-03-12 17:19:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
//WindowDefinitions
|
|
|
|
#define WIN_W 600
|
|
|
|
#define WIN_H 440
|
|
|
|
#define WIN_MIN_W 500
|
|
|
|
#define WIN_MIN_H 380
|
2015-08-11 13:29:31 +02:00
|
|
|
#define LOGIN_HEADER "Login - Email client Liza 0.9.4"
|
|
|
|
#define OPTIONS_HEADER "Options - Email client Liza 0.9.4"
|
|
|
|
#define MAILBOX_HEADER "Mail Box - Email client Liza 0.9.4"
|
2013-10-31 19:40:41 +01:00
|
|
|
#define BUFFERSIZE 512
|
2013-03-12 17:19:10 +01:00
|
|
|
proc_info Form;
|
|
|
|
#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 19:40:41 +01:00
|
|
|
dword socketnum;
|
|
|
|
|
|
|
|
sockaddr_in sockaddr;
|
2013-03-12 17:19:10 +01:00
|
|
|
|
|
|
|
int aim;
|
|
|
|
int ticks;
|
|
|
|
|
2013-10-31 19:40:41 +01:00
|
|
|
char immbuffer[BUFFERSIZE];
|
2013-03-12 17:19:10 +01:00
|
|
|
|
2013-11-04 22:40:13 +01:00
|
|
|
llist mail_list;
|
|
|
|
llist letter_view;
|
|
|
|
|
2014-04-22 00:30:28 +02:00
|
|
|
dword TAB_H = false; //19;
|
|
|
|
dword TAB_W = 150;
|
|
|
|
dword TOOLBAR_H = 31; //50;
|
|
|
|
dword STATUSBAR_H =15;
|
|
|
|
dword col_bg;
|
|
|
|
dword panel_color;
|
|
|
|
dword border_color;
|
|
|
|
|
2017-07-05 12:42:59 +02:00
|
|
|
bool open_in_a_new_window = false;
|
|
|
|
|
2015-03-16 15:23:55 +01:00
|
|
|
progress_bar wv_progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F};
|
2014-04-22 00:30:28 +02:00
|
|
|
|
2020-03-26 01:12:32 +01:00
|
|
|
#define URL_SIZE 4000;
|
|
|
|
|
2014-04-22 00:30:28 +02:00
|
|
|
int http_transfer;
|
2014-01-22 01:28:22 +01:00
|
|
|
char version[]=" WebView 0.1";
|
|
|
|
#include "..\TWB\TWB.c"
|
|
|
|
|
2013-03-12 17:19:10 +01:00
|
|
|
#include "settings.c"
|
|
|
|
#include "login.c"
|
2013-11-04 22:40:13 +01:00
|
|
|
#include "letter_attr.c"
|
2013-03-12 17:19:10 +01:00
|
|
|
#include "mail_box.c"
|
|
|
|
#include "parselist.c"
|
|
|
|
|
2014-01-22 01:28:22 +01:00
|
|
|
void main() {
|
2015-08-02 17:15:15 +02:00
|
|
|
|
2014-01-22 01:28:22 +01:00
|
|
|
CursorPointer.Load(#CursorFile);
|
2015-07-29 22:43:05 +02:00
|
|
|
load_dll(boxlib, #box_lib_init,0);
|
|
|
|
load_dll(network_lib, #network_lib_init,0);
|
|
|
|
load_dll(netcode_lib, #base64_encode,0);
|
|
|
|
load_dll(libio, #libio_init,1);
|
|
|
|
load_dll(libimg, #libimg_init,1);
|
2015-08-07 00:37:34 +02:00
|
|
|
load_dll(iconv_lib, #iconv_open,0);
|
2013-03-12 17:19:10 +01:00
|
|
|
OpenMailDat();
|
2018-10-29 12:39:31 +01:00
|
|
|
SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
|
2013-03-12 17:19:10 +01:00
|
|
|
LoginBoxLoop();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-22 01:28:22 +01:00
|
|
|
int DefineWindow(dword wtitle) {
|
2015-08-04 16:36:07 +02:00
|
|
|
system.color.get();
|
2016-11-23 12:37:13 +01:00
|
|
|
DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2, WIN_W, WIN_H, 0x73,system.color.work, 0,0);
|
2013-03-12 17:19:10 +01:00
|
|
|
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 01:28:22 +01:00
|
|
|
void OpenMailDat() {
|
2013-03-12 17:19:10 +01:00
|
|
|
char read_data[512], pass_b64[256];
|
|
|
|
ReadFile(0, 512, #read_data, "/sys/network/mail.dat");
|
|
|
|
if (!read_data)
|
|
|
|
{
|
2013-11-05 20:38:16 +01:00
|
|
|
strcpy(#email_text, "testliza@ya.ru");
|
2013-11-04 22:40:13 +01:00
|
|
|
strcpy(#pass_text, "kolibri");
|
2013-03-12 17:19:10 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-07-29 22:06:46 +02:00
|
|
|
strcpy(#pass_b64, strchr(#read_data, '\n'));
|
2013-03-12 17:19:10 +01:00
|
|
|
base64_decode stdcall (#pass_b64, #pass_text, strlen(#pass_b64));
|
2015-07-29 22:06:46 +02:00
|
|
|
ESBYTE[strchr(#read_data, '\n')] = NULL;
|
2013-03-12 17:19:10 +01:00
|
|
|
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 01:28:22 +01:00
|
|
|
void SaveAndExit() {
|
2013-03-12 17:19:10 +01:00
|
|
|
char write_data[512], pass_b64[256];
|
2013-10-31 19:40:41 +01:00
|
|
|
Close(socketnum);
|
2013-03-12 17:19:10 +01:00
|
|
|
strcpy(#write_data, #email_text);
|
2013-11-03 14:42:47 +01:00
|
|
|
chrcat(#write_data, '\n');
|
2013-03-12 17:19:10 +01:00
|
|
|
base64_encode stdcall (#pass_text, #pass_b64, strlen(#pass_text));
|
|
|
|
strcat(#write_data, #pass_b64);
|
2018-04-16 00:44:36 +02:00
|
|
|
CreateFile(strlen(#write_data)+1, #write_data, "/sys/network/mail.dat");
|
2013-03-12 17:19:10 +01:00
|
|
|
ExitProcess();
|
|
|
|
}
|
|
|
|
|
2013-11-05 20:38:16 +01:00
|
|
|
|
2014-01-22 01:28:22 +01:00
|
|
|
int GetRequest(dword command, text) {
|
2013-11-05 00:27:39 +01:00
|
|
|
strcpy(#request, command);
|
|
|
|
if (text)
|
|
|
|
{
|
|
|
|
chrcat(#request, ' ');
|
|
|
|
strcat(#request, text);
|
|
|
|
}
|
|
|
|
strcat(#request, "\n");
|
|
|
|
return strlen(#request);
|
|
|
|
}
|
|
|
|
|
2014-01-22 01:28:22 +01:00
|
|
|
void StopConnect(dword message) {
|
2013-11-05 00:27:39 +01:00
|
|
|
if (message) notify(message);
|
|
|
|
aim = STOP;
|
2013-11-05 20:38:16 +01:00
|
|
|
Close(socketnum);
|
2013-11-05 00:27:39 +01:00
|
|
|
}
|
2013-03-12 17:19:10 +01:00
|
|
|
|
2017-10-01 14:02:01 +02:00
|
|
|
void EventShowLinkMenu(dword _left, _top)
|
|
|
|
{
|
|
|
|
//do nothing, stub
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-12 17:19:10 +01:00
|
|
|
stop:
|
|
|
|
|