Skip to content

Commit

Permalink
Merge pull request #551 from stephenegriffin/clang
Browse files Browse the repository at this point in the history
Create clang.yml
  • Loading branch information
stephenegriffin committed Aug 4, 2022
2 parents 64dd3a5 + b01ff56 commit 349e565
Show file tree
Hide file tree
Showing 35 changed files with 175 additions and 130 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/clang.yml
@@ -0,0 +1,22 @@
name: Clang-format

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

workflow_dispatch:

jobs:
check-formatting:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3

- name: clang-format (w/ diff)
uses: egor-tensin/clang-format@v1
with:
# :-separated list of excluded files and directories
exclude: include:mapistub
4 changes: 0 additions & 4 deletions Deploy/clang.bat

This file was deleted.

6 changes: 4 additions & 2 deletions MrMapi/MMContents.cpp
Expand Up @@ -25,10 +25,12 @@ void DumpContentsTable(
output::DebugPrint(output::dbgLevel::Generic, L"DumpContentsTable: Outputting Contents\n");
if (cli::switchAssociatedContents.isSet())
output::DebugPrint(output::dbgLevel::Generic, L"DumpContentsTable: Outputting Associated Contents\n");
if (cli::switchMSG.isSet()) output::DebugPrint(output::dbgLevel::Generic, L"DumpContentsTable: Outputting as MSG\n");
if (cli::switchMSG.isSet())
output::DebugPrint(output::dbgLevel::Generic, L"DumpContentsTable: Outputting as MSG\n");
if (cli::switchMoreProperties.isSet())
output::DebugPrint(output::dbgLevel::Generic, L"DumpContentsTable: Will retry stream properties\n");
if (cli::switchSkip.isSet()) output::DebugPrint(output::dbgLevel::Generic, L"DumpContentsTable: Will skip attachments\n");
if (cli::switchSkip.isSet())
output::DebugPrint(output::dbgLevel::Generic, L"DumpContentsTable: Will skip attachments\n");
if (cli::switchList.isSet()) output::DebugPrint(output::dbgLevel::Generic, L"DumpContentsTable: List only mode\n");
if (ulCount)
output::DebugPrint(output::dbgLevel::Generic, L"DumpContentsTable: Limiting output to %u messages.\n", ulCount);
Expand Down
6 changes: 5 additions & 1 deletion MrMapi/mmcli.cpp
Expand Up @@ -264,7 +264,11 @@ namespace cli
switchSearchState.name(),
switchFolder.name(),
switchProfile.name());
wprintf(L" MrMAPI -%ws [-%ws <profile>] [-%ws <path to output file>]\n", switchNamedProps.name(), switchProfile.name(), switchOutput.name());
wprintf(
L" MrMAPI -%ws [-%ws <profile>] [-%ws <path to output file>]\n",
switchNamedProps.name(),
switchProfile.name(),
switchOutput.name());
wprintf(
L" MrMAPI -%ws [-%ws] [-%ws <profile>]\n",
switchAccounts.name(),
Expand Down
3 changes: 1 addition & 2 deletions UI/Controls/SortList/ContentsTableListCtrl.h
Expand Up @@ -41,8 +41,7 @@ namespace controls::sortlistctrl

// Selected item accessors
_Check_return_ void CopyRows() const;
_Check_return_ LPENTRYLIST
GetSelectedItemEIDs() const;
_Check_return_ LPENTRYLIST GetSelectedItemEIDs() const;
_Check_return_ sortlistdata::sortListData* GetSortListData(int iItem) const;
_Check_return_ LPMAPIPROP OpenNextSelectedItemProp(_Inout_opt_ int* iCurItem, modifyType bModify) const;
_Check_return_ std::vector<int> GetSelectedItemNums() const;
Expand Down
12 changes: 10 additions & 2 deletions UI/Controls/SortList/SingleMAPIPropListCtrl.cpp
Expand Up @@ -916,7 +916,7 @@ namespace controls::sortlistctrl
output::outputRestriction(output::dbgLevel::Generic, nullptr, lpResIn, lpPropBag->GetMAPIProp());
dialog::editor::RestrictEditor MyResEditor(
this,
m_lpMapiObjects,
m_lpMapiObjects,
nullptr, // No alloc parent - we must MAPIFreeBuffer the result
lpResIn);
if (MyResEditor.DisplayDialog())
Expand Down Expand Up @@ -1036,7 +1036,15 @@ namespace controls::sortlistctrl
if (PROP_TYPE(ulPropTag) == PT_UNSPECIFIED && lpEditProp) ulPropTag = lpEditProp->ulPropTag;

const auto propEditor = dialog::editor::DisplayPropertyEditor(
this, m_lpMapiObjects, IDS_PROPEDITOR, name, lpPropBag->IsAB(), lpSourceObj, ulPropTag, false, lpEditProp);
this,
m_lpMapiObjects,
IDS_PROPEDITOR,
name,
lpPropBag->IsAB(),
lpSourceObj,
ulPropTag,
false,
lpEditProp);
if (propEditor)
{
const auto lpModProp = propEditor->getValue();
Expand Down
3 changes: 1 addition & 2 deletions UI/Controls/SortList/SortHeader.cpp
Expand Up @@ -26,8 +26,7 @@ namespace controls::sortlistctrl

if (!SubclassWindow(pHeader->GetSafeHwnd()))
{
output::DebugPrint(
output::dbgLevel::UI, L"CSortHeader::Init Unable to subclass existing header!\n");
output::DebugPrint(output::dbgLevel::UI, L"CSortHeader::Init Unable to subclass existing header!\n");
return false;
}
m_hwndParent = hwndParent;
Expand Down
3 changes: 2 additions & 1 deletion UI/Dialogs/BaseDialog.cpp
Expand Up @@ -550,7 +550,8 @@ namespace dialog

if (m_lpFakeSplitter && m_lpFakeSplitter.m_hWnd)
{
hdwp = ui::DeferWindowPos(hdwp, m_lpFakeSplitter.m_hWnd, 0, 0, cx, iNewCY, L"CBaseDialog::OnSize::fakesplitter");
hdwp = ui::DeferWindowPos(
hdwp, m_lpFakeSplitter.m_hWnd, 0, 0, cx, iNewCY, L"CBaseDialog::OnSize::fakesplitter");
}

WC_B_S(EndDeferWindowPos(hdwp));
Expand Down
7 changes: 4 additions & 3 deletions UI/Dialogs/Editors/StreamEditor.cpp
Expand Up @@ -128,9 +128,10 @@ namespace dialog::editor
}

