ECNamedProp.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 ECNAMEDPROP_H
  18. #define ECNAMEDPROP_H
  19. #include <kopano/zcdefs.h>
  20. #include <mapidefs.h>
  21. #include <map>
  22. class WSTransport;
  23. // Sort function
  24. //
  25. // Doesn't really matter *how* it sorts, as long as it's reproduceable
  26. struct ltmap {
  27. bool operator()(const MAPINAMEID *a, const MAPINAMEID *b) const
  28. {
  29. int r = memcmp(a->lpguid, b->lpguid, sizeof(GUID));
  30. if(r<0)
  31. return false;
  32. else if(r>0)
  33. return true;
  34. else {
  35. if(a->ulKind != b->ulKind)
  36. return a->ulKind > b->ulKind;
  37. switch(a->ulKind) {
  38. case MNID_ID:
  39. return a->Kind.lID > b->Kind.lID;
  40. case MNID_STRING:
  41. return wcscmp(a->Kind.lpwstrName, b->Kind.lpwstrName) < 0;
  42. default:
  43. return false;
  44. }
  45. }
  46. }
  47. };
  48. class ECNamedProp _kc_final {
  49. public:
  50. ECNamedProp(WSTransport *lpTransport);
  51. virtual ~ECNamedProp();
  52. virtual HRESULT GetNamesFromIDs(LPSPropTagArray *lppPropTags, LPGUID lpPropSetGuid, ULONG ulFlags, ULONG *lpcPropNames, LPMAPINAMEID **lpppPropNames);
  53. virtual HRESULT GetIDsFromNames(ULONG cPropNames, LPMAPINAMEID *lppPropNames, ULONG ulFlags, LPSPropTagArray *lppPropTags);
  54. private:
  55. std::map<MAPINAMEID *,ULONG,ltmap> mapNames;
  56. WSTransport * lpTransport;
  57. HRESULT ResolveLocal(MAPINAMEID *lpName, ULONG *ulId);
  58. HRESULT ResolveCache(MAPINAMEID *lpName, ULONG *ulId);
  59. HRESULT ResolveReverseLocal(ULONG ulId, LPGUID lpGuid, ULONG ulFlags, void *lpBase, MAPINAMEID **lppName);
  60. HRESULT ResolveReverseCache(ULONG ulId, LPGUID lpGuid, ULONG ulFlags, void *lpBase, MAPINAMEID **lppName);
  61. HRESULT UpdateCache(ULONG ulId, MAPINAMEID *lpName);
  62. HRESULT HrCopyNameId(LPMAPINAMEID lpSrc, LPMAPINAMEID *lppDst, void *lpBase);
  63. };
  64. #endif // ECNAMEDPROP_H