Rev 4164 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4164 | Rev 4166 | ||
---|---|---|---|
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/mem.h" |
7 | #include "../lib/mem.h" |
8 | #include "../lib/dll.h" |
8 | #include "../lib/dll.h" |
9 | #include "../lib/encoding.h" |
9 | #include "../lib/encoding.h" |
10 | #include "../lib/figures.h" |
10 | #include "../lib/figures.h" |
11 | #include "../lib/file_system.h" |
11 | #include "../lib/file_system.h" |
12 | #include "../lib/list_box.h" |
12 | #include "../lib/list_box.h" |
13 | #include "../lib/socket_new.h" |
13 | #include "../lib/socket_new.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 letter_icons[sizeof(file "img/letter_icons.raw")] = FROM "img/letter_icons.raw"; |
22 | byte letter_icons[sizeof(file "img/letter_icons.raw")] = FROM "img/letter_icons.raw"; |
23 | #include "img/letter_icons.h" |
23 | #include "img/letter_icons.h" |
24 | 24 | ||
25 | //connection algorithm |
25 | //connection algorithm |
26 | enum { |
26 | enum { |
27 | STOP, |
27 | STOP, |
28 | RESOLVE, |
28 | RESOLVE, |
29 | OPEN_CONNECTION, |
29 | OPEN_CONNECTION, |
30 | GET_ANSWER_CONNECT, |
30 | GET_ANSWER_CONNECT, |
31 | SEND_USER, |
31 | SEND_USER, |
32 | GET_ANSWER_USER, |
32 | GET_ANSWER_USER, |
33 | SEND_PASS, |
33 | SEND_PASS, |
34 | GET_ANSWER_PASS, |
34 | GET_ANSWER_PASS, |
35 | SEND_NLIST, |
35 | SEND_NLIST, |
36 | GET_ANSWER_NLIST, |
36 | GET_ANSWER_NLIST, |
37 | SEND_NSTAT, |
37 | SEND_NSTAT, |
38 | GET_ANSWER_NSTAT, |
38 | GET_ANSWER_NSTAT, |
39 | SEND_RETR, |
39 | SEND_RETR, |
40 | GET_ANSWER_RETR |
40 | GET_ANSWER_RETR |
41 | }; |
41 | }; |
42 | 42 | ||
43 | //WindowDefinitions |
43 | //WindowDefinitions |
44 | #define WIN_W 600 |
44 | #define WIN_W 600 |
45 | #define WIN_H 440 |
45 | #define WIN_H 440 |
46 | #define WIN_MIN_W 500 |
46 | #define WIN_MIN_W 500 |
47 | #define WIN_MIN_H 380 |
47 | #define WIN_MIN_H 380 |
48 | #define LOGIN_HEADER "Login - Email client Liza 0.9b" |
48 | #define LOGIN_HEADER "Login - Email client Liza 0.9e" |
49 | #define OPTIONS_HEADER "Options - Email client Liza 0.9b" |
49 | #define OPTIONS_HEADER "Options - Email client Liza 0.9e" |
50 | #define MAILBOX_HEADER "Mail Box - Email client Liza 0.9b" |
50 | #define MAILBOX_HEADER "Mail Box - Email client Liza 0.9e" |
51 | #define BUFFERSIZE 512 |
51 | #define BUFFERSIZE 512 |
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 | char POP_server_path[128]; |
62 | char POP_server_path[128]; |
63 | dword POP_server_port; |
63 | dword POP_server_port; |
64 | char login[128]; |
64 | char login[128]; |
65 | char request[256+22]; |
65 | char request[256+22]; |
66 | int request_len; |
66 | int request_len; |
67 | char connection_status; |
67 | char connection_status; |
68 | dword socketnum; |
68 | dword socketnum; |
69 | 69 | ||
70 | sockaddr_in sockaddr; |
70 | sockaddr_in sockaddr; |
71 | 71 | ||
72 | int aim; |
72 | int aim; |
73 | int ticks; |
73 | int ticks; |
74 | 74 | ||
75 | char immbuffer[BUFFERSIZE]; |
75 | char immbuffer[BUFFERSIZE]; |
76 | 76 | ||
77 | llist mail_list; |
77 | llist mail_list; |
78 | llist letter_view; |
78 | llist letter_view; |
79 | 79 | ||
80 | #include "settings.c" |
80 | #include "settings.c" |
81 | #include "login.c" |
81 | #include "login.c" |
82 | #include "letter_attr.c" |
82 | #include "letter_attr.c" |
83 | #include "mail_box.c" |
83 | #include "mail_box.c" |
84 | #include "parselist.c" |
84 | #include "parselist.c" |
85 | 85 | ||
86 | 86 | ||
87 | void main() |
87 | void main() |
88 | { |
88 | { |
89 | mem_Init(); |
89 | mem_Init(); |
90 | if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("Error while loading library /rd/1/lib/box_lib.obj"); |
90 | if (load_dll2(boxlib, #box_lib_init,0)!=0) notify("Error while loading library /rd/1/lib/box_lib.obj"); |
91 | if (load_dll2(network_lib, #network_lib_init,0)!=0) notify("Error while loading library /rd/1/lib/network.obj"); |
91 | if (load_dll2(network_lib, #network_lib_init,0)!=0) notify("Error while loading library /rd/1/lib/network.obj"); |
92 | if (load_dll2(netcode_lib, #base64_encode,0)!=0) notify("Error while loading library /rd/1/lib/netcode.obj"); |
92 | if (load_dll2(netcode_lib, #base64_encode,0)!=0) notify("Error while loading library /rd/1/lib/netcode.obj"); |
93 | if (load_dll2(iconv_lib, #iconv_open,0)!=0) { notify("Error while loading library /rd/1/lib/iconv.obj"); use_iconv=2; } |
93 | if (load_dll2(iconv_lib, #iconv_open,0)!=0) { notify("Error while loading library /rd/1/lib/iconv.obj"); use_iconv=2; } |
94 | 94 | ||
95 | OpenMailDat(); |
95 | OpenMailDat(); |
96 | SetEventMask(0x27); |
96 | SetEventMask(0x27); |
97 | LoginBoxLoop(); |
97 | LoginBoxLoop(); |
98 | } |
98 | } |
99 | 99 | ||
100 | 100 | ||
101 | int DefineWindow(dword wtitle) |
101 | int DefineWindow(dword wtitle) |
102 | { |
102 | { |
103 | sc.get(); |
103 | sc.get(); |
104 | DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2, WIN_W, WIN_H, 0x73,sc.work); |
104 | DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2, WIN_W, WIN_H, 0x73,sc.work); |
105 | DrawTitle(wtitle); |
105 | DrawTitle(wtitle); |
106 | GetProcessInfo(#Form, SelfInfo); |
106 | GetProcessInfo(#Form, SelfInfo); |
107 | if (Form.status_window>2) return 0; //rolled_up |
107 | if (Form.status_window>2) return 0; //rolled_up |
108 | if (Form.width < WIN_MIN_W) MoveSize(OLD,OLD,WIN_MIN_W,OLD); |
108 | if (Form.width < WIN_MIN_W) MoveSize(OLD,OLD,WIN_MIN_W,OLD); |
109 | if (Form.height < WIN_MIN_H) MoveSize(OLD,OLD,OLD,WIN_MIN_H); |
109 | if (Form.height < WIN_MIN_H) MoveSize(OLD,OLD,OLD,WIN_MIN_H); |
110 | return 1; |
110 | return 1; |
111 | } |
111 | } |
112 | 112 | ||
113 | 113 | ||
114 | void OpenMailDat() |
114 | void OpenMailDat() |
115 | { |
115 | { |
116 | char read_data[512], pass_b64[256]; |
116 | char read_data[512], pass_b64[256]; |
117 | ReadFile(0, 512, #read_data, "/sys/network/mail.dat"); |
117 | ReadFile(0, 512, #read_data, "/sys/network/mail.dat"); |
118 | if (!read_data) |
118 | if (!read_data) |
119 | { |
119 | { |
120 | strcpy(#email_text, "testliza@ya.ru"); //temporarily, for testing |
120 | strcpy(#email_text, "testliza@ya.ru"); //temporarily, for testing |
121 | strcpy(#pass_text, "kolibri"); |
121 | strcpy(#pass_text, "kolibri"); |
122 | } |
122 | } |
123 | else |
123 | else |
124 | { |
124 | { |
125 | strcpy(#pass_b64, #read_data+strchr(#read_data, '\n')+1); |
125 | strcpy(#pass_b64, #read_data+strchr(#read_data, '\n')+1); |
126 | base64_decode stdcall (#pass_b64, #pass_text, strlen(#pass_b64)); |
126 | base64_decode stdcall (#pass_b64, #pass_text, strlen(#pass_b64)); |
127 | read_data[strchr(#read_data, '\n')-1] = NULL; |
127 | read_data[strchr(#read_data, '\n')-1] = NULL; |
128 | strcpy(#email_text, #read_data); |
128 | strcpy(#email_text, #read_data); |
129 | } |
129 | } |
130 | pass_box.size = pass_box.pos = strlen(#pass_text); |
130 | pass_box.size = pass_box.pos = strlen(#pass_text); |
131 | login_box.size = login_box.pos = strlen(#email_text); |
131 | login_box.size = login_box.pos = strlen(#email_text); |
132 | } |
132 | } |
133 | 133 | ||
134 | 134 | ||
135 | 135 | ||
136 | void SaveAndExit() |
136 | void SaveAndExit() |
137 | { |
137 | { |
138 | char write_data[512], pass_b64[256]; |
138 | char write_data[512], pass_b64[256]; |
139 | Close(socketnum); |
139 | Close(socketnum); |
140 | strcpy(#write_data, #email_text); |
140 | strcpy(#write_data, #email_text); |
141 | chrcat(#write_data, '\n'); |
141 | chrcat(#write_data, '\n'); |
142 | base64_encode stdcall (#pass_text, #pass_b64, strlen(#pass_text)); |
142 | base64_encode stdcall (#pass_text, #pass_b64, strlen(#pass_text)); |
143 | strcat(#write_data, #pass_b64); |
143 | strcat(#write_data, #pass_b64); |
144 | WriteFile(strlen(#write_data)+1, #write_data, "/sys/network/mail.dat"); |
144 | WriteFile(strlen(#write_data)+1, #write_data, "/sys/network/mail.dat"); |
145 | ExitProcess(); |
145 | ExitProcess(); |
146 | } |
146 | } |
- | 147 | ||
- | 148 | int GetRequest(dword command, text) |
|
- | 149 | { |
|
- | 150 | strcpy(#request, command); |
|
- | 151 | if (text) |
|
- | 152 | { |
|
- | 153 | chrcat(#request, ' '); |
|
- | 154 | strcat(#request, text); |
|
- | 155 | } |
|
- | 156 | strcat(#request, "\n"); |
|
- | 157 | return strlen(#request); |
|
- | 158 | } |
|
- | 159 | ||
- | 160 | void StopConnect(dword message) |
|
- | 161 | { |
|
- | 162 | if (message) notify(message); |
|
- | 163 | aim = STOP; |
|
147 | 164 | } |
|
148 | 165 | ||
149 | stop:>> |
166 | stop:>> |