PyMapiPlugin.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 _PYMAPIPLUGIN_H
  18. #define _PYMAPIPLUGIN_H
  19. #include <memory>
  20. #include <kopano/zcdefs.h>
  21. #include <kopano/ECLogger.h>
  22. #include <kopano/ECConfig.h>
  23. #include <kopano/memory.hpp>
  24. #include <edkmdb.h>
  25. #define MAKE_CUSTOM_SCODE(sev,fac,code) \
  26. (((unsigned int)(sev)<<31) | ((unsigned int)(1)<<29) | ((unsigned int)(fac)<<16) | ((unsigned int)(code)))
  27. #define MAPI_E_MP_STOP MAKE_CUSTOM_SCODE(1, FACILITY_ITF, 0x1)
  28. #define MP_CONTINUE 0 // Continue with the next hook
  29. #define MP_FAILED 1 // Whole process failed
  30. #define MP_STOP_SUCCESS 2 // Stop with the message processing go to the next recipient. Recpient return code OK
  31. #define MP_STOP_FAILED 3 // Stop with the message processing go to the next recipient. Recpient return code failed
  32. #define MP_EXIT 4 // Exit the all the hook calls and go futher with the mail process.
  33. #define MP_RETRY_LATER 5 // Stop Process and retry later
  34. class pym_plugin_intf {
  35. public:
  36. virtual ~pym_plugin_intf() _kc_impdtor;
  37. virtual HRESULT MessageProcessing(const char *func, IMAPISession *, IAddrBook *, IMsgStore *, IMAPIFolder *, IMessage *, ULONG *result) = 0;
  38. virtual HRESULT RulesProcessing(const char *func, IMAPISession *, IAddrBook *, IMsgStore *, IExchangeModifyTable *emt_rules, ULONG *result) = 0;
  39. virtual HRESULT RequestCallExecution(const char *func, IMAPISession *, IAddrBook *, IMsgStore *, IMAPIFolder *, IMessage *, ULONG *do_callexe, ULONG *result) = 0;
  40. };
  41. struct pym_factory_priv;
  42. class PyMapiPluginFactory _kc_final {
  43. public:
  44. PyMapiPluginFactory(void);
  45. ~PyMapiPluginFactory();
  46. HRESULT create_plugin(ECConfig *, ECLogger *, const char *mgr_class, pym_plugin_intf **);
  47. private:
  48. struct pym_factory_priv *m_priv;
  49. bool m_bEnablePlugin = false;
  50. std::string m_strPluginPath;
  51. ECLogger *m_lpLogger = nullptr;
  52. // Inhibit (accidental) copying
  53. PyMapiPluginFactory(const PyMapiPluginFactory &) = delete;
  54. PyMapiPluginFactory &operator=(const PyMapiPluginFactory &) = delete;
  55. };
  56. #endif