Subversion Repositories Kolibri OS

Rev

Rev 7806 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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