nameids.cpp 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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/memory.hpp>
  19. #include "nameids.h"
  20. #include <mapix.h>
  21. namespace KC {
  22. const WCHAR* nmStringNames[SIZE_NAMEDPROPS] = {
  23. L"Keywords", NULL
  24. };
  25. MAPINAMEID mnNamedProps[SIZE_NAMEDPROPS] = {
  26. // lpwstrName:L"Keywords" may work, but gives a compile warning: ISO C++ does not allow designated initializers
  27. {(LPGUID)&PS_PUBLIC_STRINGS, MNID_STRING, { 0 }},
  28. // ID names
  29. {(LPGUID)&PSETID_Meeting, MNID_ID, {dispidMeetingLocation}},
  30. {(LPGUID)&PSETID_Meeting, MNID_ID, {dispidGlobalObjectID}},
  31. {(LPGUID)&PSETID_Meeting, MNID_ID, {dispidIsRecurring}},
  32. {(LPGUID)&PSETID_Meeting, MNID_ID, {dispidCleanGlobalObjectID}},
  33. {(LPGUID)&PSETID_Meeting, MNID_ID, {dispidOwnerCriticalChange}},
  34. {(LPGUID)&PSETID_Meeting, MNID_ID, {dispidAttendeeCriticalChange}},
  35. {(LPGUID)&PSETID_Meeting, MNID_ID, {dispidOldWhenStartWhole}},
  36. {(LPGUID)&PSETID_Meeting, MNID_ID, {dispidIsException}},
  37. {(LPGUID)&PSETID_Meeting, MNID_ID, {dispidStartRecurrenceTime}},
  38. {(LPGUID)&PSETID_Meeting, MNID_ID, {dispidEndRecurrenceTime}},
  39. {(LPGUID)&PSETID_Kopano_CalDav, MNID_ID, {dispidMozGen}}, //X-MOZ-GENERATION
  40. {(LPGUID)&PSETID_Kopano_CalDav, MNID_ID, {dispidMozLastAck}}, //X-MOZ-LAST-ACK
  41. {(LPGUID)&PSETID_Kopano_CalDav, MNID_ID, {dispidMozSnoozeSuffixTime}}, //X-MOZ-SNOOZE-TIME suffix
  42. {(LPGUID)&PSETID_Kopano_CalDav, MNID_ID, {dispidMozSendInvite}}, //X-MOZ-SEND-INVITATIONS
  43. {(LPGUID)&PSETID_Kopano_CalDav, MNID_ID, {dispidApptTsRef}},
  44. {(LPGUID)&PSETID_Kopano_CalDav, MNID_ID, {dispidFldID}},
  45. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidSendAsICAL}},
  46. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidAppointmentSequenceNumber}},
  47. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidApptSeqTime}},
  48. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidBusyStatus}},
  49. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidApptAuxFlags}},
  50. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidLocation}},
  51. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidLabel}},
  52. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidApptStartWhole}},
  53. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidApptEndWhole}},
  54. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidApptDuration}},
  55. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidAllDayEvent}},
  56. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidRecurrenceState}},
  57. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidAppointmentStateFlags}},
  58. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidResponseStatus}},
  59. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidRecurring}},
  60. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidIntendedBusyStatus}},
  61. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidRecurringBase}},
  62. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidRequestSent}}, // aka PidLidFInvited
  63. {(LPGUID)&PSETID_Appointment, MNID_ID, {0x8230}},
  64. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidRecurrenceType}},
  65. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidRecurrencePattern}},
  66. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidTimeZoneData}},
  67. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidTimeZone}},
  68. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidClipStart}},
  69. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidClipEnd}},
  70. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidAllAttendeesString}}, // AllAttendees (Exluding self, ';' separated)
  71. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidToAttendeesString}}, // RequiredAttendees (Including self)
  72. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidCCAttendeesString}}, // OptionalAttendees
  73. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidNetMeetingType}},
  74. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidNetMeetingServer}},
  75. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidNetMeetingOrganizerAlias}},
  76. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidNetMeetingAutoStart}},
  77. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidAutoStartWhen}},
  78. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidConferenceServerAllowExternal}},
  79. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidNetMeetingDocPathName}},
  80. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidNetShowURL}},
  81. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidConferenceServerPassword}},
  82. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidApptReplyTime}},
  83. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidApptCounterProposal}},
  84. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidApptProposedStartWhole}},
  85. {(LPGUID)&PSETID_Appointment, MNID_ID, {dispidApptProposedEndWhole}},
  86. {(LPGUID)&PSETID_Common, MNID_ID, {dispidReminderMinutesBeforeStart}},
  87. {(LPGUID)&PSETID_Common, MNID_ID, {dispidReminderTime}},
  88. {(LPGUID)&PSETID_Common, MNID_ID, {dispidReminderSet}},
  89. {(LPGUID)&PSETID_Common, MNID_ID, {dispidPrivate}},
  90. {(LPGUID)&PSETID_Common, MNID_ID, {dispidNoAging}},
  91. {(LPGUID)&PSETID_Common, MNID_ID, {dispidSideEffect}},
  92. {(LPGUID)&PSETID_Common, MNID_ID, {dispidRemoteStatus}},
  93. {(LPGUID)&PSETID_Common, MNID_ID, {dispidCommonStart}},
  94. {(LPGUID)&PSETID_Common, MNID_ID, {dispidCommonEnd}},
  95. {(LPGUID)&PSETID_Common, MNID_ID, {dispidCommonAssign}},
  96. {(LPGUID)&PSETID_Common, MNID_ID, {dispidContacts}},
  97. {(LPGUID)&PSETID_Common, MNID_ID, {dispidOutlookInternalVersion}},
  98. {(LPGUID)&PSETID_Common, MNID_ID, {dispidOutlookVersion}},
  99. {(LPGUID)&PSETID_Common, MNID_ID, {dispidReminderNextTime}},
  100. {(LPGUID)&PSETID_Common, MNID_ID, {dispidSmartNoAttach}},
  101. {(LPGUID)&PSETID_Task, MNID_ID, {dispidTaskStatus}},
  102. {(LPGUID)&PSETID_Task, MNID_ID, {dispidTaskComplete}},
  103. {(LPGUID)&PSETID_Task, MNID_ID, {dispidTaskPercentComplete}},
  104. {(LPGUID)&PSETID_Task, MNID_ID, {dispidTaskStartDate}},
  105. {(LPGUID)&PSETID_Task, MNID_ID, {dispidTaskDueDate}},
  106. {(LPGUID)&PSETID_Task, MNID_ID, {dispidTaskRecurrenceState}},
  107. {(LPGUID)&PSETID_Task, MNID_ID, {dispidTaskIsRecurring}},
  108. {(LPGUID)&PSETID_Task, MNID_ID, {dispidTaskDateCompleted}}
  109. };
  110. /**
  111. * Lookup all required named properties actual IDs for a given MAPI object.
  112. *
  113. * @param[in] lpPropObj Call GetIDsFromNames on this object.
  114. * @param[out] lppNamedProps Array of all named properties used in mapi ical conversions.
  115. *
  116. * @return MAPI error code
  117. */
  118. HRESULT HrLookupNames(IMAPIProp *lpPropObj, LPSPropTagArray *lppNamedProps)
  119. {
  120. HRESULT hr = hrSuccess;
  121. KCHL::memory_ptr<MAPINAMEID *> lppNameIds;
  122. LPSPropTagArray lpNamedProps = NULL;
  123. hr = MAPIAllocateBuffer(sizeof(LPMAPINAMEID) * SIZE_NAMEDPROPS, &~lppNameIds);
  124. if (hr != hrSuccess)
  125. return hr;
  126. for (int i = 0; i < SIZE_NAMEDPROPS; ++i) {
  127. hr = MAPIAllocateMore(sizeof(MAPINAMEID), lppNameIds, (void**)&lppNameIds[i] );
  128. if (hr != hrSuccess)
  129. return hr;
  130. memcpy(lppNameIds[i], &mnNamedProps[i], sizeof(MAPINAMEID) );
  131. if (mnNamedProps[i].ulKind == MNID_STRING && nmStringNames[i])
  132. lppNameIds[i]->Kind.lpwstrName = (WCHAR*)nmStringNames[i];
  133. }
  134. hr = lpPropObj->GetIDsFromNames(SIZE_NAMEDPROPS, lppNameIds, MAPI_CREATE, &lpNamedProps);
  135. if (FAILED(hr))
  136. return hr;
  137. *lppNamedProps = lpNamedProps;
  138. return hrSuccess;
  139. }
  140. } /* namespace */