Committing patches from Lubomir Marinov (moving isRegistered() to AbstractProtocolProviderService) and Keio Kraaner (implementation of message filtering).

cusax-fix
Emil Ivov 18 years ago
parent c6be00c866
commit 9b93a50c3e

@ -266,17 +266,6 @@ public Map getSupportedOperationSets()
return (Map)supportedOperationSets.clone();
}
/**
* Indicates whether or not this provider is registered
*
* @return true if the provider is currently registered and false
* otherwise.
*/
public boolean isRegistered()
{
return currentRegistrationState.equals(RegistrationState.REGISTERED);
}
/**
* Starts the registration process.
*

@ -194,17 +194,6 @@ public Map getSupportedOperationSets()
return (Map)supportedOperationSets.clone();
}
/**
* Indicates whether or not this provider is registered
*
* @return true if the provider is currently registered and false
* otherwise.
*/
public boolean isRegistered()
{
return currentRegistrationState.equals(RegistrationState.REGISTERED);
}
/**
* Starts the registration process.
*

@ -401,16 +401,6 @@ public void unregister()
aimConnection.disconnect(true);
}
/**
* Indicates whether or not this provider is signed on the icq service
* @return true if the provider is currently signed on (and hence online)
* and false otherwise.
*/
public boolean isRegistered()
{
return getRegistrationState().equals(RegistrationState.REGISTERED);
}
/**
* Returns the short name of the protocol that the implementation of this
* provider is based upon (like SIP, Jabber, ICQ/AIM, or others for

@ -173,18 +173,6 @@ public Map getSupportedOperationSets()
return (Map) supportedOperationSets.clone();
}
/**
* Indicates whether or not this provider is registered
*
* @return true if the provider is currently registered and false
* otherwise.
*/
public boolean isRegistered()
{
return currentRegistrationState
.equals(RegistrationState.REGISTERED);
}
/**
* Starts the registration process.
*

@ -439,16 +439,6 @@ private void unregister(boolean fireEvent)
}
}
/**
* Indicates whether or not this provider is signed on the service
* @return true if the provider is currently signed on (and hence online)
* and false otherwise.
*/
public boolean isRegistered()
{
return getRegistrationState().equals(RegistrationState.REGISTERED);
}
/**
* Returns the short name of the protocol that the implementation of this
* provider is based upon (like SIP, Jabber, ICQ/AIM, or others for

@ -236,16 +236,6 @@ void unregister(boolean fireEvent)
}
}
/**
* Indicates whether or not this provider is signed on the service
* @return true if the provider is currently signed on (and hence online)
* and false otherwise.
*/
public boolean isRegistered()
{
return getRegistrationState().equals(RegistrationState.REGISTERED);
}
/**
* Returns the short name of the protocol that the implementation of this
* provider is based upon (like SIP, Msn, ICQ/AIM, or others for

@ -194,17 +194,6 @@ public Map getSupportedOperationSets()
return (Map)supportedOperationSets.clone();
}
/**
* Indicates whether or not this provider is registered
*
* @return true if the provider is currently registered and false
* otherwise.
*/
public boolean isRegistered()
{
return currentRegistrationState.equals(RegistrationState.REGISTERED);
}
/**
* Starts the registration process.
*

@ -88,6 +88,12 @@ public class CallParticipantSipImpl
* address of our sip registrar).
*/
private InetSocketAddress transportAddress = null;
/**
* A URL pointing to a location with call information or a call control
* web interface related to this participant.
*/
private URL callControlURL = null;
/**
* Creates a new call participant with address <tt>participantAddress</tt>.
@ -457,4 +463,29 @@ public Contact getContact()
return opSetPresence.findContactByID(getAddress());
}
/**
* Returns a URL pointing ta a location with call control information for
* this participant or <tt>null</tt> if no such URL is available for this
* call participant.
*
* @return a URL link to a location with call information or a call control
* web interface related to this participant or <tt>null</tt> if no such URL
* is available.
*/
public URL getCallInfoURL()
{
return this.callControlURL;
}
/**
* Returns a URL pointing ta a location with call control information for
* this participant.
*
* @param callControlURL a URL link to a location with call information or
* a call control web interface related to this participant.
*/
public void setCallInfoURL(URL callControlURL)
{
this.callControlURL = callControlURL;
}
}

