From 2595d97fad5c72d8d3a0c26bb05d9d2b9cf7ce83 Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Fri, 19 Jul 2019 22:58:52 +0200 Subject: [PATCH] Use capabilities to enable presenter pointer --- src/org/kde/kdeconnect/Device.java | 10 +++++++++- .../Plugins/PresenterPlugin/PresenterPlugin.java | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/org/kde/kdeconnect/Device.java b/src/org/kde/kdeconnect/Device.java index 386e803d..5514f862 100644 --- a/src/org/kde/kdeconnect/Device.java +++ b/src/org/kde/kdeconnect/Device.java @@ -49,6 +49,7 @@ import java.security.spec.PKCS8EncodedKeySpec; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -86,6 +87,11 @@ public class Device implements BaseLink.PacketReceiver { private final SharedPreferences settings; private final CopyOnWriteArrayList pluginsChangedListeners = new CopyOnWriteArrayList<>(); + private Set incomingCapabilities = new HashSet<>(); + + public boolean supportsPacketType(String type) { + return incomingCapabilities.contains(type); + } public interface PluginsChangedListener { void onPluginsChanged(Device device); @@ -492,12 +498,14 @@ public class Device implements BaseLink.PacketReceiver { Set outgoingCapabilities = identityPacket.getStringSet("outgoingCapabilities", null); Set incomingCapabilities = identityPacket.getStringSet("incomingCapabilities", null); + + if (incomingCapabilities != null && outgoingCapabilities != null) { supportedPlugins = new Vector<>(PluginFactory.pluginsForCapabilities(incomingCapabilities, outgoingCapabilities)); } else { supportedPlugins = new Vector<>(PluginFactory.getAvailablePlugins()); } - + this.incomingCapabilities = incomingCapabilities; reloadPluginsFromSettings(); diff --git a/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java b/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java index 856f2ad7..74ff7c79 100644 --- a/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java +++ b/src/org/kde/kdeconnect/Plugins/PresenterPlugin/PresenterPlugin.java @@ -44,7 +44,7 @@ public class PresenterPlugin extends Plugin { private final static String PACKET_TYPE_MOUSEPAD_REQUEST = "kdeconnect.mousepad.request"; public boolean isPointerSupported() { - return true; //TODO: Check capabilities + return device.supportsPacketType(PACKET_TYPE_PRESENTER); } @Override