if (bEditPropAsRTF)
m_ulEditorType = m_bUseWrapEx && ulOutCodePage == CP_UNICODE && !(m_ulStreamFlags & MAPI_NATIVE_BODY_TYPE_RTF)
? EDITOR_RTF_UNICODE
: EDITOR_RTF;
m_ulEditorType =
m_bUseWrapEx && ulOutCodePage == CP_UNICODE && !(m_ulStreamFlags & MAPI_NATIVE_BODY_TYPE_RTF)
? EDITOR_RTF_UNICODE
: EDITOR_RTF;
else
{
switch (PROP_TYPE(m_ulPropTag))
Expand Down
2 changes: 1 addition & 1 deletion UI/Dialogs/Editors/restriction/ResAndOrEditor.cpp
Expand Up @@ -103,7 +103,7 @@ namespace dialog::editor
const auto lpSourceRes = res->getCurrentRes();

RestrictEditor MyResEditor(this, m_lpMapiObjects, m_lpAllocParent,
lpSourceRes); // pass source res into editor
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
const auto newRes = MyResEditor.DetachModifiedSRestriction();
Expand Down
2 changes: 1 addition & 1 deletion UI/Dialogs/Editors/restriction/ResCommentEditor.cpp
Expand Up @@ -111,7 +111,7 @@ namespace dialog::editor
const auto lpSourceRes = GetSourceRes();

RestrictEditor MyResEditor(this, m_lpMapiObjects, m_lpAllocParent,
lpSourceRes); // pass source res into editor
lpSourceRes); // pass source res into editor
if (!MyResEditor.DisplayDialog()) return;

// Since m_lpNewCommentRes was owned by an m_lpAllocParent, we don't free it directly
Expand Down
2 changes: 1 addition & 1 deletion UI/Dialogs/Editors/restriction/RestrictEditor.cpp
Expand Up @@ -238,7 +238,7 @@ namespace dialog::editor
HRESULT RestrictEditor::EditAndOr(const _SRestriction* lpSourceRes)
{
ResAndOrEditor MyResEditor(this, m_lpMapiObjects, lpSourceRes,
m_lpAllocParent); // pass source res into editor
m_lpAllocParent); // pass source res into editor
if (MyResEditor.DisplayDialog())
{
m_lpOutputRes->rt = lpSourceRes->rt;
Expand Down
4 changes: 2 additions & 2 deletions UI/MAPIFormFunctions.cpp
Expand Up @@ -123,8 +123,8 @@ namespace mapi::mapiui
EID,
NUM_COLS
};
static const SizedSPropTagArray(NUM_COLS, sptaShowForm) = {NUM_COLS,
{PR_MESSAGE_FLAGS, PR_MESSAGE_CLASS_A, PR_ENTRYID}};
static const SizedSPropTagArray(NUM_COLS, sptaShowForm) = {
NUM_COLS, {PR_MESSAGE_FLAGS, PR_MESSAGE_CLASS_A, PR_ENTRYID}};

