Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.gui.main.chat
Class MetaContactChatTransport

java.lang.Object
  extended by net.java.sip.communicator.impl.gui.main.chat.MetaContactChatTransport
All Implemented Interfaces:
EventListener, ChatTransport, ContactPresenceStatusListener

public class MetaContactChatTransport
extends Object
implements ChatTransport, ContactPresenceStatusListener

The single chat implementation of the ChatTransport interface that provides abstraction to protocol provider access.

Author:
Yana Stamcheva

Constructor Summary
MetaContactChatTransport(ChatSession chatSession, Contact contact)
          Creates an instance of MetaContactChatTransport by specifying the parent chatSession and the contact associated with the transport.
 
Method Summary
 void addInstantMessageListener(MessageListener l)
          Adds an instant message listener to this chat transport.
 void addSmsMessageListener(MessageListener l)
          Adds an SMS message listener to this chat transport.
 boolean allowsFileTransfer()
          Returns true if this chat transport supports file transfer, otherwise returns false.
 boolean allowsInstantMessage()
          Returns true if this chat transport supports instant messaging, otherwise returns false.
 boolean allowsSmsMessage()
          Returns true if this chat transport supports sms messaging, otherwise returns false.
 boolean allowsTypingNotifications()
          Returns true if this chat transport supports typing notifications, otherwise returns false.
 void contactPresenceStatusChanged(ContactPresenceStatusChangeEvent evt)
          Indicates that a contact has changed its status.
 void dispose()
          Removes all previously added listeners.
 Contact getContact()
          Returns the contact associated with this transport.
 Object getDescriptor()
          Returns the descriptor of this chat transport.
 String getDisplayName()
          Returns the display name corresponding to this chat transport.
 long getMaximumFileLength()
          Returns the maximum file length supported by the protocol in bytes.
 String getName()
          Returns the contact address corresponding to this chat transport.
 ChatSession getParentChatSession()
          Returns the parent session of this chat transport.
 ProtocolProviderService getProtocolProvider()
          Returns the ProtocolProviderService, corresponding to this chat transport.
 PresenceStatus getStatus()
          Returns the presence status of this transport.
 void inviteChatContact(String contactAddress, String reason)
          Invites a contact to join this chat.
 boolean isContentTypeSupported(String contentType)
          Determines whether this chat transport supports the supplied content type
 void removeInstantMessageListener(MessageListener l)
          Removes the instant message listener from this chat transport.
 void removeSmsMessageListener(MessageListener l)
          Removes the given sms message listener from this chat transport.
 FileTransfer sendFile(File file)
          Sends the given file through this chat transport file transfer operation set.
 void sendInstantMessage(String message, String mimeType)
          Sends the given instant message trough this chat transport, by specifying the mime type (html or plain text).
 void sendSmsMessage(Contact contact, String message)
          Sends the given sms message trough this chat transport.
 void sendSmsMessage(String phoneNumber, String messageText)
          Sends the given sms message trough this chat transport.
 int sendTypingNotification(int typingState)
          Sends a typing notification state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaContactChatTransport

public MetaContactChatTransport(ChatSession chatSession,
                                Contact contact)
Creates an instance of MetaContactChatTransport by specifying the parent chatSession and the contact associated with the transport.

Parameters:
chatSession - the parent ChatSession
contact - the Contact associated with this transport
Method Detail

getContact

public Contact getContact()
Returns the contact associated with this transport.

Returns:
the contact associated with this transport

getName

public String getName()
Returns the contact address corresponding to this chat transport.

Specified by:
getName in interface ChatTransport
Returns:
The contact address corresponding to this chat transport.

getDisplayName

public String getDisplayName()
Returns the display name corresponding to this chat transport.

Specified by:
getDisplayName in interface ChatTransport
Returns:
The display name corresponding to this chat transport.

getStatus

public PresenceStatus getStatus()
Returns the presence status of this transport.

Specified by:
getStatus in interface ChatTransport
Returns:
the presence status of this transport.

getProtocolProvider

public ProtocolProviderService getProtocolProvider()
Returns the ProtocolProviderService, corresponding to this chat transport.

Specified by:
getProtocolProvider in interface ChatTransport
Returns:
the ProtocolProviderService, corresponding to this chat transport.

allowsInstantMessage

public boolean allowsInstantMessage()
Returns true if this chat transport supports instant messaging, otherwise returns false.

Specified by:
allowsInstantMessage in interface ChatTransport
Returns:
true if this chat transport supports instant messaging, otherwise returns false.

allowsSmsMessage

public boolean allowsSmsMessage()
Returns true if this chat transport supports sms messaging, otherwise returns false.

