Rev 3412 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3412 | Rev 3413 | ||
---|---|---|---|
1 | //Leency & SoUrcerer, LGPL |
1 | //Leency & SoUrcerer, LGPL |
2 | 2 | ||
3 | //libraries |
3 | //libraries |
4 | #define MEMSIZE 0xA0000 |
4 | #define MEMSIZE 0xA0000 |
5 | #include "..\lib\kolibri.h" |
5 | #include "..\lib\kolibri.h" |
6 | #include "..\lib\strings.h" |
6 | #include "..\lib\strings.h" |
7 | #include "..\lib\encoding.h" |
7 | #include "..\lib\encoding.h" |
8 | #include "..\lib\file_system.h" |
8 | #include "..\lib\file_system.h" |
9 | #include "..\lib\figures.h" |
9 | #include "..\lib\figures.h" |
10 | #include "..\lib\list_box.h" |
10 | #include "..\lib\list_box.h" |
11 | #include "..\lib\socket.h" |
11 | #include "..\lib\socket.h" |
12 | #include "..\lib\mem.h" |
12 | #include "..\lib\mem.h" |
13 | #include "..\lib\dll.h" |
13 | #include "..\lib\dll.h" |
14 | //*.obj libraries |
14 | //*.obj libraries |
15 | #include "..\lib\lib.obj\box_lib.h" |
15 | #include "..\lib\lib.obj\box_lib.h" |
16 | #include "..\lib\lib.obj\network.h" |
16 | #include "..\lib\lib.obj\network.h" |
17 | #include "..\lib\lib.obj\libio_lib.h" |
17 | #include "..\lib\lib.obj\libio_lib.h" |
18 | #include "..\lib\lib.obj\libimg_lib.h" |
18 | #include "..\lib\lib.obj\libimg_lib.h" |
19 | #include "..\lib\lib.obj\netcode.h" |
19 | #include "..\lib\lib.obj\netcode.h" |
20 | #include "..\lib\lib.obj\iconv.h" |
20 | #include "..\lib\lib.obj\iconv.h" |
21 | //images |
21 | //images |
22 | byte in_out_mail[18*36] = FROM "in_out_mail.raw"; |
22 | byte in_out_mail[18*36] = FROM "in_out_mail.raw"; |
23 | 23 | ||
24 | //connection algorithm |
24 | //connection algorithm |
25 | enum { |
25 | enum { |
26 | STOP, |
26 | STOP, |
27 | GET_PORT, |
27 | GET_PORT, |
28 | GET_SERVER_IP, |
28 | GET_SERVER_IP, |
29 | GET_SOCKET, |
29 | GET_SOCKET, |
30 | CONNECT, |
30 | CONNECT, |
31 | GET_ANSWER_CONNECT, |
31 | GET_ANSWER_CONNECT, |
32 | SEND_USER, |
32 | SEND_USER, |
33 | GET_ANSWER_USER, |
33 | GET_ANSWER_USER, |
34 | SEND_PASS, |
34 | SEND_PASS, |
35 | GET_ANSWER_PASS, |
35 | GET_ANSWER_PASS, |
36 | SEND_NLIST, |
36 | SEND_NLIST, |
37 | GET_ANSWER_NLIST, |
37 | GET_ANSWER_NLIST, |
38 | SEND_NSTAT, |
38 | SEND_NSTAT, |
39 | GET_ANSWER_NSTAT, |
39 | GET_ANSWER_NSTAT, |
40 | SEND_RETR, |
40 | SEND_RETR, |
41 | GET_ANSWER_RETR |
41 | GET_ANSWER_RETR |
42 | }; |
42 | }; |
43 | 43 | ||
44 | //WindowDefinitions |
44 | //WindowDefinitions |
45 | #define WIN_W 600 |
45 | #define WIN_W 600 |
46 | #define WIN_H 440 |
46 | #define WIN_H 440 |
47 | #define WIN_MIN_W 500 |
47 | #define WIN_MIN_W 500 |
48 | #define WIN_MIN_H 380 |
48 | #define WIN_MIN_H 380 |
49 | #define LOGIN_HEADER "Login - Email client Liza 0.77" |
49 | #define LOGIN_HEADER "Login - Email client Liza 0.8" |
50 | #define OPTIONS_HEADER "Options - Email client Liza 0.77" |
50 | #define OPTIONS_HEADER "Options - Email client Liza 0.8" |
51 | #define MAILBOX_HEADER "Mail Box - Email client Liza 0.77" |
51 | #define MAILBOX_HEADER "Mail Box - Email client Liza 0.8" |
52 | proc_info Form; |
52 | proc_info Form; |
53 | system_colors sc; |
53 | system_colors sc; |
54 | #define LBUMP 0xFFFfff |
54 | #define LBUMP 0xFFFfff |
55 | 55 | ||
56 | //progress_bar definitions |
56 | //progress_bar definitions |
57 | char cur_st_percent; |
57 | char cur_st_percent; |
58 | dword cur_st_text; |
58 | dword cur_st_text; |
59 | 59 | ||
60 | //connection data |
60 | //connection data |
61 | #define DEFAULT_POP_PORT 110; |
61 | #define DEFAULT_POP_PORT 110; |
62 | dword local_port=1000; |
62 | dword local_port=1000; |
63 | char POP_server_path[128]; |
63 | char POP_server_path[128]; |
64 | dword POP_server_IP; |
64 | dword POP_server_IP; |
65 | dword POP_server_port; |
65 | dword POP_server_port; |
66 | char login[128]; |
66 | char login[128]; |
67 | char request[256+22]; |
67 | char request[256+22]; |
68 | int request_len; |
68 | int request_len; |
69 | char connection_status; |
69 | char connection_status; |
70 | dword socket; |
70 | dword socket; |
71 | 71 | ||
72 | int aim; |
72 | int aim; |
73 | int ticks; |
73 | int ticks; |
74 | 74 | ||
75 | //global data for server response |
75 | //global data for server response |
76 | char immbuffer[512]; |
76 | char immbuffer[512]; |
77 | int immpointer; |
77 | int immpointer; |
78 | 78 | ||
79 | void immfree(){ |
79 | void immfree(){ |
80 | immpointer=0; |
80 | immpointer=0; |
81 | immbuffer[immpointer]='\0'; |
81 | immbuffer[immpointer]='\0'; |
82 | } |
82 | } |
83 | 83 | ||
84 | void immputc(char agot_char){ |
84 | void immputc(char agot_char){ |
85 | immbuffer[immpointer]=agot_char; |
85 | immbuffer[immpointer]=agot_char; |
86 | immpointer++; |
86 | immpointer++; |
87 | immbuffer[immpointer]='\0'; |
87 | immbuffer[immpointer]='\0'; |
88 | if (immpointer>511) {immpointer=0; debug ("IMM BUFFER OVERFLOW ERROR"); aim=NULL;} |
88 | if (immpointer>511) {immpointer=0; debug ("IMM BUFFER OVERFLOW ERROR"); aim=NULL;} |
89 | } |
89 | } |
90 | 90 | ||
91 | #include "settings.c" |
91 | #include "settings.c" |
92 | #include "login.c" |
92 | #include "login.c" |
93 | #include "mail_box.c" |
93 | #include "mail_box.c" |
94 | #include "parselist.c" |
94 | #include "parselist.c" |
95 | 95 | ||
96 | 96 | ||
97 | void main() |
97 | void main() |
98 | { |
98 | { |
99 | mem_Init(); |
99 | mem_Init(); |
100 | if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("Error while loading library /rd/1/lib/box_lib.obj"); |
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"); |
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"); |
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; } |
103 | if (load_dll2(iconv_lib, #iconv_open,0)!=0) { notify("Error while loading library /rd/1/lib/iconv.obj"); use_iconv=2; } |
104 | 104 | ||
105 | OpenMailDat(); |
105 | OpenMailDat(); |
106 | SetEventMask(0x27); |
106 | SetEventMask(0x27); |
107 | LoginBoxLoop(); |
107 | LoginBoxLoop(); |
108 | } |
108 | } |
109 | 109 | ||
110 | 110 | ||
111 | int DefineWindow(dword wtitle) |
111 | int DefineWindow(dword wtitle) |
112 | { |
112 | { |
113 | sc.get(); |
113 | sc.get(); |
114 | DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2, WIN_W, WIN_H, 0x73,sc.work); |
114 | DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2, WIN_W, WIN_H, 0x73,sc.work); |
115 | DrawTitle(wtitle); |
115 | DrawTitle(wtitle); |
116 | GetProcessInfo(#Form, SelfInfo); |
116 | GetProcessInfo(#Form, SelfInfo); |
117 | if (Form.status_window>2) return 0; //rolled_up |
117 | if (Form.status_window>2) return 0; //rolled_up |
118 | if (Form.width < WIN_MIN_W) MoveSize(OLD,OLD,WIN_MIN_W,OLD); |
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); |
119 | if (Form.height < WIN_MIN_H) MoveSize(OLD,OLD,OLD,WIN_MIN_H); |
120 | return 1; |
120 | return 1; |
121 | } |
121 | } |
122 | 122 | ||
123 | 123 | ||
124 | void OpenMailDat() |
124 | void OpenMailDat() |
125 | { |
125 | { |
126 | char read_data[512], pass_b64[256]; |
126 | char read_data[512], pass_b64[256]; |
127 | ReadFile(0, 512, #read_data, "/sys/network/mail.dat"); |
127 | ReadFile(0, 512, #read_data, "/sys/network/mail.dat"); |
128 | if (!read_data) |
128 | if (!read_data) |
129 | { |
129 | { |
130 | strcpy(#email_text, "eiroglif@yandex.ru"); //temporarily, for testing |
130 | strcpy(#email_text, "eiroglif@yandex.ru"); //temporarily, for testing |
131 | //strcpy(#email_text, "example@mail.com"); |
131 | //strcpy(#email_text, "example@mail.com"); |
132 | strcpy(#pass_text, "rostov"); |
132 | strcpy(#pass_text, "rostov"); |
133 | } |
133 | } |
134 | else |
134 | else |
135 | { |
135 | { |
136 | strcpy(#pass_b64, #read_data+strchr(#read_data, '\n')+1); |
136 | strcpy(#pass_b64, #read_data+strchr(#read_data, '\n')+1); |
137 | base64_decode stdcall (#pass_b64, #pass_text, strlen(#pass_b64)); |
137 | base64_decode stdcall (#pass_b64, #pass_text, strlen(#pass_b64)); |
138 | read_data[strchr(#read_data, '\n')-1] = NULL; |
138 | read_data[strchr(#read_data, '\n')-1] = NULL; |
139 | strcpy(#email_text, #read_data); |
139 | strcpy(#email_text, #read_data); |
140 | } |
140 | } |
141 | pass_box.size = pass_box.pos = strlen(#pass_text); |
141 | pass_box.size = pass_box.pos = strlen(#pass_text); |
142 | login_box.size = login_box.pos = strlen(#email_text); |
142 | login_box.size = login_box.pos = strlen(#email_text); |
143 | } |
143 | } |
144 | 144 | ||
145 | 145 | ||
146 | 146 | ||
147 | void SaveAndExit() |
147 | void SaveAndExit() |
148 | { |
148 | { |
149 | char write_data[512], pass_b64[256]; |
149 | char write_data[512], pass_b64[256]; |
150 | strcpy(#write_data, #email_text); |
150 | strcpy(#write_data, #email_text); |
151 | strcat(#write_data, "\n"); |
151 | strcat(#write_data, "\n"); |
152 | base64_encode stdcall (#pass_text, #pass_b64, strlen(#pass_text)); |
152 | base64_encode stdcall (#pass_text, #pass_b64, strlen(#pass_text)); |
153 | strcat(#write_data, #pass_b64); |
153 | strcat(#write_data, #pass_b64); |
154 | WriteFile(strlen(#write_data)+1, #write_data, "/sys/network/mail.dat"); |
154 | WriteFile(strlen(#write_data)+1, #write_data, "/sys/network/mail.dat"); |
155 | ExitProcess(); |
155 | ExitProcess(); |
156 | } |
156 | } |
157 | 157 | ||
158 | 158 | ||
159 | stop:>> |
159 | stop:>> |