POP3.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. #ifndef POP3_H
  18. #define POP3_H
  19. #include <vector>
  20. #include <kopano/zcdefs.h>
  21. #include "ClientProto.h"
  22. /**
  23. * @defgroup gateway_pop3 POP3
  24. * @ingroup gateway
  25. * @{
  26. */
  27. #define POP3_MAX_RESPONSE_LENGTH 512
  28. #define POP3_RESP_OK "+OK "
  29. #define POP3_RESP_TEMPFAIL "-ERR [SYS/TEMP] "
  30. #define POP3_RESP_PERMFAIL "-ERR [SYS/PERM] "
  31. #define POP3_RESP_AUTH_ERROR "-ERR [AUTH] "
  32. #define POP3_RESP_ERR "-ERR "
  33. /* enum POP3_Command { POP3_CMD_USER, POP3_CMD_PASS, POP3_CMD_STAT, POP3_CMD_LIST, POP3_CMD_RETR, POP3_CMD_DELE, POP3_CMD_NOOP, */
  34. /* POP3_CMD_RSET, POP3_CMD_QUIT, POP3_CMD_TOP, POP3_CMD_UIDL }; */
  35. class POP3 _kc_final : public ClientProto {
  36. public:
  37. POP3(const char *szServerPath, ECChannel *lpChannel, ECLogger *lpLogger, ECConfig *lpConfig);
  38. ~POP3();
  39. int getTimeoutMinutes();
  40. HRESULT HrSendGreeting(const std::string &strHostString);
  41. HRESULT HrCloseConnection(const std::string &strQuitMsg);
  42. HRESULT HrProcessCommand(const std::string &strInput);
  43. HRESULT HrDone(bool bSendResponse);
  44. private:
  45. std::string GetCapabilityString();
  46. HRESULT HrCmdCapability();
  47. HRESULT HrCmdStarttls();
  48. HRESULT HrCmdUser(const std::string &strUser);
  49. HRESULT HrCmdPass(const std::string &strPass);
  50. HRESULT HrCmdStat();
  51. HRESULT HrCmdList();
  52. HRESULT HrCmdList(unsigned int ulMailNr);
  53. HRESULT HrCmdRetr(unsigned int ulMailNr);
  54. HRESULT HrCmdDele(unsigned int ulMailNr);
  55. HRESULT HrCmdNoop();
  56. HRESULT HrCmdRset();
  57. HRESULT HrCmdQuit();
  58. HRESULT HrCmdUidl();
  59. HRESULT HrCmdUidl(unsigned int ulMailNr);
  60. HRESULT HrCmdTop(unsigned int ulMailNr, unsigned int ulLines);
  61. HRESULT HrResponse(const std::string &strResult, const std::string &strResponse);
  62. struct MailListItem {
  63. SBinary sbEntryID;
  64. ULONG ulSize;
  65. bool bDeleted;
  66. };
  67. HRESULT HrMakeMailList();
  68. HRESULT HrLogin(const std::string &strUsername, const std::string &strPassword);
  69. std::string DotFilter(const char *input);
  70. BOOL IsAuthorized() { return !!lpStore; }
  71. IMAPISession *lpSession = nullptr;
  72. IMsgStore *lpStore = nullptr;
  73. IMAPIFolder *lpInbox = nullptr;
  74. IAddrBook *lpAddrBook = nullptr;
  75. sending_options sopt;
  76. std::string szUser;
  77. std::vector<MailListItem> lstMails;
  78. };
  79. /** @} */
  80. #endif