|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A protocol is a specific implementation of instant messaging services. Popular examples of instant messaging services are MSN, Yahoo!, NIM etc.
Hamsam provides an implementation independent way of dealing with protocols through this interface. Each of the protocols implements the methods in this interface, so that a user of Hamsam library can use these methods to talk to any protocol available.
This also makes Hamsam a plug-and-play library. The Protocol
interface along with the ProtocolManager
class, helps
to easily add new protocols, without any change to the source code. This
means that, if you have an application coded properly, you don't need to
change that code, as and when new versions of Hamsam library (with new
protocol additions) are released.
ProtocolManager
Method Summary | |
void |
addToBuddyList(Buddy buddy)
Add a buddy to your buddy list. |
void |
changeBuddyAlias(Buddy buddy,
java.lang.String alias)
Changes the alias of a buddy. |
void |
changeStatus(java.lang.String status)
Change the status message for the user logged in for this protocol. |
void |
connect(java.lang.String username,
java.lang.String password,
ProxyInfo info)
Connect to the instant messaging server. |
void |
deleteFromBuddyList(Buddy buddy)
Delete a buddy from your buddy list. |
void |
disconnect()
Disconnect from the instant messaging service. |
java.lang.String |
getProtocolName()
Returns the name of this protocol. |
SmileyComponent[] |
getSupportedSmileys()
Returns an array of all SmileyComponents supported by this protocol. |
java.lang.String[] |
getSupportedStatusMessages()
Returns an array of status messages supported by this protocol. |
void |
ignoreBuddy(Buddy buddy)
Prevent a buddy from sending you messages. |
boolean |
isBuddyAddRequestSupported()
Determines whether this protocol will notify you if a user attempts to add you to his / her buddy list. |
boolean |
isBuddyGroupSupported()
Determines whether this protocol supports arranging buddies in different groups. |
boolean |
isBuddyNameAliasSupported()
Determines whether this protocol supports buddy name aliases. |
boolean |
isConferenceSupported()
Determines whether this protocol supports conferences. |
boolean |
isIgnoreSupported()
Determines whether this protocol supports ignoring buddies. |
boolean |
isInvisibleSupported()
Determines whether this protocol supports setting the status of the user to invisible. |
boolean |
isMailNotifySupported()
Determines whether this protocol supports e-mail alerts. |
boolean |
isOfflineMessageSupported()
Determines whether this protocol supports sending and receiving offline messages. |
boolean |
isTypingNotifySupported()
Determines whether this protocol supports typing notifications. |
void |
quitConference(Conference conf)
Disconnect the current user from a conference. |
void |
sendConferenceMessage(Conference conf,
Message message)
Send a conference message. |
void |
sendInstantMessage(Buddy buddy,
Message message)
Send an instant message to a buddy. |
void |
setListener(IMListener listener)
Sets the listener for this protocol. |
void |
startConference(Conference conf,
java.lang.String message)
Start a new conference by inviting some buddies. |
void |
typingStarted(Buddy buddy)
Notify this buddy that you have started typing. |
void |
typingStopped(Buddy buddy)
Notify this buddy that you have stopped typing. |
void |
unignoreBuddy(Buddy buddy)
Undo a previous ignore operation for a buddy. |
Method Detail |
public void changeStatus(java.lang.String status) throws IllegalArgumentException, IllegalStateException
status
is null
, the status is changed
to invisible. If this protocol does not support invisible status,
it throws an IllegalArgumentException.
A protocol may support only a limited range of status messages. If you pass a status message which is not supported by the underlying protocol, it will throw an IllegalArgumentException. In order to get a complete list of supported status messages, use the getSupportedStatusMessages() method.
status
- the new status message.
IllegalArgumentException
- if status
is null and this
protocol does not support invisible status,
or the status message is invalid.
IllegalStateException
- if the protocol is not connected.isInvisibleSupported()
,
getSupportedStatusMessages()
public void connect(java.lang.String username, java.lang.String password, ProxyInfo info) throws IllegalStateException
username
- the user id to log in.password
- the password for authentication.info
- the proxy information explaining how to connect.
IllegalStateException
- if no listener is set using the
setListener
method.public void disconnect() throws IllegalStateException
IllegalStateException
- if the protocol is not connected.public java.lang.String getProtocolName()
public boolean isBuddyAddRequestSupported()
true
if this protocol supports buddy add notifications,
false
otherwise.public boolean isBuddyNameAliasSupported()
true
if this protocol supports buddy aliases,
false
otherwise.public boolean isBuddyGroupSupported()
true
if this protocol supports buddy groups,
false
otherwise.public boolean isIgnoreSupported()
true
if this protocol supports buddy ignore,
false
otherwise.public boolean isOfflineMessageSupported()
true
if this protocol supports offline messages,
false
otherwise.public boolean isTypingNotifySupported()
true
if this protocol supports typing notifications,
false
otherwise.public boolean isConferenceSupported()
true
if this protocol supports conferences,
false
otherwise.Conference
public boolean isMailNotifySupported()
true
if this protocol supports e-mail notifications,
false
otherwise.public boolean isInvisibleSupported()
true
if this protocol supports invisible status,
false
otherwise.public void setListener(IMListener listener)
listener
- the listener for this protocol, pass null
to unregister the current listener.public void startConference(Conference conf, java.lang.String message) throws UnsupportedOperationException, IllegalStateException
conf
- the conference which is to be started.message
- the invitation message to be sent.
UnsupportedOperationException
- if this protocol does not support
conferences.
IllegalStateException
- if the protocol is not yet connected.public void quitConference(Conference conf) throws UnsupportedOperationException, IllegalStateException
conf
- the conference from which the user has to disconnect.
UnsupportedOperationException
- if this protocol does not support
conferences.
IllegalStateException
- if the protocol is not yet connected.public void sendConferenceMessage(Conference conf, Message message) throws UnsupportedOperationException, IllegalStateException
conf
- the conference to which the message is to be sent.message
- the instant message to be sent.
UnsupportedOperationException
- if this protocol does not support
conferences.
IllegalStateException
- if the protocol is not yet connected.public void addToBuddyList(Buddy buddy) throws IllegalArgumentException, IllegalStateException
IMListener
.
buddy
- the buddy to be added.
IllegalArgumentException
- if the protocol supports buddy groups and the
group of the buddy is not specified.
IllegalStateException
- if the protocol is not yet connected.IMListener.buddyAddRequest
,
IMListener.buddyAdded
,
IMListener.buddyAddFailed
public void deleteFromBuddyList(Buddy buddy) throws IllegalArgumentException, IllegalStateException
IMListener
.
buddy
- the buddy to be deleted.
IllegalArgumentException
- if the protocol supports buddy groups and the
group of the buddy is not specified.
IllegalStateException
- if the protocol is not yet connected.IMListener.buddyDeleted
,
IMListener.buddyDeleteFailed
public void ignoreBuddy(Buddy buddy) throws UnsupportedOperationException, IllegalStateException
IMListener
.
buddy
- the buddy to be ignored.
UnsupportedOperationException
- if this protocol does not support ignoring buddies.
IllegalStateException
- if the protocol is not yet connected.IMListener.buddyIgnored
,
IMListener.buddyIgnoreFailed
public void unignoreBuddy(Buddy buddy) throws UnsupportedOperationException, IllegalStateException
IMListener
.
buddy
- the buddy to be ignored.
UnsupportedOperationException
- if this protocol does not support ignoring buddies.
IllegalStateException
- if the protocol is not yet connected.IMListener.buddyUnignored
,
IMListener.buddyUnignoreFailed
public void sendInstantMessage(Buddy buddy, Message message) throws IllegalStateException
buddy
- the buddy to whom the message should be sent.message
- the message to be sent.
IllegalStateException
- if the protocol is not yet connected.public void typingStarted(Buddy buddy) throws UnsupportedOperationException, IllegalStateException
buddy
- the buddy to whom the typing notification is to be sent.
UnsupportedOperationException
- if this protocol does not support
typing notifications.
IllegalStateException
- if the protocol is not yet connected.public void typingStopped(Buddy buddy) throws UnsupportedOperationException, IllegalStateException
buddy
- the buddy to whom the typing notification is to be sent.
UnsupportedOperationException
- if this protocol does not support
typing notifications.
IllegalStateException
- if the protocol is not yet connected.public SmileyComponent[] getSupportedSmileys()
public java.lang.String[] getSupportedStatusMessages()
null
is returned.
null
if this protocol supports any status message.public void changeBuddyAlias(Buddy buddy, java.lang.String alias) throws UnsupportedOperationException
buddy
- the buddy whose alias needs to be changed.alias
- the new alias of this buddy.
UnsupportedOperationException
- if this protocol does not support
buddy aliases.isBuddyNameAliasSupported()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |