123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #include <kopano/platform.h>
- #include <kopano/ECABEntryID.h>
- #include <kopano/ECGuid.h>
- #include <mapicode.h>
- namespace KC {
- struct ABEID {
- BYTE abFlags[4];
- GUID guid;
- ULONG ulVersion;
- ULONG ulType;
- ULONG ulId;
- char szExId[1];
- char szPadding[3];
- ABEID(ULONG ulType, GUID guid, ULONG ulId) {
- memset(this, 0, sizeof(ABEID));
- this->ulType = ulType;
- this->guid = guid;
- this->ulId = ulId;
- }
- };
- static ABEID g_sDefaultEid(MAPI_MAILUSER, MUIDECSAB, 0);
- unsigned char *g_lpDefaultEid = (unsigned char*)&g_sDefaultEid;
- const unsigned int g_cbDefaultEid = sizeof(g_sDefaultEid);
- static ABEID g_sEveryOneEid(MAPI_DISTLIST, MUIDECSAB, 1);
- unsigned char *g_lpEveryoneEid = (unsigned char*)&g_sEveryOneEid;
- const unsigned int g_cbEveryoneEid = sizeof(g_sEveryOneEid);
- static ABEID g_sSystemEid(MAPI_MAILUSER, MUIDECSAB, 2);
- unsigned char *g_lpSystemEid = (unsigned char*)&g_sSystemEid;
- const unsigned int g_cbSystemEid = sizeof(g_sSystemEid);
- static HRESULT CheckEntryId(unsigned int cbEntryId, const ENTRYID *lpEntryId,
- unsigned int ulId, unsigned int ulType, bool *lpbResult)
- {
- bool bResult = true;
- if (cbEntryId < sizeof(ABEID) || lpEntryId == NULL || lpbResult == NULL)
- return MAPI_E_INVALID_PARAMETER;
- auto lpEid = reinterpret_cast<const ABEID *>(lpEntryId);
- if (lpEid->ulId != ulId)
- bResult = false;
-
- else if (lpEid->ulType != ulType)
- bResult = false;
- else if (lpEid->ulVersion == 1 && lpEid->szExId[0])
- bResult = false;
- *lpbResult = bResult;
- return hrSuccess;
- }
- HRESULT EntryIdIsDefault(unsigned int cbEntryId, const ENTRYID *lpEntryId,
- bool *lpbResult)
- {
- return CheckEntryId(cbEntryId, lpEntryId, 0, MAPI_MAILUSER, lpbResult);
- }
- HRESULT EntryIdIsSystem(unsigned int cbEntryId, const ENTRYID *lpEntryId,
- bool *lpbResult)
- {
- return CheckEntryId(cbEntryId, lpEntryId, 2, MAPI_MAILUSER, lpbResult);
- }
- HRESULT EntryIdIsEveryone(unsigned int cbEntryId, const ENTRYID *lpEntryId,
- bool *lpbResult)
- {
- return CheckEntryId(cbEntryId, lpEntryId, 1, MAPI_DISTLIST, lpbResult);
- }
- HRESULT GetNonPortableObjectId(unsigned int cbEntryId,
- const ENTRYID *lpEntryId, unsigned int *lpulObjectId)
- {
- if (cbEntryId < sizeof(ABEID) || lpEntryId == NULL || lpulObjectId == NULL)
- return MAPI_E_INVALID_PARAMETER;
- *lpulObjectId = reinterpret_cast<const ABEID *>(lpEntryId)->ulId;
- return hrSuccess;
- }
- HRESULT GetNonPortableObjectType(unsigned int cbEntryId,
- const ENTRYID *lpEntryId, ULONG *lpulObjectType)
- {
- if (cbEntryId < sizeof(ABEID) || lpEntryId == NULL || lpulObjectType == NULL)
- return MAPI_E_INVALID_PARAMETER;
- *lpulObjectType = reinterpret_cast<const ABEID *>(lpEntryId)->ulType;
- return hrSuccess;
- }
- }
|