Skip to content
Open
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
9 changes: 9 additions & 0 deletions TVAgentAPI/Library/export/TVAgentAPI/IAccessControlModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ class IAccessControlModule : public IModule
Denied = 2,
};

enum class ControlMode : int32_t
{
Disabled = 0,
ViewOnly = 1,
FullControl = 2,
};

using AccessChangedCallback = Callback<void(Feature feature, Access access, void* userdata) noexcept>;
using AccessConfirmationRequestCallback = Callback<void(Feature feature, void* userdata) noexcept>;

Expand Down Expand Up @@ -106,6 +113,8 @@ class IAccessControlModule : public IModule
* @return false on internal error, true otherwise.
*/
virtual bool rejectAccessRequest(Feature feature) = 0;

virtual bool setControlMode(ControlMode controlMode) = 0;
};

} // namespace tvagentapi
27 changes: 27 additions & 0 deletions TVAgentAPI/Library/internal/AccessControl/AccessControlModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ std::shared_ptr<IModule> CreateModule<IModule::Type::AccessControl>(

using Feature = IAccessControlModule::Feature;
using Access = IAccessControlModule::Access;
using ControlMode = IAccessControlModule::ControlMode;
using CommunicationFeature = TVRemoteScreenSDKCommunication::AccessControlService::AccessControl;
using CommunicationAccess = TVRemoteScreenSDKCommunication::AccessControlService::Access;
using CommunicationControlMode = TVRemoteScreenSDKCommunication::SessionControlService::ControlMode;

namespace
{
Expand Down Expand Up @@ -125,6 +127,18 @@ bool accessToCommunication(Access access, CommunicationAccess& outAccess)
return false;
}

CommunicationControlMode controlModeToCommunication (ControlMode mode)
{
switch (mode)
{
case ControlMode::Disabled: return CommunicationControlMode::Disable;
case ControlMode::ViewOnly: return CommunicationControlMode::ScreenSharing;
case ControlMode::FullControl: return CommunicationControlMode::FullControl;
}

return CommunicationControlMode::Unknown;
}

bool sendAccessConfirmationReply(Feature feature, bool isAllowed, const std::weak_ptr<AgentConnection>& weakConnection)
{
auto connection = weakConnection.lock();
Expand Down Expand Up @@ -277,4 +291,17 @@ bool AccessControlModule::rejectAccessRequest(Feature feature)
return sendAccessConfirmationReply(feature, false, m_connection);
}

bool AccessControlModule::setControlMode(ControlMode controlMode)
{
auto connection = m_connection.lock();
if (!connection)
{
return false;
}

auto communicationChannel = connection->getCommunicationChannel();
communicationChannel->sendControlMode(controlModeToCommunication(controlMode));
return true;
}

} // namespace tvagentapi
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class AccessControlModule final : public IAccessControlModule
bool acceptAccessRequest(Feature feature) override;
bool rejectAccessRequest(Feature feature) override;

bool setControlMode(ControlMode controlMode) override;

// IModule
bool isSupported() const override;

Expand Down