org.walluck.oscar.client
Class AbstractOscarClient

java.lang.Object
  extended by org.walluck.oscar.client.AbstractOscarClient
All Implemented Interfaces:
EventListener, DaimBuddyListener, DaimLoginListener, DaimMsgListener

public class AbstractOscarClient
extends Object
implements DaimLoginListener, DaimMsgListener, DaimBuddyListener

Class AbstractOscarClient The easiest way to create an Oscar client is to extend this abstract class. This class listens on all the Oscar events available to clients, and provides default responses to them. For example, a file request by default is refused. The more methods you override, the more of the Oscar functionality becomes available to your client. If you use this class, you MUST call it's constructor. If you have a constructor in your own class, just call super(); as the first thing in it!

Since:
1.0
Version:
1.0
Author:
Alain Penders

Field Summary
protected  AdminTool admtool
           
protected  AdvertTool advtool
           
protected  BOSTool bostool
           
protected  BuddyListTool budtool
           
protected  ChatNavTool chntool
           
protected  ChatTool chttool
           
protected  ODirTool dirtool
           
protected  FileTransferTool filtool
           
protected  IconTool icotool
           
protected  ICQTool icqtool
           
protected  InviteTool invtool
           
protected  LocateTool loctool
           
protected  LoginTool logtool
           
protected  UserLookupTool loktool
           
protected  MailTool maltool
           
protected  MiscTool msctool
           
protected  ICBMTool msgtool
           
protected  PopupTool poptool
           
protected  AIMSession session
           
protected  SSITool ssitool
           
protected  StatsTool ststool
           
protected  ServiceTool svctool
           
protected  TranslateTool trntool
           
 
Constructor Summary
AbstractOscarClient()
           
 
Method Summary
 boolean addBuddy(String name, String group)
          Add a buddy to the buddy list.
 void buddyOffline(String sn, Buddy buddy)
          Called when a buddy goes offline.
 void buddyOnline(String sn, Buddy buddy)
          Called when a buddy goes online.
 void incomingICQ(UserInfo from, int uin, int args, String message)
          We received an ICQ message.
 void incomingIM(Buddy buddy, UserInfo from, AOLIM args)
          Called when a message is received from someone.
 void joinRoomRequest(JoinRoomRequest jrr)
          Someone requested us to join a chat room.
 void login(String screenname, String password)
          Log in using the provided screenname and password.
 void loginDone(DaimLoginEvent dle)
          Method called when the login is succesful.
 void loginError(DaimLoginEvent dle)
          Method called when a login login fails.
 void logout()
          Log out and close the connection.
 boolean moveBuddy(String name, String oldGroup, String newGroup)
          Move a Buddy to another buddy group.
 void newBuddyList(Buddy[] buddies)
          The server sent us our buddy list.
 void newUIN(DaimLoginEvent dle)
          Method called when a new UIN is assigned by the server (ICQ account registration).
 void receivedContacts(UserInfo from, int uin, Map contact, boolean massmessage)
          Received a list of contacts in an ICQ message

In the contact Map, the keys are UINs as Strings, and the values are the correcponding nick names.

 void receivedICQSMS(UserInfo from, int uin, ICQSMSMessage message, boolean massmessage)
          Received SMS message over ICQ
 void receivedURL(UserInfo from, int uin, String url, String description, boolean massmessage)
          Received an ICQ URL message
 boolean removeBuddy(String name, String group)
          Remove a buddy from the buddy list.
 boolean renameGroup(String oldGroup, String newGroup)
          Rename a group.
 void sendIM(String sn, String message, int imflags)
          Send an IM
 void typingNotification(String sn, short typing)
          Typing notification for a user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

session

protected AIMSession session

admtool

protected AdminTool admtool

advtool

protected AdvertTool advtool

bostool

protected BOSTool bostool

budtool

protected BuddyListTool budtool

chntool

protected ChatNavTool chntool

chttool

protected ChatTool chttool

filtool

protected FileTransferTool filtool

msgtool

protected ICBMTool msgtool

icotool

protected IconTool icotool

icqtool

protected ICQTool icqtool

invtool

protected InviteTool invtool

loctool

protected LocateTool loctool

logtool

protected LoginTool logtool

maltool

protected MailTool maltool

msctool

protected MiscTool msctool

dirtool

protected ODirTool dirtool

poptool

protected PopupTool poptool

svctool

protected ServiceTool svctool

ssitool

protected SSITool ssitool

ststool

protected StatsTool ststool

trntool

protected TranslateTool trntool

loktool

protected UserLookupTool loktool
Constructor Detail

AbstractOscarClient

public AbstractOscarClient()
Method Detail

login

public void login(String screenname,
                  String password)
           throws IOException
Log in using the provided screenname and password.

Parameters:
screenname -
password -
Throws:
IOException

logout

public void logout()
Log out and close the connection.


sendIM

public void sendIM(String sn,
                   String message,
                   int imflags)
            throws IOException
Send an IM

Parameters:
sn - Screen Name you're sending to.
message - Message to send
imflags - Flags. Only flag used is AIMConstant.AIM_IMFLAG_AWAY
Throws:
IOException - if an error occurs

addBuddy

public boolean addBuddy(String name,
                        String group)
                 throws IOException
Add a buddy to the buddy list.

Parameters:
name - Name of the buddy
group - Group to add him in
Returns:
true if the add is possible and was sent to the server.
Throws:
IOException - if an error occurs

