Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.yahoo
Class OperationSetBasicInstantMessagingYahooImpl

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.AbstractOperationSetBasicInstantMessaging
      extended by net.java.sip.communicator.impl.protocol.yahoo.OperationSetBasicInstantMessagingYahooImpl
All Implemented Interfaces:
OperationSet, OperationSetBasicInstantMessaging, OperationSetInstantMessageFiltering

public class OperationSetBasicInstantMessagingYahooImpl
extends AbstractOperationSetBasicInstantMessaging
implements OperationSetInstantMessageFiltering

A straightforward implementation of the basic instant messaging operation set.

Author:
Damian Minkov, Symphorien Wanko, Keio Kraaner

Field Summary
 
Fields inherited from interface net.java.sip.communicator.service.protocol.OperationSetBasicInstantMessaging
DEFAULT_MIME_ENCODING, DEFAULT_MIME_TYPE, HTML_MIME_TYPE
 
Constructor Summary
OperationSetBasicInstantMessagingYahooImpl(ProtocolProviderServiceYahooImpl provider)
          Creates an instance of this operation set.
 
Method Summary
 void addEventFilter(EventFilter filter)
          Registers an EventFilter with this operation set so that events, that do not need processing, are filtered out.
 Message createMessage(String content, String contentType, String encoding, String subject)
          Create a Message instance for sending arbitrary MIME-encoding content.
(package private)  String decodeMessage(String message)
          Decode the received chat message.
protected  void fireMessageEvent(EventObject evt)
          Delivers the specified event to all registered message listeners.
 boolean isContentTypeSupported(String contentType)
          Determines wheter the protocol supports the supplied content type
 boolean isOfflineMessagingSupported()
          Determines wheter the protocol provider (or the protocol itself) support sending and receiving offline messages.
 String processLinks(String message)
          Format links in the given message.
 void removeEventFilter(EventFilter filter)
          Unregisteres an EventFilter so that it won't check any more if an event should be filtered out.
 void sendInstantMessage(Contact to, Message message)
          Sends the message to the destination indicated by the to contact.
 
Methods inherited from class net.java.sip.communicator.service.protocol.AbstractOperationSetBasicInstantMessaging
addMessageListener, createMessage, createMessage, fireMessageDelivered, fireMessageDeliveryFailed, fireMessageReceived, isContentTypeSupported, messageDeliveryPendingTransform, removeMessageListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationSetBasicInstantMessagingYahooImpl

OperationSetBasicInstantMessagingYahooImpl(ProtocolProviderServiceYahooImpl provider)
Creates an instance of this operation set.

Parameters:
provider - a ref to the ProtocolProviderServiceImpl that created us and that we'll use for retrieving the underlying aim connection.
Method Detail

isOfflineMessagingSupported

public boolean isOfflineMessagingSupported()
Determines wheter the protocol provider (or the protocol itself) support sending and receiving offline messages. Most often this method would return true for protocols that support offline messages and false for those that don't. It is however possible for a protocol to support these messages and yet have a particular account that does not (i.e. feature not enabled on the protocol server). In cases like this it is possible for this method to return true even when offline messaging is not supported, and then have the sendMessage method throw an OperationFailedException with code - OFFLINE_MESSAGES_NOT_SUPPORTED.

Specified by:
isOfflineMessagingSupported in interface OperationSetBasicInstantMessaging
Returns:
true if the protocol supports offline messages and false otherwise.

isContentTypeSupported

public boolean isContentTypeSupported(String contentType)
Determines wheter the protocol supports the supplied content type

Specified by:
isContentTypeSupported in interface OperationSetBasicInstantMessaging
Parameters:
contentType - the type we want to check
Returns:
true if the protocol supports it and false otherwise.

createMessage

public Message createMessage(String content,
                             String contentType,
                             String encoding,
                             String subject)
Description copied from interface: OperationSetBasicInstantMessaging
Create a Message instance for sending arbitrary MIME-encoding content.

Specified by:
createMessage in interface OperationSetBasicInstantMessaging
Specified by:
createMessage in class AbstractOperationSetBasicInstantMessaging
Parameters:
content - content value
contentType - the MIME-type for content
encoding - encoding used for content
subject - a String subject or null for now subject.
Returns:
the newly created message.

sendInstantMessage

public void sendInstantMessage(Contact to,
                               Message message)
                        throws IllegalStateException,
                               IllegalArgumentException
Sends the message to the destination indicated by the to contact.

Specified by:
sendInstantMessage in interface OperationSetBasicInstantMessaging
Parameters:
to - the Contact to send message to
message - the Message to send.
Throws:
IllegalStateException - if the underlying stack is not registered and initialized.
IllegalArgumentException - if to is not an instance of ContactImpl.

fireMessageEvent

protected void fireMessageEvent(EventObject evt)
Delivers the specified event to all registered message listeners.

Overrides:
fireMessageEvent in class AbstractOperationSetBasicInstantMessaging
Parameters:
evt - the EventObject that we'd like delivered to all registered message listerners.

decodeMessage

String decodeMessage(String message)
Decode the received chat message. If the message contains  the following text is decoded by the MessageDecoder of yahoo api Then make http links clickable and fix the font size of html code

Parameters:
message - the chat message
Returns:
a decoded message.

processLinks

public String processLinks(String message)
Format links in the given message. Skips all links, which are already in HTML format and converts all other links.

Parameters:
message - The source message string.
Returns:
The message string with properly formatted links.

addEventFilter

public void addEventFilter(EventFilter filter)
Registers an EventFilter with this operation set so that events, that do not need processing, are filtered out.

Specified by:
addEventFilter in interface OperationSetInstantMessageFiltering
Parameters:
filter - the EventFilter to register.

removeEventFilter

public void removeEventFilter(EventFilter filter)
Unregisteres an EventFilter so that it won't check any more if an event should be filtered out.

Specified by:
removeEventFilter in interface OperationSetInstantMessageFiltering
Parameters:
filter - the EventFilter to unregister.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.