@ -754,6 +754,12 @@ private void processInviteOK(ClientTransaction clientTransaction,
callParticipant
, callParticipant.getSdpDescription());
ack.setContent(sdp, contentTypeHeader);
//set the call url in case there was one
/** @todo this should be done in CallSession, once we move
* it here.*/
callParticipant.setCallInfoURL(
callSession.getCallInfoURL());
}
}
@ -775,6 +781,10 @@ private void processInviteOK(ClientTransaction clientTransaction,
callSession.processSdpAnswer(callParticipant
, callParticipant.getSdpDescription());
//set the call url in case there was one
/** @todo this should be done in CallSession, once we move
* it here.*/
callParticipant.setCallInfoURL(callSession.getCallInfoURL());
}
catch (ParseException exc)
{
@ -1840,6 +1850,11 @@ public synchronized void answerCallParticipant(CallParticipant participant)
sdp = callSession.processSdpOffer(
callParticipant
, callParticipant.getSdpDescription());
//set the call url in case there was one
/** @todo this should be done in CallSession, once we move
* it here.*/
callParticipant.setCallInfoURL(callSession.getCallInfoURL());
}
//if there was no offer in the invite - create an offer
else

@ -197,7 +197,7 @@ public class ProtocolProviderServiceSipImpl
* A String indicating the default debug level for the jain-sip-ri (must be
* log4j compatible).
*/
private static final String NSPVALUE_TRACE_LEVEL = "DEBUG";
private static final String NSPVALUE_TRACE_LEVEL = "ERROR";
/**
* The name of the property under which the jain-sip-ri would expect to find
@ -357,7 +357,8 @@ public String getProtocolName()
*
* @param event The event to register
*/
public void registerEvent(String event) {
public void registerEvent(String event)
{
synchronized (this.registeredEvents) {
if (!this.registeredEvents.contains(event)) {
this.registeredEvents.add(event);
@ -370,24 +371,11 @@ public void registerEvent(String event) {
*
* @return The list of all the registered events
*/
public List getKnownEventsList() {
public List getKnownEventsList()
{
return this.registeredEvents;
}
/**
* Indicates whether or not this provider is registered
* @return true if the provider is currently registered and false otherwise.
*/
public boolean isRegistered()
{
if(this.sipRegistrarConnection == null )
{
return false;
}
return sipRegistrarConnection.getRegistrationState()
.equals(RegistrationState.REGISTERED);
}
/**
* Returns an array containing all operation sets supported by the current
* implementation. When querying this method users must be prepared to

@ -567,17 +567,6 @@ public Map getSupportedOperationSets()
return (Map)supportedOperationSets.clone();
}
/**
* Indicates whether or not this provider is registered
*
* @return true if the provider is currently registered and false
* otherwise.
*/
public boolean isRegistered()
{
return currentRegistrationState.equals(RegistrationState.REGISTERED);
}
/**
* Starts the registration process.
*

@ -21,9 +21,11 @@
* set.
*
* @author Damian Minkov
* @author Keio Kraaner
*/
public class OperationSetBasicInstantMessagingYahooImpl
implements OperationSetBasicInstantMessaging
implements OperationSetBasicInstantMessaging,
OperationSetInstantMessageFiltering
{
/**
* Logger for this class
@ -45,8 +47,14 @@ public class OperationSetBasicInstantMessagingYahooImpl
/**
* A list of listeneres registered for message events.
*/
private Vector messageListeners = new Vector();
private Vector<MessageListener> messageListeners
= new Vector<MessageListener>();
/**
* A list of filters registered for message events.
*/
private Vector<EventFilter> eventFilters = new Vector<EventFilter>();
/**
* The provider that created us.
*/
@ -310,6 +318,36 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
*/
private void fireMessageEvent(EventObject evt)
{
// check if this event should be filtered out
Iterator<EventFilter> filters = null;
synchronized (eventFilters)
{
filters = new ArrayList<EventFilter>(eventFilters).iterator();
}
// return if a filter has filtered this event out
boolean filtered = false;
while (filters.hasNext())
{
try
{
if (filters.next().filterEvent(evt))
{
filtered = true;
}
}
catch(Exception exc)
{
logger.error("An exception occurred while filtering an event.",
exc);
}
}
if (filtered)
{
logger.trace("Message event filtered.");
return;
}
Iterator listeners = null;
synchronized (messageListeners)
{
@ -627,4 +665,35 @@ private String formatLinksToHTML(String text)
return linkBuffer.toString();
}
/**
* Registers an <tt>EventFilter</tt> with this operation set so that
* events, that do not need processing, are filtered out.
*
* @param filter the <tt>EventFilter</tt> to register.
*/
public void addEventFilter(EventFilter filter)
{
synchronized(eventFilters)
{
if(!eventFilters.contains(filter))
{
eventFilters.add(filter);
}
}
}
/**
* Unregisteres an <tt>EventFilter</tt> so that it won't check any more
* if an event should be filtered out.
*
* @param filter the <tt>EventFilter</tt> to unregister.
*/
public void removeEventFilter(EventFilter filter)
{
synchronized(eventFilters)
{
eventFilters.remove(filter);
}
}
}

@ -265,16 +265,6 @@ void unregister(boolean fireEvent)
}
}
/**
* Indicates whether or not this provider is signed on the service
* @return true if the provider is currently signed on (and hence online)
* and false otherwise.
*/
public boolean isRegistered()
{
return getRegistrationState().equals(RegistrationState.REGISTERED);
}
/**
* Returns the short name of the protocol that the implementation of this
* provider is based upon (like SIP, Msn, ICQ/AIM, or others for

@ -206,17 +206,6 @@ public Map getSupportedOperationSets()
//Copy the map so that the caller is not able to modify it.
return (Map)supportedOperationSets.clone();
}
/**
* Indicates whether or not this provider is registered
*
* @return true if the provider is currently registered and false
* otherwise.
*/
public boolean isRegistered()
{
return currentRegistrationState.equals(RegistrationState.REGISTERED);
}
/**
* Starts the registration process.

@ -109,4 +109,14 @@ public void processSdpAnswer(CallParticipant responder, String sdpAnswer)
* <tt>CallSession</tt>.
*/
public int getAudioPort();
/**
* Returns a URL pointing ta a location with call control information for
* this call or <tt>null</tt> if no such URL is available.
*
* @return a URL link to a location with call information or a call control
* web interface for the specified participant or <tt>null</tt> if no such
* URL is available.
*/
public URL getCallInfoURL();
}

@ -11,7 +11,7 @@
/**
*
* @author Martin Andre
* @author Symphorien Wanko
*/
public class MediaEvent
extends java.util.EventObject

@ -7,6 +7,7 @@
package net.java.sip.communicator.service.protocol;
import java.util.*;
import java.net.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;
@ -143,4 +144,20 @@ public String toString()
return getDisplayName() + " <" + getAddress()
+ ">;status=" + getState().getStateString();
}
/**
* Returns a URL pointing ta a location with call control information for
* this participant or <tt>null</tt> if no such URL is available for this
* call participant.
*
* @return a URL link to a location with call information or a call control
* web interface related to this participant or <tt>null</tt> if no such URL
* is available.
*/
public URL getCallInfoURL()
{
//if signaling protocols (such as SIP) know where to get this URL from
//they should override this method
return null;
}
}

@ -12,7 +12,7 @@
import net.java.sip.communicator.util.*;
/**
* Implements "standard" functionality of <tt>ProtocolProviderService</code> in
* Implements "standard" functionality of <tt>ProtocolProviderService</tt> in
* order to make it easier for implementers to provide complete solutions while
* focusing on protocol-specific details.
*/
@ -104,6 +104,17 @@ public String getProtocolDisplayName()
return (displayName == null) ? getProtocolName() : displayName;
}
/**
* Indicates whether or not this provider is registered
*
* @return true if the provider is currently registered and false
* otherwise.
*/
public boolean isRegistered()
{
return getRegistrationState().equals(RegistrationState.REGISTERED);
}
/**
* Removes the specified registration state change listener so that it does
* not receive any further notifications upon changes of the

@ -122,4 +122,14 @@ public interface CallParticipant
* if no particular contact has been associated.
*/
public Contact getContact();
/**
* Returns a URL pointing ta a location with call control information or
* null if such an URL is not available for the current call participant.
*
* @return a URL link to a location with call information or a call control
* web interface related to this participant or <tt>null</tt> if no such URL
* is available.
*/
public URL getCallInfoURL();
}

