Subversion Repositories Kolibri OS

Rev

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