Subversion Repositories Kolibri OS

Rev

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

  1. //Leency & SoUrcerer, LGPL
  2.  
  3. //libraries
  4. #define MEMSIZE 0xA0000
  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. //*.obj libraries
  15. #include "..\lib\lib.obj\box_lib.h"
  16. #include "..\lib\lib.obj\network.h"
  17. #include "..\lib\lib.obj\libio_lib.h"
  18. #include "..\lib\lib.obj\libimg_lib.h"
  19. #include "..\lib\lib.obj\netcode.h"
  20. #include "..\lib\lib.obj\iconv.h"
  21. //images
  22. byte in_out_mail[18*36] = FROM "in_out_mail.raw";
  23.  
  24. //connection algorithm
  25. enum {
  26.         STOP,
  27.         RESOLVE,
  28.         OPEN_CONNECTION,
  29.         GET_ANSWER_CONNECT,
  30.         SEND_USER,
  31.         GET_ANSWER_USER,
  32.         SEND_PASS,
  33.         GET_ANSWER_PASS,
  34.         SEND_NLIST,
  35.         GET_ANSWER_NLIST,
  36.         SEND_NSTAT,
  37.         GET_ANSWER_NSTAT,
  38.         SEND_RETR,
  39.         GET_ANSWER_RETR,
  40.         FAILED
  41. };
  42.  
  43. //WindowDefinitions
  44. #define WIN_W         600
  45. #define WIN_H         440
  46. #define WIN_MIN_W     500
  47. #define WIN_MIN_H     380
  48. #define LOGIN_HEADER   "Login - Email client Liza 0.9"
  49. #define OPTIONS_HEADER "Options - Email client Liza 0.9"
  50. #define MAILBOX_HEADER "Mail Box - Email client Liza 0.9"
  51. #define BUFFERSIZE              512    
  52. proc_info Form;
  53. system_colors sc;
  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. #include "settings.c"
  78. #include "login.c"
  79. #include "mail_box.c"
  80. #include "parselist.c"
  81.  
  82.  
  83. void main()
  84. {
  85.         mem_Init();
  86.         if (load_dll2(boxlib, #box_lib_init,0)!=0)              notify("Error while loading library /rd/1/lib/box_lib.obj");
  87.         if (load_dll2(network_lib, #network_lib_init,0)!=0)     notify("Error while loading library /rd/1/lib/network.obj");
  88.         if (load_dll2(netcode_lib, #base64_encode,0)!=0)        notify("Error while loading library /rd/1/lib/netcode.obj");
  89.         if (load_dll2(iconv_lib, #iconv_open,0)!=0)           { notify("Error while loading library /rd/1/lib/iconv.obj"); use_iconv=2; }
  90.  
  91.         OpenMailDat();
  92.         SetEventMask(0x27);
  93.         LoginBoxLoop();
  94. }
  95.  
  96.  
  97. int DefineWindow(dword wtitle)
  98. {
  99.         sc.get();
  100.         DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2, WIN_W, WIN_H, 0x73,sc.work);
  101.         DrawTitle(wtitle);
  102.         GetProcessInfo(#Form, SelfInfo);
  103.         if (Form.status_window>2) return 0; //rolled_up
  104.         if (Form.width < WIN_MIN_W) MoveSize(OLD,OLD,WIN_MIN_W,OLD);
  105.         if (Form.height < WIN_MIN_H) MoveSize(OLD,OLD,OLD,WIN_MIN_H);
  106.         return 1;
  107. }
  108.  
  109.  
  110. void OpenMailDat()
  111. {
  112.         char read_data[512], pass_b64[256];
  113.         ReadFile(0, 512, #read_data, "/sys/network/mail.dat");
  114.         if (!read_data)
  115.         {
  116.                 strcpy(#email_text, "example@mail.com");
  117.         }
  118.         else
  119.         {
  120.                 strcpy(#pass_b64, #read_data+strchr(#read_data, '\n')+1);
  121.                 base64_decode stdcall (#pass_b64, #pass_text, strlen(#pass_b64));
  122.                 read_data[strchr(#read_data, '\n')-1] = NULL;
  123.                 strcpy(#email_text, #read_data);
  124.         }
  125.         pass_box.size = pass_box.pos = strlen(#pass_text);
  126.         login_box.size = login_box.pos = strlen(#email_text);
  127. }
  128.  
  129.  
  130.  
  131. void SaveAndExit()
  132. {
  133.         char write_data[512], pass_b64[256];
  134.         Close(socketnum);
  135.         strcpy(#write_data, #email_text);
  136.         strcat(#write_data, "\n");
  137.         base64_encode stdcall (#pass_text, #pass_b64, strlen(#pass_text));
  138.         strcat(#write_data, #pass_b64);
  139.         WriteFile(strlen(#write_data)+1, #write_data, "/sys/network/mail.dat");
  140.         ExitProcess();
  141. }
  142.  
  143.  
  144. stop:
  145.  
  146.