uploaded liza, deleted installer.lst

git-svn-id: svn://kolibrios.org@3368 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2013-03-12 16:19:10 +00:00
parent de654e7a3a
commit 8075b8b15d
12 changed files with 1334 additions and 4366 deletions

View File

@ -1,4 +1,4 @@
..\C--\C-- main.c /lst
..\C--\C-- main.c
@del installer.kex
@rename main.com installer.kex
@pause

View File

@ -55,8 +55,8 @@ int DefineWindow(dword wtitle, wbutton)
void main()
{
mem_Init();
if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("Error while loading library /rd/1/lib/box_lib.obj");
SetEventMask(0x27);
//if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("Error while loading library /rd/1/lib/box_lib.obj");
//SetEventMask(0x27);
program_path[strrchr(#program_path, '/')] = 0x0;
HalloLoop();
}

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,7 @@ void llist::SetSizes(int xx, yy, ww, hh, min_hh, line_hh)
h = hh;
min_h = min_hh;
line_h = line_hh;
visible = h / line_h;
}

View File

@ -0,0 +1,5 @@
..\C--\C-- liza.c
@del liza_mail
@rename liza.com liza_mail
@del warning.txt
@pause

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1 @@
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>幹雁艸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¦¦¦¦¦¦¦¦¦¦¦<EFBFBD><EFBFBD><EFBFBD><EFBFBD>蓙茣幹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>幹観冪玻璞嶹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>嶹增瘁蕨牢幹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>旭逸闖電土旙韶韭跛跛跛跛跛跛跛跛跟韶毫歛詑闖鎔旭<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>艸裴蠎室忻恁跛聿聿聿聿聿聿跛齎旙幻瑚裴艸腦<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>いむ玻矜矮粐亀逆孚艸艢玻玻琅聿捶找臆粐籵矜玻爐い<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>旙旙旙湎渟栩<EFBFBD><EFBFBD><EFBFBD>墺壯窿窿窈慓<EFBFBD><EFBFBD><EFBFBD>樛權湎旙旙旙<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>墺墻嶽冪僥Ё裴雖⑬ゥェЁ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>嗷孚孕墺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>蕨鰐面いれ跛迯迥裴裴裴裴裴褄迯迯蹣<EFBFBD>様溶蕨<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>篤蕩□繞繖粐烝烝烝烝烝烝烝烝烝窿竍艸いで杷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ёл毫嶽嶬墺厰厶嗷嗷嗷嗷嗷嘔厰厰叟忻湎洫<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ddd<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ddd<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>幹雁艸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¦¦¦¦¦¦¦¦¦¦¦<EFBFBD><EFBFBD><EFBFBD><EFBFBD>蓙茣幹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>幹観冪玻璞嶹<15><15><17><><EFBFBD>齠齡<E9BDA0><E9BDA1><EFBFBD><EFBFBD>嶹增瘁蕨牢幹<E789A2><E5B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>旭逸闖電土旙<15><><15>跛跛跛跛跛跛韶鞆毫詑啄闖旭<E99796><E697AD><EFBFBD><EFBFBD><15><15><15><15><15><15>x<><EFBFBD><15>聿聿聿跛齎旙幻瑚裴艸腦<E889B8><E885A6><EFBFBD><EFBFBD><15><17><EFBFBD>琢鸞<E790A2><EFBFBD><E99B9B><EFBFBD>~<7E><><EFBFBD><15>聿聆捶臆俄粐矜矗玻い<E78EBB><E38184><EFBFBD><EFBFBD><15><1F>,<1F>,<1F>,<1F>,*<2A>8<17>&<1D>%<15> <15><><E68593><EFBFBD><EFBFBD>樛權湎旙旙旙<E69799><E69799><EFBFBD><EFBFBD><EFBFBD><EFBFBD><14><13><15><15><15><15><1D>&<1D>)<15><17><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8A3B4>嗷孚孕墺<E5AD95><E5A2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E8A3B4><EFBFBD><EFBFBD>誓製十<E8A3BD><E58D81><EFBFBD><15><1F>,<15>捶搖裴裴褄迯迯蹣<E8BFAF>様溶蕨<E6BAB6><E895A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>篤蕩□繞<E296A1><15><15><>烝烝烝烝烝焜窿艸腓い杷<E38184><E69DB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ёл毫嶽嶬墺厰厶嗷嗷嗷嗷嗷嘔厰厰叟忻湎洫<E6B98E><E6B4AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ddd<64><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ddd<64><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>幹雁艸<E99B81><E889B8><EFBFBD><EFBFBD><EFBFBD>¦¦¦¦¦¦¦¦¦¦¦<EFBFA4><EFBC87><EFBFBD><EFBFBD>蓙茣幹<E88CA3><E5B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>幹観冪玻璞嶹<E7929E><E5B6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><15><>蕨牢幹<E789A2><E5B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>旭逸闖電土旙韶韭跛跛跛跛跛跛跛跛跟韶<E8B79F><E99FB6><><E78484><EFBFBD><><E697AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>艸裴蠎室忻恁跛聿<E8B79B><E881BF><EFBFBD><15><><15><><15><><15><><15><>踝x遧<78><E981A7><EFBFBD><><E8A3B4><EFBFBD><EFBFBD>いむ玻矜矮粐亀逆孚艸<E5AD9A><E889B8><EFBFBD><>兊遧兆兊遧着<E981A7><E79D80>踞}焄<><E78484><EFBFBD><15><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>旙旙旙湎渟栩<E6B89F><E6A0A9><EFBFBD><EFBFBD><E5A2BA><EFBFBD>萵)柤!紡<15><><12><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>墺墻嶽冪僥Ё裴雖⑬<E99B96><E291AC><12><><12><><12><><12><><12><><1D><><><E8A3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>蕨鰐面いれ跛迯迥裴裴袮捶捶掉樛樛<E6A89B><E6A89B><EFBFBD><1F><><12><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>篤蕩□繞繖粐烝烝烝烝烝烝烝烝烝窿<E7839D><E7AABF><EFBFBD><12><><><E69BB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ёл毫嶽嶬墺厰厶嗷嗷嗷嗷嗷嘔厰厰叟忻湎洫<E6B98E><E6B4AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ddd<64><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ddd<64><64><EFBFBD>

