Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.ssh
Class OperationSetBasicInstantMessagingSSHImpl

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

public class OperationSetBasicInstantMessagingSSHImpl
extends AbstractOperationSetBasicInstantMessaging

Instant messaging functionality for the SSH protocol.

Author:
Shobhit Jindal

Field Summary
 
Fields inherited from interface net.java.sip.communicator.service.protocol.OperationSetBasicInstantMessaging
DEFAULT_MIME_ENCODING, DEFAULT_MIME_TYPE, HTML_MIME_TYPE
 
Constructor Summary
OperationSetBasicInstantMessagingSSHImpl(ProtocolProviderServiceSSHImpl provider)
          Creates an instance of this operation set keeping a reference to the parent protocol provider and presence operation set.
 
Method Summary
 Message createMessage(String content, String contentType, String encoding, String subject)
          Create a Message instance for sending arbitrary MIME-encoding content.
(package private)  void deliverMessage(Message message, ContactSSH to)
          In case the to Contact corresponds to another ssh protocol provider registered with SIP Communicator, we deliver the message to them, in case the to Contact represents us, we fire a MessageReceivedEvent, and if to is simply a contact in our contact list, then we simply echo the message.
protected  void fireMessageReceived(Message message, Contact from)
          Notifies all registered message listeners that a message has been received.
 boolean isContentTypeSupported(String contentType)
          Determines wheter the protocol supports the supplied content type
 boolean isOfflineMessagingSupported()
          Determines whether the SSH protocol provider supports sending and receiving offline messages.
 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, fireMessageEvent, isContentTypeSupported, messageDeliveryPendingTransform, removeMessageListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationSetBasicInstantMessagingSSHImpl

public OperationSetBasicInstantMessagingSSHImpl(ProtocolProviderServiceSSHImpl provider)
Creates an instance of this operation set keeping a reference to the parent protocol provider and presence operation set.

Parameters:
provider - The provider instance that creates us.
Method Detail

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. An attempt is made to re-establish the shell connection if the current one is invalid. The reply from server is sent by a seperate reader thread

Parameters:
to - the Contact to send message to
message - the Message to send.
Throws:
IllegalStateException - if the underlying ICQ stack is not registered and initialized.
IllegalArgumentException - if to is not an instance belonging to the underlying implementation.

deliverMessage

void deliverMessage(Message message,
                    ContactSSH to)
In case the to Contact corresponds to another ssh protocol provider registered with SIP Communicator, we deliver the message to them, in case the to Contact represents us, we fire a MessageReceivedEvent, and if to is simply a contact in our contact list, then we simply echo the message.

Parameters:
message - the Message the message to deliver.
to - the Contact that we should deliver the message to.

fireMessageReceived

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

Overrides:
fireMessageReceived in class AbstractOperationSetBasicInstantMessaging
Parameters:
message - the Message that has been received.
from - the Contact that message was received from.

isOfflineMessagingSupported

public boolean isOfflineMessagingSupported()
Determines whether the SSH protocol provider supports sending and receiving offline messages.

Returns:
false

isContentTypeSupported

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

Parameters:
contentType - the type we want to check
Returns:
true if the protocol 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.