StorageUtil.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 STORAGEUTIL_H
  18. #define STORAGEUTIL_H
  19. #include <kopano/kcodes.h>
  20. #include <mapidefs.h>
  21. namespace KC {
  22. class ECDatabase;
  23. class ECAttachmentStorage;
  24. class ECSession;
  25. ECRESULT CreateAttachmentStorage(ECDatabase *lpDatabase, ECAttachmentStorage **lppAttachmentStorage);
  26. ECRESULT CreateObject(ECSession *lpecSession, ECDatabase *lpDatabase, unsigned int ulParentObjId, unsigned int ulParentType, unsigned int ulObjType, unsigned int ulFlags, unsigned int *lpulObjId);
  27. enum eSizeUpdateAction{ UPDATE_SET, UPDATE_ADD, UPDATE_SUB };
  28. ECRESULT GetObjectSize(ECDatabase* lpDatabase, unsigned int ulObjId, unsigned int* lpulSize);
  29. ECRESULT CalculateObjectSize(ECDatabase* lpDatabase, unsigned int objid, unsigned int ulObjType, unsigned int* lpulSize);
  30. ECRESULT UpdateObjectSize(ECDatabase* lpDatabase, unsigned int ulObjId, unsigned int ulObjType, eSizeUpdateAction updateAction, long long llSize);
  31. /**
  32. * Get the corrected object type used to determine course of action.
  33. * MAPI_MESSAGE objects can contain only MAPI_ATTACH, MAPI_MAILUSER and MAPI_DISTLIST sub objects,
  34. * but in practice the object type can be different. This function will return MAPI_MAILUSER for
  35. * any MAPI_MESSAGE subtype that does not match the mentioned types.
  36. */
  37. static inline unsigned int RealObjType(unsigned int ulObjType, unsigned int ulParentType) {
  38. if (ulParentType == MAPI_MESSAGE && ulObjType != MAPI_MAILUSER && ulObjType != MAPI_DISTLIST && ulObjType != MAPI_ATTACH)
  39. return MAPI_MAILUSER;
  40. return ulObjType;
  41. }
  42. } /* namespace */
  43. #endif // ndef STORAGEUTIL_H