Rev 7752 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7752 | Rev 7757 | ||
---|---|---|---|
1 | //Leency & SoUrcerer, LGPL |
1 | //Leency & SoUrcerer, LGPL |
2 | 2 | ||
3 | //libraries |
3 | //libraries |
4 | #define MEMSIZE 0x100000 |
4 | #define MEMSIZE 0x100000 |
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/gui.h" |
9 | #include "../lib/gui.h" |
10 | #include "../lib/fs.h" |
10 | #include "../lib/fs.h" |
11 | #include "../lib/list_box.h" |
11 | #include "../lib/list_box.h" |
12 | #include "../lib/socket.h" |
12 | #include "../lib/socket.h" |
13 | #include "../lib/draw_buf.h" |
13 | #include "../lib/draw_buf.h" |
14 | #include "../lib/cursor.h" |
14 | #include "../lib/cursor.h" |
15 | #include "../lib/collection.h" |
15 | #include "../lib/collection.h" |
16 | //*.obj libraries |
16 | //*.obj libraries |
17 | #include "../lib/obj/box_lib.h" |
17 | #include "../lib/obj/box_lib.h" |
18 | #include "../lib/obj/network.h" |
18 | #include "../lib/obj/network.h" |
19 | #include "../lib/obj/http.h" |
19 | #include "../lib/obj/http.h" |
20 | #include "../lib/obj/libio.h" |
20 | #include "../lib/obj/libio.h" |
21 | #include "../lib/obj/libimg.h" |
21 | #include "../lib/obj/libimg.h" |
22 | #include "../lib/obj/netcode.h" |
22 | #include "../lib/obj/netcode.h" |
23 | #include "../lib/obj/iconv.h" |
23 | #include "../lib/obj/iconv.h" |
24 | //patterns |
24 | //patterns |
25 | #include "../lib/patterns/history.h" |
- | |
26 | #include "../lib/patterns/http_downloader.h" |
25 | #include "../lib/patterns/http_downloader.h" |
27 | //images |
26 | //images |
28 | byte letter_icons[sizeof(file "img/letter_icons.raw")] = FROM "img/letter_icons.raw"; |
27 | byte letter_icons[sizeof(file "img/letter_icons.raw")] = FROM "img/letter_icons.raw"; |
29 | #include "img/letter_icons.h" |
28 | #include "img/letter_icons.h" |
30 | 29 | ||
31 | _http http = {0}; |
30 | _http http = {0}; |
32 | bool debug_mode = false; |
31 | bool debug_mode = false; |
33 | char accept_language[]= "Accept-Language: ru\n"; |
32 | char accept_language[]= "Accept-Language: ru\n"; |
34 | 33 | ||
35 | //connection algorithm |
34 | //connection algorithm |
36 | enum { |
35 | enum { |
37 | STOP, |
36 | STOP, |
38 | RESOLVE, |
37 | RESOLVE, |
39 | OPEN_CONNECTION, |
38 | OPEN_CONNECTION, |
40 | GET_ANSWER_CONNECT, |
39 | GET_ANSWER_CONNECT, |
41 | SEND_USER, |
40 | SEND_USER, |
42 | GET_ANSWER_USER, |
41 | GET_ANSWER_USER, |
43 | SEND_PASS, |
42 | SEND_PASS, |
44 | GET_ANSWER_PASS, |
43 | GET_ANSWER_PASS, |
45 | SEND_NLIST, |
44 | SEND_NLIST, |
46 | GET_ANSWER_NLIST, |
45 | GET_ANSWER_NLIST, |
47 | SEND_NSTAT, |
46 | SEND_NSTAT, |
48 | GET_ANSWER_NSTAT, |
47 | GET_ANSWER_NSTAT, |
49 | SEND_RETR, |
48 | SEND_RETR, |
50 | GET_ANSWER_RETR |
49 | GET_ANSWER_RETR |
51 | }; |
50 | }; |
52 | 51 | ||
53 | //WindowDefinitions |
52 | //WindowDefinitions |
54 | #define WIN_W 600 |
53 | #define WIN_W 600 |
55 | #define WIN_H 440 |
54 | #define WIN_H 440 |
56 | #define WIN_MIN_W 500 |
55 | #define WIN_MIN_W 500 |
57 | #define WIN_MIN_H 380 |
56 | #define WIN_MIN_H 380 |
58 | #define LOGIN_HEADER "Login - Email client Liza 0.9.4" |
57 | #define LOGIN_HEADER "Login - Email client Liza 0.9.4" |
59 | #define OPTIONS_HEADER "Options - Email client Liza 0.9.4" |
58 | #define OPTIONS_HEADER "Options - Email client Liza 0.9.4" |
60 | #define MAILBOX_HEADER "Mail Box - Email client Liza 0.9.4" |
59 | #define MAILBOX_HEADER "Mail Box - Email client Liza 0.9.4" |
61 | #define BUFFERSIZE 512 |
60 | #define BUFFERSIZE 512 |
62 | proc_info Form; |
61 | proc_info Form; |
63 | #define LBUMP 0xFFFfff |
62 | #define LBUMP 0xFFFfff |
64 | 63 | ||
65 | //progress_bar definitions |
64 | //progress_bar definitions |
66 | char cur_st_percent; |
65 | char cur_st_percent; |
67 | dword cur_st_text; |
66 | dword cur_st_text; |
68 | 67 | ||
69 | //connection data |
68 | //connection data |
70 | #define DEFAULT_POP_PORT 110; |
69 | #define DEFAULT_POP_PORT 110; |
71 | char POP_server_path[128]; |
70 | char POP_server_path[128]; |
72 | dword POP_server_port; |
71 | dword POP_server_port; |
73 | char login[128]; |
72 | char login[128]; |
74 | char request[256+22]; |
73 | char request[256+22]; |
75 | int request_len; |
74 | int request_len; |
76 | char connection_status; |
75 | char connection_status; |
77 | dword socketnum; |
76 | dword socketnum; |
78 | 77 | ||
79 | sockaddr_in sockaddr; |
78 | sockaddr_in sockaddr; |
80 | 79 | ||
81 | int aim; |
80 | int aim; |
82 | int ticks; |
81 | int ticks; |
83 | 82 | ||
84 | char immbuffer[BUFFERSIZE]; |
83 | char immbuffer[BUFFERSIZE]; |
85 | 84 | ||
86 | llist mail_list; |
85 | llist mail_list; |
87 | llist letter_view; |
86 | llist letter_view; |
88 | 87 | ||
89 | dword TAB_H = false; //19; |
88 | dword TAB_H = false; //19; |
90 | dword TAB_W = 150; |
89 | dword TAB_W = 150; |
91 | dword TOOLBAR_H = 31; //50; |
90 | dword TOOLBAR_H = 31; //50; |
92 | dword STATUSBAR_H =15; |
91 | dword STATUSBAR_H =15; |
93 | dword col_bg; |
92 | dword col_bg; |
94 | dword panel_color; |
93 | dword panel_color; |
95 | dword border_color; |
94 | dword border_color; |
96 | 95 | ||
97 | bool open_in_a_new_window = false; |
96 | bool open_in_a_new_window = false; |
98 | 97 | ||
99 | progress_bar wv_progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F}; |
98 | progress_bar wv_progress_bar = {0, 10, 83, 150, 12, 0, 0, 100, 0xeeeEEE, 8072B7EBh, 0x9F9F9F}; |
100 | 99 | ||
101 | #define URL_SIZE 4000; |
100 | #define URL_SIZE 4000; |
102 | 101 | ||
103 | int http_transfer; |
102 | int http_transfer; |
104 | char version[]=" WebView 0.1"; |
103 | char version[]=" WebView 0.1"; |
105 | #include "..\TWB\TWB.c" |
104 | #include "..\TWB\TWB.c" |
106 | 105 | ||
107 | #include "settings.c" |
106 | #include "settings.c" |
108 | #include "login.c" |
107 | #include "login.c" |
109 | #include "letter_attr.c" |
108 | #include "letter_attr.c" |
110 | #include "mail_box.c" |
109 | #include "mail_box.c" |
111 | #include "parselist.c" |
110 | #include "parselist.c" |
112 | 111 | ||
113 | void main() { |
112 | void main() { |
114 | 113 | ||
115 | CursorPointer.Load(#CursorFile); |
114 | CursorPointer.Load(#CursorFile); |
116 | load_dll(boxlib, #box_lib_init,0); |
115 | load_dll(boxlib, #box_lib_init,0); |
117 | load_dll(network_lib, #network_lib_init,0); |
116 | load_dll(network_lib, #network_lib_init,0); |
118 | load_dll(netcode_lib, #base64_encode,0); |
117 | load_dll(netcode_lib, #base64_encode,0); |
119 | load_dll(libio, #libio_init,1); |
118 | load_dll(libio, #libio_init,1); |
120 | load_dll(libimg, #libimg_init,1); |
119 | load_dll(libimg, #libimg_init,1); |
121 | load_dll(iconv_lib, #iconv_open,0); |
120 | load_dll(iconv_lib, #iconv_open,0); |
122 | OpenMailDat(); |
121 | OpenMailDat(); |
123 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); |
122 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK); |
124 | LoginBoxLoop(); |
123 | LoginBoxLoop(); |
125 | } |
124 | } |
126 | 125 | ||
127 | 126 | ||
128 | int DefineWindow(dword wtitle) { |
127 | int DefineWindow(dword wtitle) { |
129 | system.color.get(); |
128 | system.color.get(); |
130 | DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2, WIN_W, WIN_H, 0x73,system.color.work, 0,0); |
129 | DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2, WIN_W, WIN_H, 0x73,system.color.work, 0,0); |
131 | DrawTitle(wtitle); |
130 | DrawTitle(wtitle); |
132 | GetProcessInfo(#Form, SelfInfo); |
131 | GetProcessInfo(#Form, SelfInfo); |
133 | if (Form.status_window>2) return 0; //rolled_up |
132 | if (Form.status_window>2) return 0; //rolled_up |
134 | if (Form.width < WIN_MIN_W) MoveSize(OLD,OLD,WIN_MIN_W,OLD); |
133 | if (Form.width < WIN_MIN_W) MoveSize(OLD,OLD,WIN_MIN_W,OLD); |
135 | if (Form.height < WIN_MIN_H) MoveSize(OLD,OLD,OLD,WIN_MIN_H); |
134 | if (Form.height < WIN_MIN_H) MoveSize(OLD,OLD,OLD,WIN_MIN_H); |
136 | return 1; |
135 | return 1; |
137 | } |
136 | } |
138 | 137 | ||
139 | 138 | ||
140 | void OpenMailDat() { |
139 | void OpenMailDat() { |
141 | char read_data[512], pass_b64[256]; |
140 | char read_data[512], pass_b64[256]; |
142 | ReadFile(0, 512, #read_data, "/sys/network/mail.dat"); |
141 | ReadFile(0, 512, #read_data, "/sys/network/mail.dat"); |
143 | if (!read_data) |
142 | if (!read_data) |
144 | { |
143 | { |
145 | strcpy(#email_text, "testliza@ya.ru"); |
144 | strcpy(#email_text, "testliza@ya.ru"); |
146 | strcpy(#pass_text, "kolibri"); |
145 | strcpy(#pass_text, "kolibri"); |
147 | } |
146 | } |
148 | else |
147 | else |
149 | { |
148 | { |
150 | strcpy(#pass_b64, strchr(#read_data, '\n')); |
149 | strcpy(#pass_b64, strchr(#read_data, '\n')); |
151 | base64_decode stdcall (#pass_b64, #pass_text, strlen(#pass_b64)); |
150 | base64_decode stdcall (#pass_b64, #pass_text, strlen(#pass_b64)); |
152 | ESBYTE[strchr(#read_data, '\n')] = NULL; |
151 | ESBYTE[strchr(#read_data, '\n')] = NULL; |
153 | strcpy(#email_text, #read_data); |
152 | strcpy(#email_text, #read_data); |
154 | } |
153 | } |
155 | pass_box.size = pass_box.pos = strlen(#pass_text); |
154 | pass_box.size = pass_box.pos = strlen(#pass_text); |
156 | login_box.size = login_box.pos = strlen(#email_text); |
155 | login_box.size = login_box.pos = strlen(#email_text); |
157 | } |
156 | } |
158 | 157 | ||
159 | void SaveAndExit() { |
158 | void SaveAndExit() { |
160 | char write_data[512], pass_b64[256]; |
159 | char write_data[512], pass_b64[256]; |
161 | Close(socketnum); |
160 | Close(socketnum); |
162 | strcpy(#write_data, #email_text); |
161 | strcpy(#write_data, #email_text); |
163 | chrcat(#write_data, '\n'); |
162 | chrcat(#write_data, '\n'); |
164 | base64_encode stdcall (#pass_text, #pass_b64, strlen(#pass_text)); |
163 | base64_encode stdcall (#pass_text, #pass_b64, strlen(#pass_text)); |
165 | strcat(#write_data, #pass_b64); |
164 | strcat(#write_data, #pass_b64); |
166 | CreateFile(strlen(#write_data)+1, #write_data, "/sys/network/mail.dat"); |
165 | CreateFile(strlen(#write_data)+1, #write_data, "/sys/network/mail.dat"); |
167 | ExitProcess(); |
166 | ExitProcess(); |
168 | } |
167 | } |
169 | 168 | ||
170 | 169 | ||
171 | int GetRequest(dword command, text) { |
170 | int GetRequest(dword command, text) { |
172 | strcpy(#request, command); |
171 | strcpy(#request, command); |
173 | if (text) |
172 | if (text) |
174 | { |
173 | { |
175 | chrcat(#request, ' '); |
174 | chrcat(#request, ' '); |
176 | strcat(#request, text); |
175 | strcat(#request, text); |
177 | } |
176 | } |
178 | strcat(#request, "\n"); |
177 | strcat(#request, "\n"); |
179 | return strlen(#request); |
178 | return strlen(#request); |
180 | } |
179 | } |
181 | 180 | ||
182 | void StopConnect(dword message) { |
181 | void StopConnect(dword message) { |
183 | if (message) notify(message); |
182 | if (message) notify(message); |
184 | aim = STOP; |
183 | aim = STOP; |
185 | Close(socketnum); |
184 | Close(socketnum); |
186 | } |
185 | } |
187 | 186 | ||
188 | void EventShowLinkMenu(dword _left, _top) |
187 | void EventShowLinkMenu(dword _left, _top) |
189 | { |
188 | { |
190 | //do nothing, stub |
189 | //do nothing, stub |
191 | return; |
190 | return; |
192 | } |
191 | } |
193 | 192 | ||
194 | stop:>> |
193 | stop:>> |