ECABProp.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. #include <kopano/platform.h>
  18. #include <kopano/ECInterfaceDefs.h>
  19. #include "kcore.hpp"
  20. #include "ECABProp.h"
  21. #include "Mem.h"
  22. #include <kopano/ECGuid.h>
  23. #include <kopano/ECDefs.h>
  24. #include <kopano/CommonUtil.h>
  25. #include <kopano/ECDebug.h>
  26. ECABProp::ECABProp(void *lpProvider, ULONG ulObjType, BOOL fModify,
  27. const char *szClassName) :
  28. ECGenericProp(lpProvider, ulObjType, fModify, szClassName)
  29. {
  30. this->HrAddPropHandlers(PR_RECORD_KEY, DefaultABGetProp, DefaultSetPropComputed, (void*) this);
  31. this->HrAddPropHandlers(PR_STORE_SUPPORT_MASK, DefaultABGetProp, DefaultSetPropComputed, (void*) this);
  32. }
  33. HRESULT ECABProp::QueryInterface(REFIID refiid, void **lppInterface)
  34. {
  35. REGISTER_INTERFACE2(ECABProp, this);
  36. REGISTER_INTERFACE2(ECUnknown, this);
  37. REGISTER_INTERFACE2(IMAPIProp, &this->m_xMAPIProp);
  38. REGISTER_INTERFACE2(IUnknown, &this->m_xMAPIProp);
  39. return MAPI_E_INTERFACE_NOT_SUPPORTED;
  40. }
  41. HRESULT ECABProp::DefaultABGetProp(ULONG ulPropTag, void* lpProvider, ULONG ulFlags, LPSPropValue lpsPropValue, void *lpParam, void *lpBase)
  42. {
  43. HRESULT hr = hrSuccess;
  44. auto lpProp = static_cast<ECABProp *>(lpParam);
  45. switch(PROP_ID(ulPropTag)) {
  46. case PROP_ID(PR_RECORD_KEY):
  47. lpsPropValue->ulPropTag = PR_RECORD_KEY;
  48. if(lpProp->m_lpEntryId && lpProp->m_cbEntryId > 0) {
  49. lpsPropValue->Value.bin.cb = lpProp->m_cbEntryId;
  50. hr = ECAllocateMore(lpsPropValue->Value.bin.cb, lpBase, reinterpret_cast<void **>(&lpsPropValue->Value.bin.lpb));
  51. if (hr != hrSuccess)
  52. break;
  53. memcpy(lpsPropValue->Value.bin.lpb, lpProp->m_lpEntryId, lpsPropValue->Value.bin.cb);
  54. } else {
  55. hr = MAPI_E_NOT_FOUND;
  56. }
  57. break;
  58. case PROP_ID(PR_STORE_SUPPORT_MASK):
  59. {
  60. unsigned int ulClientVersion = -1;
  61. GetClientVersion(&ulClientVersion);
  62. // No real unicode support in outlook 2000 and xp
  63. if (ulClientVersion > CLIENT_VERSION_OLK2002) {
  64. lpsPropValue->Value.l = STORE_UNICODE_OK;
  65. lpsPropValue->ulPropTag = PR_STORE_SUPPORT_MASK;
  66. } else {
  67. hr = MAPI_E_NOT_FOUND;
  68. }
  69. break;
  70. }
  71. default:
  72. hr = lpProp->HrGetRealProp(ulPropTag, ulFlags, lpBase, lpsPropValue);
  73. break;
  74. }
  75. return hr;
  76. }
  77. HRESULT ECABProp::TableRowGetProp(void* lpProvider, struct propVal *lpsPropValSrc, LPSPropValue lpsPropValDst, void **lpBase, ULONG ulType)
  78. {
  79. HRESULT hr = hrSuccess;
  80. switch(lpsPropValSrc->ulPropTag) {
  81. case PROP_TAG(PT_ERROR,PROP_ID(PR_AB_PROVIDER_ID)):
  82. lpsPropValDst->ulPropTag = PR_AB_PROVIDER_ID;
  83. lpsPropValDst->Value.bin.cb = sizeof(GUID);
  84. hr = ECAllocateMore(sizeof(GUID), lpBase, reinterpret_cast<void **>(&lpsPropValDst->Value.bin.lpb));
  85. if (hr != hrSuccess)
  86. break;
  87. memcpy(lpsPropValDst->Value.bin.lpb, &MUIDECSAB, sizeof(GUID));
  88. break;
  89. default:
  90. hr = MAPI_E_NOT_FOUND;
  91. break;
  92. }
  93. return hr;
  94. }
  95. ECABLogon* ECABProp::GetABStore()
  96. {
  97. return (ECABLogon*)lpProvider;
  98. }
  99. // Interface IMAPIProp
  100. DEF_ULONGMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, AddRef, (void))
  101. DEF_ULONGMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, Release, (void))
  102. DEF_HRMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, QueryInterface, (REFIID, id), (void **, intf))
  103. DEF_HRMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, GetLastError, (HRESULT, hError), (ULONG, ulFlags), (LPMAPIERROR *, lppMapiError))
  104. DEF_HRMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, SaveChanges, (ULONG, ulFlags))
  105. DEF_HRMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, GetProps, (const SPropTagArray *, lpPropTagArray), (ULONG, ulFlags), (ULONG *, lpcValues), (SPropValue **, lppPropArray))
  106. DEF_HRMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, GetPropList, (ULONG, ulFlags), (LPSPropTagArray *, lppPropTagArray))
  107. DEF_HRMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, OpenProperty, (ULONG, ulPropTag), (LPCIID, lpiid), (ULONG, ulInterfaceOptions), (ULONG, ulFlags), (LPUNKNOWN *, lppUnk))
  108. DEF_HRMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, SetProps, (ULONG, cValues), (const SPropValue *, lpPropArray), (SPropProblemArray **, lppProblems))
  109. DEF_HRMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, DeleteProps, (const SPropTagArray *, lpPropTagArray), (SPropProblemArray **, lppProblems))
  110. DEF_HRMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, CopyTo, (ULONG, ciidExclude), (LPCIID, rgiidExclude), (const SPropTagArray *, lpExcludeProps), (ULONG, ulUIParam), (LPMAPIPROGRESS, lpProgress), (LPCIID, lpInterface), (void *, lpDestObj), (ULONG, ulFlags), (SPropProblemArray **, lppProblems))
  111. DEF_HRMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, CopyProps, (const SPropTagArray *, lpIncludeProps), (ULONG, ulUIParam), (LPMAPIPROGRESS, lpProgress), (LPCIID, lpInterface), (void *, lpDestObj), (ULONG, ulFlags), (SPropProblemArray **, lppProblems))
  112. DEF_HRMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, GetNamesFromIDs, (LPSPropTagArray *, pptaga), (LPGUID, lpguid), (ULONG, ulFlags), (ULONG *, pcNames), (LPMAPINAMEID **, pppNames))
  113. DEF_HRMETHOD1(TRACE_MAPI, ECABProp, MAPIProp, GetIDsFromNames, (ULONG, cNames), (LPMAPINAMEID *, ppNames), (ULONG, ulFlags), (LPSPropTagArray *, pptaga))