Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions msipackage/package.wix.in
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,6 @@
</RegistryKey>
</RegistryKey>

<!-- IWSLCComposeSession-->
<RegistryKey Root="HKCR" Key="Interface\{96DFF26B-422A-44F3-B675-23DA2BA32C77}">
<RegistryValue Value="IWSLCComposeSession" Type="string" />
<RegistryKey Key="ProxyStubClsid32">
<RegistryValue Value="{4EA0C6DD-E9FF-48E7-994E-13A31D10DC60}" Type="string" />
</RegistryKey>
</RegistryKey>

<!-- IComposeProgressCallback-->
<RegistryKey Root="HKCR" Key="Interface\{308809E7-2EB6-4A48-99D9-C959054FDDA9}">
<RegistryValue Value="IComposeProgressCallback" Type="string" />
Expand Down
16 changes: 0 additions & 16 deletions src/windows/service/inc/wslc.idl
Original file line number Diff line number Diff line change
Expand Up @@ -758,20 +758,6 @@ typedef struct _WSLCComposeOperationResult
ULONG AffectedContainersCount;
} WSLCComposeOperationResult;

[
uuid(96DFF26B-422A-44F3-B675-23DA2BA32C77),
pointer_default(unique),
object
]
interface IWSLCComposeSession : IUnknown
{
HRESULT GetConfigPath([out] LPWSTR* Path);
HRESULT ListContainers([out, size_is(, *Count)] WSLCContainerEntry** Containers, [out] ULONG* Count);
HRESULT Start();
HRESULT Attach();
HRESULT Stop([in] ULONG Timeout);
}

