From 86c0143219a843385df04b18c343c4b5d2d9fd29 Mon Sep 17 00:00:00 2001 From: Vincent Lucas Date: Wed, 9 May 2012 16:49:19 +0000 Subject: [PATCH] Synopsis: Corrects desktop sharing problem: sometimes not sending key and mouse event. Problem: The CallPeer grants remote control whereas the call user interface is not ready and has not registered its remote control listener yet. Correction: Adds a list of granted remote control peers for the AbstractOperationSetDesktopSharingClient. This list is used to remember granted peers, when the granted event occurs before the corresponding UI listener registration. Thus, when a new UI remote control listener is registered, a new remote control granted event is fired to this new listener for all granted remote control peers. --- ...tractOperationSetDesktopSharingClient.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/net/java/sip/communicator/service/protocol/AbstractOperationSetDesktopSharingClient.java b/src/net/java/sip/communicator/service/protocol/AbstractOperationSetDesktopSharingClient.java index d20df1909..c6d88a329 100644 --- a/src/net/java/sip/communicator/service/protocol/AbstractOperationSetDesktopSharingClient.java +++ b/src/net/java/sip/communicator/service/protocol/AbstractOperationSetDesktopSharingClient.java @@ -26,6 +26,12 @@ public abstract class AbstractOperationSetDesktopSharingClient implements OperationSetDesktopSharingClient { + /** + * List of the granted remote control peers for this client. Used to + * remember granted remote control peers, when the granted event is fired + * before the corresponding UI listener registration. + */ + private Vector grantedRemoteControlPeers = new Vector(); /** * The list of RemoteControlListeners to be notified when a change @@ -91,6 +97,19 @@ else if (l.equals(listener)) new WeakReference(listener)); } } + + // Removes the null peers from the granted remote control peer list. + this.removesNullAndRevokedControlPeer(null); + // Notifies the new listener about the already granted remote control + // peers. + CallPeer peer; + for(int i = 0; i < this.grantedRemoteControlPeers.size(); ++i) + { + peer = this.grantedRemoteControlPeers.get(i); + RemoteControlGrantedEvent event = + new RemoteControlGrantedEvent(peer); + listener.remoteControlGranted(event); + } } /** @@ -100,6 +119,9 @@ else if (l.equals(listener)) */ public void fireRemoteControlGranted(CallPeer peer) { + // Adds the peer to the granted remote control peer list. + this.grantedRemoteControlPeers.add(peer); + List listeners = getListeners(); if (!listeners.isEmpty()) @@ -108,7 +130,9 @@ public void fireRemoteControlGranted(CallPeer peer) = new RemoteControlGrantedEvent(peer); for(RemoteControlListener l : listeners) + { l.remoteControlGranted(event); + } } } @@ -129,6 +153,9 @@ public void fireRemoteControlRevoked(CallPeer peer) for(RemoteControlListener l : listeners) l.remoteControlRevoked(event); } + + // Removes the peer from the granted remote control peer list. + this.removesNullAndRevokedControlPeer(peer.getPeerID()); } /** @@ -184,4 +211,25 @@ public void removeRemoteControlListener(RemoteControlListener listener) } } } + + /** + * Removes null and the peer corresponding to the revokedPeerID from the + * granted control peer list. + * + * @param revokedPeerID The ID of the revoked peer. May be null to only + * clear null instances from the granted control peer list. + */ + private void removesNullAndRevokedControlPeer(String revokedPeerID) + { + CallPeer peer; + for(int i = 0; i < this.grantedRemoteControlPeers.size(); ++i) + { + peer = this.grantedRemoteControlPeers.get(i); + if(peer == null || peer.getPeerID().equals(revokedPeerID)) + { + this.grantedRemoteControlPeers.remove(i); + --i; + } + } + } }