Subversion Repositories Kolibri OS

Rev

Rev 4152 | 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 letter_icons[sizeof(file "img/letter_icons.raw")] = FROM "img/letter_icons.raw";
  23. #include "img/letter_icons.h"
  24.  
  25. //connection algorithm
  26. enum {
  27.         STOP,
  28.         RESOLVE,
  29.         OPEN_CONNECTION,
  30.         GET_ANSWER_CONNECT,
  31.         SEND_USER,
  32.         GET_ANSWER_USER,
  33.         SEND_PASS,
  34.         GET_ANSWER_PASS,
  35.         SEND_NLIST,
  36.         GET_ANSWER_NLIST,
  37.         SEND_NSTAT,
  38.         GET_ANSWER_NSTAT,
  39.         SEND_RETR,
  40.         GET_ANSWER_RETR,
  41.         FAILED
  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.9b"
  50. #define OPTIONS_HEADER "Options - Email client Liza 0.9b"
  51. #define MAILBOX_HEADER "Mail Box - Email client Liza 0.9b"
  52. #define BUFFERSIZE              512    
  53. proc_info Form;
  54. system_colors sc;
  55. #define LBUMP 0xFFFfff
  56.  
  57. //progress_bar definitions
  58. char cur_st_percent;
  59. dword cur_st_text;
  60.  
  61. //connection data
  62. #define DEFAULT_POP_PORT 110;
  63. char POP_server_path[128];
  64. dword POP_server_port;
  65. char login[128];
  66. char request[256+22];
  67. int request_len;
  68. char connection_status;
  69. dword socketnum;
  70.  
  71. sockaddr_in sockaddr;
  72.  
  73. int aim;
  74. int ticks;
  75.  
  76. char immbuffer[BUFFERSIZE];
  77.  
  78. #include "settings.c"
  79. #include "login.c"
  80. #include "mail_box.c"
  81. #include "parselist.c"
  82.  
  83.  
  84. void main()
  85. {
  86.         mem_Init();
  87.         if (load_dll2(boxlib, #box_lib_init,0)!=0)              notify("Error while loading library /rd/1/lib/box_lib.obj");
  88.         if (load_dll2(network_lib, #network_lib_init,0)!=0)     notify("Error while loading library /rd/1/lib/network.obj");
  89.         if (load_dll2(netcode_lib, #base64_encode,0)!=0)        notify("Error while loading library /rd/1/lib/netcode.obj");
  90.         if (load_dll2(iconv_lib, #iconv_open,0)!=0)           { notify("Error while loading library /rd/1/lib/iconv.obj"); use_iconv=2; }
  91.  
  92.         OpenMailDat();
  93.         SetEventMask(0x27);
  94.         LoginBoxLoop();
  95. }
  96.  
  97.  
  98. int DefineWindow(dword wtitle)
  99. {
  100.         sc.get();
  101.         DefineAndDrawWindow(GetScreenWidth()-WIN_W/2,GetScreenHeight()-WIN_H/2, WIN_W, WIN_H, 0x73,sc.work);
  102.         DrawTitle(wtitle);
  103.         GetProcessInfo(#Form, SelfInfo);
  104.         if (Form.status_window>2) return 0; //rolled_up
  105.         if (Form.width < WIN_MIN_W) MoveSize(OLD,OLD,WIN_MIN_W,OLD);
  106.         if (Form.height < WIN_MIN_H) MoveSize(OLD,OLD,OLD,WIN_MIN_H);
  107.         return 1;
  108. }
  109.  
  110.  
  111. void OpenMailDat()
  112. {
  113.         char read_data[512], pass_b64[256];
  114.         ReadFile(0, 512, #read_data, "/sys/network/mail.dat");
  115.         if (!read_data)
  116.         {
  117.                 strcpy(#email_text, "example@mail.com");
  118.         }
  119.         else
  120.         {
  121.                 strcpy(#pass_b64, #read_data+strchr(#read_data, '\n')+1);
  122.                 base64_decode stdcall (#pass_b64, #pass_text, strlen(#pass_b64));
  123.                 read_data[strchr(#read_data, '\n')-1] = NULL;
  124.                 strcpy(#email_text, #read_data);
  125.         }
  126.         pass_box.size = pass_box.pos = strlen(#pass_text);
  127.         login_box.size = login_box.pos = strlen(#email_text);
  128. }
  129.  
  130.  
  131.  
  132. void SaveAndExit()
  133. {
  134.         char write_data[512], pass_b64[256];
  135.         Close(socketnum);
  136.         strcpy(#write_data, #email_text);
  137.         chrcat(#write_data, '\n');
  138.         base64_encode stdcall (#pass_text, #pass_b64, strlen(#pass_text));
  139.         strcat(#write_data, #pass_b64);
  140.         WriteFile(strlen(#write_data)+1, #write_data, "/sys/network/mail.dat");
  141.         ExitProcess();
  142. }
  143.  
  144.  
  145. stop:
  146.  
  147.