if (!lpMessage || !lpMAPISession || !lpSourceFolder) return MAPI_E_INVALID_PARAMETER;

Expand Down
6 changes: 2 additions & 4 deletions UI/MySecInfo.cpp
Expand Up @@ -46,10 +46,8 @@ namespace mapi::mapiui

GENERIC_MAPPING gmFolders = {frightsReadAny, frightsEditOwned | frightsDeleteOwned, rightsNone, rightsAll};

GENERIC_MAPPING gmMessages = {msgrightsGenericRead,
msgrightsGenericWrite,
msgrightsGenericExecute,
msgrightsGenericAll};
GENERIC_MAPPING gmMessages =
{msgrightsGenericRead, msgrightsGenericWrite, msgrightsGenericExecute, msgrightsGenericAll};

CMySecInfo::CMySecInfo(_In_ const LPMAPIPROP lpMAPIProp, const ULONG ulPropTag)
{
Expand Down
13 changes: 7 additions & 6 deletions UI/file/exporter.cpp
Expand Up @@ -23,12 +23,13 @@ namespace file
dialog::editor::CEditor MyData(
pParentWnd, IDS_SAVEMESSAGETOFILE, IDS_SAVEMESSAGETOFILEPROMPT, CEDITOR_BUTTON_OK | CEDITOR_BUTTON_CANCEL);

UINT uidDropDown[] = {IDS_DDTEXTFILE,
IDS_DDMSGFILEANSI,
IDS_DDMSGFILEUNICODE,
IDS_DDEMLFILE,
IDS_DDEMLFILEUSINGICONVERTERSESSION,
IDS_DDTNEFFILE};
UINT uidDropDown[] = {
IDS_DDTEXTFILE,
IDS_DDMSGFILEANSI,
IDS_DDMSGFILEUNICODE,
IDS_DDEMLFILE,
IDS_DDEMLFILEUSINGICONVERTERSESSION,
IDS_DDTNEFFILE};
MyData.AddPane(
viewpane::DropDownPane::Create(0, IDS_FORMATTOSAVEMESSAGE, _countof(uidDropDown), uidDropDown, true));
if (bMultiSelect)
Expand Down
19 changes: 10 additions & 9 deletions UI/mapiui.cpp
Expand Up @@ -67,13 +67,14 @@ namespace ui::mapiui

const auto progress = hWnd ? mapi::mapiui::GetMAPIProgress(L"CopyTo", hWnd) : LPMAPIPROGRESS{};

return {true,
MyData.GetHex(1) | (progress ? MAPI_DIALOG : 0),
guid::StringToGUID(MyData.GetStringW(0)),
progress,
progress ? reinterpret_cast<ULONG_PTR>(hWnd) : NULL,
GetExcludedTags(lpTagArray, lpSource, bIsAB),
true};
return {
true,
MyData.GetHex(1) | (progress ? MAPI_DIALOG : 0),
guid::StringToGUID(MyData.GetStringW(0)),
progress,
progress ? reinterpret_cast<ULONG_PTR>(hWnd) : NULL,
GetExcludedTags(lpTagArray, lpSource, bIsAB),
true};
}

void ExportMessages(_In_ LPMAPIFOLDER lpFolder, HWND hWnd)
Expand Down Expand Up @@ -113,8 +114,8 @@ namespace ui::mapiui
fldNUM_COLS
};

static const SizedSPropTagArray(fldNUM_COLS, fldCols) = {fldNUM_COLS,
{PR_ENTRYID, PR_SUBJECT_W, PR_RECORD_KEY}};
static const SizedSPropTagArray(fldNUM_COLS, fldCols) = {
fldNUM_COLS, {PR_ENTRYID, PR_SUBJECT_W, PR_RECORD_KEY}};

hRes = WC_MAPI(lpTable->SetColumns(LPSPropTagArray(&fldCols), TBL_ASYNC));

