Rev 3413 | 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 |
||
4 | #define MEMSIZE 0xA0000 |
||
5 | #include "..\lib\kolibri.h" |
||
6 | #include "..\lib\strings.h" |
||
7 | #include "..\lib\encoding.h" |
||
8 | #include "..\lib\file_system.h" |
||
9 | #include "..\lib\figures.h" |
||
10 | #include "..\lib\list_box.h" |
||
11 | #include "..\lib\socket.h" |
||
12 | #include "..\lib\mem.h" |
||
13 | #include "..\lib\dll.h" |
||
14 | //*.obj libraries |
||
15 | #include "..\lib\lib.obj\box_lib.h" |
||
16 | #include "..\lib\lib.obj\network.h" |
||
17 | #include "..\lib\lib.obj\libio_lib.h" |
||
18 | #include "..\lib\lib.obj\libimg_lib.h" |
||
19 | #include "..\lib\lib.obj\netcode.h" |
||
20 | #include "..\lib\lib.obj\iconv.h" |
||
21 | //images |
||
22 | byte in_out_mail[18*36] = FROM "in_out_mail.raw"; |
||
23 | |||
24 | //connection algorithm |
||
25 | enum { |
||
26 | STOP, |
||
27 | GET_PORT, |
||
28 | GET_SERVER_IP, |
||
29 | GET_SOCKET, |
||
30 | CONNECT, |
||
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, |
||
41 | GET_ANSWER_RETR |
||
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 |
||
3413 | leency | 49 | #define LOGIN_HEADER "Login - Email client Liza 0.8" |
50 | #define OPTIONS_HEADER "Options - Email client Liza 0.8" |
||
51 | #define MAILBOX_HEADER "Mail Box - Email client Liza 0.8" |
||
3368 | leency | 52 | proc_info Form; |
53 | system_colors sc; |
||
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 | dword local_port=1000; |
||
63 | char POP_server_path[128]; |
||
64 | dword POP_server_IP; |
||
65 | dword POP_server_port; |
||
66 | char login[128]; |
||
67 | char request[256+22]; |
||
68 | int request_len; |
||
69 | char connection_status; |
||
70 | dword socket; |
||
71 | |||
72 | int aim; |
||
73 | int ticks; |
||
74 | |||
75 | //global data for server response |
||
76 | char immbuffer[512]; |
||
77 | int immpointer; |
||
78 | |||
79 | void immfree(){ |
||
80 | immpointer=0; |
||
81 | immbuffer[immpointer]='\0'; |
||
82 | } |
||
83 | |||
84 | void immputc(char agot_char){ |
||
85 | immbuffer[immpointer]=agot_char; |
||
86 | immpointer++; |
||
87 | immbuffer[immpointer]='\0'; |
||
88 | if (immpointer>511) {immpointer=0; debug ("IMM BUFFER OVERFLOW ERROR"); aim=NULL;} |
||
89 | } |
||
90 | |||
91 | #include "settings.c" |
||
92 | #include "login.c" |
||
93 | #include "mail_box.c" |
||
94 | #include "parselist.c" |
||
95 | |||
96 | |||
97 | void main() |
||
98 | { |
||
99 | mem_Init(); |
||
100 | if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("Error while loading library /rd/1/lib/box_lib.obj"); |
||
101 | if (load_dll2(network_lib, #network_lib_init,0)!=0) notify("Error while loading library /rd/1/lib/network.obj"); |
||
102 | if (load_dll2(netcode_lib, #base64_encode,0)!=0) notify("Error while loading library /rd/1/lib/netcode.obj"); |
||
103 | if (load_dll2(iconv_lib, #iconv_open,0)!=0) { notify("Error while loading library /rd/1/lib/iconv.obj"); use_iconv=2; } |
||
104 | |||
105 | OpenMailDat(); |
||
106 | SetEventMask(0x27); |
||
107 | LoginBoxLoop(); |
||
108 | } |
||
109 | |||
110 | |||
111 | int DefineWindow(dword wtitle) |
||
112 | { |
||
113 | sc.get(); |
||
114 | DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2, WIN_W, WIN_H, 0x73,sc.work); |
||
115 | DrawTitle(wtitle); |
||
116 | GetProcessInfo(#Form, SelfInfo); |
||
117 | if (Form.status_window>2) return 0; //rolled_up |
||
118 | if (Form.width < WIN_MIN_W) MoveSize(OLD,OLD,WIN_MIN_W,OLD); |
||
119 | if (Form.height < WIN_MIN_H) MoveSize(OLD,OLD,OLD,WIN_MIN_H); |
||
120 | return 1; |
||
121 | } |
||
122 | |||
123 | |||
124 | void OpenMailDat() |
||
125 | { |
||
126 | char read_data[512], pass_b64[256]; |
||
127 | ReadFile(0, 512, #read_data, "/sys/network/mail.dat"); |
||
128 | if (!read_data) |
||
129 | { |
||
3414 | leency | 130 | //strcpy(#email_text, "eiroglif@yandex.ru"); //temporarily, for testing |
131 | strcpy(#email_text, "example@mail.com"); |
||
132 | //strcpy(#pass_text, "rostov"); |
||
3368 | leency | 133 | } |
134 | else |
||
135 | { |
||
136 | strcpy(#pass_b64, #read_data+strchr(#read_data, '\n')+1); |
||
137 | base64_decode stdcall (#pass_b64, #pass_text, strlen(#pass_b64)); |
||
138 | read_data[strchr(#read_data, '\n')-1] = NULL; |
||
139 | strcpy(#email_text, #read_data); |
||
140 | } |
||
141 | pass_box.size = pass_box.pos = strlen(#pass_text); |
||
142 | login_box.size = login_box.pos = strlen(#email_text); |
||
143 | } |
||
144 | |||
145 | |||
146 | |||
147 | void SaveAndExit() |
||
148 | { |
||
149 | char write_data[512], pass_b64[256]; |
||
150 | strcpy(#write_data, #email_text); |
||
151 | strcat(#write_data, "\n"); |
||
152 | base64_encode stdcall (#pass_text, #pass_b64, strlen(#pass_text)); |
||
153 | strcat(#write_data, #pass_b64); |
||
154 | WriteFile(strlen(#write_data)+1, #write_data, "/sys/network/mail.dat"); |
||
155 | ExitProcess(); |
||
156 | } |
||
157 | |||
158 | |||
159 | stop:>> |
||
160 |