Specified by:
allowsSmsMessage in interface ChatTransport
Returns:
true if this chat transport supports sms messaging, otherwise returns false.

allowsTypingNotifications

public boolean allowsTypingNotifications()
Returns true if this chat transport supports typing notifications, otherwise returns false.

Specified by:
allowsTypingNotifications in interface ChatTransport
Returns:
true if this chat transport supports typing notifications, otherwise returns false.

allowsFileTransfer

public boolean allowsFileTransfer()
Returns true if this chat transport supports file transfer, otherwise returns false.

Returns:
true if this chat transport supports file transfer, otherwise returns false.

sendInstantMessage

public void sendInstantMessage(String message,
                               String mimeType)
                        throws Exception
Sends the given instant message trough this chat transport, by specifying the mime type (html or plain text).

Specified by:
sendInstantMessage in interface ChatTransport
Parameters:
message - The message to send.
mimeType - The mime type of the message to send: text/html or text/plain.
Throws:
Exception - if the send operation is interrupted

isContentTypeSupported

public boolean isContentTypeSupported(String contentType)
Determines whether this chat transport supports the supplied content type

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

sendSmsMessage

public void sendSmsMessage(String phoneNumber,
                           String messageText)
                    throws Exception
Sends the given sms message trough this chat transport.

Specified by:
sendSmsMessage in interface ChatTransport
Parameters:
phoneNumber - phone number of the destination
messageText - The message to send.
Throws:
Exception - if the send operation is interrupted

sendSmsMessage

public void sendSmsMessage(Contact contact,
                           String message)
                    throws Exception
Sends the given sms message trough this chat transport.

Specified by:
sendSmsMessage in interface ChatTransport
Parameters:
contact - the destination contact
message - the message to send
Throws:
Exception - if the send operation is interrupted

sendTypingNotification

public int sendTypingNotification(int typingState)
Sends a typing notification state.

Specified by:
sendTypingNotification in interface ChatTransport
Parameters:
typingState - the typing notification state to send
Returns:
the result of this operation. One of the TYPING_NOTIFICATION_XXX constants defined in this class

sendFile

public FileTransfer sendFile(File file)
                      throws Exception
Sends the given file through this chat transport file transfer operation set.

Specified by:
sendFile in interface ChatTransport
Parameters:
file - the file to send
Returns:
the FileTransfer object charged to transfer the file
Throws:
Exception - if anything goes wrong

getMaximumFileLength

public long getMaximumFileLength()
Returns the maximum file length supported by the protocol in bytes.

Specified by:
getMaximumFileLength in interface ChatTransport
Returns:
the file length that is supported.

inviteChatContact

public void inviteChatContact(String contactAddress,
                              String reason)
Description copied from interface: ChatTransport
Invites a contact to join this chat.

Specified by:
inviteChatContact in interface ChatTransport
Parameters:
contactAddress - the address of the contact we invite
reason - the reason for the invite

getParentChatSession

public ChatSession getParentChatSession()
Returns the parent session of this chat transport. A ChatSession could contain more than one transports.

Specified by:
getParentChatSession in interface ChatTransport
Returns:
the parent session of this chat transport

addSmsMessageListener

public void addSmsMessageListener(MessageListener l)
Adds an SMS message listener to this chat transport.

Specified by:
addSmsMessageListener in interface ChatTransport
Parameters:
l - The message listener to add.

addInstantMessageListener

public void addInstantMessageListener(MessageListener l)
Adds an instant message listener to this chat transport.

Specified by:
addInstantMessageListener in interface ChatTransport
Parameters:
l - The message listener to add.

removeSmsMessageListener

public void removeSmsMessageListener(MessageListener l)
Removes the given sms message listener from this chat transport.

Specified by:
removeSmsMessageListener in interface ChatTransport
Parameters:
l - The message listener to remove.

removeInstantMessageListener

public void removeInstantMessageListener(MessageListener l)
Removes the instant message listener from this chat transport.

Specified by:
removeInstantMessageListener in interface ChatTransport
Parameters:
l - The message listener to remove.

contactPresenceStatusChanged

public void contactPresenceStatusChanged(ContactPresenceStatusChangeEvent evt)
Indicates that a contact has changed its status.

Specified by:
contactPresenceStatusChanged in interface ContactPresenceStatusListener
Parameters:
evt - The presence event containing information about the contact status change.

dispose

public void dispose()
Removes all previously added listeners.

Specified by:
dispose in interface ChatTransport

getDescriptor

public Object getDescriptor()
Returns the descriptor of this chat transport.

Specified by:
getDescriptor in interface ChatTransport
Returns:
the descriptor of this chat transport

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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