Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.service.protocol
Class AbstractOperationSetBasicInstantMessaging

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.AbstractOperationSetBasicInstantMessaging
All Implemented Interfaces:
OperationSet, OperationSetBasicInstantMessaging
Direct Known Subclasses:
MockBasicInstantMessaging, OperationSetBasicInstantMessagingDictImpl, OperationSetBasicInstantMessagingGibberishImpl, OperationSetBasicInstantMessagingIcqImpl, OperationSetBasicInstantMessagingJabberImpl, OperationSetBasicInstantMessagingMsnImpl, OperationSetBasicInstantMessagingRssImpl, OperationSetBasicInstantMessagingSipImpl, OperationSetBasicInstantMessagingSSHImpl, OperationSetBasicInstantMessagingYahooImpl, OperationSetBasicInstantMessagingZeroconfImpl

public abstract class AbstractOperationSetBasicInstantMessaging
extends Object
implements OperationSetBasicInstantMessaging

Represents a default implementation of OperationSetBasicInstantMessaging in order to make it easier for implementers to provide complete solutions while focusing on implementation-specific details.

Author:
Lubomir Marinov

Nested Class Summary
(package private) static class AbstractOperationSetBasicInstantMessaging.MessageEventType
           
 
Field Summary
 
Fields inherited from interface net.java.sip.communicator.service.protocol.OperationSetBasicInstantMessaging
DEFAULT_MIME_ENCODING, DEFAULT_MIME_TYPE, HTML_MIME_TYPE
 
Constructor Summary
AbstractOperationSetBasicInstantMessaging()
           
 
Method Summary
 void addMessageListener(MessageListener listener)
          Registers a MessageListener with this operation set so that it gets notifications of successful message delivery, failure or reception of incoming messages..
 Message createMessage(byte[] content, String contentType, String encoding, String subject)
          Create a Message instance for sending arbitrary MIME-encoding content.
 Message createMessage(String messageText)
          Create a Message instance for sending a simple text messages with default (text/plain) content type and encoding.
abstract  Message createMessage(String content, String contentType, String encoding, String subject)
          Create a Message instance for sending arbitrary MIME-encoding content.
protected  void fireMessageDelivered(Message message, Contact to)
          Notifies all registered message listeners that a message has been delivered successfully to its addressee..
protected  void fireMessageDeliveryFailed(Message message, Contact to, int errorCode)
           
protected  void fireMessageEvent(EventObject evt)
          Delivers the specified event to all registered message listeners.
protected  void fireMessageReceived(Message message, Contact from)
          Notifies all registered message listeners that a message has been received.
 boolean isContentTypeSupported(String contentType, Contact contact)
          Determines whether the protocol supports the supplied content type for the given contact.
 MessageDeliveredEvent messageDeliveryPendingTransform(MessageDeliveredEvent evt)
           
 void removeMessageListener(MessageListener listener)
          Unregisters listener so that it won't receive any further notifications upon successful message delivery, failure or reception of incoming messages..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.java.sip.communicator.service.protocol.OperationSetBasicInstantMessaging
isContentTypeSupported, isOfflineMessagingSupported, sendInstantMessage
 

Constructor Detail

AbstractOperationSetBasicInstantMessaging

public AbstractOperationSetBasicInstantMessaging()
Method Detail

addMessageListener

public void addMessageListener(MessageListener listener)
Registers a MessageListener with this operation set so that it gets notifications of successful message delivery, failure or reception of incoming messages..

Specified by:
addMessageListener in interface OperationSetBasicInstantMessaging
Parameters:
listener - the MessageListener to register.

createMessage

public Message createMessage(byte[] content,
                             String contentType,
                             String encoding,
                             String subject)
Create a Message instance for sending arbitrary MIME-encoding content.

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.

createMessage

public Message createMessage(String messageText)
Create a Message instance for sending a simple text messages with default (text/plain) content type and encoding.

Specified by:
createMessage in interface OperationSetBasicInstantMessaging
Parameters:
messageText - the string content of the message.
Returns:
Message the newly created message

createMessage

public abstract 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
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.

fireMessageDelivered

protected void fireMessageDelivered(Message message,
                                    Contact to)
Notifies all registered message listeners that a message has been delivered successfully to its addressee..

Parameters:
message - the Message that has been delivered.
to - the Contact that message was delivered to.

fireMessageDeliveryFailed

protected void fireMessageDeliveryFailed(Message message,
                                         Contact to,
                                         int errorCode)

fireMessageEvent

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

Parameters:
evt - the EventObject that we'd like delivered to all registered message listeners.

fireMessageReceived

protected void fireMessageReceived(Message message,
                                   Contact from)
Notifies all registered message listeners that a message has been received.

Parameters:
message - the Message that has been received.
from - the Contact that message was received from.

removeMessageListener

public void removeMessageListener(MessageListener listener)
Unregisters listener so that it won't receive any further notifications upon successful message delivery, failure or reception of incoming messages..

Specified by:
removeMessageListener in interface OperationSetBasicInstantMessaging
Parameters:
listener - the MessageListener to unregister.

messageDeliveryPendingTransform

public MessageDeliveredEvent messageDeliveryPendingTransform(MessageDeliveredEvent evt)

isContentTypeSupported

public boolean isContentTypeSupported(String contentType,
                                      Contact contact)
Determines whether the protocol supports the supplied content type for the given contact.

Specified by:
isContentTypeSupported in interface OperationSetBasicInstantMessaging
Parameters:
contentType - the type we want to check
contact - contact which is checked for supported contentType
Returns:
true if the contact supports it and false otherwise.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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