Expand Down
3 changes: 2 additions & 1 deletion UnitTest/tests/flagtest.cpp
Expand Up @@ -38,7 +38,8 @@ namespace flagtest
unittest::AreEqualEx(
L"MAPI_SUBMITTED | 0x5", flags::InterpretFlags(PROP_ID(PR_RECIPIENT_TYPE), MAPI_SUBMITTED | 0x5));
unittest::AreEqualEx(
L"MAPI_SUBMITTED | 0x20000000 | 0x5", flags::InterpretFlags(PROP_ID(PR_RECIPIENT_TYPE), MAPI_SUBMITTED | 0x20000005));
L"MAPI_SUBMITTED | 0x20000000 | 0x5",
flags::InterpretFlags(PROP_ID(PR_RECIPIENT_TYPE), MAPI_SUBMITTED | 0x20000005));

// flagFLAG with no null
unittest::AreEqualEx(L"0x0", flags::InterpretFlags(PROP_ID(PR_SUBMIT_FLAGS), 0));
Expand Down
9 changes: 5 additions & 4 deletions core/interpret/sid.cpp
Expand Up @@ -114,8 +114,8 @@ namespace sid
if (cchSidName && sidNameBuf.back() == L'\0') sidNameBuf.pop_back();
if (cchSidDomain && sidDomainBuf.back() == L'\0') sidDomainBuf.pop_back();

return SidAccount{std::wstring(sidDomainBuf.begin(), sidDomainBuf.end()),
std::wstring(sidNameBuf.begin(), sidNameBuf.end())};
return SidAccount{
std::wstring(sidDomainBuf.begin(), sidDomainBuf.end()), std::wstring(sidNameBuf.begin(), sidNameBuf.end())};
}

_Check_return_ SidAccount LookupAccountSid(std::vector<BYTE> buf)
Expand Down Expand Up @@ -250,7 +250,8 @@ namespace sid
}
}

return SecurityDescriptor{strings::join(sdString, L"\r\n"),
flags::InterpretFlags(flagSecurityInfo, SECURITY_INFORMATION_OF(buf.data()))};
return SecurityDescriptor{
strings::join(sdString, L"\r\n"),
flags::InterpretFlags(flagSecurityInfo, SECURITY_INFORMATION_OF(buf.data()))};
}
} // namespace sid
11 changes: 3 additions & 8 deletions core/mapi/cache/namedPropCache.cpp
Expand Up @@ -269,18 +269,13 @@ namespace cache
return cache;
}

_Check_return_ std::shared_ptr<namedPropCacheEntry> namedPropCache::find(
const std::shared_ptr<cache::namedPropCacheEntry>& entry,
bool bMatchID,
bool bMatchName)
_Check_return_ std::shared_ptr<namedPropCacheEntry>
namedPropCache::find(const std::shared_ptr<cache::namedPropCacheEntry>& entry, bool bMatchID, bool bMatchName)
{
if (fIsSet(output::dbgLevel::NamedPropCache))
{
output::DebugPrint(
output::dbgLevel::NamedPropCache,
L"find: bMatchID=%d, bMatchName=%d\n",
bMatchID,
bMatchName);
output::dbgLevel::NamedPropCache, L"find: bMatchID=%d, bMatchName=%d\n", bMatchID, bMatchName);
entry->output();
}

Expand Down
4 changes: 2 additions & 2 deletions core/mapi/cache/namedPropCache.h
Expand Up @@ -11,15 +11,15 @@ namespace cache
_In_ LPMAPIPROP lpMAPIProp,
_In_opt_ LPSPropTagArray lpPropTags,
ULONG ulFlags,
std::vector<std::shared_ptr<namedPropCacheEntry>> &names);
std::vector<std::shared_ptr<namedPropCacheEntry>>& names);

// Returns a vector of tags for the input names
// Sourced directly from MAPI
_Check_return_ LPSPropTagArray
GetIDsFromNames(_In_ LPMAPIPROP lpMAPIProp, std::vector<MAPINAMEID> nameIDs, ULONG ulFlags);

template <typename TMapiObj>
inline HRESULT GetRootFolder(TMapiObj* pMapiObj, LPMAPIFOLDER *lppMAPIFolder) noexcept
inline HRESULT GetRootFolder(TMapiObj* pMapiObj, LPMAPIFOLDER* lppMAPIFolder) noexcept
{
ULONG objt = 0;
return pMapiObj->OpenEntry(
Expand Down

0 comments on commit 349e565

Please sign in to comment.