moveBuddy

public boolean moveBuddy(String name,
                         String oldGroup,
                         String newGroup)
                  throws IOException
Move a Buddy to another buddy group.

Parameters:
name - Name of buddy to move
oldGroup - Old buddy group
newGroup - New buddy group
Returns:
true if the move is possible and sent to the server.
Throws:
IOException - if an error occurs

removeBuddy

public boolean removeBuddy(String name,
                           String group)
                    throws IOException
Remove a buddy from the buddy list. If the buddy doesn't exist in the Buddy list the server sent us, or the AIMSession is not in a state where the remove command can be sent, this method will return false, and the budddy will not be removed!

Parameters:
name - Screen name of buddy to remove.
group - Group the buddy belongs to.
Returns:
true if the buddy can be removed
Throws:
IOException - if an error occurs

renameGroup

public boolean renameGroup(String oldGroup,
                           String newGroup)
                    throws IOException
Rename a group.

Parameters:
oldGroup - Old name
newGroup - New name
Returns:
true if the group can be renamed and the request is sent to the server
Throws:
IOException - if an error occurs

loginError

public void loginError(DaimLoginEvent dle)
Method called when a login login fails.

AIMSession will be set with the session that failed. errorCode will be set with the failure error code. See AIMConstants.AIM_LOGINERROR_* for error codes.

Specified by:
loginError in interface DaimLoginListener
Parameters:
dle - DaimLoginEvent

loginDone

public void loginDone(DaimLoginEvent dle)
Method called when the login is succesful.

AIMSession will be set.

Specified by:
loginDone in interface DaimLoginListener
Parameters:
dle -

newUIN

public void newUIN(DaimLoginEvent dle)
Method called when a new UIN is assigned by the server (ICQ account registration).

AIMSession and UIN will be set.

Specified by:
newUIN in interface DaimLoginListener
Parameters:
dle -

incomingIM

public void incomingIM(Buddy buddy,
                       UserInfo from,
                       AOLIM args)
Called when a message is received from someone.

Use from.getSN() to get the buddy's ScreenName if Buddy is null.

Use args.getMsg() to get the message.

Specified by:
incomingIM in interface DaimMsgListener
Parameters:
buddy - Buddy who sent the message, or null if not created yet.
from - UserInfo
args -

joinRoomRequest

public void joinRoomRequest(JoinRoomRequest jrr)
Someone requested us to join a chat room.

To accept, call ChatTool.joinRoom() with the JoinRoomRequest instance.

Specified by:
joinRoomRequest in interface DaimMsgListener

typingNotification

public void typingNotification(String sn,
                               short typing)
Typing notification for a user.

Specified by:
typingNotification in interface DaimMsgListener
Parameters:
sn - Screen Name
typing - Typing code.

incomingICQ

public void incomingICQ(UserInfo from,
                        int uin,
                        int args,
                        String message)
We received an ICQ message. This is a regular IM message if type == AIMConstants.AIM_ICQMSG_NORMAL.

SMS, URL, and CONTACT type messages are handled with different methods.

Specified by:
incomingICQ in interface DaimMsgListener
Parameters:
from - UserInfo
uin - UIN#
args - Args. See AIMConstants.AIM_ICQMSG_*
message - Message.

receivedURL

public void receivedURL(UserInfo from,
                        int uin,
                        String url,
                        String description,
                        boolean massmessage)
Received an ICQ URL message

Specified by:
receivedURL in interface DaimMsgListener
Parameters:
from - UserInfo
uin - UIN#
url - URL
description - URL Description or null
massmessage - Is this a mass-message?

receivedContacts

public void receivedContacts(UserInfo from,
                             int uin,
                             Map contact,
                             boolean massmessage)
Received a list of contacts in an ICQ message

In the contact Map, the keys are UINs as Strings, and the values are the correcponding nick names.

Specified by:
receivedContacts in interface DaimMsgListener
Parameters:
from - UserInfo
uin - UIN#
contact - HashMap
massmessage - Is this a mass-message?

receivedICQSMS

public void receivedICQSMS(UserInfo from,
                           int uin,
                           ICQSMSMessage message,
                           boolean massmessage)
Received SMS message over ICQ

Specified by:
receivedICQSMS in interface DaimMsgListener
Parameters:
from - UserInfo
uin - UIN#
message - ICQSMSMessage
massmessage - Is this a mass-message?

newBuddyList

public void newBuddyList(Buddy[] buddies)
The server sent us our buddy list. (In general this list replaces everyone who was already in the buddy list.)

Specified by:
newBuddyList in interface DaimBuddyListener
Parameters:
buddies - Array of Buddy's

buddyOffline

public void buddyOffline(String sn,
                         Buddy buddy)
Called when a buddy goes offline.

Note: it's possible that this method gets called with buddy == null. Check for it!

Specified by:
buddyOffline in interface DaimBuddyListener
Parameters:
sn - ScreenName
buddy - Buddy

buddyOnline

public void buddyOnline(String sn,
                        Buddy buddy)
Called when a buddy goes online.

The buddy's attributes are all updated before this is called. If you cache them, you must update them as well!

Note: it's possible that this method gets called with buddy == null. Check for it!

Specified by:
buddyOnline in interface DaimBuddyListener
Parameters:
sn - ScreenName
buddy - Buddy