typedef struct _WSLCDeletedImageInformation
{
char Image[WSLC_MAX_IMAGE_NAME_LENGTH + 1];
Expand Down Expand Up @@ -1022,8 +1008,6 @@ interface IWSLCSession : IUnknown
// it (or the client exiting) lets the VM idle-terminate again.
HRESULT BeginContainerOperation([out] IUnknown** Operation);

HRESULT CreateComposeSession([in] LPCWSTR Path, [out] IWSLCComposeSession** ComposeSession);

// Executes synchronously, including callback delivery and cleanup. Request buffers remain valid until return.
// Envelope/transport failures fail the method; S_OK supplies a terminal result, whose Result carries the execution HRESULT.
// The caller frees Result->ErrorMessage and Result->AffectedContainers with CoTaskMemFree.
Expand Down
48 changes: 48 additions & 0 deletions src/windows/wslc/commands/ComposeAttachCommand.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*++

Copyright (c) Microsoft. All rights reserved.

Module Name:

ComposeAttachCommand.cpp

Abstract:

Implements the Compose attach command.

--*/

#include "precomp.h"
#include "ComposeCommand.h"
#include "ComposeTasks.h"
#include "SessionTasks.h"
#include "Task.h"

using namespace wsl::windows::wslc::task;
using namespace wsl::shared;

namespace wsl::windows::wslc {

std::vector<Argument> ComposeAttachCommand::GetArguments() const
{
return {
Argument::Create(ArgType::Path, {.Required = true, .Desc = Localization::WSLCCLI_ComposePathArgDescription()}),
};
}

std::wstring ComposeAttachCommand::ShortDescription() const
{
return Localization::WSLCCLI_ComposeAttachDesc();
}

std::wstring ComposeAttachCommand::LongDescription() const
{
return Localization::WSLCCLI_ComposeAttachLongDesc();
}

void ComposeAttachCommand::ExecuteInternal(CLIExecutionContext& context) const
{
context << ResolveSession << AttachCompose;
}

} // namespace wsl::windows::wslc
145 changes: 4 additions & 141 deletions src/windows/wslc/commands/ComposeCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,20 @@ Module Name:
--*/

#include "precomp.h"
#include "ArgumentConvertedTypes.h"
#include "ComposeCommand.h"
#include "ComposeService.h"
#include "SessionTasks.h"
#include "Task.h"

using namespace wsl::windows::wslc::services;
using namespace wsl::windows::wslc::task;
using namespace wsl::shared;

namespace wsl::windows::wslc {

namespace {

std::vector<Argument> ComposePathArguments(bool IncludeTimeout = false)
{
std::vector<Argument> arguments{
Argument::Create(ArgType::Path, {.Required = true, .Desc = Localization::WSLCCLI_ComposePathArgDescription()}),
};
if (IncludeTimeout)
{
arguments.emplace_back(Argument::Create(ArgType::Time));
}

return arguments;
}

models::Session& ResolveComposeSession(CLIExecutionContext& Context)
{
Context << ResolveSession;
return Context.Data.Get<Data::Session>();
}

std::wstring ComposePath(CLIExecutionContext& Context)
{
return std::filesystem::absolute(Context.Args.GetValue<ArgType::Path>()).wstring();
}

} // namespace

std::vector<std::unique_ptr<Command>> ComposeCommand::CreateCommands() const
{
std::vector<std::unique_ptr<Command>> commands;
commands.push_back(std::make_unique<ComposeAttachCommand>(FullName()));
commands.push_back(std::make_unique<ComposeCreateCommand>(FullName()));
commands.push_back(std::make_unique<ComposeUpCommand>(FullName()));
commands.push_back(std::make_unique<ComposeStartCommand>(FullName()));
commands.push_back(std::make_unique<ComposeAttachCommand>(FullName()));
commands.push_back(std::make_unique<ComposeStopCommand>(FullName()));
commands.push_back(std::make_unique<ComposeUpCommand>(FullName()));
return commands;
}

Expand All @@ -74,112 +40,9 @@ std::wstring ComposeCommand::LongDescription() const
return Localization::WSLCCLI_ComposeCommandLongDesc();
}

void ComposeCommand::ExecuteInternal(CLIExecutionContext& Context) const
{
OutputHelp(Context.Terminal);
}

std::vector<Argument> ComposeCreateCommand::GetArguments() const
{
return ComposePathArguments();
}

std::wstring ComposeCreateCommand::ShortDescription() const
{
return Localization::WSLCCLI_ComposeCreateDesc();
}

std::wstring ComposeCreateCommand::LongDescription() const
{
return Localization::WSLCCLI_ComposeCreateLongDesc();
}

void ComposeCreateCommand::ExecuteInternal(CLIExecutionContext& Context) const
{
ComposeService::Create(ResolveComposeSession(Context), ComposePath(Context));
}

std::vector<Argument> ComposeUpCommand::GetArguments() const
{
return ComposePathArguments();
}

std::wstring ComposeUpCommand::ShortDescription() const
{
return Localization::WSLCCLI_ComposeUpDesc();
}

std::wstring ComposeUpCommand::LongDescription() const
{
return Localization::WSLCCLI_ComposeUpLongDesc();
}

void ComposeUpCommand::ExecuteInternal(CLIExecutionContext& Context) const
{
Context.ExitCode = ComposeService::Up(Context.Terminal, ResolveComposeSession(Context), ComposePath(Context));
}

std::vector<Argument> ComposeStartCommand::GetArguments() const
{
return ComposePathArguments();
}

std::wstring ComposeStartCommand::ShortDescription() const
{
return Localization::WSLCCLI_ComposeStartDesc();
}

std::wstring ComposeStartCommand::LongDescription() const
{
return Localization::WSLCCLI_ComposeStartLongDesc();
}

void ComposeStartCommand::ExecuteInternal(CLIExecutionContext& Context) const
{
ComposeService::Start(ResolveComposeSession(Context), ComposePath(Context));
}

std::vector<Argument> ComposeAttachCommand::GetArguments() const
{
return ComposePathArguments();
}

std::wstring ComposeAttachCommand::ShortDescription() const
{
return Localization::WSLCCLI_ComposeAttachDesc();
}

std::wstring ComposeAttachCommand::LongDescription() const
{
return Localization::WSLCCLI_ComposeAttachLongDesc();
}

void ComposeAttachCommand::ExecuteInternal(CLIExecutionContext& Context) const
{
Context.ExitCode = ComposeService::Attach(Context.Terminal, ResolveComposeSession(Context), ComposePath(Context));
}

std::vector<Argument> ComposeStopCommand::GetArguments() const
{
return ComposePathArguments(true);
}

std::wstring ComposeStopCommand::ShortDescription() const
{
return Localization::WSLCCLI_ComposeStopDesc();
}

std::wstring ComposeStopCommand::LongDescription() const
{
return Localization::WSLCCLI_ComposeStopLongDesc();
}

void ComposeStopCommand::ExecuteInternal(CLIExecutionContext& Context) const
void ComposeCommand::ExecuteInternal(CLIExecutionContext& context) const
{
constexpr LONG c_defaultTimeout = 10;
const LONG timeout = Context.Args.Contains(ArgType::Time) ? Context.Args.GetValue<ArgType::Time>() : c_defaultTimeout;
THROW_HR_IF(E_INVALIDARG, timeout < 0);
ComposeService::Stop(ResolveComposeSession(Context), ComposePath(Context), static_cast<ULONG>(timeout));
OutputHelp(context.Terminal);
}

} // namespace wsl::windows::wslc
40 changes: 20 additions & 20 deletions src/windows/wslc/commands/ComposeCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace wsl::windows::wslc {
struct ComposeCommand final : public Command
{
constexpr static std::wstring_view CommandName = L"compose";
ComposeCommand(const std::wstring& Parent) : Command(CommandName, Parent)
ComposeCommand(const std::wstring& parent) : Command(CommandName, parent)
{
}

Expand All @@ -30,13 +30,13 @@ struct ComposeCommand final : public Command

protected:
std::vector<std::unique_ptr<Command>> CreateCommands() const override;
void ExecuteInternal(CLIExecutionContext& Context) const override;
void ExecuteInternal(CLIExecutionContext& context) const override;
};

struct ComposeCreateCommand final : public Command
struct ComposeAttachCommand final : public Command
{
constexpr static std::wstring_view CommandName = L"create";
ComposeCreateCommand(const std::wstring& Parent) : Command(CommandName, Parent)
constexpr static std::wstring_view CommandName = L"attach";
ComposeAttachCommand(const std::wstring& parent) : Command(CommandName, parent)
{
}

Expand All @@ -45,13 +45,13 @@ struct ComposeCreateCommand final : public Command
std::wstring LongDescription() const override;

protected:
void ExecuteInternal(CLIExecutionContext& Context) const override;
void ExecuteInternal(CLIExecutionContext& context) const override;
};

struct ComposeUpCommand final : public Command
struct ComposeCreateCommand final : public Command
{
constexpr static std::wstring_view CommandName = L"up";
ComposeUpCommand(const std::wstring& Parent) : Command(CommandName, Parent)
constexpr static std::wstring_view CommandName = L"create";
ComposeCreateCommand(const std::wstring& parent) : Command(CommandName, parent)
{
}

Expand All @@ -60,13 +60,13 @@ struct ComposeUpCommand final : public Command
std::wstring LongDescription() const override;

protected:
void ExecuteInternal(CLIExecutionContext& Context) const override;
void ExecuteInternal(CLIExecutionContext& context) const override;
};

struct ComposeStartCommand final : public Command
{
constexpr static std::wstring_view CommandName = L"start";
ComposeStartCommand(const std::wstring& Parent) : Command(CommandName, Parent)
ComposeStartCommand(const std::wstring& parent) : Command(CommandName, parent)
{
}

Expand All @@ -75,13 +75,13 @@ struct ComposeStartCommand final : public Command
std::wstring LongDescription() const override;

protected:
void ExecuteInternal(CLIExecutionContext& Context) const override;
void ExecuteInternal(CLIExecutionContext& context) const override;
};

struct ComposeAttachCommand final : public Command
struct ComposeStopCommand final : public Command
{
constexpr static std::wstring_view CommandName = L"attach";
ComposeAttachCommand(const std::wstring& Parent) : Command(CommandName, Parent)
constexpr static std::wstring_view CommandName = L"stop";
ComposeStopCommand(const std::wstring& parent) : Command(CommandName, parent)
{
}

Expand All @@ -90,13 +90,13 @@ struct ComposeAttachCommand final : public Command
std::wstring LongDescription() const override;

protected:
void ExecuteInternal(CLIExecutionContext& Context) const override;
void ExecuteInternal(CLIExecutionContext& context) const override;
};

struct ComposeStopCommand final : public Command
struct ComposeUpCommand final : public Command
{
constexpr static std::wstring_view CommandName = L"stop";
ComposeStopCommand(const std::wstring& Parent) : Command(CommandName, Parent)
constexpr static std::wstring_view CommandName = L"up";
ComposeUpCommand(const std::wstring& parent) : Command(CommandName, parent)
{
}

Expand All @@ -105,7 +105,7 @@ struct ComposeStopCommand final : public Command
std::wstring LongDescription() const override;

protected:
void ExecuteInternal(CLIExecutionContext& Context) const override;
void ExecuteInternal(CLIExecutionContext& context) const override;
};

} // namespace wsl::windows::wslc
Loading
Loading