Subversion Repositories Kolibri OS

Rev

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