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