From fc5049ad613400e6fcd11d495f5cf16cfbe409d1 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Sat, 19 Dec 2020 21:29:06 -0500 Subject: [PATCH 1/8] start hiding list data --- .../SortList/ContentsTableListCtrl.cpp | 24 ++++++++---------- UI/Controls/SortList/SortListCtrl.cpp | 12 ++++----- .../StyleTree/HierarchyTableTreeCtrl.cpp | 8 +++--- UI/Dialogs/ContentsTable/AclDlg.cpp | 12 ++++----- UI/Dialogs/ContentsTable/ContentsTableDlg.cpp | 3 +-- UI/Dialogs/ContentsTable/FormContainerDlg.cpp | 11 +++----- UI/Dialogs/ContentsTable/MainDlg.cpp | 4 +-- UI/Dialogs/ContentsTable/RulesDlg.cpp | 14 +++++------ .../Editors/MultiValuePropertyEditor.cpp | 2 +- UI/Dialogs/Editors/QSSpecialFolders.cpp | 2 +- UI/Dialogs/Editors/RestrictEditor.cpp | 2 +- .../HierarchyTable/HierarchyTableDlg.cpp | 7 ++---- core/mapi/mapiFunctions.cpp | 5 ---- core/mapi/mapiFunctions.h | 15 ++++++++++- core/propertyBag/mapiPropPropertyBag.cpp | 18 ++++++------- core/propertyBag/rowPropertyBag.cpp | 9 +++---- core/sortlistdata/sortListData.h | 25 ++++++++++++++++--- 17 files changed, 90 insertions(+), 83 deletions(-) diff --git a/UI/Controls/SortList/ContentsTableListCtrl.cpp b/UI/Controls/SortList/ContentsTableListCtrl.cpp index 0ca7019ff..558d2d21a 100644 --- a/UI/Controls/SortList/ContentsTableListCtrl.cpp +++ b/UI/Controls/SortList/ContentsTableListCtrl.cpp @@ -898,7 +898,7 @@ namespace controls::sortlistctrl SetRowStrings(iRow, lpsRowData); // Do this last so that our row can't get sorted before we're done! - lpData->bItemFullyLoaded = true; + lpData->setFullyLoaded(true); } } @@ -1212,12 +1212,10 @@ namespace controls::sortlistctrl { // go get the original row for display in the prop list control lpData = GetSortListData(pNMListView->iItem); - ULONG cValues = 0; - LPSPropValue lpProps = nullptr; + auto row = SRow{}; if (lpData) { - cValues = lpData->cSourceProps; - lpProps = lpData->lpSourceProps; + row = lpData->getRow(); } lpMAPIProp = m_lpHostDlg->OpenItemProp(pNMListView->iItem, modifyType::REQUEST_MODIFY); @@ -1225,15 +1223,15 @@ namespace controls::sortlistctrl szTitle = strings::loadstring(IDS_DISPLAYNAMENOTFOUND); // try to use our rowset first - if (NODISPLAYNAME != m_ulDisplayNameColumn && lpProps && m_ulDisplayNameColumn < cValues) + if (NODISPLAYNAME != m_ulDisplayNameColumn && row.lpProps && m_ulDisplayNameColumn < row.cValues) { - if (strings::CheckStringProp(&lpProps[m_ulDisplayNameColumn], PT_STRING8)) + if (strings::CheckStringProp(&row.lpProps[m_ulDisplayNameColumn], PT_STRING8)) { - szTitle = strings::stringTowstring(lpProps[m_ulDisplayNameColumn].Value.lpszA); + szTitle = strings::stringTowstring(row.lpProps[m_ulDisplayNameColumn].Value.lpszA); } - else if (strings::CheckStringProp(&lpProps[m_ulDisplayNameColumn], PT_UNICODE)) + else if (strings::CheckStringProp(&row.lpProps[m_ulDisplayNameColumn], PT_UNICODE)) { - szTitle = lpProps[m_ulDisplayNameColumn].Value.lpszW; + szTitle = row.lpProps[m_ulDisplayNameColumn].Value.lpszW; } else { @@ -1430,15 +1428,13 @@ namespace controls::sortlistctrl hRes = EC_B(SetItem(&lvItem)); // Set new image for the row // Save the row type (header/leaf) into lpData - const auto lpProp = PpropFindProp(lpData->lpSourceProps, lpData->cSourceProps, PR_ROW_TYPE); + const auto lpProp = lpData->GetOneProp(PR_ROW_TYPE); if (lpProp && PR_ROW_TYPE == lpProp->ulPropTag) { lpProp->Value.l = contents->m_ulRowType; } - SRow sRowData = {}; - sRowData.cValues = lpData->cSourceProps; - sRowData.lpProps = lpData->lpSourceProps; + auto sRowData = lpData->getRow(); SetRowStrings(iItem, &sRowData); } diff --git a/UI/Controls/SortList/SortListCtrl.cpp b/UI/Controls/SortList/SortListCtrl.cpp index 34e3b447c..e561454e2 100644 --- a/UI/Controls/SortList/SortListCtrl.cpp +++ b/UI/Controls/SortList/SortListCtrl.cpp @@ -342,8 +342,8 @@ namespace controls::sortlistctrl if (!lpData2) return sort1First; // sort null items to the end - this makes lParam1>lParam2 // Don't sort items which aren't fully loaded - if (!lpData1->bItemFullyLoaded) return sort2First; - if (!lpData2->bItemFullyLoaded) return sort1First; + if (!lpData1->getFullyLoaded()) return sort2First; + if (!lpData2->getFullyLoaded()) return sort1First; switch (lpSortInfo->sortstyle) { @@ -480,13 +480,13 @@ namespace controls::sortlistctrl auto lpData = reinterpret_cast(GetItemData(i)); if (lpData) { + auto row = lpData->getRow(); lpData->clearSortValues(); - if (ulSourceCol < lpData->cSourceProps && - PROP_TYPE(lpData->lpSourceProps[ulSourceCol].ulPropTag) == PT_SYSTIME) + if (ulSourceCol < row.cValues && PROP_TYPE(row.lpProps[ulSourceCol].ulPropTag) == PT_SYSTIME) { lpData->setSortValue( - {lpData->lpSourceProps[ulSourceCol].Value.ft.dwLowDateTime, - lpData->lpSourceProps[ulSourceCol].Value.ft.dwHighDateTime}); + {row.lpProps[ulSourceCol].Value.ft.dwLowDateTime, + row.lpProps[ulSourceCol].Value.ft.dwHighDateTime}); } } } diff --git a/UI/Controls/StyleTree/HierarchyTableTreeCtrl.cpp b/UI/Controls/StyleTree/HierarchyTableTreeCtrl.cpp index f5143b9d9..ca17c575e 100644 --- a/UI/Controls/StyleTree/HierarchyTableTreeCtrl.cpp +++ b/UI/Controls/StyleTree/HierarchyTableTreeCtrl.cpp @@ -347,8 +347,9 @@ namespace controls } LPCTSTR szName = nullptr; - if (PROP_TYPE(lpData->lpSourceProps[0].ulPropTag) == PT_TSTRING) - szName = lpData->lpSourceProps[0].Value.LPSZ; + auto row = lpData->getRow(); + if (row.cValues > 0 && PROP_TYPE(row.lpProps[0].ulPropTag) == PT_TSTRING) + szName = row.lpProps[0].Value.LPSZ; output::DebugPrintEx( output::dbgLevel::Hierarchy, CLASS, @@ -473,8 +474,7 @@ namespace controls auto lpMAPIContainer = GetContainer(hItem, modifyType::REQUEST_MODIFY); if (!lpMAPIContainer) return; - SPropValue sDisplayName; - sDisplayName.ulPropTag = PR_DISPLAY_NAME; + auto sDisplayName = SPropValue{PR_DISPLAY_NAME, 0}; sDisplayName.Value.LPSZ = szText; EC_MAPI_S(HrSetOneProp(lpMAPIContainer, &sDisplayName)); diff --git a/UI/Dialogs/ContentsTable/AclDlg.cpp b/UI/Dialogs/ContentsTable/AclDlg.cpp index 98914e563..e3d2b960e 100644 --- a/UI/Dialogs/ContentsTable/AclDlg.cpp +++ b/UI/Dialogs/ContentsTable/AclDlg.cpp @@ -141,8 +141,8 @@ namespace dialog const auto bin = MyData.GetBinary(0, false); lpNewItem->aEntries[0].rgPropVals[0].ulPropTag = PR_MEMBER_ENTRYID; - mapi::setBin(lpNewItem->aEntries[0].rgPropVals[0]) = {static_cast(bin.size()), - const_cast(bin.data())}; + mapi::setBin(lpNewItem->aEntries[0].rgPropVals[0]) = { + static_cast(bin.size()), const_cast(bin.data())}; lpNewItem->aEntries[0].rgPropVals[1].ulPropTag = PR_MEMBER_RIGHTS; lpNewItem->aEntries[0].rgPropVals[1].Value.ul = MyData.GetHex(1); @@ -219,13 +219,12 @@ namespace dialog mapi::allocate(2 * sizeof(SPropValue), lpTempList); lpTempList->aEntries[iArrayPos].cValues = 2; - auto lpSPropValue = - PpropFindProp(lpData->lpSourceProps, lpData->cSourceProps, PR_MEMBER_ID); + auto lpSPropValue = lpData->GetOneProp(PR_MEMBER_ID); lpTempList->aEntries[iArrayPos].rgPropVals[0].ulPropTag = lpSPropValue->ulPropTag; lpTempList->aEntries[iArrayPos].rgPropVals[0].Value = lpSPropValue->Value; - lpSPropValue = PpropFindProp(lpData->lpSourceProps, lpData->cSourceProps, PR_MEMBER_RIGHTS); + lpSPropValue = lpData->GetOneProp(PR_MEMBER_RIGHTS); lpTempList->aEntries[iArrayPos].rgPropVals[1].ulPropTag = lpSPropValue->ulPropTag; lpTempList->aEntries[iArrayPos].rgPropVals[1].Value = lpSPropValue->Value; @@ -233,8 +232,7 @@ namespace dialog else if (ulFlags & ACL_INCLUDE_ID) { lpTempList->aEntries[iArrayPos].cValues = 1; - lpTempList->aEntries[iArrayPos].rgPropVals = - PpropFindProp(lpData->lpSourceProps, lpData->cSourceProps, PR_MEMBER_ID); + lpTempList->aEntries[iArrayPos].rgPropVals = lpData->GetOneProp(PR_MEMBER_ID); } } } diff --git a/UI/Dialogs/ContentsTable/ContentsTableDlg.cpp b/UI/Dialogs/ContentsTable/ContentsTableDlg.cpp index 4139f7226..8b6870df6 100644 --- a/UI/Dialogs/ContentsTable/ContentsTableDlg.cpp +++ b/UI/Dialogs/ContentsTable/ContentsTableDlg.cpp @@ -575,8 +575,7 @@ namespace dialog // If we have a row to give, give it - it's free if (lpData) { - MyRow.cValues = lpData->cSourceProps; - MyRow.lpProps = lpData->lpSourceProps; + MyRow = lpData->getRow(); MyAddInMenuParams.lpRow = &MyRow; MyAddInMenuParams.ulCurrentFlags |= MENU_FLAGS_ROW; } diff --git a/UI/Dialogs/ContentsTable/FormContainerDlg.cpp b/UI/Dialogs/ContentsTable/FormContainerDlg.cpp index 0614fd235..6300e0d70 100644 --- a/UI/Dialogs/ContentsTable/FormContainerDlg.cpp +++ b/UI/Dialogs/ContentsTable/FormContainerDlg.cpp @@ -155,10 +155,8 @@ namespace dialog const auto lpListData = m_lpContentsTableListCtrl->GetSortListData(iSelectedItem); if (lpListData) { - const auto lpProp = PpropFindProp( - lpListData->lpSourceProps, - lpListData->cSourceProps, - PR_MESSAGE_CLASS_A); // ResolveMessageClass requires an ANSI string + const auto lpProp = + lpListData->GetOneProp(PR_MESSAGE_CLASS_A); // ResolveMessageClass requires an ANSI string if (strings::CheckStringProp(lpProp, PT_STRING8)) { const auto hRes = EC_MAPI( @@ -184,10 +182,7 @@ namespace dialog // Find the highlighted item AttachNum if (!lpListData) break; - const auto lpProp = PpropFindProp( - lpListData->lpSourceProps, - lpListData->cSourceProps, - PR_MESSAGE_CLASS_A); // RemoveForm requires an ANSI string + const auto lpProp = lpListData->GetOneProp(PR_MESSAGE_CLASS_A); // RemoveForm requires an ANSI string if (strings::CheckStringProp(lpProp, PT_STRING8)) { output::DebugPrintEx( diff --git a/UI/Dialogs/ContentsTable/MainDlg.cpp b/UI/Dialogs/ContentsTable/MainDlg.cpp index 9b42e5c22..4051d41eb 100644 --- a/UI/Dialogs/ContentsTable/MainDlg.cpp +++ b/UI/Dialogs/ContentsTable/MainDlg.cpp @@ -1503,9 +1503,9 @@ namespace dialog { SBinary serviceUID = {}; SBinary providerUID = {}; - auto lpProp = PpropFindProp(lpListData->lpSourceProps, lpListData->cSourceProps, PR_SERVICE_UID); + auto lpProp = lpListData->GetOneProp(PR_SERVICE_UID); if (lpProp && PT_BINARY == PROP_TYPE(lpProp->ulPropTag)) serviceUID = mapi::getBin(lpProp); - lpProp = PpropFindProp(lpListData->lpSourceProps, lpListData->cSourceProps, PR_MDB_PROVIDER); + lpProp = lpListData->GetOneProp(PR_MDB_PROVIDER); if (lpProp && PT_BINARY == PROP_TYPE(lpProp->ulPropTag)) providerUID = mapi::getBin(lpProp); MAPIUID emsmdbUID = {0}; diff --git a/UI/Dialogs/ContentsTable/RulesDlg.cpp b/UI/Dialogs/ContentsTable/RulesDlg.cpp index f423853c2..8338c7e0c 100644 --- a/UI/Dialogs/ContentsTable/RulesDlg.cpp +++ b/UI/Dialogs/ContentsTable/RulesDlg.cpp @@ -152,18 +152,19 @@ namespace dialog const auto lpData = m_lpContentsTableListCtrl->GetSortListData(iSelectedItem); if (lpData) { + auto row = lpData->getRow(); if (ulFlags & RULE_INCLUDE_ID && ulFlags & RULE_INCLUDE_OTHER) { lpTempList->aEntries[iArrayPos].rgPropVals = - mapi::allocate(lpData->cSourceProps * sizeof(SPropValue), lpTempList); + mapi::allocate(row.cValues * sizeof(SPropValue), lpTempList); if (lpTempList->aEntries[iArrayPos].rgPropVals) { ULONG ulDst = 0; - for (ULONG ulSrc = 0; ulSrc < lpData->cSourceProps; ulSrc++) + for (ULONG ulSrc = 0; ulSrc < row.cValues; ulSrc++) { - if (lpData->lpSourceProps[ulSrc].ulPropTag == PR_RULE_PROVIDER_DATA) + if (row.lpProps[ulSrc].ulPropTag == PR_RULE_PROVIDER_DATA) { - const auto bin = mapi::getBin(lpData->lpSourceProps[ulSrc]); + const auto bin = mapi::getBin(row.lpProps[ulSrc]); if (!bin.cb || !bin.lpb) { // PR_RULE_PROVIDER_DATA was NULL - we don't want this @@ -173,7 +174,7 @@ namespace dialog hRes = EC_H(mapi::MyPropCopyMore( &lpTempList->aEntries[iArrayPos].rgPropVals[ulDst], - &lpData->lpSourceProps[ulSrc], + &row.lpProps[ulSrc], MAPIAllocateMore, lpTempList)); ulDst++; @@ -185,8 +186,7 @@ namespace dialog else if (ulFlags & RULE_INCLUDE_ID) { lpTempList->aEntries[iArrayPos].cValues = 1; - lpTempList->aEntries[iArrayPos].rgPropVals = - PpropFindProp(lpData->lpSourceProps, lpData->cSourceProps, PR_RULE_ID); + lpTempList->aEntries[iArrayPos].rgPropVals = lpData->GetOneProp(PR_RULE_ID); } } } diff --git a/UI/Dialogs/Editors/MultiValuePropertyEditor.cpp b/UI/Dialogs/Editors/MultiValuePropertyEditor.cpp index c149dde9d..194d97942 100644 --- a/UI/Dialogs/Editors/MultiValuePropertyEditor.cpp +++ b/UI/Dialogs/Editors/MultiValuePropertyEditor.cpp @@ -124,7 +124,7 @@ namespace dialog::editor UpdateListRow(&sProp, iMVCount); - lpData->bItemFullyLoaded = true; + lpData->setFullyLoaded(true); } } } diff --git a/UI/Dialogs/Editors/QSSpecialFolders.cpp b/UI/Dialogs/Editors/QSSpecialFolders.cpp index 7229d80c2..b65a8e047 100644 --- a/UI/Dialogs/Editors/QSSpecialFolders.cpp +++ b/UI/Dialogs/Editors/QSSpecialFolders.cpp @@ -184,7 +184,7 @@ namespace dialog::editor } MAPIFreeBuffer(defaultEid); - lpData->bItemFullyLoaded = true; + lpData->setFullyLoaded(true); } } diff --git a/UI/Dialogs/Editors/RestrictEditor.cpp b/UI/Dialogs/Editors/RestrictEditor.cpp index 39f437413..7839fbf66 100644 --- a/UI/Dialogs/Editors/RestrictEditor.cpp +++ b/UI/Dialogs/Editors/RestrictEditor.cpp @@ -1319,7 +1319,7 @@ namespace dialog::editor SetListString(ulListNum, iRow, 1, std::to_wstring(lpEntryList->lpbin[iRow].cb)); SetListString(ulListNum, iRow, 2, strings::BinToHexString(&lpEntryList->lpbin[iRow], false)); SetListString(ulListNum, iRow, 3, strings::BinToTextString(&lpEntryList->lpbin[iRow], true)); - if (lpData) lpData->bItemFullyLoaded = true; + if (lpData) lpData->setFullyLoaded(true); } } diff --git a/UI/Dialogs/HierarchyTable/HierarchyTableDlg.cpp b/UI/Dialogs/HierarchyTable/HierarchyTableDlg.cpp index 151640311..c841641b3 100644 --- a/UI/Dialogs/HierarchyTable/HierarchyTableDlg.cpp +++ b/UI/Dialogs/HierarchyTable/HierarchyTableDlg.cpp @@ -277,15 +277,12 @@ namespace dialog } else { - SRow MyRow = {0}; - // If we have a row to give, give it - it's free const auto lpData = m_lpHierarchyTableTreeCtrl.GetSelectedItemData(); if (lpData) { - MyRow.cValues = lpData->cSourceProps; - MyRow.lpProps = lpData->lpSourceProps; - MyAddInMenuParams.lpRow = &MyRow; + auto row = lpData->getRow(); + MyAddInMenuParams.lpRow = &row; MyAddInMenuParams.ulCurrentFlags |= MENU_FLAGS_ROW; } diff --git a/core/mapi/mapiFunctions.cpp b/core/mapi/mapiFunctions.cpp index e016bce7a..c94ed1ea4 100644 --- a/core/mapi/mapiFunctions.cpp +++ b/core/mapi/mapiFunctions.cpp @@ -2891,9 +2891,4 @@ namespace mapi return false; } - - LPSPropValue FindProp(const SPropValue* lpPropArray, ULONG cValues, ULONG ulPropTag) - { - return PpropFindProp(const_cast(lpPropArray), cValues, ulPropTag); - } } // namespace mapi \ No newline at end of file diff --git a/core/mapi/mapiFunctions.h b/core/mapi/mapiFunctions.h index 73119e505..8c7bc4eee 100644 --- a/core/mapi/mapiFunctions.h +++ b/core/mapi/mapiFunctions.h @@ -385,5 +385,18 @@ namespace mapi bool IsABObject(_In_opt_ LPMAPIPROP lpProp); bool IsABObject(ULONG ulProps, LPSPropValue lpProps) noexcept; - LPSPropValue FindProp(const SPropValue* lpPropArray, ULONG cValues, ULONG ulPropTag); + inline _Check_return_ LPSPropValue + FindProp(_In_ const SPropValue* lpPropArray, _In_ const ULONG cValues, _In_ const ULONG ulPropTag) + { + return PpropFindProp(const_cast(lpPropArray), cValues, ulPropTag); + } + + inline _Check_return_ HRESULT DupeProps( + _In_ const int cValues, + _In_ const SPropValue* lpPropArray, + _In_ const LPALLOCATEBUFFER lpAllocateBuffer, + _Out_ LPSPropValue* lppPropArray) + { + return ScDupPropset(cValues, const_cast(lpPropArray), lpAllocateBuffer, lppPropArray); + } } // namespace mapi \ No newline at end of file diff --git a/core/propertyBag/mapiPropPropertyBag.cpp b/core/propertyBag/mapiPropPropertyBag.cpp index 5948de166..d386274f1 100644 --- a/core/propertyBag/mapiPropPropertyBag.cpp +++ b/core/propertyBag/mapiPropPropertyBag.cpp @@ -69,10 +69,10 @@ namespace propertybag // The caller will assume the memory was allocated from them, so copy before handing it back if (hRes == MAPI_E_NOT_FOUND && m_lpListData) { - const auto lpProp = PpropFindProp(m_lpListData->lpSourceProps, m_lpListData->cSourceProps, ulPropTag); + const auto lpProp = m_lpListData->GetOneProp(ulPropTag); if (lpProp) { - hRes = WC_MAPI(ScDupPropset(1, lpProp, MAPIAllocateBuffer, &lpPropRet)); + hRes = WC_H(mapi::DupeProps(1, lpProp, MAPIAllocateBuffer, &lpPropRet)); } } @@ -94,7 +94,7 @@ namespace propertybag { // m_lpListData->lpSourceProps is the only data we might hand out that we didn't allocate // Don't delete it!!! - if (m_lpListData && m_lpListData->lpSourceProps == lpProp) return; + if (m_lpListData && m_lpListData->getRow().lpProps == lpProp) return; if (lpProp) MAPIFreeBuffer(lpProp); } @@ -170,12 +170,11 @@ namespace propertybag if (!m_bGetPropsSucceeded && m_lpListData) { - m_lpListData->cSourceProps; - m_lpListData->lpSourceProps; auto models = std::vector>{}; - for (ULONG i = 0; i < m_lpListData->cSourceProps; i++) + const auto row = m_lpListData->getRow(); + for (ULONG i = 0; i < row.cValues; i++) { - auto prop = m_lpListData->lpSourceProps[i]; + const auto prop = row.lpProps[i]; models.push_back(model::propToModel(&prop, prop.ulPropTag, m_lpProp, m_bIsAB)); } @@ -187,7 +186,7 @@ namespace propertybag _Check_return_ std::shared_ptr mapiPropPropertyBag::GetOneModel(_In_ ULONG ulPropTag) { auto lpPropVal = LPSPropValue{}; - auto hRes = WC_MAPI(mapi::HrGetOnePropEx(m_lpProp, ulPropTag, fMapiUnicode, &lpPropVal)); + const auto hRes = WC_MAPI(mapi::HrGetOnePropEx(m_lpProp, ulPropTag, fMapiUnicode, &lpPropVal)); if (SUCCEEDED(hRes) && lpPropVal) { const auto model = model::propToModel(lpPropVal, ulPropTag, m_lpProp, m_bIsAB); @@ -203,8 +202,7 @@ namespace propertybag // So we fetch it from there instead if (hRes == MAPI_E_NOT_FOUND && m_lpListData) { - lpPropVal = PpropFindProp(m_lpListData->lpSourceProps, m_lpListData->cSourceProps, ulPropTag); - return model::propToModel(lpPropVal, ulPropTag, m_lpProp, m_bIsAB); + return model::propToModel(m_lpListData->GetOneProp(ulPropTag), ulPropTag, m_lpProp, m_bIsAB); } // If we still don't have a prop, build an error prop diff --git a/core/propertyBag/rowPropertyBag.cpp b/core/propertyBag/rowPropertyBag.cpp index c393fe002..12a8bb516 100644 --- a/core/propertyBag/rowPropertyBag.cpp +++ b/core/propertyBag/rowPropertyBag.cpp @@ -10,8 +10,9 @@ namespace propertybag { if (lpListData) { - m_cValues = lpListData->cSourceProps; - m_lpProps = lpListData->lpSourceProps; + auto row = lpListData->getRow(); + m_cValues = row.cValues; + m_lpProps = row.lpProps; } if (mapi::IsABObject(m_cValues, m_lpProps)) m_bIsAB = true; @@ -182,9 +183,7 @@ namespace propertybag const auto hRes = EC_H(ConcatLPSPropValue(1, lpProp, m_cValues, m_lpProps, &ulNewArray, &lpNewArray)); if (SUCCEEDED(hRes)) { - MAPIFreeBuffer(m_lpListData->lpSourceProps); - m_lpListData->cSourceProps = ulNewArray; - m_lpListData->lpSourceProps = lpNewArray; + m_lpListData->setRow(ulNewArray, lpNewArray); m_cValues = ulNewArray; m_lpProps = lpNewArray; diff --git a/core/sortlistdata/sortListData.h b/core/sortlistdata/sortListData.h index 4b50c5a5d..9f9343495 100644 --- a/core/sortlistdata/sortListData.h +++ b/core/sortlistdata/sortListData.h @@ -1,5 +1,6 @@ #pragma once #include +#include namespace sortlistdata { @@ -25,6 +26,17 @@ namespace sortlistdata template std::shared_ptr cast() noexcept { return std::dynamic_pointer_cast(lpData); } + _Check_return_ SRow getRow() { return {0, cSourceProps, lpSourceProps}; } + void setRow(_In_ ULONG cProps, _In_ SPropValue* lpProps) + { + MAPIFreeBuffer(lpSourceProps); + cSourceProps = cProps; + lpSourceProps = lpProps; + } + + _Check_return_ bool getFullyLoaded() noexcept { return bItemFullyLoaded; } + void setFullyLoaded(_In_ const bool _fullyLoaded) noexcept { bItemFullyLoaded = _fullyLoaded; } + const std::wstring& getSortText() const noexcept { return sortText; } void setSortText(const std::wstring& _sortText); const ULARGE_INTEGER& getSortValue() const noexcept { return sortValue; } @@ -35,14 +47,19 @@ namespace sortlistdata sortValue = {}; } - ULONG cSourceProps{}; - LPSPropValue - lpSourceProps{}; // Stolen from lpsRowData in sortListData::InitializeContents - free with MAPIFreeBuffer - bool bItemFullyLoaded{}; + _Check_return_ SPropValue* GetOneProp(const ULONG ulPropTag) + { + return mapi::FindProp(lpSourceProps, cSourceProps, ulPropTag); + } private: std::shared_ptr lpData{}; std::wstring sortText{}; ULARGE_INTEGER sortValue{}; + + ULONG cSourceProps{}; + LPSPropValue + lpSourceProps{}; // Stolen from lpsRowData in sortListData::InitializeContents - free with MAPIFreeBuffer + bool bItemFullyLoaded{}; }; } // namespace sortlistdata \ No newline at end of file From 5e3f9b1390d303bdcea3657a9eb20bba4c4c0d22 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Sat, 19 Dec 2020 22:24:51 -0500 Subject: [PATCH 2/8] hide more data --- UI/Dialogs/Editors/RestrictEditor.cpp | 43 +++++++-------------------- core/mapi/mapiFunctions.cpp | 5 +--- core/sortlistdata/binaryData.cpp | 15 ++++++++-- core/sortlistdata/binaryData.h | 15 ++++++++++ 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/UI/Dialogs/Editors/RestrictEditor.cpp b/UI/Dialogs/Editors/RestrictEditor.cpp index 7839fbf66..6ccb010b6 100644 --- a/UI/Dialogs/Editors/RestrictEditor.cpp +++ b/UI/Dialogs/Editors/RestrictEditor.cpp @@ -1359,15 +1359,7 @@ namespace dialog::editor CEditor BinEdit(this, IDS_EIDEDITOR, IDS_EIDEDITORPROMPT, CEDITOR_BUTTON_OK | CEDITOR_BUTTON_CANCEL); - auto lpSourcebin = LPSBinary{}; - if (binary->m_OldBin.lpb) - { - lpSourcebin = &binary->m_OldBin; - } - else - { - lpSourcebin = &binary->m_NewBin; - } + auto lpSourcebin = binary->getCurrentBin(); BinEdit.AddPane( viewpane::TextPane::CreateSingleLinePane(0, IDS_EID, strings::BinToHexString(lpSourcebin, false), false)); @@ -1375,14 +1367,16 @@ namespace dialog::editor if (BinEdit.DisplayDialog()) { auto bin = strings::HexStringToBin(BinEdit.GetStringW(0)); - binary->m_NewBin.lpb = mapi::ByteVectorToMAPI(bin, m_lpNewEntryList); - if (binary->m_NewBin.lpb) + auto newBin = SBinary{}; + newBin.lpb = mapi::ByteVectorToMAPI(bin, m_lpNewEntryList); + if (newBin.lpb) { - binary->m_NewBin.cb = static_cast(bin.size()); - const auto szTmp = std::to_wstring(binary->m_NewBin.cb); + newBin.cb = static_cast(bin.size()); + binary->setCurrentBin(newBin); + const auto szTmp = std::to_wstring(newBin.cb); SetListString(ulListNum, iItem, 1, szTmp); - SetListString(ulListNum, iItem, 2, strings::BinToHexString(&binary->m_NewBin, false)); - SetListString(ulListNum, iItem, 3, strings::BinToTextString(&binary->m_NewBin, true)); + SetListString(ulListNum, iItem, 2, strings::BinToHexString(&newBin, false)); + SetListString(ulListNum, iItem, 3, strings::BinToTextString(&newBin, true)); return true; } } @@ -1409,24 +1403,7 @@ namespace dialog::editor const auto binary = lpData->cast(); if (binary) { - if (binary->m_NewBin.lpb) - { - m_lpNewEntryList->lpbin[paneID].cb = binary->m_NewBin.cb; - m_lpNewEntryList->lpbin[paneID].lpb = binary->m_NewBin.lpb; - // clean out the source - binary->m_OldBin.lpb = nullptr; - } - else - { - m_lpNewEntryList->lpbin[paneID].cb = binary->m_OldBin.cb; - m_lpNewEntryList->lpbin[paneID].lpb = - mapi::allocate(m_lpNewEntryList->lpbin[paneID].cb, m_lpNewEntryList); - - memcpy( - m_lpNewEntryList->lpbin[paneID].lpb, - binary->m_OldBin.lpb, - m_lpNewEntryList->lpbin[paneID].cb); - } + m_lpNewEntryList->lpbin[paneID] = binary->detachBin(m_lpNewEntryList); } } } diff --git a/core/mapi/mapiFunctions.cpp b/core/mapi/mapiFunctions.cpp index c94ed1ea4..32398b27c 100644 --- a/core/mapi/mapiFunctions.cpp +++ b/core/mapi/mapiFunctions.cpp @@ -1917,10 +1917,7 @@ namespace mapi if (lpNewMessage) { - SPropValue sProp; - - sProp.dwAlignPad = 0; - sProp.ulPropTag = PR_DELETE_AFTER_SUBMIT; + auto sProp = SPropValue{PR_DELETE_AFTER_SUBMIT}; sProp.Value.b = true; output::DebugPrint(output::dbgLevel::Generic, L"Setting PR_DELETE_AFTER_SUBMIT to true.\n"); diff --git a/core/sortlistdata/binaryData.cpp b/core/sortlistdata/binaryData.cpp index feef6b447..6d4272b9e 100644 --- a/core/sortlistdata/binaryData.cpp +++ b/core/sortlistdata/binaryData.cpp @@ -14,8 +14,19 @@ namespace sortlistdata { if (lpOldBin) { - m_OldBin.cb = lpOldBin->cb; - m_OldBin.lpb = lpOldBin->lpb; + m_OldBin = *lpOldBin; + } + } + + _Check_return_ SBinary binaryData::detachBin(_In_opt_ const VOID* parent) + { + if (m_NewBin.lpb) + { + return m_NewBin; + } + else + { + return mapi::CopySBinary(m_OldBin, parent); } } } // namespace sortlistdata \ No newline at end of file diff --git a/core/sortlistdata/binaryData.h b/core/sortlistdata/binaryData.h index e8c6cce53..3d446aaa4 100644 --- a/core/sortlistdata/binaryData.h +++ b/core/sortlistdata/binaryData.h @@ -12,6 +12,21 @@ namespace sortlistdata binaryData(_In_opt_ LPSBinary lpOldBin) noexcept; + _Check_return_ inline LPSBinary getCurrentBin() + { + if (m_NewBin.lpb) + { + return &m_OldBin; + } + else + { + return &m_NewBin; + } + } + void setCurrentBin(_In_ const SBinary& bin) { m_NewBin = bin; } + _Check_return_ SBinary detachBin(_In_opt_ const VOID* parent); + + private: SBinary m_OldBin{}; // not allocated - just a pointer SBinary m_NewBin{}; // MAPIAllocateMore from m_lpNewEntryList }; From 65413254f4119588df367f597bd1897f1fd74ba1 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Sat, 19 Dec 2020 22:37:30 -0500 Subject: [PATCH 3/8] hide more data --- UI/Dialogs/Editors/RestrictEditor.cpp | 33 +++++++++------------------ core/sortlistdata/binaryData.h | 2 +- core/sortlistdata/commentData.h | 6 ++++- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/UI/Dialogs/Editors/RestrictEditor.cpp b/UI/Dialogs/Editors/RestrictEditor.cpp index 6ccb010b6..a46907a91 100644 --- a/UI/Dialogs/Editors/RestrictEditor.cpp +++ b/UI/Dialogs/Editors/RestrictEditor.cpp @@ -731,7 +731,7 @@ namespace dialog::editor const auto comment = lpData->cast(); if (!comment) return false; - auto lpSourceProp = comment->m_lpNewProp ? comment->m_lpNewProp : comment->m_lpOldProp; + auto lpSourceProp = comment->getCurrentProp(); auto sProp = SPropValue{}; @@ -746,17 +746,17 @@ namespace dialog::editor lpSourceProp = &sProp; } - comment->m_lpNewProp = + auto prop = DisplayPropertyEditor(this, IDS_PROPEDITOR, false, m_lpAllocParent, NULL, NULL, false, lpSourceProp); // Since lpData->data.Comment.lpNewProp was owned by an m_lpAllocParent, we don't free it directly - if (comment->m_lpNewProp) + if (prop) { + comment->setCurrentProp(prop); std::wstring szTmp; std::wstring szAltTmp; - SetListString( - ulListNum, iItem, 1, proptags::TagToString(comment->m_lpNewProp->ulPropTag, nullptr, false, true)); - property::parseProperty(comment->m_lpNewProp, &szTmp, &szAltTmp); + SetListString(ulListNum, iItem, 1, proptags::TagToString(prop->ulPropTag, nullptr, false, true)); + property::parseProperty(prop, &szTmp, &szAltTmp); SetListString(ulListNum, iItem, 2, szTmp); SetListString(ulListNum, iItem, 3, szAltTmp); return true; @@ -785,22 +785,11 @@ namespace dialog::editor const auto comment = lpData->cast(); if (comment) { - if (comment->m_lpNewProp) - { - EC_H_S(mapi::MyPropCopyMore( - &lpNewCommentProp[paneID], - comment->m_lpNewProp, - MAPIAllocateMore, - m_lpAllocParent)); - } - else - { - EC_H_S(mapi::MyPropCopyMore( - &lpNewCommentProp[paneID], - comment->m_lpOldProp, - MAPIAllocateMore, - m_lpAllocParent)); - } + EC_H_S(mapi::MyPropCopyMore( + &lpNewCommentProp[paneID], + comment->getCurrentProp(), + MAPIAllocateMore, + m_lpAllocParent)); } } } diff --git a/core/sortlistdata/binaryData.h b/core/sortlistdata/binaryData.h index 3d446aaa4..c370e3adb 100644 --- a/core/sortlistdata/binaryData.h +++ b/core/sortlistdata/binaryData.h @@ -12,7 +12,7 @@ namespace sortlistdata binaryData(_In_opt_ LPSBinary lpOldBin) noexcept; - _Check_return_ inline LPSBinary getCurrentBin() + _Check_return_ LPSBinary getCurrentBin() { if (m_NewBin.lpb) { diff --git a/core/sortlistdata/commentData.h b/core/sortlistdata/commentData.h index e2462d92d..91b61a8f7 100644 --- a/core/sortlistdata/commentData.h +++ b/core/sortlistdata/commentData.h @@ -12,7 +12,11 @@ namespace sortlistdata static void init(sortListData* data, _In_opt_ const _SPropValue* lpOldProp); - const _SPropValue* m_lpOldProp; // not allocated - just a pointer + _Check_return_ const SPropValue* getCurrentProp() { return m_lpNewProp ? m_lpNewProp : m_lpOldProp; } + void setCurrentProp(_In_ SPropValue* prop) { m_lpNewProp = prop; } + + private: + const SPropValue* m_lpOldProp; // not allocated - just a pointer LPSPropValue m_lpNewProp; // Owned by an alloc parent - do not free }; } // namespace sortlistdata \ No newline at end of file From f7b8b3efd1bda305b019868adc305d60f73e5781 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Sat, 19 Dec 2020 22:48:37 -0500 Subject: [PATCH 4/8] start hiding contents data --- UI/Controls/SortList/ContentsTableListCtrl.cpp | 15 +++------------ UI/Dialogs/ContentsTable/FolderDlg.cpp | 11 +++++------ UI/Dialogs/ContentsTable/MainDlg.cpp | 11 +++++------ UI/MyMAPIFormViewer.cpp | 2 +- core/sortlistdata/contentsData.h | 4 ++++ 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/UI/Controls/SortList/ContentsTableListCtrl.cpp b/UI/Controls/SortList/ContentsTableListCtrl.cpp index 558d2d21a..2bbf86843 100644 --- a/UI/Controls/SortList/ContentsTableListCtrl.cpp +++ b/UI/Controls/SortList/ContentsTableListCtrl.cpp @@ -966,18 +966,9 @@ namespace controls::sortlistctrl if (lpData) { const auto contents = lpData->cast(); - if (contents && contents->m_lpEntryID) + if (contents && contents->getEntryID()) { - lpTempList->lpbin[iArrayPos].cb = contents->m_lpEntryID->cb; - lpTempList->lpbin[iArrayPos].lpb = - mapi::allocate(contents->m_lpEntryID->cb, lpTempList); - if (lpTempList->lpbin[iArrayPos].lpb) - { - CopyMemory( - lpTempList->lpbin[iArrayPos].lpb, - contents->m_lpEntryID->lpb, - contents->m_lpEntryID->cb); - } + lpTempList->lpbin[iArrayPos] = mapi::CopySBinary(*contents->getEntryID(), lpTempList); } } } @@ -1099,7 +1090,7 @@ namespace controls::sortlistctrl const auto contents = lpListData->cast(); if (!contents) return nullptr; - const auto lpEID = contents->m_lpEntryID; + const auto lpEID = contents->getEntryID(); if (!lpEID || lpEID->cb == 0) return nullptr; output::DebugPrint(output::dbgLevel::Generic, L"Item being opened:\n"); diff --git a/UI/Dialogs/ContentsTable/FolderDlg.cpp b/UI/Dialogs/ContentsTable/FolderDlg.cpp index 1031ccdf3..a7d16e383 100644 --- a/UI/Dialogs/ContentsTable/FolderDlg.cpp +++ b/UI/Dialogs/ContentsTable/FolderDlg.cpp @@ -1150,9 +1150,9 @@ namespace dialog const auto contents = lpData->cast(); if (!contents || !m_lpFolder) return MAPI_E_INVALID_PARAMETER; - if (contents->m_lpEntryID) + if (contents->getEntryID()) { - hRes = EC_H(mapi::ResendSingleMessage(m_lpFolder, contents->m_lpEntryID, m_hWnd)); + hRes = EC_H(mapi::ResendSingleMessage(m_lpFolder, contents->getEntryID(), m_hWnd)); } return hRes; @@ -1738,7 +1738,7 @@ namespace dialog ULONG ulMessageStatus = NULL; - const auto lpMessageEID = contents->m_lpEntryID; + const auto lpMessageEID = contents->getEntryID(); if (lpMessageEID) { const auto hRes = EC_MAPI(m_lpFolder->GetMessageStatus( @@ -1785,8 +1785,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - const auto lpMessageEID = contents->m_lpEntryID; - + const auto lpMessageEID = contents->getEntryID(); if (lpMessageEID) { ULONG ulOldStatus = NULL; @@ -1845,7 +1844,7 @@ namespace dialog if (!contents) return MAPI_E_INVALID_PARAMETER; auto lpMDB = m_lpMapiObjects->GetMDB(); // do not release - const auto lpMessageEID = contents->m_lpEntryID; + const auto lpMessageEID = contents->getEntryID(); if (lpMDB && lpMessageEID) { hRes = EC_MAPI(lpMDB->AbortSubmit(lpMessageEID->cb, reinterpret_cast(lpMessageEID->lpb), NULL)); diff --git a/UI/Dialogs/ContentsTable/MainDlg.cpp b/UI/Dialogs/ContentsTable/MainDlg.cpp index 4051d41eb..d8bcdc375 100644 --- a/UI/Dialogs/ContentsTable/MainDlg.cpp +++ b/UI/Dialogs/ContentsTable/MainDlg.cpp @@ -381,7 +381,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - const auto lpEntryID = contents->m_lpEntryID; + const auto lpEntryID = contents->getEntryID(); if (lpEntryID) { ULONG ulFlags = NULL; @@ -653,7 +653,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - const auto lpItemEID = contents->m_lpEntryID; + const auto lpItemEID = contents->getEntryID(); if (lpItemEID) { auto lpMDB = mapi::store::CallOpenMsgStore( @@ -686,7 +686,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - const auto lpItemEID = contents->m_lpEntryID; + const auto lpItemEID = contents->getEntryID(); if (lpItemEID) { auto lpMDB = mapi::store::CallOpenMsgStore( @@ -1187,7 +1187,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - const auto lpItemEID = contents->m_lpEntryID; + const auto lpItemEID = contents->getEntryID(); if (lpItemEID) { editor::CEditor MyData( @@ -1497,8 +1497,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - const auto lpItemEID = contents->m_lpEntryID; - + const auto lpItemEID = contents->getEntryID(); if (lpItemEID) { SBinary serviceUID = {}; diff --git a/UI/MyMAPIFormViewer.cpp b/UI/MyMAPIFormViewer.cpp index 41b23c048..375fabc9b 100644 --- a/UI/MyMAPIFormViewer.cpp +++ b/UI/MyMAPIFormViewer.cpp @@ -703,7 +703,7 @@ namespace mapi::mapiui const auto contents = lpData->cast(); if (contents) { - const auto lpEID = contents->m_lpEntryID; + const auto lpEID = contents->getEntryID(); if (lpEID) { *ppMessage = mapi::CallOpenEntry( diff --git a/core/sortlistdata/contentsData.h b/core/sortlistdata/contentsData.h index bb0fd78f8..6953e4403 100644 --- a/core/sortlistdata/contentsData.h +++ b/core/sortlistdata/contentsData.h @@ -13,7 +13,11 @@ namespace sortlistdata contentsData(_In_ LPSRow lpsRowData); ~contentsData(); + _Check_return_ LPSBinary getEntryID() { return m_lpEntryID; } + + private: LPSBinary m_lpEntryID{}; // Allocated with MAPIAllocateBuffer + public: LPSBinary m_lpLongtermID{}; // Allocated with MAPIAllocateBuffer LPSBinary m_lpInstanceKey{}; // Allocated with MAPIAllocateBuffer LPSBinary m_lpServiceUID{}; // Allocated with MAPIAllocateBuffer From c4bea24267b7213b553c7288d2bdb4db35ddad33 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Sat, 19 Dec 2020 23:50:23 -0500 Subject: [PATCH 5/8] hide more data --- .../SortList/ContentsTableListCtrl.cpp | 23 +++++---- UI/Dialogs/ContentsTable/AttachmentsDlg.cpp | 12 ++--- UI/Dialogs/ContentsTable/FolderDlg.cpp | 2 +- UI/Dialogs/ContentsTable/MailboxTableDlg.cpp | 4 +- .../ContentsTable/MsgServiceTableDlg.cpp | 10 ++-- UI/Dialogs/ContentsTable/ProfileListDlg.cpp | 50 +++++++++---------- UI/Dialogs/ContentsTable/ProviderTableDlg.cpp | 2 +- UI/Dialogs/ContentsTable/RecipientsDlg.cpp | 2 +- core/sortlistdata/contentsData.h | 14 +++++- 9 files changed, 64 insertions(+), 55 deletions(-) diff --git a/UI/Controls/SortList/ContentsTableListCtrl.cpp b/UI/Controls/SortList/ContentsTableListCtrl.cpp index 2bbf86843..71ef607b1 100644 --- a/UI/Controls/SortList/ContentsTableListCtrl.cpp +++ b/UI/Controls/SortList/ContentsTableListCtrl.cpp @@ -1347,7 +1347,7 @@ namespace controls::sortlistctrl // No lpData or wrong type of row - no work done if (!lpData) return S_FALSE; const auto contents = lpData->cast(); - if (!contents || contents->m_ulRowType == TBL_LEAF_ROW || contents->m_ulRowType == TBL_EMPTY_CATEGORY) + if (!contents || contents->getRowType() == TBL_LEAF_ROW || contents->getRowType() == TBL_EMPTY_CATEGORY) return S_FALSE; auto bDidWork = false; @@ -1355,19 +1355,20 @@ namespace controls::sortlistctrl lvItem.iItem = iItem; lvItem.iSubItem = 0; lvItem.mask = LVIF_IMAGE; - switch (contents->m_ulRowType) + switch (contents->getRowType()) { default: break; case TBL_COLLAPSED_CATEGORY: { - if (contents->m_lpInstanceKey) + if (contents->getInstanceKey()) { + auto instanceKey = contents->getInstanceKey(); LPSRowSet lpRowSet = nullptr; ULONG ulRowsAdded = 0; hRes = EC_MAPI(m_lpContentsTable->ExpandRow( - contents->m_lpInstanceKey->cb, contents->m_lpInstanceKey->lpb, 256, NULL, &lpRowSet, &ulRowsAdded)); + instanceKey->cb, instanceKey->lpb, 256, NULL, &lpRowSet, &ulRowsAdded)); if (hRes == S_OK && lpRowSet) { for (ULONG i = 0; i < lpRowSet->cRows; i++) @@ -1381,7 +1382,7 @@ namespace controls::sortlistctrl } FreeProws(lpRowSet); - contents->m_ulRowType = TBL_EXPANDED_CATEGORY; + contents->setRowType(TBL_EXPANDED_CATEGORY); lvItem.iImage = static_cast(sortIcon::nodeExpanded); bDidWork = true; } @@ -1389,12 +1390,12 @@ namespace controls::sortlistctrl break; case TBL_EXPANDED_CATEGORY: - if (contents->m_lpInstanceKey) + if (contents->getInstanceKey()) { + auto instanceKey = contents->getInstanceKey(); ULONG ulRowsRemoved = 0; - hRes = EC_MAPI(m_lpContentsTable->CollapseRow( - contents->m_lpInstanceKey->cb, contents->m_lpInstanceKey->lpb, NULL, &ulRowsRemoved)); + hRes = EC_MAPI(m_lpContentsTable->CollapseRow(instanceKey->cb, instanceKey->lpb, NULL, &ulRowsRemoved)); if (hRes == S_OK && ulRowsRemoved) { for (int i = iItem + ulRowsRemoved; i > iItem; i--) @@ -1406,7 +1407,7 @@ namespace controls::sortlistctrl } } - contents->m_ulRowType = TBL_COLLAPSED_CATEGORY; + contents->setRowType(TBL_COLLAPSED_CATEGORY); lvItem.iImage = static_cast(sortIcon::nodeCollapsed); bDidWork = true; } @@ -1422,7 +1423,7 @@ namespace controls::sortlistctrl const auto lpProp = lpData->GetOneProp(PR_ROW_TYPE); if (lpProp && PR_ROW_TYPE == lpProp->ulPropTag) { - lpProp->Value.l = contents->m_ulRowType; + lpProp->Value.l = contents->getRowType(); } auto sRowData = lpData->getRow(); @@ -1589,7 +1590,7 @@ namespace controls::sortlistctrl const auto contents = lpListData->cast(); if (contents) { - const auto lpCurInstance = contents->m_lpInstanceKey; + const auto lpCurInstance = contents->getInstanceKey(); if (lpCurInstance) { if (!memcmp(lpCurInstance->lpb, instance.lpb, instance.cb)) diff --git a/UI/Dialogs/ContentsTable/AttachmentsDlg.cpp b/UI/Dialogs/ContentsTable/AttachmentsDlg.cpp index f869d516e..8e3a2ff21 100644 --- a/UI/Dialogs/ContentsTable/AttachmentsDlg.cpp +++ b/UI/Dialogs/ContentsTable/AttachmentsDlg.cpp @@ -102,7 +102,7 @@ namespace dialog if (lpListData) { const auto contents = lpListData->cast(); - if (contents && ATTACH_EMBEDDED_MSG == contents->m_ulAttachMethod) + if (contents && contents->getAttachMethod() == ATTACH_EMBEDDED_MSG) { auto lpMessage = OpenEmbeddedMessage(); if (lpMessage) @@ -170,8 +170,8 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - const auto ulAttachNum = contents->m_ulAttachNum; - const auto ulAttachMethod = contents->m_ulAttachMethod; + const auto ulAttachNum = contents->getAttachNum(); + const auto ulAttachMethod = contents->getAttachMethod(); // Check for matching cached attachment to avoid reopen if (ulAttachNum != m_ulAttachNum || !m_lpAttach) @@ -226,7 +226,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - lpAttNumList.push_back(contents->m_ulAttachNum); + lpAttNumList.push_back(contents->getAttachNum()); } } } @@ -324,7 +324,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - attachnums.push_back(contents->m_ulAttachNum); + attachnums.push_back(contents->getAttachNum()); } } } @@ -390,7 +390,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - const auto ulAttachNum = contents->m_ulAttachNum; + const auto ulAttachNum = contents->getAttachNum(); EC_MAPI_S(m_lpMessage->OpenAttach( ulAttachNum, nullptr, MAPI_BEST_ACCESS, static_cast(&lpAttach))); diff --git a/UI/Dialogs/ContentsTable/FolderDlg.cpp b/UI/Dialogs/ContentsTable/FolderDlg.cpp index a7d16e383..d99ec6161 100644 --- a/UI/Dialogs/ContentsTable/FolderDlg.cpp +++ b/UI/Dialogs/ContentsTable/FolderDlg.cpp @@ -699,7 +699,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - const auto lpMessageEID = contents->m_lpLongtermID; + const auto lpMessageEID = contents->getLongTermID(); if (lpMessageEID) { LPMAPIPROP lpMAPIProp = nullptr; diff --git a/UI/Dialogs/ContentsTable/MailboxTableDlg.cpp b/UI/Dialogs/ContentsTable/MailboxTableDlg.cpp index 5925fcb00..9370a1447 100644 --- a/UI/Dialogs/ContentsTable/MailboxTableDlg.cpp +++ b/UI/Dialogs/ContentsTable/MailboxTableDlg.cpp @@ -95,13 +95,13 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - if (!contents->m_szDN.empty()) + if (!contents->getDN().empty()) { auto lpNewMDB = mapi::store::OpenOtherUsersMailbox( lpMAPISession, lpSourceMDB, m_lpszServerName, - contents->m_szDN, + contents->getDN(), strings::emptystring, ulFlags, false); diff --git a/UI/Dialogs/ContentsTable/MsgServiceTableDlg.cpp b/UI/Dialogs/ContentsTable/MsgServiceTableDlg.cpp index 91d6ceca6..52014b049 100644 --- a/UI/Dialogs/ContentsTable/MsgServiceTableDlg.cpp +++ b/UI/Dialogs/ContentsTable/MsgServiceTableDlg.cpp @@ -138,7 +138,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - const auto lpServiceUID = contents->m_lpServiceUID; + const auto lpServiceUID = contents->getServiceUID(); if (lpServiceUID) { EC_MAPI_S(m_lpServiceAdmin->AdminProviders( @@ -182,7 +182,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - const auto lpServiceUID = contents->m_lpServiceUID; + const auto lpServiceUID = contents->getServiceUID(); if (lpServiceUID) { EC_H_CANCEL_S(m_lpServiceAdmin->ConfigureMsgService( @@ -211,7 +211,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - const auto lpServiceUID = contents->m_lpServiceUID; + const auto lpServiceUID = contents->getServiceUID(); if (lpServiceUID) { lpProfSect = mapi::profile::OpenProfileSection(m_lpServiceAdmin, lpServiceUID); @@ -270,9 +270,9 @@ namespace dialog CLASS, L"OnDeleteSelectedItem", L"Deleting service from \"%hs\"\n", - contents->m_szProfileDisplayName.c_str()); + contents->getProfileDisplayName().c_str()); - const auto lpServiceUID = contents->m_lpServiceUID; + const auto lpServiceUID = contents->getServiceUID(); if (lpServiceUID) { WC_MAPI_S(m_lpServiceAdmin->DeleteMsgService(reinterpret_cast(lpServiceUID->lpb))); diff --git a/UI/Dialogs/ContentsTable/ProfileListDlg.cpp b/UI/Dialogs/ContentsTable/ProfileListDlg.cpp index bf97416ad..21adf5bb1 100644 --- a/UI/Dialogs/ContentsTable/ProfileListDlg.cpp +++ b/UI/Dialogs/ContentsTable/ProfileListDlg.cpp @@ -132,9 +132,9 @@ namespace dialog const auto contents = lpListData->cast(); if (!contents) break; - if (!contents->m_szProfileDisplayName.empty()) + if (!contents->getProfileDisplayName().empty()) { - new CMsgServiceTableDlg(m_lpParent, m_lpMapiObjects, contents->m_szProfileDisplayName); + new CMsgServiceTableDlg(m_lpParent, m_lpMapiObjects, contents->getProfileDisplayName()); } } } @@ -184,6 +184,7 @@ namespace dialog const auto contents = lpListData->cast(); if (!contents) break; + const auto displayName = contents->getProfileDisplayName(); output::DebugPrintEx( output::dbgLevel::Generic, CLASS, @@ -191,10 +192,10 @@ namespace dialog L"Adding Server \"%ws\" and Mailbox \"%ws\" to profile \"%ws\"\n", // STRING_OK szServer.c_str(), szMailbox.c_str(), - contents->m_szProfileDisplayName.c_str()); + displayName.c_str()); EC_H_S(mapi::profile::HrAddExchangeToProfile( - reinterpret_cast(m_hWnd), szServer, szMailbox, contents->m_szProfileDisplayName)); + reinterpret_cast(m_hWnd), szServer, szMailbox, displayName)); } } } @@ -228,6 +229,7 @@ namespace dialog auto szPath = MyFile.GetStringW(0); const auto bPasswordSet = MyFile.GetCheck(1); auto szPwd = MyFile.GetStringW(2); + const auto displayName = contents->getProfileDisplayName(); output::DebugPrintEx( output::dbgLevel::Generic, @@ -236,19 +238,14 @@ namespace dialog L"Adding PST \"%ws\" to profile \"%ws\", bUnicodePST = 0x%X\n, bPasswordSet = 0x%X, password = " L"\"%ws\"\n", szPath.c_str(), - contents->m_szProfileDisplayName.c_str(), + displayName.c_str(), bUnicodePST, bPasswordSet, szPwd.c_str()); CWaitCursor Wait; // Change the mouse to an hourglass while we work. EC_H_S(mapi::profile::HrAddPSTToProfile( - reinterpret_cast(m_hWnd), - bUnicodePST, - szPath, - contents->m_szProfileDisplayName, - bPasswordSet, - szPwd)); + reinterpret_cast(m_hWnd), bUnicodePST, szPath, displayName, bPasswordSet, szPwd)); } } } @@ -277,13 +274,14 @@ namespace dialog const auto contents = lpListData->cast(); if (!contents) break; + const auto displayName = contents->getProfileDisplayName(); output::DebugPrintEx( output::dbgLevel::Generic, CLASS, L"OnAddServiceToProfile", L"Adding service \"%ws\" to profile \"%ws\"\n", szService.c_str(), - contents->m_szProfileDisplayName.c_str()); + displayName.c_str()); EC_H_S(mapi::profile::HrAddServiceToProfile( szService, @@ -291,7 +289,7 @@ namespace dialog MyData.GetCheck(1) ? SERVICE_UI_ALWAYS : 0, 0, nullptr, - contents->m_szProfileDisplayName)); + displayName)); } } @@ -332,14 +330,15 @@ namespace dialog const auto contents = lpListData->cast(); if (!contents) break; + const auto displayName = contents->getProfileDisplayName(); output::DebugPrintEx( output::dbgLevel::DeleteSelectedItem, CLASS, L"OnDeleteSelectedItem", L"Deleting profile \"%ws\"\n", - contents->m_szProfileDisplayName.c_str()); + displayName.c_str()); - EC_H_S(mapi::profile::HrRemoveProfile(contents->m_szProfileDisplayName)); + EC_H_S(mapi::profile::HrRemoveProfile(displayName)); } OnRefreshView(); // Update the view since we don't have notifications here. @@ -359,12 +358,13 @@ namespace dialog const auto contents = lpListData->cast(); if (!contents) break; + const auto displayName = contents->getProfileDisplayName(); output::DebugPrintEx( output::dbgLevel::DeleteSelectedItem, CLASS, L"OnGetProfileServiceVersion", L"Getting profile service version for \"%ws\"\n", - contents->m_szProfileDisplayName.c_str()); + displayName.c_str()); ULONG ulServerVersion = 0; mapi::profile::EXCHANGE_STORE_VERSION_NUM storeVersion = {0}; @@ -372,11 +372,7 @@ namespace dialog auto bFoundServerFullVersion = false; WC_H_S(GetProfileServiceVersion( - contents->m_szProfileDisplayName, - &ulServerVersion, - &storeVersion, - &bFoundServerVersion, - &bFoundServerFullVersion)); + displayName, &ulServerVersion, &storeVersion, &bFoundServerVersion, &bFoundServerFullVersion)); editor::CEditor MyData( this, IDS_PROFILESERVERVERSIONTITLE, IDS_PROFILESERVERVERSIONPROMPT, CEDITOR_BUTTON_OK); @@ -441,14 +437,15 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { + const auto displayName = contents->getProfileDisplayName(); output::DebugPrintEx( output::dbgLevel::Generic, CLASS, L"OnSetDefaultProfile", L"Setting profile \"%ws\" as default\n", - contents->m_szProfileDisplayName.c_str()); + displayName.c_str()); - EC_H_S(mapi::profile::HrSetDefaultProfile(contents->m_szProfileDisplayName)); + EC_H_S(mapi::profile::HrSetDefaultProfile(displayName)); OnRefreshView(); // Update the view since we don't have notifications here. } @@ -484,7 +481,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - cache::CGlobalCache::getInstance().SetProfileToCopy(contents->m_szProfileDisplayName); + cache::CGlobalCache::getInstance().SetProfileToCopy(contents->getProfileDisplayName()); } } } @@ -529,15 +526,16 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { + const auto displayName = contents->getProfileDisplayName(); auto file = file::CFileDialogExW::SaveAs( L"xml", // STRING_OK - contents->m_szProfileDisplayName + L".xml", + displayName + L".xml", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, strings::loadstring(IDS_XMLFILES), this); if (!file.empty()) { - output::ExportProfile(contents->m_szProfileDisplayName, strings::emptystring, false, file); + output::ExportProfile(displayName, strings::emptystring, false, file); } } } diff --git a/UI/Dialogs/ContentsTable/ProviderTableDlg.cpp b/UI/Dialogs/ContentsTable/ProviderTableDlg.cpp index 5badeaf63..f43ee5f59 100644 --- a/UI/Dialogs/ContentsTable/ProviderTableDlg.cpp +++ b/UI/Dialogs/ContentsTable/ProviderTableDlg.cpp @@ -67,7 +67,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - const auto lpProviderUID = contents->m_lpProviderUID; + const auto lpProviderUID = contents->getProviderUID(); if (lpProviderUID) { lpProfSect = mapi::profile::OpenProfileSection(m_lpProviderAdmin, lpProviderUID); diff --git a/UI/Dialogs/ContentsTable/RecipientsDlg.cpp b/UI/Dialogs/ContentsTable/RecipientsDlg.cpp index 05a859ab4..2a938367b 100644 --- a/UI/Dialogs/ContentsTable/RecipientsDlg.cpp +++ b/UI/Dialogs/ContentsTable/RecipientsDlg.cpp @@ -131,7 +131,7 @@ namespace dialog const auto contents = lpListData->cast(); if (contents) { - lpProp->Value.l = contents->m_ulRowID; + lpProp->Value.l = contents->getRowID(); } else { diff --git a/core/sortlistdata/contentsData.h b/core/sortlistdata/contentsData.h index 6953e4403..2d01010fa 100644 --- a/core/sortlistdata/contentsData.h +++ b/core/sortlistdata/contentsData.h @@ -14,10 +14,20 @@ namespace sortlistdata ~contentsData(); _Check_return_ LPSBinary getEntryID() { return m_lpEntryID; } + _Check_return_ LPSBinary getLongTermID() { return m_lpLongtermID; } + _Check_return_ LPSBinary getInstanceKey() { return m_lpInstanceKey; } + _Check_return_ LPSBinary getServiceUID() { return m_lpServiceUID; } + _Check_return_ LPSBinary getProviderUID() { return m_lpProviderUID; } + _Check_return_ std::wstring getDN() { return m_szDN; } + _Check_return_ std::wstring getProfileDisplayName() { return m_szProfileDisplayName; } + _Check_return_ ULONG getAttachNum() { return m_ulAttachNum; } + _Check_return_ ULONG getAttachMethod() { return m_ulAttachMethod; } + _Check_return_ ULONG getRowID() { return m_ulRowID; } + _Check_return_ ULONG getRowType() { return m_ulRowType; } + void setRowType(ULONG rowType) { m_ulRowType = rowType; } private: LPSBinary m_lpEntryID{}; // Allocated with MAPIAllocateBuffer - public: LPSBinary m_lpLongtermID{}; // Allocated with MAPIAllocateBuffer LPSBinary m_lpInstanceKey{}; // Allocated with MAPIAllocateBuffer LPSBinary m_lpServiceUID{}; // Allocated with MAPIAllocateBuffer @@ -28,5 +38,5 @@ namespace sortlistdata ULONG m_ulAttachMethod{}; ULONG m_ulRowID{}; // for recipients ULONG m_ulRowType{}; // PR_ROW_TYPE - }; + }; // namespace sortlistdata } // namespace sortlistdata \ No newline at end of file From de751cae723852bad3c942f61437a60539391896 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Sat, 19 Dec 2020 23:56:47 -0500 Subject: [PATCH 6/8] hide more --- .../Editors/MultiValuePropertyEditor.cpp | 34 +++++++++---------- core/sortlistdata/mvPropData.h | 3 +- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/UI/Dialogs/Editors/MultiValuePropertyEditor.cpp b/UI/Dialogs/Editors/MultiValuePropertyEditor.cpp index 194d97942..2970313c8 100644 --- a/UI/Dialogs/Editors/MultiValuePropertyEditor.cpp +++ b/UI/Dialogs/Editors/MultiValuePropertyEditor.cpp @@ -119,7 +119,7 @@ namespace dialog::editor const auto mvprop = lpData->cast(); if (mvprop) { - sProp.Value = mvprop->m_val; + sProp.Value = mvprop->getVal(); } UpdateListRow(&sProp, iMVCount); @@ -233,45 +233,45 @@ namespace dialog::editor switch (PROP_TYPE(m_lpsOutputValue->ulPropTag)) { case PT_MV_I2: - m_lpsOutputValue->Value.MVi.lpi[iMVCount] = mvprop->m_val.i; + m_lpsOutputValue->Value.MVi.lpi[iMVCount] = mvprop->getVal().i; break; case PT_MV_LONG: - m_lpsOutputValue->Value.MVl.lpl[iMVCount] = mvprop->m_val.l; + m_lpsOutputValue->Value.MVl.lpl[iMVCount] = mvprop->getVal().l; break; case PT_MV_DOUBLE: - m_lpsOutputValue->Value.MVdbl.lpdbl[iMVCount] = mvprop->m_val.dbl; + m_lpsOutputValue->Value.MVdbl.lpdbl[iMVCount] = mvprop->getVal().dbl; break; case PT_MV_CURRENCY: - m_lpsOutputValue->Value.MVcur.lpcur[iMVCount] = mvprop->m_val.cur; + m_lpsOutputValue->Value.MVcur.lpcur[iMVCount] = mvprop->getVal().cur; break; case PT_MV_APPTIME: - m_lpsOutputValue->Value.MVat.lpat[iMVCount] = mvprop->m_val.at; + m_lpsOutputValue->Value.MVat.lpat[iMVCount] = mvprop->getVal().at; break; case PT_MV_SYSTIME: - m_lpsOutputValue->Value.MVft.lpft[iMVCount] = mvprop->m_val.ft; + m_lpsOutputValue->Value.MVft.lpft[iMVCount] = mvprop->getVal().ft; break; case PT_MV_I8: - m_lpsOutputValue->Value.MVli.lpli[iMVCount] = mvprop->m_val.li; + m_lpsOutputValue->Value.MVli.lpli[iMVCount] = mvprop->getVal().li; break; case PT_MV_R4: - m_lpsOutputValue->Value.MVflt.lpflt[iMVCount] = mvprop->m_val.flt; + m_lpsOutputValue->Value.MVflt.lpflt[iMVCount] = mvprop->getVal().flt; break; case PT_MV_STRING8: m_lpsOutputValue->Value.MVszA.lppszA[iMVCount] = - mapi::CopyStringA(mvprop->m_val.lpszA, m_lpAllocParent); + mapi::CopyStringA(mvprop->getVal().lpszA, m_lpAllocParent); break; case PT_MV_UNICODE: m_lpsOutputValue->Value.MVszW.lppszW[iMVCount] = - mapi::CopyStringW(mvprop->m_val.lpszW, m_lpAllocParent); + mapi::CopyStringW(mvprop->getVal().lpszW, m_lpAllocParent); break; case PT_MV_BINARY: m_lpsOutputValue->Value.MVbin.lpbin[iMVCount] = - mapi::CopySBinary(mvprop->m_val.bin, m_lpAllocParent); + mapi::CopySBinary(mvprop->getVal().bin, m_lpAllocParent); break; case PT_MV_CLSID: - if (mvprop->m_val.lpguid) + if (mvprop->getVal().lpguid) { - m_lpsOutputValue->Value.MVguid.lpguid[iMVCount] = *mvprop->m_val.lpguid; + m_lpsOutputValue->Value.MVguid.lpguid[iMVCount] = *mvprop->getVal().lpguid; } break; @@ -319,7 +319,7 @@ namespace dialog::editor SPropValue tmpPropVal = {}; // Strip off MV_FLAG since we're displaying only a row tmpPropVal.ulPropTag = m_ulPropTag & ~MV_FLAG; - tmpPropVal.Value = mvprop->m_val; + tmpPropVal.Value = mvprop->getVal(); const auto lpNewValue = DisplayPropertyEditor( this, @@ -371,7 +371,7 @@ namespace dialog::editor { const auto lpData = GetListRowData(0, i); const auto mvprop = lpData->cast(); - ret.push_back(mvprop ? mvprop->m_val.l : LONG{}); + ret.push_back(mvprop ? mvprop->getVal().l : LONG{}); } return ret; @@ -387,7 +387,7 @@ namespace dialog::editor { const auto lpData = GetListRowData(0, i); const auto mvprop = lpData->cast(); - const auto bin = mvprop ? mvprop->m_val.bin : SBinary{}; + const auto bin = mvprop ? mvprop->getVal().bin : SBinary{}; ret.push_back(std::vector(bin.lpb, bin.lpb + bin.cb)); } diff --git a/core/sortlistdata/mvPropData.h b/core/sortlistdata/mvPropData.h index e9030c4cf..065cfb47a 100644 --- a/core/sortlistdata/mvPropData.h +++ b/core/sortlistdata/mvPropData.h @@ -14,9 +14,10 @@ namespace sortlistdata mvPropData(_In_opt_ const _SPropValue* lpProp, ULONG iProp); mvPropData(_In_opt_ const _SPropValue* lpProp); - _PV m_val{}; + _Check_return_ _PV getVal() { return m_val; } private: + _PV m_val{}; std::string m_lpszA{}; std::wstring m_lpszW{}; std::vector m_lpBin{}; From 88c3055fd8459c543ed12292b42dacea3915f795 Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Sun, 20 Dec 2020 00:04:56 -0500 Subject: [PATCH 7/8] hide more --- UI/Controls/SortList/SingleMAPIPropListCtrl.cpp | 6 +++--- UI/Dialogs/Editors/PropertySelector.cpp | 2 +- UI/Dialogs/Editors/TagArrayEditor.cpp | 6 +++--- core/sortlistdata/propListData.h | 3 +++ 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/UI/Controls/SortList/SingleMAPIPropListCtrl.cpp b/UI/Controls/SortList/SingleMAPIPropListCtrl.cpp index 5593b12e9..e3f197eb5 100644 --- a/UI/Controls/SortList/SingleMAPIPropListCtrl.cpp +++ b/UI/Controls/SortList/SingleMAPIPropListCtrl.cpp @@ -292,8 +292,8 @@ namespace controls::sortlistctrl CLASS, L"GetSelectedPropTag", L"returning lpPropTag = 0x%X\n", - prop->m_ulPropTag); - return prop->m_ulPropTag; + prop->getPropTag()); + return prop->getPropTag(); } } } @@ -651,7 +651,7 @@ namespace controls::sortlistctrl const auto prop = lpListData->cast(); if (prop) { - ulPropType = PROP_TYPE(prop->m_ulPropTag); + ulPropType = PROP_TYPE(prop->getPropTag()); } } diff --git a/UI/Dialogs/Editors/PropertySelector.cpp b/UI/Dialogs/Editors/PropertySelector.cpp index 1a1f8c645..fe3caf5c2 100644 --- a/UI/Dialogs/Editors/PropertySelector.cpp +++ b/UI/Dialogs/Editors/PropertySelector.cpp @@ -71,7 +71,7 @@ namespace dialog::editor const auto prop = lpListData->cast(); if (prop) { - m_ulPropTag = prop->m_ulPropTag; + m_ulPropTag = prop->getPropTag(); } } diff --git a/UI/Dialogs/Editors/TagArrayEditor.cpp b/UI/Dialogs/Editors/TagArrayEditor.cpp index f6ad61475..62f24bbf9 100644 --- a/UI/Dialogs/Editors/TagArrayEditor.cpp +++ b/UI/Dialogs/Editors/TagArrayEditor.cpp @@ -90,7 +90,7 @@ namespace dialog::editor const auto prop = lpData->cast(); if (!prop) return false; - const auto ulOrigPropTag = prop->m_ulPropTag; + const auto ulOrigPropTag = prop->getPropTag(); CPropertyTagEditor MyPropertyTag( NULL, // title @@ -105,7 +105,7 @@ namespace dialog::editor if (ulNewPropTag != ulOrigPropTag) { - prop->m_ulPropTag = ulNewPropTag; + prop->setPropTag(ulNewPropTag); const auto namePropNames = cache::NameIDToStrings(ulNewPropTag, m_lpMAPIProp, nullptr, nullptr, m_bIsAB); @@ -185,7 +185,7 @@ namespace dialog::editor const auto prop = lpData->cast(); if (prop) { - mapi::setTag(m_lpOutputTagArray, iTagCount) = prop->m_ulPropTag; + mapi::setTag(m_lpOutputTagArray, iTagCount) = prop->getPropTag(); } } } diff --git a/core/sortlistdata/propListData.h b/core/sortlistdata/propListData.h index f9a01f9b9..d3c973d99 100644 --- a/core/sortlistdata/propListData.h +++ b/core/sortlistdata/propListData.h @@ -11,7 +11,10 @@ namespace sortlistdata static void init(sortListData* data, _In_ ULONG ulPropTag); propListData(_In_ ULONG ulPropTag) noexcept; + _Check_return_ ULONG getPropTag() { return m_ulPropTag; } + void setPropTag(ULONG ulPropTag) { m_ulPropTag = ulPropTag; } + private: ULONG m_ulPropTag{}; }; } // namespace sortlistdata \ No newline at end of file From 37c98eba9d4ddc87d0593e5654d19f99fb0471bb Mon Sep 17 00:00:00 2001 From: Stephen Griffin Date: Sun, 20 Dec 2020 15:29:00 -0500 Subject: [PATCH 8/8] hide more data --- UI/Dialogs/Editors/RestrictEditor.cpp | 18 +++++------------- core/sortlistdata/binaryData.h | 4 ++-- core/sortlistdata/resData.cpp | 19 +++++++++++++++++++ core/sortlistdata/resData.h | 15 +++++++++++++++ 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/UI/Dialogs/Editors/RestrictEditor.cpp b/UI/Dialogs/Editors/RestrictEditor.cpp index a46907a91..c8c1e1f95 100644 --- a/UI/Dialogs/Editors/RestrictEditor.cpp +++ b/UI/Dialogs/Editors/RestrictEditor.cpp @@ -535,14 +535,15 @@ namespace dialog::editor const auto res = lpData->cast(); if (!res) return false; - const auto lpSourceRes = res->m_lpNewRes ? res->m_lpNewRes : res->m_lpOldRes; + const auto lpSourceRes = res->getCurrentRes(); CRestrictEditor MyResEditor(this, m_lpAllocParent, lpSourceRes); // pass source res into editor if (!MyResEditor.DisplayDialog()) return false; // Since lpData->data.Res.lpNewRes was owned by an m_lpAllocParent, we don't free it directly - res->m_lpNewRes = MyResEditor.DetachModifiedSRestriction(); - SetListString(ulListNum, iItem, 1, property::RestrictionToString(res->m_lpNewRes, nullptr)); + const auto newRes = MyResEditor.DetachModifiedSRestriction(); + res->setCurrentRes(newRes); + SetListString(ulListNum, iItem, 1, property::RestrictionToString(newRes, nullptr)); return true; } @@ -565,16 +566,7 @@ namespace dialog::editor const auto res = lpData->cast(); if (res) { - if (res->m_lpNewRes) - { - memcpy(&lpNewResArray[paneID], res->m_lpNewRes, sizeof(SRestriction)); - memset(res->m_lpNewRes, 0, sizeof(SRestriction)); - } - else - { - EC_H_S(mapi::HrCopyRestrictionArray( - res->m_lpOldRes, m_lpAllocParent, 1, &lpNewResArray[paneID])); - } + lpNewResArray[paneID] = res->detachRes(m_lpAllocParent); } } } diff --git a/core/sortlistdata/binaryData.h b/core/sortlistdata/binaryData.h index c370e3adb..96e848434 100644 --- a/core/sortlistdata/binaryData.h +++ b/core/sortlistdata/binaryData.h @@ -16,11 +16,11 @@ namespace sortlistdata { if (m_NewBin.lpb) { - return &m_OldBin; + return &m_NewBin; } else { - return &m_NewBin; + return &m_OldBin; } } void setCurrentBin(_In_ const SBinary& bin) { m_NewBin = bin; } diff --git a/core/sortlistdata/resData.cpp b/core/sortlistdata/resData.cpp index c09401d62..8bb3ef11f 100644 --- a/core/sortlistdata/resData.cpp +++ b/core/sortlistdata/resData.cpp @@ -1,6 +1,7 @@ #include #include #include +#include namespace sortlistdata { @@ -12,4 +13,22 @@ namespace sortlistdata } resData::resData(_In_opt_ const _SRestriction* lpOldRes) noexcept : m_lpOldRes(lpOldRes) {} + + _Check_return_ _SRestriction resData::detachRes(_In_opt_ const VOID* parent) + { + auto ret = _SRestriction{}; + if (m_lpNewRes) + { + memcpy(&ret, m_lpNewRes, sizeof(SRestriction)); + // clear out members so we don't double free + memset(m_lpNewRes, 0, sizeof(SRestriction)); + } + else + { + EC_H_S(mapi::HrCopyRestrictionArray(m_lpOldRes, parent, 1, &ret)); + } + + return ret; + } + } // namespace sortlistdata \ No newline at end of file diff --git a/core/sortlistdata/resData.h b/core/sortlistdata/resData.h index 5d55ad39a..900c8f1ee 100644 --- a/core/sortlistdata/resData.h +++ b/core/sortlistdata/resData.h @@ -12,6 +12,21 @@ namespace sortlistdata resData(_In_opt_ const _SRestriction* lpOldRes) noexcept; + _Check_return_ const _SRestriction* getCurrentRes() + { + if (m_lpNewRes) + { + return m_lpNewRes; + } + else + { + return m_lpOldRes; + } + } + void setCurrentRes(_In_ _SRestriction* res) { m_lpNewRes = res; } + _Check_return_ _SRestriction detachRes(_In_opt_ const VOID* parent); + + private: const _SRestriction* m_lpOldRes{}; // not allocated - just a pointer LPSRestriction m_lpNewRes{}; // Owned by an alloc parent - do not free };