vconverter.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 ICALMAPI_VCONVERTER_H
  18. #define ICALMAPI_VCONVERTER_H
  19. #include <kopano/zcdefs.h>
  20. #include "vtimezone.h"
  21. #include "icalitem.h"
  22. #include <kopano/RecurrenceState.h>
  23. #include <kopano/charset/convert.h>
  24. #include <mapidefs.h>
  25. #include <libical/ical.h>
  26. namespace KC {
  27. class VConverter {
  28. public:
  29. /* lpNamedProps must be the GetIDsFromNames() of the array in nameids.h */
  30. VConverter(LPADRBOOK lpAdrBook, timezone_map *mapTimeZones, LPSPropTagArray lpNamedProps, const std::string& strCharset, bool blCensor, bool bNoRecipients, IMailUser *lpImailUser);
  31. virtual ~VConverter(void) _kc_impdtor;
  32. virtual HRESULT HrICal2MAPI(icalcomponent *lpEventRoot /* in */, icalcomponent *lpEvent /* in */, icalitem *lpPrevItem /* in */, icalitem **lppRet /* out */);
  33. virtual HRESULT HrMAPI2ICal(LPMESSAGE lpMessage /* in */, icalproperty_method *lpicMethod /* out */, std::list<icalcomponent*> *lpEventList /* out */);
  34. protected:
  35. LPADRBOOK m_lpAdrBook;
  36. timezone_map *m_mapTimeZones;
  37. timezone_map_iterator m_iCurrentTimeZone;
  38. LPSPropTagArray m_lpNamedProps;
  39. std::string m_strCharset;
  40. IMailUser *m_lpMailUser;
  41. bool m_bCensorPrivate;
  42. bool m_bNoRecipients;
  43. ULONG m_ulUserStatus;
  44. convert_context m_converter;
  45. virtual HRESULT HrGetUID(icalcomponent *lpEvent, std::string *strUid);
  46. virtual HRESULT HrMakeBinaryUID(const std::string &strUid, void *base, SPropValue *lpPropValue);
  47. virtual HRESULT HrResolveUser(void *base, std::list<icalrecip> *lplstIcalRecip);
  48. virtual bool bIsUserLoggedIn(const std::wstring &strUser);
  49. /* ical -> mapi helper functions */
  50. virtual HRESULT HrCompareUids(icalitem *lpIcalItem, icalcomponent *lpicEvent);
  51. virtual HRESULT HrAddUids(icalcomponent *lpicEvent, icalitem *lpIcalItem);
  52. virtual HRESULT HrHandleExceptionGuid(icalcomponent *lpiEvent, void *base, SPropValue *lpsProp);
  53. virtual HRESULT HrAddRecurrenceID(icalcomponent *lpiEvent, icalitem *lpIcalItem);
  54. virtual HRESULT HrAddBaseProperties(icalproperty_method icMethod, icalcomponent *lpicEvent, void *base, bool bIsException, std::list<SPropValue> *lplstMsgProps) = 0; /* pure, must be overloaded */
  55. virtual HRESULT HrAddStaticProps(icalproperty_method icMethod, icalitem *lpIcalItem);
  56. virtual HRESULT HrAddSimpleHeaders(icalcomponent *lpicEvent, icalitem *lpIcalItem);
  57. virtual HRESULT HrAddBusyStatus(icalcomponent *lpicEvent, icalproperty_method icMethod, icalitem *lpIcalItem);
  58. virtual HRESULT HrAddXHeaders(icalcomponent *lpicEvent, icalitem *lpIcalItem);
  59. virtual HRESULT HrAddCategories(icalcomponent *lpicEvent, icalitem *lpIcalItem);
  60. virtual HRESULT HrAddTimes(icalproperty_method icMethod, icalcomponent *lpicEventRoot, icalcomponent *lpicEvent, bool bIsAllday, icalitem *lpIcalItem) = 0; /* pure, must be overloaded */
  61. virtual HRESULT HrAddOrganizer(icalitem *lpIcalItem, std::list<SPropValue> *lplstMsgProps, const std::wstring &strEmail, const std::wstring &strName, const std::string &strType, ULONG cbEntryID, LPENTRYID lpEntryID);
  62. virtual HRESULT HrAddRecipients(icalcomponent *lpicEvent, icalitem *lpIcalItem, std::list<SPropValue> *lplstMsgProps, std::list<icalrecip> * lplstIcalRecip);
  63. virtual HRESULT HrAddReplyRecipients(icalcomponent *lpicEvent, icalitem *lpIcalItem);
  64. virtual HRESULT HrAddReminder(icalcomponent *lpicEventRoot, icalcomponent *lpicEvent, icalitem *lpIcalItem);
  65. virtual HRESULT HrAddRecurrence(icalcomponent *lpicEventRoot, icalcomponent *lpicEvent, bool bIsAllday, icalitem *lpIcalItem);
  66. virtual HRESULT HrAddException(icalcomponent *lpEventRoot, icalcomponent *lpEvent, bool bIsAllday, icalitem *lpPrevItem);
  67. virtual HRESULT HrAddTimeZone(icalproperty *lpicProp, icalitem *lpIcalItem);
  68. virtual HRESULT HrRetrieveAlldayStatus(icalcomponent *lpicEvent, bool *blIsAllday);
  69. /* mapi -> ical helper functions */
  70. virtual HRESULT HrMAPI2ICal(LPMESSAGE lpMessage, icalproperty_method *lpicMethod, icaltimezone **lppicTZinfo, std::string *lpstrTZid, icalcomponent **lppEvent) = 0; /* pure */
  71. virtual HRESULT HrMAPI2ICal(LPMESSAGE lpMessage, icalproperty_method *lpicMethod, icaltimezone **lppicTZinfo, std::string *lpstrTZid, icalcomponent *lpEvent);
  72. virtual HRESULT HrFindTimezone(ULONG ulProps, LPSPropValue lpProps, std::string *lpstrTZid, TIMEZONE_STRUCT *lpTZinfo, icaltimezone **lppicTZinfo);
  73. virtual HRESULT HrSetTimeProperty(time_t tStamp, bool bDateOnly, icaltimezone *lpicTZinfo, const std::string &strTZid, icalproperty_kind icalkind, icalproperty *lpicProp);
  74. virtual HRESULT HrSetTimeProperty(time_t tStamp, bool bDateOnly, icaltimezone *lpicTZinfo, const std::string &strTZid, icalproperty_kind icalkind, icalcomponent *lpicEvent);
  75. virtual HRESULT HrSetOrganizerAndAttendees(LPMESSAGE lpParentMsg /* if exception*/, LPMESSAGE lpMessage, ULONG ulProps, LPSPropValue lpProps, icalproperty_method *lpicMethod, icalcomponent *lpicEvent);
  76. virtual HRESULT HrSetTimeProperties(LPSPropValue lpMsgProps, ULONG ulMsgProps, icaltimezone *lpicTZinfo, const std::string &strTZid, icalcomponent *lpEvent);
  77. virtual HRESULT HrSetICalAttendees(LPMESSAGE lpMessage, const std::wstring &strOrganizer, icalcomponent *lpicEvent);
  78. virtual HRESULT HrSetBusyStatus(LPMESSAGE lpMessage, ULONG ulBusyStatus, icalcomponent *lpicEvent);
  79. virtual HRESULT HrSetXHeaders(ULONG ulProps, LPSPropValue lpProps, LPMESSAGE lpMessage, icalcomponent *lpicEvent);
  80. virtual HRESULT HrSetVAlarm(ULONG ulProps, LPSPropValue lpProps, icalcomponent *lpicEvent);
  81. virtual HRESULT HrSetBody(LPMESSAGE lpMessage, icalproperty **lppicProp);
  82. virtual HRESULT HrSetItemSpecifics(ULONG ulProps, LPSPropValue lpProps, icalcomponent *lpicEvent);
  83. virtual HRESULT HrSetRecurrenceID(LPSPropValue lpMsgProps, ULONG ulMsgProps, icaltimezone *lpicTZinfo, const std::string &strTZid, icalcomponent *lpiEvent);
  84. /* recurrence + exceptions */
  85. virtual HRESULT HrSetRecurrence(LPMESSAGE lpMessage, icalcomponent *lpicEvent, icaltimezone *lpicTZinfo, const std::string &strTZid, std::list<icalcomponent*> *lpEventList);
  86. virtual HRESULT HrUpdateReminderTime(icalcomponent *lpicEvent, LONG lReminder);
  87. virtual HRESULT HrGetExceptionMessage(LPMESSAGE lpMessage, time_t tStart, LPMESSAGE *lppMessage);
  88. };
  89. HRESULT HrCopyString(convert_context& converter, std::string& strCharset, void *base, const char* lpszSrc, WCHAR** lppszDst);
  90. HRESULT HrCopyString(void *base, const WCHAR* lpwszSrc, WCHAR** lppwszDst);
  91. } /* namespace */
  92. #endif