|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IClient
Allows the user to interact with the IM server. Invokes the methods on IGateway to handle incoming messages and events.
IGateway
Field Summary | |
---|---|
static int |
AIM
The AOL Instant Messenger protocol. |
static String |
CONNECTION_CLOSED_REASON
The server has closed the client connection for some reason (for example, if the client's account has been suspended or deleted). |
static String |
DISCONNECT_REASON
The client was disconnected via the disconnect() method. |
static String |
FAILED_LOGIN_REASON
The login attempt failed for some reason. |
static int |
ICQ
The ICQ protocol. |
static int |
JABBER
The Jabber (XMPP) protocol. |
static int |
JSC
Zion's JBuddy Message Server (JSC) protocol. |
static int |
LCS
The Microsoft Live Communications Server protocol. |
static int |
MSN
The MSN Messenger protocol. |
static String |
NETWORK_ERROR_REASON
The connection was lost as a result of some network error (for example, the socket may have been forcefully closed as a result of a problem with the network, or the server may have closed our socket connection). |
static int |
PLAIN_TEXT
The plain text mode for receiving Instant Messages in plain text only. |
static int |
RICH_TEXT
The plain text mode for receiving Instant Messages in their native form. |
static int |
SAMETIME
The Lotus Instant Messaging (Sametime) protocol. |
static String |
SERVICE_TEMPORARILY_UNAVAILABLE_REASON
The server has closed the client connection because it is temporarily available or cannot currently accept any more logins. |
static String |
UNKNOWN_REASON
The connection was lost for an unknown reason. |
static String |
USER_BOOTED_REASON
The client has signed on at another location, therefore terminating the current connection. |
static int |
YIM
The Yahoo Messenger protocol. |
Method Summary | |
---|---|
boolean |
addBuddy(String name,
String nick,
String group)
This method modifies the local buddylist and informs the IM server that one wishes to receive periodic status messages on the online state of a given user. |
boolean |
addBuddyToList(IBuddy buddy,
IBuddyList blist)
This method modifies the local buddylist and informs the IM server that one wishes to receive periodic status messages on the online state of a given buddy. |
boolean |
addDeny(String name,
String nick,
String group)
This method informs the IM server that one wishes to disallow the given user from receiving periodic status messages on our online state. |
void |
addFileSessionInvitationListener(IFileSessionInvitationListener listener)
Adds a file session invitation listener. |
void |
addGateway(IGateway gateway)
Registers a gateway to receive incoming messages, presence and other events from this client. |
boolean |
addPermit(String name,
String nick,
String group)
This method informs the IM server that one wishes to allow the given user to receive periodic status messages on our online state. |
boolean |
connect()
Initiates the connection and signs on to the IM server. |
boolean |
connect(String host,
int port)
Initiates the connection and signs on to the IM server at the specified address. |
IFileSession |
createFileSession(String recipient,
File file)
Creates an outgoing file session. |
void |
disconnect()
Disconnects this client from the IM server. |
IBuddyList |
getBuddyList()
Returns a reference to this client's Buddy List. |
IConferenceService |
getConferenceService()
Returns this client's conference service. |
String |
getCustomAwayMessage()
Returns this client's custom away message. |
IBuddyList |
getDenyList()
Returns a reference to this client's Deny List. |
Date |
getIdleTimeStamp()
Returns the date and time this client went idle (from passing IDLE to setStatus ). |
String |
getName()
Returns this client's username. |
String |
getNickName()
Returns this client's nickname (display name). |
String |
getPassword()
Returns this client's password. |
IBuddyList |
getPermitList()
Returns a reference to this client's Permit List. |
int |
getPermitMode()
Returns this client's permit mode. |
int |
getPlainTextMode()
Returns this client's plain text mode for receiving Instant Messages. |
int |
getProtocol()
Returns this client's protocol. |
String |
getProtocolName()
Returns the name of this client's protocol. |
Date |
getSignOnTimeStamp()
Returns the date and time that this client signed on to the IM server. |
int |
getStatus()
Returns this client's current online status. |
String |
getStatusAsString()
Returns this client's current online status, represented as a printable string (currently in English). |
Date |
getStatusTimeStamp()
Returns the date and time of the last status change for this client (from the last call to setStatus). |
boolean |
isOnline()
Returns true if this client is connected to the IM server. |
boolean |
isSecure()
Returns true if this client is connected to the server, and the connection is secure. |
int |
numberOfMessagesReceived()
Returns the number of messages received by this client since it connected to the server. |
int |
numberOfMessagesSent()
Returns the number of messages sent by this client since it connected to the server. |
boolean |
removeBuddy(String name,
String group)
This method informs the IM server that one no longer wishes to receive periodic status messages on the online state of a given user. |
boolean |
removeBuddyFromList(IBuddy buddy,
IBuddyList blist)
This method modifies the local buddylist and informs the IM server that one no longer wishes to receive periodic status messages on the online state of a given buddy. |
boolean |
removeDeny(String name,
String group)
This method informs the IM server that one wishes to allow the given user to receive periodic status messages on our online state. |
void |
removeFileSessionInvitationListener(IFileSessionInvitationListener listener)
Removes a file session invitation listener. |
void |
removeGateway(IGateway gateway)
Stops a gateway from receiving incoming messages and events from this client. |
boolean |
removePermit(String name,
String group)
This method informs the IM server that one wishes to disallow the given user from receiving periodic status messages on our online state. |
void |
sendConfigToServer()
Saves buddy list, permit list, deny list, and permit mode changes to the server. |
boolean |
sendIM(String name,
String message)
Sends an instant message to a user. |
boolean |
sendMessage(IMessage message)
Sends an instant message to a user. |
boolean |
setKeepAliveInterval(int interval)
Sets the interval at which keep alive packets are automatically sent by this client. |
boolean |
setNickName(String nickName)
Sets this client's nickname (display name). |
boolean |
setPermitMode(int mode)
Sets this client's permit mode. |
int |
setPlainTextMode(int mode)
Sets this client's plain text mode for receiving Instant Messages. |
void |
setSecure(boolean isSecure,
boolean isRequired)
Specifies whether a secure connection to the server should be used. |
boolean |
setStatus(int status,
String customMessage)
Sets this client's availability status. |
Field Detail |
---|
static final int PLAIN_TEXT
IGateway.incomingMessage
is called.
setPlainTextMode(int)
,
Constant Field Valuesstatic final int RICH_TEXT
setPlainTextMode(int)
,
Constant Field Valuesstatic final int AIM
static final int ICQ
static final int MSN
static final int YIM
static final int JABBER
static final int SAMETIME
static final int LCS
static final int JSC
static final String CONNECTION_CLOSED_REASON
IGateway.connectionLost(com.zion.jbuddy.IClient, java.lang.String)
,
Constant Field Valuesstatic final String DISCONNECT_REASON
disconnect()
method.
IGateway.connectionLost(com.zion.jbuddy.IClient, java.lang.String)
,
Constant Field Valuesstatic final String FAILED_LOGIN_REASON
IGateway.connectionLost(com.zion.jbuddy.IClient, java.lang.String)
,
Constant Field Valuesstatic final String NETWORK_ERROR_REASON
IGateway.connectionLost(com.zion.jbuddy.IClient, java.lang.String)
,
Constant Field Valuesstatic final String SERVICE_TEMPORARILY_UNAVAILABLE_REASON
IGateway.connectionLost(com.zion.jbuddy.IClient, java.lang.String)
,
Constant Field Valuesstatic final String USER_BOOTED_REASON
IGateway.connectionLost(com.zion.jbuddy.IClient, java.lang.String)
,
Constant Field Valuesstatic final String UNKNOWN_REASON
IGateway.connectionLost(com.zion.jbuddy.IClient, java.lang.String)
,
Constant Field ValuesMethod Detail |
---|
String getName()
String getNickName()
Valid for AIM, ICQ, MSN, SAMETIME.
boolean setNickName(String nickName) throws IOException
This is typically set when the client is created through IClientFactory, and is not guaranteed to be unique within this client's protocol. The nickname change may only last for the given session, depending on the protocol.
Valid for AIM, ICQ, MSN.
IOException
- if there is a problem communicating with the serverString getPassword()
String getProtocolName()
int getProtocol()
IBuddyList getBuddyList()
All instant messaging programs utilize the concept of having a list of buddies (or "friends") for which the user can detect online presence. This eases communication with other users. In JBuddy, we call this a "Buddy List".
The Buddy List will be populated by the IClient during the connection process. Therefore, you may add any users stored locally before calling connect().
IBuddyList getPermitList()
Many instant messaging programs have the ability to allow only a certain set of users to be aware of our online presence and/or send us instant messages. In JBuddy we call this the "Permit List".
The Permit List will be populated by the IClient during the connection process. Therefore, you may add any users stored locally before calling connect().
Valid for AIM, JABBER, JSC, MSN, SAMETIME.
IBuddyList getDenyList()
Many instant messaging programs have the ability to block a certain set of users from being aware of our online presence and/or sending us instant messages. In JBuddy we call this the "Deny List".
The Deny List will be populated by the IClient during the connection process. Therefore, you may add any users stored locally before calling connect().
boolean setPermitMode(int mode) throws IOException
A denied user (a user denied as a result of the permit mode) can not send messages to the client, or receive presence updates from the client (it will appear as if the client is offline to the user). Depending on the protocol, the client may not be able to send messages to the user, or receive presence updates from the user (it will appear as if the user is offline to the client).
The following are prevented when a user is denied.
"Incoming" means from the user to the client.
"Outgoing" means from the client to the user.
"All" means both incoming and outgoing.
Since JBuddy 2.0, AIM and ICQ clients must call sendConfigToServer() for
the changes to be saved to the server. This also requests buddy
presence and applies privacy settings.
Since JBuddy 2.4, JABBER clients must call sendConfigToServer() for the changes to be saved to the server. This also applies privacy settings.
IOException
- if there was a problem communicating with the serverPERMIT_ALL
,
PERMIT_SOME
,
DENY_ALL
,
DENY_SOME
,
IAimClient.sendConfigToServer()
,
IIcqClient.sendConfigToServer()
,
IJabberClient.sendConfigToServer()
int getPermitMode()
PERMIT_ALL
,
PERMIT_SOME
,
DENY_ALL
,
DENY_SOME
IConferenceService getConferenceService() throws IOException
Valid for AIM, ICQ, JABBER, LCS, MSN, SAMETIME, YIM.
IOException
- if this client does not support conferencing,
or some other problem occurredvoid addGateway(IGateway gateway)
void removeGateway(IGateway gateway)
boolean connect() throws IOException
You should wait until isOnline()
returns true
before using this client.
IOException
- if there was a problem connecting to the serverboolean connect(String host, int port) throws IOException
You should wait until isOnline()
returns true
before using this client.
IOException
- if there was a problem connecting to the servervoid disconnect()
boolean setKeepAliveInterval(int interval)
interval
- the interval, in seconds. If this is a positive value,
keep alives will be sent for this client. Otherwise,
they will not.
boolean isOnline()
int numberOfMessagesSent()
int numberOfMessagesReceived()
IGateway.incomingMessage(com.zion.jbuddy.IClient, com.zion.jbuddy.IMessage)
boolean sendIM(String name, String message) throws IOException
If the message is null and this client's status is something other than ONLINE (but not OFFLINE), the custom away message (if it has been set with setStatus()) will be sent as an auto response message to the user. In AIM and ICQ, this turns on an auto response flag for the recipient to see.
name
- the unique name for the person you are sending the instant
message tomessage
- the text of the message you wish to send
IOException
- if there is a problem communicating with the serverboolean sendMessage(IMessage message) throws Exception
Use this method instead of sendIM(name, message)
to send
messages with special types (including AUTO_RESPONSE, TYPING, etc).
message
- the specified message
Exception
- if there is a problem communicating with the serverIMessageFactory.factory(int, IClient, String, String)
,
IMessageFactory.factory(int, IClient, String, com.zion.jbuddy.richcontent.RichContent)
int getPlainTextMode()
Many protocols allow markup such as HTML or ASCII tags to be included in an Instant Message, to enhance content. Depending on the situation, these tags may not be desirable.
The default mode is PLAIN_TEXT.
PLAIN_TEXT
,
RICH_TEXT
int setPlainTextMode(int mode) throws Exception
Many protocols allow markup such as HTML or ASCII tags to be included in an Instant Message, to enhance content. Depending on the situation, these tags may not be desirable.
Exception
- if the specified mode is invalidPLAIN_TEXT
,
RICH_TEXT
void setSecure(boolean isSecure, boolean isRequired)
Valid for AIM, ICQ, JABBER, JSC, LCS.
This method will do nothing if it is called on a client that doesn't support TLS connections.
isSecure
- whether a secure connection to the server should be
used. If this is true, when connecting, a TLS
connection will be opened with the server.isRequired
- whether a secure connection to the server is required.
If isSecure and isRequired are both true, connect()
will only succeed if a secure connection was
successfully established.boolean isSecure()
Valid for AIM, ICQ, JABBER, JSC, LCS.
boolean setStatus(int status, String customMessage) throws IOException
To go idle (if the protocol supports it), set the status to
IDLE
.
A protocol may support being idle at the same time as another status
(for example, AWAY and IDLE at the same time).
If this is the case, going idle will not change the client's status to
IDLE (the client's current status will be preserved).
Otherwise, the client's status will be changed to IDLE.
To return from an idle state, set any other status type.
If you set the status to INVISIBLE
(and the
protocol supports it), the client will appear to users as being OFFLINE.
To go OFFLINE
, the preferred method is to call
the client's disconnect
method, although setting the
status to OFFLINE will also disconnect the client.
The various Instant Messaging protocols each have their own ways of
specifying that the user has stepped away from their computer or is not
available for some reason. This method tries to handle all of the
various ways of doing this. For that reason, each of the various APIs
may not use both of the parameters to this method, or may use them in
different ways:
AIM Clients
ICQ Clients
JABBER Clients
JSC Clients
MSN Clients
SAMETIME Clients
YIM Clients
status
- the status type.
See IBuddy
for available status types.customMessage
- the custom message
IOException
- if there is a problem communicating with the serverIBuddy
int getStatus()
String getStatusAsString()
Date getStatusTimeStamp()
Date getIdleTimeStamp()
IDLE
to setStatus
).
Date getSignOnTimeStamp()
String getCustomAwayMessage()
sendIM(String, String)
void sendConfigToServer() throws IOException
This is convenience method. This can be called on any IClient. Only those client types that implement this method (currently only IAimClient, IIcqClient, and IJabberClient) will actually do any work. Other clients automatically send config changes to the server.
IOException
- if there is a problem communicating with the serverboolean addBuddyToList(IBuddy buddy, IBuddyList blist) throws IOException
In some IM protocols the other user may be able to block you from receiving this information.
Since JBuddy 2.0, AIM and ICQ clients must call sendConfigToServer() for the changes to be saved to the server. This also requests buddy presence and applies privacy settings.
Since JBuddy 2.4, JABBER clients must call sendConfigToServer() for the changes to be saved to the server. This also applies privacy settings.
buddy
- the unique buddy for the person whom you wish to receive
periodic status messages onblist
- the list to add buddy to
IOException
- if there was some problem communicating with the IM
serversendConfigToServer()
boolean removeBuddyFromList(IBuddy buddy, IBuddyList blist) throws IOException
Since JBuddy 2.0, AIM and ICQ clients must call sendConfigToServer() for the changes to be saved to the server. This also requests buddy presence and applies privacy settings.
Since JBuddy 2.4, JABBER clients must call sendConfigToServer() for the changes to be saved to the server. This also applies privacy settings.
buddy
- the unique buddy for the person whom you no longer wish to
receive periodic status messages onblist
- the list to remove buddy from. If the user is in multiple
groups in your Buddy List, you must remove all
individually. The IM server will stop sending periodic
status updates after the last occurrence of this buddy
is removed from the list.
IOException
- if there was some problem communicating with the IM
serversendConfigToServer()
boolean addBuddy(String name, String nick, String group) throws IOException
In some IM protocols, the other user may be able to block you from receiving this information.
Since JBuddy 2.0, AIM and ICQ clients must call sendConfigToServer() for the changes to be saved to the server. This also requests buddy presence and applies privacy settings.
name
- the unique user name for the person whom you wish to receive
periodic status messages onnick
- the nickname to reference this user. If null, a default
nickname will be chosen.group
- the name of the group in your Buddy List to which you wish
to add the user. If the group specified does not exist, it
will be created.
IOException
- if there was some problem communicating with the IM
serversendConfigToServer()
boolean removeBuddy(String name, String group) throws IOException
Since JBuddy 2.0, AIM and ICQ clients must call sendConfigToServer() for the changes to be saved to the server. This also requests buddy presence and applies privacy settings.
name
- the unique user name for the person whom you no longer wish
to receive periodic status messages ongroup
- the name of the group in your buddy list that this user is
currently in. If the user is in multiple groups in your
Buddy List, you must remove all individually. The IM
server will stop sending periodic status updates after the
last occurrence of this buddy (screenname) is removed from
the list.
IOException
- if there was some problem communicating with the IM
serversendConfigToServer()
boolean addPermit(String name, String nick, String group) throws IOException
Since JBuddy 2.0, AIM and ICQ clients must call sendConfigToServer() for the changes to be saved to the server. This also requests buddy presence and applies privacy settings.
Since JBuddy 2.4, JABBER clients must call sendConfigToServer() for the changes to be saved to the server. This also applies privacy settings.
Valid for AIM, JABBER, JSC, LCS, MSN, SAMETIME.
name
- the unique user name for the person whom you wish to add to
your Permit Listnick
- the nickname to reference this usergroup
- the name of the group in your Permit List which you wish to
add the user to. If the group specified does not exist, it
will be created.
IOException
- if there was some problem communicating with the IM
serversendConfigToServer()
boolean removePermit(String name, String group) throws IOException
Since JBuddy 2.0, AIM and ICQ clients must call sendConfigToServer() for the changes to be saved to the server. This also requests buddy presence and applies privacy settings.
Since JBuddy 2.4, JABBER clients must call sendConfigToServer() for the changes to be saved to the server. This also applies privacy settings.
Valid for AIM, JABBER, JSC, LCS, MSN, SAMETIME.
name
- the unique user name for the person whom you wish to remove
from your Permit Listgroup
- the name of the group in your Permit List that this user is
currently in. If the user is in multiple groups in your
Permit List, you must remove all individually. The IM
server will stop sending periodic status updates after the
*first* call to removePermit().
IOException
- if there was some problem communicating with the IM
serversendConfigToServer()
boolean addDeny(String name, String nick, String group) throws IOException
Since JBuddy 2.0, AIM and ICQ clients must call sendConfigToServer() for the changes to be saved to the server. This also requests buddy presence and applies privacy settings.
Since JBuddy 2.4, JABBER clients must call sendConfigToServer() for the changes to be saved to the server. This also applies privacy settings.
name
- the unique user name for the person whom you wish to add to
your Deny Listnick
- the nickname to reference this usergroup
- the name of the group in your Deny List which you wish to
add the user to. If the group specified does not exist, it
will be created.
IOException
- if there was some problem communicating with the IM
serversendConfigToServer()
boolean removeDeny(String name, String group) throws IOException
Since JBuddy 2.0, AIM and ICQ clients must call sendConfigToServer() for the changes to be saved to the server. This also requests buddy presence and applies privacy settings.
Since JBuddy 2.4, JABBER clients must call sendConfigToServer() for the changes to be saved to the server. This also applies privacy settings.
name
- the unique user name for the person whom you wish to remove
from your Deny Listgroup
- the name of the group in your Deny List that this user is
currently in. If the user is in multiple groups in your
Deny List, you must remove all individually. The IM server
will start sending periodic status updates again after the
*first* call to removeDeny().
IOException
- if there was some problem communicating with the IM
serversendConfigToServer()
IFileSession createFileSession(String recipient, File file) throws IOException
IOException
- if file transfer is not supported by this protocol,
the file was not found, or another problem occurredvoid addFileSessionInvitationListener(IFileSessionInvitationListener listener)
void removeFileSessionInvitationListener(IFileSessionInvitationListener listener)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |