ECArchiveAwareAttach.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 <new>
  18. #include <kopano/platform.h>
  19. #include "ECArchiveAwareAttach.h"
  20. #include "ECArchiveAwareMessage.h"
  21. HRESULT ECArchiveAwareAttachFactory::Create(ECMsgStore *lpMsgStore, ULONG ulObjType, BOOL fModify, ULONG ulAttachNum, ECMAPIProp *lpRoot, ECAttach **lppAttach) const
  22. {
  23. return ECArchiveAwareAttach::Create(lpMsgStore, ulObjType, fModify, ulAttachNum, lpRoot, lppAttach);
  24. }
  25. ECArchiveAwareAttach::ECArchiveAwareAttach(ECMsgStore *lpMsgStore, ULONG ulObjType, BOOL fModify, ULONG ulAttachNum, ECMAPIProp *lpRoot)
  26. : ECAttach(lpMsgStore, ulObjType, fModify, ulAttachNum, lpRoot)
  27. , m_lpRoot(dynamic_cast<ECArchiveAwareMessage*>(lpRoot))
  28. {
  29. assert(m_lpRoot != NULL); // We don't expect an ECArchiveAwareAttach to be ever created by any other object than a ECArchiveAwareMessage.
  30. // Override the handler defined in ECAttach
  31. this->HrAddPropHandlers(PR_ATTACH_SIZE, ECAttach::GetPropHandler, SetPropHandler, (void*)this, FALSE, FALSE);
  32. }
  33. HRESULT ECArchiveAwareAttach::Create(ECMsgStore *lpMsgStore, ULONG ulObjType, BOOL fModify, ULONG ulAttachNum, ECMAPIProp *lpRoot, ECAttach **lppAttach)
  34. {
  35. return alloc_wrap<ECArchiveAwareAttach>(lpMsgStore, ulObjType, fModify,
  36. ulAttachNum, lpRoot).as(IID_ECAttach, lppAttach);
  37. }
  38. HRESULT ECArchiveAwareAttach::SetPropHandler(ULONG ulPropTag,
  39. void */*lpProvider*/, const SPropValue *lpsPropValue, void *lpParam)
  40. {
  41. auto lpAttach = static_cast<ECArchiveAwareAttach *>(lpParam);
  42. HRESULT hr = hrSuccess;
  43. switch(ulPropTag) {
  44. case PR_ATTACH_SIZE:
  45. if (lpAttach->m_lpRoot && lpAttach->m_lpRoot->IsLoading())
  46. hr = lpAttach->HrSetRealProp(lpsPropValue);
  47. else
  48. hr = MAPI_E_COMPUTED;
  49. break;
  50. default:
  51. hr = MAPI_E_NOT_FOUND;
  52. break;
  53. }
  54. return hr;
  55. }