-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
285 additions
and
97 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/common/client/include/microsoft/net/remote/NetRemoteClient.hxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
#ifndef NET_REMOTE_CLIENT | ||
#define NET_REMOTE_CLIENT | ||
|
||
#include <string_view> | ||
|
||
namespace Microsoft::Net::Remote | ||
{ | ||
/** | ||
* @brief Identifiers for commands supported by the server. | ||
*/ | ||
enum class NetRemoteCommandId | ||
{ | ||
None, | ||
WifiEnumerateAcessPoints, | ||
}; | ||
} // namespace Microsoft::Net::Remote | ||
|
||
#endif // NET_REMOTE_CLIENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <format> | ||
|
||
#include <grpcpp/client_context.h> | ||
#include <magic_enum.hpp> | ||
#include <microsoft/net/remote/NetRemoteCliHandlerOperations.hxx> | ||
#include <microsoft/net/remote/protocol/NetRemoteService.grpc.pb.h> | ||
#include <plog/Log.h> | ||
|
||
using namespace Microsoft::Net::Remote; | ||
|
||
using namespace Microsoft::Net::Remote; | ||
using namespace Microsoft::Net::Remote::Service; | ||
using namespace Microsoft::Net::Remote::Wifi; | ||
|
||
NetRemoteCliHandlerOperations::NetRemoteCliHandlerOperations(std::shared_ptr<NetRemoteServerConnection> connection) : | ||
m_connection(std::move(connection)) | ||
{ | ||
} | ||
|
||
void | ||
NetRemoteCliHandlerOperations::WifiEnumerateAccessPoints() | ||
{ | ||
WifiEnumerateAccessPointsRequest request{}; | ||
WifiEnumerateAccessPointsResult result{}; | ||
grpc::ClientContext clientContext{}; | ||
|
||
auto status = m_connection->Client->WifiEnumerateAccessPoints(&clientContext, request, &result); | ||
if (!status.ok()) { | ||
LOGE << std::format("Failed to enumerate WiFi access points, error={} details={} message={}", magic_enum::enum_name(status.error_code()), status.error_details(), status.error_message()); | ||
return; | ||
} | ||
} | ||
|
||
std::unique_ptr<INetRemoteCliHandlerOperations> | ||
NetRemoteCliHandlerOperationsFactory::Create(std::shared_ptr<NetRemoteServerConnection> connection) | ||
{ | ||
return std::make_unique<NetRemoteCliHandlerOperations>(std::move(connection)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/common/tools/cli/include/microsoft/net/remote/NetRemoteCliHandlerOperations.hxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
#ifndef NET_REMOTE_CLI_HANDLER_OPERATIONS_HXX | ||
#define NET_REMOTE_CLI_HANDLER_OPERATIONS_HXX | ||
|
||
#include <memory> | ||
|
||
#include <microsoft/net/remote/INetRemoteCliHandlerOperations.hxx> | ||
#include <microsoft/net/remote/NetRemoteServerConnection.hxx> | ||
|
||
namespace Microsoft::Net::Remote | ||
{ | ||
/** | ||
* @brief Base implementation for handling CLI operations. This uses a remote server connection to carry out the | ||
* operations. | ||
*/ | ||
struct NetRemoteCliHandlerOperations : | ||
public INetRemoteCliHandlerOperations | ||
{ | ||
virtual ~NetRemoteCliHandlerOperations() = default; | ||
|
||
/** | ||
* @brief Construct a new NetRemoteCliHandlerOperations object with the specified server connection. | ||
* | ||
* @param connection The server connection to use to carry out operations. | ||
*/ | ||
NetRemoteCliHandlerOperations(std::shared_ptr<NetRemoteServerConnection> connection); | ||
|
||
/** | ||
* @brief Enumerate available WiFi access points. | ||
*/ | ||
virtual void | ||
WifiEnumerateAccessPoints() override; | ||
|
||
private: | ||
std::shared_ptr<NetRemoteServerConnection> m_connection; | ||
}; | ||
|
||
struct NetRemoteCliHandlerOperationsFactory : | ||
public INetRemoteCliHandlerOperationsFactory | ||
{ | ||
virtual ~NetRemoteCliHandlerOperationsFactory() = default; | ||
|
||
/** | ||
* @brief Create a new INetRemoteCliHandlerOperationsFactory instance with the specified server connection. | ||
* | ||
* @param connection The server connection the handler will use to carry out operations. | ||
* @return std::unique_ptr<INetRemoteCliHandlerOperations> | ||
*/ | ||
virtual std::unique_ptr<INetRemoteCliHandlerOperations> | ||
Create(std::shared_ptr<NetRemoteServerConnection> connection) override; | ||
}; | ||
} // namespace Microsoft::Net::Remote | ||
|
||
#endif // NET_REMOTE_CLI_HANDLER_OPERATIONS_HXX |
Oops, something went wrong.