@ -0,0 +1,36 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.java.sip.communicator.service.protocol;
/**
* An operation set that allows plugins to register filters which could
* intercept instant messages and determine whether or not they should be
* dispatched to regular listeners. <tt>EventFilter</tt>-s allow implementating
* features that use standard instant messaging channels to exchange
*
* @author Keio Kraaner
*/
import net.java.sip.communicator.service.protocol.event.*;
public interface OperationSetInstantMessageFiltering
extends OperationSet
{
/**
* Registeres an <tt>EventFilter</tt> with this operation set so that
* events, that do not need processing, are filtered out.
*
* @param filter the <tt>EventFilter</tt> to register.
*/
public void addEventFilter(EventFilter filter);
/**
* Unregisteres an <tt>EventFilter</tt> so that it won't check any more
* if an event should be filtered out.
*
* @param filter the <tt>EventFilter</tt> to unregister.
*/
public void removeEventFilter(EventFilter filter);
}

@ -0,0 +1,32 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.protocol.event;
import java.util.*;
/**
* An event filter that decides whether an instant message event should be
* filtered or not. For instance, maybe some type of received messages should not be
* shown in the chat windows. In such cases implementations of this filter would block
* this message before it is delivered to other IM listeners.
* <p>
* Note that in order to be able to use this Filter, protocols should implement
* <tt>OperationSetMessageFiltering</tt>.
* <p>
* @author Keio Kraaner
*/
public interface EventFilter
{
/**
* Checks if an event should be filtered out or processed.
*
* @param msg The event that should be checked
* @return <tt>true</tt> if the event was filtered out, otherwise
* <tt>false</tt>.
*/
public boolean filterEvent(EventObject msg);
}
Loading…
Cancel
Save