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.
cusax-fix
Vincent Lucas 14 years ago
parent b48bf9721a
commit 86c0143219

@ -26,6 +26,12 @@ public abstract class AbstractOperationSetDesktopSharingClient
<T extends ProtocolProviderService>
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<CallPeer> grantedRemoteControlPeers = new Vector<CallPeer>();
/**
* The list of <tt>RemoteControlListener</tt>s to be notified when a change
@ -91,6 +97,19 @@ else if (l.equals(listener))
new WeakReference<RemoteControlListener>(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<RemoteControlListener> 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;
}
}
}
}

Loading…
Cancel
Save