Subversion Repositories Kolibri OS

Rev

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