160
programs/cmm/liza/liza.c Normal file
View File

@ -0,0 +1,160 @@
//Leency & SoUrcerer, LGPL
//libraries
#define MEMSIZE 0xA0000
#include "..\lib\kolibri.h"
#include "..\lib\strings.h"
#include "..\lib\encoding.h"
#include "..\lib\file_system.h"
#include "..\lib\figures.h"
#include "..\lib\list_box.h"
#include "..\lib\socket.h"
#include "..\lib\mem.h"
#include "..\lib\dll.h"
//*.obj libraries
#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"
//images
byte in_out_mail[18*36] = FROM "in_out_mail.raw";
//connection algorithm
enum {
STOP,
GET_PORT,
GET_SERVER_IP,
GET_SOCKET,
CONNECT,
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,
GET_ANSWER_RETR
};
//WindowDefinitions
#define WIN_W 600
#define WIN_H 440
#define WIN_MIN_W 500
#define WIN_MIN_H 380
#define LOGIN_HEADER "Login - Email client Liza 0.77"
#define OPTIONS_HEADER "Options - Email client Liza 0.77"
#define MAILBOX_HEADER "Mail Box - Email client Liza 0.77"
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;
dword local_port=1000;
char POP_server_path[128];
dword POP_server_IP;
dword POP_server_port;
char login[128];
char request[256+22];
int request_len;
char connection_status;
dword socket;
int aim;
int ticks;
//global data for server response
char immbuffer[512];
int immpointer;
void immfree(){
immpointer=0;
immbuffer[immpointer]='\0';
}
void immputc(char agot_char){
immbuffer[immpointer]=agot_char;
immpointer++;
immbuffer[immpointer]='\0';
if (immpointer>511) {immpointer=0; debug ("IMM BUFFER OVERFLOW ERROR"); aim=NULL;}
}
#include "settings.c"
#include "login.c"
#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)
{
//strcpy(#email_text, "eiroglif@yandex.ru"); //temporarily, for testing
strcpy(#email_text, "example@mail.com");
//strcpy(#pass_text, "rostov");
}
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];
strcpy(#write_data, #email_text);
strcat(#write_data, "\n");
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:

298
programs/cmm/liza/login.c Normal file
View File

@ -0,0 +1,298 @@
//Leency & SoUrcerer, LGPL
//LoginPanel
#define PANEL_W 220
#define PANEL_H 140
int panel_x, panel_y;
//edit_boxes at LoginPanel
int mouse_dd;
unsigned char email_text[128];
unsigned char pass_text[32];
edit_box login_box= {PANEL_W-6,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(email_text)+2,#email_text,#mouse_dd,0b10};
edit_box pass_box= {PANEL_W-6,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(pass_text)+2,#pass_text,#mouse_dd,0b1};
void LoginBoxLoop()
{
int key, id;
char socket_char;
SetLoginStatus(NULL,NULL);
goto _LB_DRAW;
loop()
{
WaitEventTimeout(2);
switch(EAX & 0xFF)
{
case evMouse:
IF (GetProcessSlot(Form.ID)-GetActiveProcess()!=0) break;
edit_box_mouse stdcall (#login_box);
edit_box_mouse stdcall (#pass_box);
break;
case evButton:
id = GetButtonID();
if (id==1) SaveAndExit();
if (id==11) OptionsLoop();
if (id==12)
{
if (!aim) aim=GET_PORT; else aim=NULL;
GetSettings();
SetLoginStatus(NULL, NULL);
DrawLoginScreen();
}
break;
case evKey:
key = GetKey();
if (key==9)
{
if (login_box.flags & 0b10)
{ pass_box.flags = 0b11; login_box.flags = 0; }
else
{ pass_box.flags = 0b1; login_box.flags = 0b10; }
edit_box_draw stdcall(#login_box);
edit_box_draw stdcall(#pass_box);
break;
}
if (key==13)
{
if (aim) break;
aim=GET_PORT;
GetSettings();
SetLoginStatus(NULL, NULL);
DrawLoginScreen();
}
EAX=key<<8;
edit_box_key stdcall(#login_box);
edit_box_key stdcall(#pass_box);
break;
case evReDraw: _LB_DRAW:
if !(DefineWindow(LOGIN_HEADER)) break;
DrawLoginScreen();
break;
default:
if (!aim) { SetLoginStatus(NULL, NULL); break; }
if (!email_text) { notify("Enter email!"); aim=NULL; }
if (!pass_text) { notify("Enter password!"); aim=NULL; }
if ((!login) || (!POP_server_path)) { notify("Email should be such as username@somesite.com"); aim=NULL; }
if (aim == GET_PORT)
{
SetLoginStatus(5, "Search for free local port...");
local_port = GetFreePort(1000);
if (!local_port) { notify("Error: There is no free local ports"); aim=NULL; break;}
SetLoginStatus(12, "Obtain server IP...");
aim = GET_SERVER_IP;
}
if (aim == GET_SERVER_IP)
{
POP_server_IP = GetIPfromAdress(#POP_server_path);
if (!POP_server_IP) { SetLoginStatus(12, "Can't obtain server IP. Retry..."); break; }
SetLoginStatus(25, "Obtain to open socket..."w);
aim = GET_SOCKET;
}
if (aim == GET_SOCKET)
{
socket = OpenSocket(local_port, POP_server_port, POP_server_IP, SOCKET_ACTIVE);
if (socket == 0xffffffff) { SetLoginStatus(25, "Error obtaining socket. Retry..."); break;}
SetLoginStatus(40, "Establish a connection...");
aim = CONNECT;
}
if (aim == CONNECT)
{
connection_status=StatusSocket(socket);
if (connection_status==0) {notify("Connection to server isn't possible"); aim=NULL; break; };
if (connection_status==7) {SetLoginStatus(40, "Server disconnected. Retry..."); break; };
if (connection_status!=4) break; //0-connection isn't possible, 2-connecting, 4-connected, 7-server disconnected
SetLoginStatus(55, "Connection established. Reading answer...");
immfree();
aim = GET_ANSWER_CONNECT;
}
if (aim == GET_ANSWER_CONNECT)
{
if (!PollSocket(socket)) break;
socket_char=ReadSocket(socket);
immputc(socket_char);
if (socket_char=='\n')
{
debug(#immbuffer);
if (strstr(#immbuffer,"+OK"))
{
SetLoginStatus(60, "Verifying username...");
aim = SEND_USER;
immfree();
}
else
{
immfree();
//aim=NULL; //may don't need retry?
SetLoginStatus(55, "Failed to connect to server. Retry...");
}
}
}
if (aim == SEND_USER)
{
request_len = GetRequest("USER", #login);
WriteSocket(socket,request_len,#request);
if (EAX == 0xffffffff) { SetLoginStatus(60, "Failed to send USER. Retry..."); break;}
SetLoginStatus(70, "Login verifying...");
debug("Send USER, awaiting answer...");
aim = GET_ANSWER_USER;
}
if (aim == GET_ANSWER_USER)
{
if (!PollSocket(socket)) break;
socket_char=ReadSocket(socket);
immputc(socket_char);
if (socket_char=='\n')
{
debug("GOT::");
debug(#immbuffer);
if (strstr(#immbuffer,"+OK"))
{ aim = SEND_PASS; SetLoginStatus(80, "Verifying password..."); immfree(); }
else
{ notify("Wrong username"); immfree(); aim=NULL;}
}
}
if (aim == SEND_PASS)
{
debug("\n Send PASS, awaiting answer...");
request_len = GetRequest("PASS", #pass_text);
WriteSocket(socket,request_len,#request);
if (EAX == 0xffffffff) { SetLoginStatus(80, "Failed to send PASS. Retry..."); break;}
aim = GET_ANSWER_PASS;
}
if (aim == GET_ANSWER_PASS)
{
if (!PollSocket(socket)) break;
socket_char=ReadSocket(socket);
immputc(socket_char);
if (socket_char=='\n')
{
debug("GOT::");
debug(#immbuffer);
if (strstr(#immbuffer,"+OK"))
{
SetLoginStatus(100, "Entering mailbox...");
aim=SEND_NSTAT;
immfree();
MailBoxLoop();
}
else
{
notify("Wrong password");
aim=NULL;
immfree();
}
}
}
}
}
}
void DrawLoginScreen()
{
panel_x = Form.cwidth - PANEL_W /2;
panel_y = Form.cheight - PANEL_H /2 - 5;
DrawBar(0,0, Form.cwidth, Form.cheight, sc.work);
WriteText(panel_x,panel_y,0x80,sc.work_text,"Your Email:");
DrawRectangle(panel_x, panel_y+12, PANEL_W,20, sc.work_graph); //border
DrawRectangle3D(panel_x+1, panel_y+13, PANEL_W-2,18, 0xDDDddd, 0xFFFfff); //shadow
DrawRectangle(panel_x+2, panel_y+14, PANEL_W-4,16, 0xFFFfff);
login_box.left = panel_x+3;
login_box.top = panel_y+15;
edit_box_draw stdcall(#login_box);
WriteText(panel_x,panel_y+40,0x80,sc.work_text,"Password:");
DrawRectangle(panel_x, panel_y+52, PANEL_W,20, sc.work_graph); //border
DrawRectangle3D(panel_x+1, panel_y+53, PANEL_W-2,18, 0xDDDddd, 0xFFFfff); //shadow
DrawRectangle(panel_x+2, panel_y+54, PANEL_W-4,16, 0xFFFfff);
pass_box.left = panel_x+3;
pass_box.top = panel_y+55;
edit_box_draw stdcall(#pass_box);
if (!aim)
{
DrawCaptButton(panel_x,panel_y+90,100,20,11,sc.work_button, sc.work_button_text,"Settings");
DrawCaptButton(panel_x+120,panel_y+90,100,20,12,sc.work_button, sc.work_button_text,"Enter >");
}
else DrawCaptButton(panel_x+120,panel_y+90,100,20,12,sc.work_button, sc.work_button_text,"Stop");
SetLoginStatus(cur_st_percent, cur_st_text);
}
int GetRequest(dword command, text)
{
strcpy(#request, command);
if (text)
{
strcat(#request, " ");
strcat(#request, text);
}
strcat(#request, "\n");
return strlen(#request);
}
void GetServerPathAndLogin()
{
int i=strchr(#email_text,'@');
POP_server_path=login=NULL;
if (i)
{
strcpy(#POP_server_path, "pop.");
strcat(#POP_server_path, #email_text+i);
}
strcpy(#login, #email_text);
login[i-1]=NULL;
}
void GetSettings()
{
GetServerPathAndLogin(); //get
if (checked[CUSTOM])
{
if (!strcmp(#POP_server_path, "pop.gmail.com")) POP_server_port = 995;
else POP_server_port = DEFAULT_POP_PORT;
}
if (checked[MANUAL])
{
strcpy(#POP_server_path, #POP_server1);
POP_server_port = atoi(#POP_server_port1);
}
debug(#POP_server_path);
debug(#login);
debug(itoa(POP_server_port));
}
void SetLoginStatus(dword percent1, text1)
{
DrawProgressBar(10, Form.cheight-22, PANEL_W, 12, sc.work, sc.work_graph, 0x54B1D6, sc.work_text, percent1, text1);
cur_st_percent = percent1;
cur_st_text = text1;
}

View File

@ -0,0 +1,585 @@
//Leency & SoUrcerer, LGPL
#define LIST_INFO_H 59
int status_bar_h = 15;
scroll_bar scroll1 = { 17,200,210, LIST_INFO_H-3,18,0,115,15,0,0xCCCccc,0xD2CED0,0x555555,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
scroll_bar scroll2 = { 17,200,210, LIST_INFO_H,18,0,115,15,0,0xCCCccc,0xD2CED0,0x555555,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
llist mail_list;
llist letter_view;
char from[256];
char to[256];
char date[256];
char subj[256];
dword mdata;
char *listbuffer;
char *listpointer;
char *mailbuffer;
char *mailpointer;
enum {
GET_MAIL = 20,
SEND_MAIL,
DELETE_LETTER,
SAVE_LETTER,
STOP_LOADING,
EXIT_MAIL,
CHANGE_CHARSET,
CLOSE_CHANGE_CHARSET
};
void MailBoxLoop()
{
int key, id;
mouse m;
int panels_drag = 0;
char socket_char;
int letter_size;
dword line_col, text_col;
mail_list.h = Form.cheight/4;
mail_list.ClearList();
SetMailBoxStatus( NULL , NULL);
cur_charset = 0;
goto _MB_DRAW;
loop()
{
WaitEventTimeout(2);
switch(EAX & 0xFF)
{
case evMouse:
IF (GetProcessSlot(Form.ID)-GetActiveProcess()!=0) break;
m.get();
if (!m.lkm) panels_drag=0;
if (m.lkm) && (m.y>mail_list.y+mail_list.h-1) && (m.y<mail_list.y+mail_list.h+6)
&& (!scroll1.delta2) && (!scroll2.delta2) panels_drag = 1;
if (panels_drag)
{
if (m.y<mail_list.y+mail_list.min_h) || (m.y>Form.cheight-letter_view.min_h-status_bar_h-LIST_INFO_H) break;
mail_list.h = m.y - mail_list.y-2;
DrawMailBox();
break;
}
if (!mail_list.count) break;
if (!panels_drag) { scrollbar_v_mouse (#scroll1); scrollbar_v_mouse (#scroll2); }
if (mail_list.first <> scroll1.position)
{
mail_list.first = scroll1.position;
DrawMailList();
break;
};
if (letter_view.first <> scroll2.position)
{
letter_view.first = scroll2.position;
DrawLetter();
break;
};
if (mail_list.y+mail_list.h + 10 > m.y)
{
if (mail_list.MouseScroll(m.vert)) DrawMailList();
}
else
{
if (letter_view.MouseScroll(m.vert)) DrawLetter();
}
break;
case evButton:
id = GetButtonID();
if (id==1) SaveAndExit();
if (id==GET_MAIL) aim = SEND_NSTAT;
if (id==SAVE_LETTER)
{
if (!mailbuffer) break;
WriteFile(strlen(mailbuffer), mailbuffer, "mail.txt");
pause(10);
RunProgram("tinypad", "mail.txt");
}
if (id==STOP_LOADING)
{
StopLoading();
DrawStatusBar();
DrawMailList();
}
if (id==EXIT_MAIL)
{
StopLoading();
LoginBoxLoop();
}
if (id==CHANGE_CHARSET)
{
DefineButton(0,0,Form.cwidth,Form.cheight, CLOSE_CHANGE_CHARSET+BT_HIDE+BT_NOFRAME);
DrawRectangle(Form.cwidth-100, Form.cheight-status_bar_h- 70, 70, 82, sc.work_graph);
DrawRectangle3D(Form.cwidth-99, Form.cheight-status_bar_h- 69, 68, 80, 0xFFFfff, sc.work);
for (id=0; id<5; id++)
{
if (cur_charset==id+1) { line_col=sc.work_button; text_col=sc.work_button_text; }
else { line_col=sc.work; text_col=sc.work_text; }
DrawBar(Form.cwidth-98, id*16+Form.cheight-status_bar_h- 68, 67, 16, line_col);
DrawCaptButton(Form.cwidth-100, id*16+Form.cheight-status_bar_h- 68, 70,16, 10+id+BT_HIDE,
0, text_col, charsets[id+1]);
}
}
if (id==CLOSE_CHANGE_CHARSET) goto _MB_DRAW;
if (id>=30)
{
if (aim) break;
mail_list.current = mail_list.first + id - 30;
DrawMailList();
aim = SEND_RETR;
}
break;
case evKey:
key = GetKey();
if (key == 177){ //down
if (aim) break;
if (mail_list.current >= mail_list.count-1) break;
mail_list.current++ ;
if (mail_list.current >= mail_list.first + mail_list.visible) mail_list.first++ ;
DrawMailList();
aim = SEND_RETR;
}
if (key == 178){ //up
if (aim) break;
if (mail_list.current<=0) break;
mail_list.current-- ;
if (mail_list.current < mail_list.first) mail_list.first-- ;
DrawMailList();
aim = SEND_RETR;
}
if (key == 180){ //home
if (aim) break;
mail_list.first = mail_list.current = 0;
DrawMailList();
aim = SEND_RETR;
}
if (key == 181){ //end
if (aim) break;
mail_list.first = mail_list.count - mail_list.visible;
mail_list.current = mail_list.count - 1;
DrawMailList();
aim = SEND_RETR;
}
break;
case evReDraw: _MB_DRAW:
if !(DefineWindow(MAILBOX_HEADER)) break;
scroll1.bckg_col = scroll2.bckg_col = 0xBBBbbb;
scroll1.frnt_col = scroll2.frnt_col = sc.work;
scroll1.line_col = scroll2.line_col = sc.work_graph;
DrawToolbar();
DrawMailBox();
break;
default:
if (aim == SEND_NSTAT)
{
debug("Counting mail, awaiting answer...");
request_len = GetRequest("STAT", NULL);
WriteSocket(socket,request_len,#request);
if (EAX == 0xffffffff) { debug("Error sending STAT. Retry..."w); break;}
aim = GET_ANSWER_NSTAT;
}
if (aim == GET_ANSWER_NSTAT)
{
if (!PollSocket(socket)) break;
socket_char=ReadSocket(socket);
immputc(socket_char);
if (socket_char=='\n')
{
debug("GOT::");
debug(#immbuffer);
if (strstr(#immbuffer,"+OK"))
{
mail_list.count = GetMailCount();
debug("Letters:");
debug(itoa(mail_list.count));
listbuffer = free(listbuffer);
listbuffer = mem_Alloc(30*mail_list.count); //24* original
listpointer = listbuffer;
aim = SEND_NLIST;
debug("Recieving mail list...");
immfree();
}
else
{
notify("Sorry, can't recieve your mail");
immfree();
aim=NULL; //aim = SEND_NLIST;
}
}
}
if (aim == SEND_NLIST)
{
WriteText(5, Form.cheight-11, 0x80, sc.work_text, "Send LIST, awaiting answer...");
request_len = GetRequest("LIST", NULL);
WriteSocket(socket,request_len,#request);
if (EAX == 0xffffffff) {debug("Error while sending LIST. Retry..."); break;}
aim = GET_ANSWER_NLIST;
}
if (aim == GET_ANSWER_NLIST)
{
ticks = PollSocket(socket);
if (!ticks) break;
for (;ticks>0;ticks--)
{
socket_char=ReadSocket(socket);
listputc(socket_char);
if (socket_char=='.') //this way of checking end of message IS BAD
{
aim = SEND_RETR;
debug("Got mail list");
DrawMailBox();
CreateMailsArray();
SetMailsSizes();
}
}
}
if (aim == SEND_RETR)
{
from = to = date = subj = cur_charset = NULL;
letter_view.ClearList();
DrawMailBox();
debug("Send RETR, awaiting answer...");
request_len = GetRequest("RETR", itoa(mail_list.current+1));
WriteSocket(socket,request_len,#request);
if (EAX == 0xffffffff) { notify("Error while trying to get letter from server"); aim=NULL; break;}
mailbuffer = free(mailbuffer);
letter_size = GetLetterSize(mail_list.current+1) + 1024;
mailbuffer = malloc(letter_size);
mailpointer = mailbuffer;
aim = GET_ANSWER_RETR;
}
if (aim == GET_ANSWER_RETR)
{
ticks=PollSocket(socket);
if (!ticks) break;
for (;ticks>0;ticks--)
{
socket_char=ReadSocket(socket);
//debugch(socket_char);
*mailpointer=socket_char;
mailpointer++;
*mailpointer='\0';
if (!aim) continue;
if (letter_size + mailbuffer - mailpointer - 2 < 0)
{
debug("Buffer overflow!!1 Realloc..."w);
letter_size += 4096;
mailbuffer = realloc(mailbuffer, letter_size);
if (!mailbuffer) {debug("Relloc error!"); aim=NULL; break;}
}
if (letter_size>5000)
{
id = mailpointer - mailbuffer * 100 ;
id /= letter_size - 1024;
if (id!=cur_st_percent) SetMailBoxStatus( id , NULL);
}
ParceMail();
}
}
}
}
}
void DrawMailBox()
{
DrawMailList();
DrawLetterInfo();
DrawLetter();
DrawStatusBar();
}
void DrawToolbar()
{
#define BUT_Y 7
#define BUT_H 22
#define BUT_W 74
#define BUT_SPACE 11
int toolbar_w = BUT_Y + BUT_H + BUT_Y + 3;
mail_list.SetSizes(0, toolbar_w, Form.cwidth - scroll1.size_x - 1, mail_list.h, 60,18);
DrawBar(0,0, Form.cwidth,toolbar_w-3, sc.work);
DrawCaptButton(10 , BUT_Y, BUT_W, BUT_H, GET_MAIL, sc.work_button, sc.work_button_text,"Get mail");
DrawCaptButton(BUT_W+BUT_SPACE + 10, BUT_Y, BUT_W, BUT_H, SEND_MAIL, sc.work_button, sc.work_button_text,"Send Email");
DrawCaptButton(BUT_W+BUT_SPACE*2 + 10, BUT_Y, BUT_W, BUT_H, DELETE_LETTER, sc.work_button, sc.work_button_text,"Delete");
DrawCaptButton(BUT_W+BUT_SPACE*3 + 10, BUT_Y, BUT_W, BUT_H, SAVE_LETTER, sc.work_button, sc.work_button_text,"Save");
DrawCaptButton(Form.cwidth-BUT_W - 10, BUT_Y, BUT_W, BUT_H, EXIT_MAIL, sc.work_button, sc.work_button_text,"< Exit");
DrawBar(0, mail_list.y-3, mail_list.w,1, sc.work_graph);
DrawBar(0, mail_list.y-2, mail_list.w,1, 0xdfdfdf);
DrawBar(0, mail_list.y-1, mail_list.w,1, 0xf0f0f0);
}
void DrawMailList()
{
int i, on_y;
mail_list.visible = mail_list.h / mail_list.line_h;
for (i=30; i<150; i++) DeleteButton(i);
for (i=0; (i<mail_list.visible) && (i+mail_list.first<mail_list.count); i++)
{
on_y = i*mail_list.line_h + mail_list.y;
if (mail_list.current==mail_list.first+i)
{
DrawBar(0, on_y, mail_list.w, mail_list.line_h-1, 0xEEEeee);
WriteText(strlen(itoa(i+mail_list.first+1))*6 + 42, on_y+5, 0x80, 0, #subj);
PutMailDirectionImage(strlen(itoa(i+mail_list.first+1))*6 + 18, mail_list.line_h-12/2+ on_y, #to, #from);
}
else
{
DrawBar(0, on_y, mail_list.w, mail_list.line_h-1, 0xFFFfff);
PutMailDirectionImage(strlen(itoa(i+mail_list.first+1))*6 + 18, mail_list.line_h-12/2+ on_y, NULL, NULL);
}
DefineButton(0, on_y, mail_list.w-1, mail_list.line_h, 30+i+BT_HIDE+BT_NOFRAME);
DrawBar(0, on_y + mail_list.line_h-1, mail_list.w, 1, 0xCCCccc);
WriteText(10, on_y+5, 0x80, 0, itoa(i+mail_list.first+1));
//WriteText(mail_list.w - 40, on_y+5, 0x80, 0, itoa(GetLetterSize(i+mail_list.first+1)));
WriteText(mail_list.w - 40, on_y+5, 0x80, 0, ConvertSize(GetLetterSize(i+mail_list.first+1)));
}
DrawBar(0, i*mail_list.line_h + mail_list.y, mail_list.w, -i*mail_list.line_h+mail_list.h, 0xFFFfff);
DrawScroller1();
}
void PutMailDirectionImage(int x,y, to_str, from_str)
{
char mail_direction=0;
if (strstri(to_str, #email_text)) mail_direction = 1;
if (strstri(from_str, #email_text)) mail_direction = 2;
_PutImage(x, y, 18,12, sizeof(in_out_mail)/3*mail_direction + #in_out_mail);
}
dword ConvertSize(unsigned int bytes)
{
unsigned char size_prefix[8], size_nm[4];
if (bytes>=1073741824) strcpy(#size_nm, " Gb");
else if (bytes>=1048576) strcpy(#size_nm, " Mb");
else if (bytes>=1024) strcpy(#size_nm, " Kb");
else strcpy(#size_nm, " b ");
while (bytes>1023) bytes/=1024;
strcpy(#size_prefix, itoa(bytes));
strcat(#size_prefix, #size_nm);
return #size_prefix;
}
void DrawLetterInfo()
{
int lt_y = mail_list.y+mail_list.h;
DrawBar(0, lt_y, mail_list.w, 1, sc.work_graph);
DrawBar(0, lt_y+1, Form.cwidth, 1, LBUMP);
DrawBar(0, lt_y+2, Form.cwidth, LIST_INFO_H-4, sc.work);
WriteText(mail_list.w-30/2, lt_y, 0x80, 0x888888, "= = =");
WriteText(mail_list.w-30/2, lt_y+1, 0x80, 0xEeeeee, "= = =");
DrawBar(0, lt_y+LIST_INFO_H-2, mail_list.w, 1, sc.work_graph); //bottom
DrawBar(0, lt_y+LIST_INFO_H-1, mail_list.w, 1, 0xdfdfdf);
DrawBar(0, lt_y+LIST_INFO_H , mail_list.w, 1, 0xf0f0f0);
WriteTextB(10, lt_y+8 , 0x80, sc.work_text, "From:");
WriteText(45, lt_y+8 , 0x80, sc.work_text, #from);
WriteTextB(10, lt_y+20 , 0x80, sc.work_text, "To:");
WriteText(45, lt_y+20 , 0x80, sc.work_text, #to);
WriteTextB(10, lt_y+32, 0x80, sc.work_text, "Date:");
WriteText(45, lt_y+32, 0x80, sc.work_text, #date);
WriteTextB(10, lt_y+44, 0x80, sc.work_text, "Subject:");
WriteText(66, lt_y+44, 0x80, sc.work_text, #subj);
}
void DrawLetter()
{
int i=0;
dword cur_line, next_line, line_text;
cur_line = mdata;
letter_view.SetSizes(0, mail_list.y+mail_list.h+LIST_INFO_H+1, Form.cwidth - scroll2.size_x - 1,
Form.cheight - mail_list.y - mail_list.h - LIST_INFO_H - 1 - status_bar_h, 60, 12);
if (mailbuffer) && (!aim)
{
for ( ; i < letter_view.first; i++) cur_line = GetNextLine(cur_line);
for (i=0; i < letter_view.h / letter_view.line_h; i++)
{
next_line = GetNextLine(cur_line);
line_text = CopyBetweenOffsets(cur_line, next_line);
cur_line = next_line;
if (cur_line >= mailpointer) || (cur_line==1) break;
DrawBar(letter_view.x, i*letter_view.line_h + letter_view.y, letter_view.w, letter_view.line_h, 0xFFFfff);
if (line_text) { WriteText(letter_view.x+5, i*letter_view.line_h+letter_view.y+3, 0x80, 0, line_text); free(line_text);}
}
}
DrawBar(letter_view.x, i*letter_view.line_h + letter_view.y, letter_view.w, -i*letter_view.line_h + letter_view.h-1, 0xFFFfff);
DrawBar(letter_view.x, letter_view.y + letter_view.h-1, letter_view.w, 1, sc.work_graph);
DrawScroller2();
}
void DrawScroller1()
{
scroll1.max_area = mail_list.count;
scroll1.cur_area = mail_list.visible;
scroll1.position = mail_list.first;
scroll1.all_redraw=1;
scroll1.start_x = mail_list.x + mail_list.w;
scroll1.start_y = mail_list.y - 3;
scroll1.size_y = mail_list.h + 4;
scrollbar_v_draw(#scroll1);
}
void DrawScroller2()
{
scroll2.max_area = letter_view.count;
scroll2.cur_area = letter_view.visible;
scroll2.position = letter_view.first;
scroll2.all_redraw=1;
scroll2.start_x = letter_view.x + letter_view.w;
scroll2.start_y = letter_view.y - 3;
scroll2.size_y = letter_view.h + 3;
scrollbar_v_draw(#scroll2);
}
void DrawStatusBar()
{
int st_y = Form.cheight -status_bar_h;
DrawBar(0, st_y, Form.cwidth, status_bar_h, sc.work);
if (aim) {
SetMailBoxStatus(cur_st_percent, cur_st_text);
DrawCaptButton(240, st_y+1, 36, status_bar_h-3, STOP_LOADING, sc.work_button, sc.work_button_text,"Stop");
}
DrawCaptButton(Form.cwidth - 100, st_y+1, 70, status_bar_h-2, CHANGE_CHARSET+BT_HIDE, sc.work, sc.work_text,charsets[cur_charset]);
}
void SetMailBoxStatus(dword percent1, text1)
{
DrawProgressBar(3, Form.cheight -status_bar_h + 1, 220, 12, sc.work, 0xC3C3C3, 0x54B1D6, sc.work_text, percent1, text1);
cur_st_percent = percent1;
cur_st_text = text1;
}
void StopLoading()
{
aim = NULL;
mailbuffer = free(mailbuffer);
to = from = date = subj = cur_charset = NULL;
while (PollSocket(socket)) ReadSocket(socket);
}
int GetMailCount(){
char tmpbuf4[512];
strcpyb(#immbuffer, #tmpbuf4, "+OK ", " ");
return atoi(#tmpbuf4);
}
void listputc(char agot_char){
*listpointer=agot_char;
listpointer++;
*listpointer='\0';
}
int GetLetterSize_(int number){
char serch_num[24];
char letter_size1[24];
strcpy(#serch_num, "\n");
strcat(#serch_num, itoa(number));
strcat(#serch_num, " ");
strcpyb(listbuffer, #letter_size1, #serch_num, "\n");
return atoi(#letter_size1);
}
struct line_element
{
byte m_type;
char adress[64];
char header[256];
int size;
};
dword mails_db;
void CreateMailsArray()
{
mails_db = free(mails_db);
mails_db = malloc( mail_list.count * sizeof(line_element) );
}
dword GetCurrentElement(int el_N)
{
return sizeof(line_element)*el_N + #mails_db;
}
void SetMailsSizes()
{
int i, temp;
for (i=0; i < mail_list.count; i++)
{
temp = GetLetterSize_(i);
EBX = GetCurrentElement(i); //в регистр EBX суём адрес блока памяти со смещением к элементу N с котрым мы хотим работать
EBX.line_element.size = temp;//работаем с m_type N-ного элемента структуры отраженной на блок памяти
}
}
int GetLetterSize(int el_N)
{
EBX = GetCurrentElement(el_N);
return EBX.line_element.size;
}

View File

@ -0,0 +1,164 @@
//Leency & SoUrcerer, LGPL
void ParceMail()
{
dword line_off, new_buf;
char tline[256];
if ( mailpointer-mailbuffer>9 ) if ( (strncmp(mailpointer-5,"\r\n.\r\n",5)==0) || (strncmp(mailpointer-3,"\n.\n",3)==0) )
{
if (strstr(mailbuffer, "+OK")!=mailbuffer)
{
aim = GET_ANSWER_RETR;
mailpointer = mailbuffer;
debug("GET_ANSWER_RETR != +OK, retry GET_ANSWER_RETR");
return;
}
aim=NULL;
DSBYTE[mailpointer+1] = '\0';
debug("Real letter size:");
debugi(mailpointer - mailbuffer);
if (strstri(mailbuffer, "quoted-printable")!=0)
{
debug ("getting qp");
new_buf = malloc(mailpointer-mailbuffer);
qp_decode stdcall (mailbuffer, new_buf, mailpointer-mailbuffer);
if (EAX==-1) debug("Too small buffer to convert QUOTED-PRINTABLE");
else
{
mailbuffer = free(mailbuffer);
mailbuffer = new_buf;
mailpointer = strlen(mailbuffer) + mailbuffer;
}
}
debug ("getting list info");
GetHeader(#from, "\nFrom:");
GetHeader(#to, "\nTo:");
GetHeader(#date, "\nDate:");
GetHeader(#subj, "\nSubject:");
mdata = strstr(mailbuffer, "\n\r") + 3;
debug ("converting to dos");
ConvertToDOS(mdata, mailbuffer);
FromHTMLtoTXT();
letter_view.first = letter_view.count = 0;
line_off = mdata;
while (line_off>1)
{
line_off = GetNextLine(line_off);
letter_view.count++;
}
debug ("DrawMailBox()");
DrawMailBox();
}
}
void ConvertToDOS(dword inbuf, searchin)
{
dword dos_buf=0;
if (use_iconv==1)
{
cur_charset = CH_CP866;
if (strstri(searchin, "windows-1251")!=0) || (strstri(searchin, "windows1251")!=0)
{ dos_buf = ChangeCharset("CP1251", "CP866", inbuf); cur_charset = CH_CP1251;}
else if (strstri(searchin, "koi8-")!=0)
{ dos_buf = ChangeCharset("KOI8-RU", "CP866", inbuf); cur_charset = CH_KOI8;}
else if (strstri(searchin, "utf-8")!=0) || (strstri(searchin, "utf8")!=0)
{ dos_buf = ChangeCharset("UTF-8", "CP866", inbuf); cur_charset = CH_UTF8;}
else if (strstri(searchin, "iso8859-5")!=0) || (strstri(searchin, "iso-8859-5")!=0)
{ dos_buf = ChangeCharset("ISO8859-5", "CP866", inbuf); cur_charset = CH_ISO8859_5;}
else if (strstri(searchin, "windows-1252")!=0) || (strstri(searchin, "windows1252")!=0)
{ dos_buf = ChangeCharset("CP1252", "CP866", inbuf); cur_charset = CH_CP1252;}
}
else
{
if (strstri(searchin, "windows-1251")!=0) wintodos( inbuf); else
if (strstri(searchin, "koi8-")!=0) koitodos( inbuf); else
if (strstri(searchin, "utf-8")!=0) utf8rutodos( inbuf);
}
}
void FromHTMLtoTXT()
{
dword cur_chr, txt_buf_srt, txt_buf_end, is_tag=0;
int i;
if (strstri(mdata, "<html>")==0) && (strstri(mailbuffer, "text/html")==0) {debug("no html tags found"); return;}
debug ("converting: html -> txt");
cur_chr = mdata;
txt_buf_srt = malloc(mailpointer - mailbuffer);
txt_buf_end = txt_buf_srt;
while (cur_chr < mailpointer)
{
if (DSBYTE[cur_chr]=='<') is_tag = 1;
if (!is_tag)
{
DSBYTE[txt_buf_end] = DSBYTE[cur_chr];
txt_buf_end++;
_END:
}
if (DSBYTE[cur_chr]=='>') is_tag = NULL;
cur_chr++;
}
DSBYTE[txt_buf_end] = '\0';
strcpy(mdata, txt_buf_srt);
mailpointer = strlen(mailbuffer) + mailbuffer; //тупо везде это ставить
free(txt_buf_srt);
}
dword GetNextLine(dword start_offset)
{
dword off_n = strstr(start_offset, "\n") + 1, //разрыв строки
off_w = letter_view.w / 6 - 2 + start_offset, //max длинна скроки
off_m;
off_m = off_w;
if (off_n < off_w) return off_n;
while (off_m > start_offset) //перенос по словам
{
if (DSBYTE[off_m]==' ') || (DSBYTE[off_m]=='\9') || (DSBYTE[off_m]=='-') return off_m;
off_m--;
}
return off_w;
}
dword CopyBetweenOffsets(dword start, end) //do not forget to free(line) after use
{
dword line, new_line;
if (end <= start) return 0;
line = new_line = malloc(end - start + 3);
while (end > start)
{
DSBYTE[new_line] = DSBYTE[start];
start++;
new_line++;
}
DSBYTE[new_line] = '\0';
return line;
}
void GetHeader(dword workstr, searchstr)
{
char tmpbuf[512];
dword Qoff;
strcpyb(mailbuffer, workstr, searchstr, "\n");
if (strstri(workstr, "?Q?"))
{
qp_decode stdcall (workstr, #tmpbuf, strlen(workstr));
ConvertToDOS(#tmpbuf, workstr);
strcpy(workstr, #tmpbuf);
Qoff = strstri(workstr, "?Q?");
strcpy(workstr, Qoff);
}
if (strstr(workstr, "?B?"))
{
base64_decode stdcall (strstri(workstr, "?B?"), #tmpbuf, strlen(workstr));
ConvertToDOS(#tmpbuf, workstr);
strcpy(workstr, #tmpbuf);
}
if (strlen(workstr)+10*6-Form.cwidth>0) { workstr=Form.cwidth/6+workstr-12; DSBYTE[workstr]='\0';}
}

View File

@ -0,0 +1,117 @@
//Leency & SoUrcerer, LGPL
#define CUSTOM 0
#define MANUAL 1
char checked[3] = { 1, 0 };
int use_iconv = 1;
char *text1[] = {"POP server adress:", "POP server port:", "SMTP server adress:", "SMTP server port:", '\0'};
dword mouse_opt;
unsigned char POP_server1[128]="pop.server.com";
unsigned char POP_server_port1[5]="110";
unsigned char SMTP_server1[128]="smtp.server.com";
unsigned char SMTP_server_port1[5]="25";
edit_box POP_server_box = {210,190,90 ,0xffffff,0x94AECE,0xffc90E,0xffffff,0,sizeof(POP_server1),#POP_server1,#mouse_opt,0};
edit_box POP_server_port_box = {210,190,115,0xffffff,0x94AECE,0xffc90E,0xffffff,0,5,#POP_server_port1,#mouse_opt,0b1000000000000000};
edit_box SMTP_server_box = {210,190,140,0xffffff,0x94AECE,0xffc90E,0xffffff,0,sizeof(SMTP_server1),#SMTP_server1,#mouse_opt,0};
edit_box SMTP_server_port_box = {210,190,165,0xffffff,0x94AECE,0xffc90E,0xffffff,0,5,#SMTP_server_port1,#mouse_opt,0b1000000000000000};
void OptionsLoop()
{
int key, id;
POP_server_box.size = strlen(#POP_server1);
POP_server_port_box.size = strlen(#POP_server_port1);
SMTP_server_box.size = strlen(#SMTP_server1);
SMTP_server_port_box.size = strlen(#SMTP_server_port1);
goto _OPT_WIN;
loop()
{
switch(WaitEvent())
{
case evMouse:
IF (GetProcessSlot(Form.ID)-GetActiveProcess()!=0) break;
if (checked[1]==0) break;
edit_box_mouse stdcall(#POP_server_box);
edit_box_mouse stdcall(#POP_server_port_box);
edit_box_mouse stdcall(#SMTP_server_box);
edit_box_mouse stdcall(#SMTP_server_port_box);
break;
case evButton:
id = GetButtonID();
if (id==1) SaveAndExit();
if (id==19) LoginBoxLoop();
if (id==17) || (id==18)
{
if (checked[id-17]==1) break;
checked[0]><checked[1];
if (checked[1]) POP_server_box.flags = 0b10;
OptionsWindow();
}
if (id==20)
{
if (use_iconv==2) break;
if (use_iconv==1) use_iconv=0; else use_iconv=1;
OptionsWindow();
}
break;
case evKey:
key = GetKey();
if (checked[1]==0) break;
if (key==9)
{
if (POP_server_box.flags & 0b10) { POP_server_box.flags -= 0b10; POP_server_port_box.flags += 0b10; } else
if (POP_server_port_box.flags & 0b10) { POP_server_port_box.flags -= 0b10; SMTP_server_box.flags += 0b10; } else
if (SMTP_server_box.flags & 0b10) { SMTP_server_box.flags -= 0b10; SMTP_server_port_box.flags += 0b10; } else
if (SMTP_server_port_box.flags & 0b10) { SMTP_server_port_box.flags -= 0b10; POP_server_box.flags += 0b10; } else
POP_server_box.flags = 0b10;
OptionsWindow();
}
EAX=key<<8;
edit_box_key stdcall(#POP_server_box);
edit_box_key stdcall(#POP_server_port_box);
edit_box_key stdcall(#SMTP_server_box);
edit_box_key stdcall(#SMTP_server_port_box);
break;
case evReDraw: _OPT_WIN:
if !(DefineWindow(OPTIONS_HEADER)) break;
DrawBar(0,0, Form.cwidth, Form.cheight, sc.work);
OptionsWindow();
break;
}
}
}
void OptionsWindow()
{
#define ELEM_X 25
int i;
DrawBar(0, Form.cheight - 40, Form.cwidth, 1, sc.work_graph);
DrawBar(0, Form.cheight - 40+1, Form.cwidth, 1, LBUMP);
DrawCaptButton(Form.cwidth-79, Form.cheight-32, 70, 25, 19, sc.work_button, sc.work_button_text,"Apply");
WriteTextB(ELEM_X, 20, 0x90, sc.work_text, "Network settings");
CheckBox(ELEM_X, 45, 12, 12, 17, "Use custom settings", sc.work_graph, sc.work_text, checked[0]);
CheckBox(ELEM_X, 65, 12, 12, 18, "Manual configuration", sc.work_graph, sc.work_text, checked[1]);
for (i=0; i<4; i++)
{
WriteText(ELEM_X+40, i*25+4+POP_server_box.top, 0x80, sc.work_text, text1[i]);
DrawRectangle(POP_server_box.left-1, i*25+POP_server_box.top-1, POP_server_box.width+2, 16, sc.work_graph);
}
edit_box_draw stdcall(#POP_server_box);
edit_box_draw stdcall(#POP_server_port_box);
edit_box_draw stdcall(#SMTP_server_box);
edit_box_draw stdcall(#SMTP_server_port_box);
WriteTextB(ELEM_X, 205, 0x90, sc.work_text, "MailBox settings");
CheckBox(ELEM_X, 230,12, 12, 20, "Use iconv library for converting text charsets", sc.work_graph, sc.work_text, use_iconv);
}