Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.rss
Class OperationSetBasicInstantMessagingRssImpl

java.lang.Object
  extended by net.java.sip.communicator.service.protocol.AbstractOperationSetBasicInstantMessaging
      extended by net.java.sip.communicator.impl.protocol.rss.OperationSetBasicInstantMessagingRssImpl
All Implemented Interfaces:
EventListener, RegistrationStateChangeListener, OperationSet, OperationSetBasicInstantMessaging

public class OperationSetBasicInstantMessagingRssImpl
extends AbstractOperationSetBasicInstantMessaging
implements RegistrationStateChangeListener

Instant messaging functionalities for the RSS protocol.

Author:
Jean-Albert Vescovo, Mihai Balan

Field Summary
 
Fields inherited from interface net.java.sip.communicator.service.protocol.OperationSetBasicInstantMessaging
DEFAULT_MIME_ENCODING, DEFAULT_MIME_TYPE, HTML_MIME_TYPE
 
Constructor Summary
OperationSetBasicInstantMessagingRssImpl(ProtocolProviderServiceRssImpl provider, OperationSetPersistentPresenceRssImpl opSetPersPresence)
          Creates an instance of this operation set keeping a reference to the parent protocol provider and presence operation set.
 
Method Summary
 Message createMessage(String messageText)
          Create a Message instance for sending a simple text messages with default (text/html) content type and encoding.
 Message createMessage(String content, String contentType, String encoding, String subject)
          Create a Message instance for sending arbitrary MIME-encoding content.
 void createTimer()
          Creates the timer for refreshing RSS feeds.
 OperationSetPersistentPresenceRssImpl getOpSetPersPresence()
          Returns a reference to the presence operation set instance used by our source provider.
 ProtocolProviderServiceRssImpl getParentProvider()
          Returns the protocol provider that this operation set belongs to.
 boolean isContentTypeSupported(String contentType)
          Determines whether the protocol supports the supplied content type.
 boolean isOfflineMessagingSupported()
          Determines whether the protocol provider (or the protocol itself) supports sending and receiving offline messages.
 void refreshAllRssFeeds()
          Refreshes all the registered feeds.
 void refreshRssFeed(ContactRssImpl rssURL)
          Refreshes a specific RSS feed.
 void registrationStateChanged(RegistrationStateChangeEvent evt)
          The method is called by the ProtocolProvider whenever a change in the registration state of the corresponding provider has occurred.
 void sendInstantMessage(Contact to, Message message)
          Sends the message to the destination indicated by the to contact.
 void stopTimer()
          Cancels the timer if the user switched to the OFFLINE status.
 void threadedContactFeedUpdate(ContactRssImpl contact)
          Retrieves the feeds for a new RSS feed just added as persistent contact.
 
Methods inherited from class net.java.sip.communicator.service.protocol.AbstractOperationSetBasicInstantMessaging
addMessageListener, createMessage, fireMessageDelivered, fireMessageDeliveryFailed, fireMessageEvent, fireMessageReceived, isContentTypeSupported, messageDeliveryPendingTransform, removeMessageListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationSetBasicInstantMessagingRssImpl

public OperationSetBasicInstantMessagingRssImpl(ProtocolProviderServiceRssImpl provider,
                                                OperationSetPersistentPresenceRssImpl opSetPersPresence)
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.
opSetPersPresence - the currently valid OperationSetPersistentPresenceRssImpl instance.
Method Detail

createMessage

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

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

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.

refreshAllRssFeeds

public void refreshAllRssFeeds()
Refreshes all the registered feeds.


refreshRssFeed

public void refreshRssFeed(ContactRssImpl rssURL)
Refreshes a specific RSS feed.

Parameters:
rssURL - the contact (feed) to be refreshed.

createTimer

public void createTimer()
Creates the timer for refreshing RSS feeds.


stopTimer

public void stopTimer()
Cancels the timer if the user switched to the OFFLINE status.


threadedContactFeedUpdate

public void threadedContactFeedUpdate(ContactRssImpl contact)
Retrieves the feeds for a new RSS feed just added as persistent contact.

Parameters:
contact - the Contact added

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 ICQ stack is not registered and initialized.
IllegalArgumentException - if to is not an instance belonging to the underlying implementation.

isOfflineMessagingSupported

public boolean isOfflineMessagingSupported()
Determines whether the protocol provider (or the protocol itself) supports 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 whether 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.

getParentProvider

public ProtocolProviderServiceRssImpl getParentProvider()
Returns the protocol provider that this operation set belongs to.

Returns:
a reference to the ProtocolProviderServiceRssImpl instance that this operation set belongs to.

getOpSetPersPresence

public OperationSetPersistentPresenceRssImpl getOpSetPersPresence()
Returns a reference to the presence operation set instance used by our source provider.

Returns:
a reference to the OperationSetPersistentPresenceRssImpl instance used by this provider.

registrationStateChanged

public void registrationStateChanged(RegistrationStateChangeEvent evt)
The method is called by the ProtocolProvider whenever a change in the registration state of the corresponding provider has occurred. We use it to start and stop the timer that periodically checks for RSS updates.

Specified by:
registrationStateChanged in interface RegistrationStateChangeListener
Parameters:
evt - ProviderStatusChangeEvent the event describing the status change.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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