common: refactor common library pt2 (#8588)

- remove common lib
- split settings, remove common-md
- move ipc interop/kb_layout to interop
- rename core -> settings, settings -> old_settings
- os-detect header-only; interop -> PowerToysInterop
- split notifications, move single-use headers where they're used
- winstore lib
- rename com utils
- rename Updating and Telemetry projects
- rename core -> settings-ui and remove examples folder
- rename settings-ui folder + consisent common/version include
This commit is contained in:
Andrey Nekrasov
2020-12-15 15:16:09 +03:00
committed by GitHub
parent cddf48547d
commit 212ea2de30
588 changed files with 3304 additions and 3328 deletions

View File

@@ -0,0 +1,37 @@
#include "pch.h"
#include "RestartManagement.h"
#include <RestartManager.h>
#include <Psapi.h>
#include <common/utils/processApi.h>
void RestartProcess(const std::wstring& processName)
{
DWORD sessionHandle{};
WCHAR sessionKey[CCH_RM_SESSION_KEY + 1];
if (RmStartSession(&sessionHandle, 0, sessionKey) != ERROR_SUCCESS)
{
return;
}
auto processHandles = getProcessHandlesByName(processName, PROCESS_QUERY_INFORMATION);
std::vector<RM_UNIQUE_PROCESS> pInfo;
for (const auto& hProcess : processHandles)
{
FILETIME creationTime{};
FILETIME _{};
if (GetProcessTimes(hProcess.get(), &creationTime, &_, &_, &_))
{
pInfo.emplace_back(RM_UNIQUE_PROCESS{ GetProcessId(hProcess.get()), creationTime });
}
}
if (pInfo.empty() ||
RmRegisterResources(sessionHandle, 0, nullptr, sizeof(pInfo), pInfo.data(), 0, nullptr) != ERROR_SUCCESS)
{
return;
}
RmShutdown(sessionHandle, RmForceShutdown, nullptr);
RmRestart(sessionHandle, 0, nullptr);
RmEndSession(sessionHandle);
}

View File

@@ -0,0 +1,5 @@
#pragma once
#include <string>
void RestartProcess(const std::wstring& processName);

View File

@@ -2,8 +2,8 @@
#include "action_runner_utils.h"
#include <common/common.h>
#include <common/winstore.h>
#include <common/utils/process_path.h>
#include <common/winstore/winstore.h>
SHELLEXECUTEINFOW launch_action_runner(const wchar_t* cmdline)
{

View File

@@ -1,7 +1,7 @@
#include "pch.h"
#include "centralized_kb_hook.h"
#include <common/common.h>
#include <common/debug_control.h>
#include <common/utils/winapi_error.h>
namespace CentralizedKeyboardHook
{
@@ -11,11 +11,10 @@ namespace CentralizedKeyboardHook
std::wstring moduleName;
std::function<bool()> action;
bool operator<(const HotkeyDescriptor& other) const
bool operator<(const HotkeyDescriptor& other) const
{
return hotkey < other.hotkey;
};
};
std::multiset<HotkeyDescriptor> hotkeyDescriptors;

View File

@@ -3,21 +3,21 @@
#include "auto_start_helper.h"
#include "Generated files/resource.h"
#include <common/common.h>
#include <common/settings_helpers.h>
#include <common/SettingsAPI/settings_helpers.h>
#include "powertoy_module.h"
#include <common/windows_colors.h>
#include <common/winstore.h>
#include <common/themes/windows_colors.h>
#include <common/winstore/winstore.h>
#include "trace.h"
#include <common/utils/elevation.h>
#include <common/version/version.h>
#include <common/utils/resources.h>
// TODO: would be nice to get rid of these globals, since they're basically cached json settings
static std::wstring settings_theme = L"system";
static bool run_as_elevated = false;
static bool download_updates_automatically = true;
extern "C" IMAGE_DOS_HEADER __ImageBase;
json::JsonObject GeneralSettings::to_json()
{
json::JsonObject result;

View File

@@ -1,6 +1,6 @@
#pragma once
#include <common/json.h>
#include <common/utils/json.h>
struct GeneralSettings
{

View File

@@ -7,19 +7,20 @@
#include "trace.h"
#include "general_settings.h"
#include "restart_elevated.h"
#include "RestartManagement.h"
#include "Generated files/resource.h"
#include <common/appMutex.h>
#include <common/common.h>
#include <common/comUtils.h>
#include <common/dpi_aware.h>
#include <common/notifications.h>
#include <common/processApi.h>
#include <common/RestartManagement.h>
#include <common/toast_dont_show_again.h>
#include <common/comUtils/comUtils.h>
#include <common/display/dpi_aware.h>
#include <common/notifications/notifications.h>
#include <common/notifications/dont_show_again.h>
#include <common/updating/installer.h>
#include <common/updating/updating.h>
#include <common/winstore.h>
#include <common/utils/appMutex.h>
#include <common/utils/elevation.h>
#include <common/utils/processApi.h>
#include <common/utils/resources.h>
#include <common/winstore/winstore.h>
#include "update_state.h"
#include "update_utils.h"
@@ -34,10 +35,12 @@
#if _DEBUG && _WIN64
#include "unhandled_exception_handler.h"
#endif
#include <common/settings_helpers.h>
#include <common/SettingsAPI/settings_helpers.h>
#include <common/logger/logger.h>
#include <common/utils/winapi_error.h>
#include <common/version/version.h>
#include <common/utils/window.h>
extern "C" IMAGE_DOS_HEADER __ImageBase;
extern updating::notifications::strings Strings;
namespace

View File

@@ -30,4 +30,4 @@
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.Storage.h>
#include <wil/resource.h>
#include <wil/resource.h>

View File

@@ -6,7 +6,7 @@
#include <vector>
#include <functional>
#include <common/json.h>
#include <common/utils/json.h>
struct PowertoyModuleDeleter
{

View File

@@ -1,6 +1,7 @@
#include "pch.h"
#include "restart_elevated.h"
#include <common/common.h>
#include <common/utils/elevation.h>
enum State
{

Binary file not shown.

View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props')" />
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(SolutionDir)tools\build\convert-resx-to-rc.ps1 . resource.base.h resource.h runner.base.rc runner.rc" />
</Target>
@@ -45,8 +44,8 @@
<EnableDpiAwareness>false</EnableDpiAwareness>
</Manifest>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\common\interop\two_way_pipe_message_ipc.cpp" />
<ClCompile Include="action_runner_utils.cpp" />
<ClCompile Include="auto_start_helper.cpp" />
<ClCompile Include="general_settings.cpp" />
@@ -157,15 +156,27 @@
</CopyFileToFolders>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\common\common.vcxproj">
<Project>{74485049-c722-400f-abe5-86ac52d929b3}</Project>
<ProjectReference Include="..\common\COMUtils\COMUtils.vcxproj">
<Project>{7319089e-46d6-4400-bc65-e39bdf1416ee}</Project>
</ProjectReference>
<ProjectReference Include="..\common\Display\Display.vcxproj">
<Project>{caba8dfb-823b-4bf2-93ac-3f31984150d9}</Project>
</ProjectReference>
<ProjectReference Include="..\common\logger\logger.vcxproj">
<Project>{d9b8fc84-322a-4f9f-bbb9-20915c47ddfd}</Project>
</ProjectReference>
<ProjectReference Include="..\common\notifications\notifications.vcxproj">
<Project>{1d5be09d-78c0-4fd7-af00-ae7c1af7c525}</Project>
</ProjectReference>
<ProjectReference Include="..\common\Themes\Themes.vcxproj">
<Project>{98537082-0fdb-40de-abd8-0dc5a4269bab}</Project>
</ProjectReference>
<ProjectReference Include="..\common\updating\updating.vcxproj">
<Project>{17da04df-e393-4397-9cf0-84dabe11032e}</Project>
</ProjectReference>
<ProjectReference Include="..\common\WinStore\Winstore.vcxproj">
<Project>{c502a854-53ac-4ebb-8dc0-e4af2191e4f6}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View File

@@ -39,6 +39,9 @@
<ClCompile Include="centralized_kb_hook.cpp">
<Filter>Utils</Filter>
</ClCompile>
<ClCompile Include="..\common\interop\two_way_pipe_message_ipc.cpp">
<Filter>Utils</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
@@ -140,13 +143,12 @@
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="runner.base.rc" />
</ItemGroup>
<ItemGroup>
<Manifest Include="PowerToys.exe.manifest" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="runner.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
<ResourceCompile Include="Generated Files/runner.rc" />
</ItemGroup>
</Project>

View File

@@ -5,21 +5,23 @@
#include <aclapi.h>
#include "powertoy_module.h"
#include <common/two_way_pipe_message_ipc.h>
#include <common/interop/two_way_pipe_message_ipc.h>
#include "tray_icon.h"
#include "general_settings.h"
#include <common/windows_colors.h>
#include <common/common.h>
#include <common/themes/windows_colors.h>
#include "restart_elevated.h"
#include "update_utils.h"
#include "centralized_kb_hook.h"
#include <common/json.h>
#include <common/settings_helpers.cpp>
#include <common/os-detect.h>
#include <common/version.h>
#include <common/VersionHelper.h>
#include <common/utils/json.h>
#include <common/SettingsAPI/settings_helpers.cpp>
#include <common/version/version.h>
#include <common/version/helper.h>
#include <common/logger/logger.h>
#include <common/utils/elevation.h>
#include <common/utils/winapi_error.h>
#include <common/utils/process_path.h>
#include <common/utils/os-detect.h>
#define BUFSIZE 1024

View File

@@ -3,9 +3,9 @@
#include "settings_window.h"
#include "tray_icon.h"
#include <Windows.h>
#include <common/common.h>
extern "C" IMAGE_DOS_HEADER __ImageBase;
#include <common/utils/resources.h>
#include <common/version/version.h>
namespace
{

View File

@@ -1,9 +1,9 @@
#include "pch.h"
#include "update_state.h"
#include <common/json.h>
#include <common/timeutil.h>
#include <common/settings_helpers.h>
#include <common/utils/json.h>
#include <common/utils/timeutil.h>
#include <common/SettingsAPI/settings_helpers.h>
namespace
{

View File

@@ -1,20 +1,17 @@
#include "pch.h"
#include <common/common.h>
#include "Generated Files/resource.h"
#include "action_runner_utils.h"
#include "update_state.h"
#include "update_utils.h"
#include <common/timeutil.h>
#include <common/updating/installer.h>
#include <common/updating/updating.h>
#include <common/updating/notifications.h>
#include <common/utils/resources.h>
#include <common/utils/timeutil.h>
#include <runner/general_settings.h>
extern "C" IMAGE_DOS_HEADER __ImageBase;
auto Strings = create_notifications_strings();
bool start_msi_uninstallation_sequence()