src/net/java/sip/communicator/service/protocol/AbstractOperationSetDesktopSharingClient.java
/**
     * Adds a <tt>RemoteControlListener</tt> to be notified when the remote peer
     * accepts to give us full control of their desktop.
     * <p>
     * The default implementation of
     * <tt>AbstractOperationSetDesktopSharingClient</tt> adds a
     * <tt>WeakReference</tt> to the specified <tt>RemoteControlListener</tt> in
     * order to avoid memory leaks because of code which calls
     * <tt>addRemoteControlListener</tt> and never calls
     * <tt>removeRemoteControlListener</tt>.
     * </p>
     *
     * @param listener the <tt>RemoteControlListener</tt> to add
     */
Adds a RemoteControlListener to be notified when the remote peer
accepts to give us full control of their desktop.

The default implementation of
AbstractOperationSetDesktopSharingClient adds a
WeakReference to the specified RemoteControlListener in
order to avoid memory leaks because of code which calls
addRemoteControlListener and never calls
removeRemoteControlListener.

@param listener the RemoteControlListener to add
Adds a RemoteControlListener to be notified when the remote peer accepts to give us full control of their desktop . The default implementation of AbstractOperationSetDesktopSharingClient adds a WeakReference to the specified RemoteControlListener in order to avoid memory leaks because of code which calls addRemoteControlListener and never calls removeRemoteControlListener . @param listener the RemoteControlListener to add
public void addRemoteControlListener(RemoteControlListener listener)
    {
        synchronized (listeners)
        {
            Iterator<WeakReference<RemoteControlListener>> i
                = listeners.iterator();
            boolean contains = false;
            while (i.hasNext())
            {
                RemoteControlListener l = i.next().get();
                if (l == null)
                    i.remove();
                else if (l.equals(listener))
                    contains = true;
            }
            if (!contains)
            {
                listeners.add(
                        new WeakReference<RemoteControlListener>(listener));
                listener.getCallPeer().addCallPeerListener(callPeerListener);
            }
        }
        CallPeer peer = listener.getCallPeer();
        if(this.removesNullAndRevokedControlPeer(peer.getPeerID()) != -1)
            listener.remoteControlGranted(new RemoteControlGrantedEvent(peer));
        if (deferredRemoteControlPeers.contains(peer.getAddress()))
        {
            fireRemoteControlGranted(peer);
            deferredRemoteControlPeers.remove(peer.getAddress());
        }
    }
public void addRemoteControlListener ( RemoteControlListener listener ) { synchronized ( listeners ) { Iterator < WeakReference < RemoteControlListener > > i = listeners . iterator ( ) ; boolean contains = false ; while ( i . hasNext ( ) ) { RemoteControlListener l = i . next ( ) . get ( ) ; if ( l == null ) i . remove ( ) ; else if ( l . equals ( listener ) ) contains = true ; } if ( ! contains ) { listeners . add ( new WeakReference < RemoteControlListener > ( listener ) ) ; listener . getCallPeer ( ) . addCallPeerListener ( callPeerListener ) ; } } CallPeer peer = listener . getCallPeer ( ) ; if ( this . removesNullAndRevokedControlPeer ( peer . getPeerID ( ) ) != - 1 ) listener . remoteControlGranted ( new RemoteControlGrantedEvent ( peer ) ) ; if ( deferredRemoteControlPeers . contains ( peer . getAddress ( ) ) ) { fireRemoteControlGranted ( peer ) ; deferredRemoteControlPeers . remove ( peer . getAddress ( ) ) ; } }
Adds a <tt>RemoteControlListener</tt> to be notified when the remote peer
 accepts to give us full control of their desktop.
Adds a <tt > RemoteControlListener< / tt > to be notified when the remote peer accepts to give us full control of their desktop .
// Notifies the new listener if the corresponding peer has already been // granted to remotely control the shared desktop. // Removes the null peers from the granted remote control peer list. // If the corresponding peer was in the granted list, then this peer has // already been granted and we must call the remoteControlGranted // function for this listener.