org.walluck.oscar.tools
Class BuddyListTool

java.lang.Object
  extended by org.walluck.oscar.tools.Tool
      extended by org.walluck.oscar.tools.BuddyListTool
All Implemented Interfaces:
BuddyListListener, Listener

public class BuddyListTool
extends Tool
implements BuddyListListener

BuddyList tool.

Since:
1.0
Version:
1.0
Author:
David Walluck

Field Summary
static int UC_AB
           
static int UC_ADMIN
           
static int UC_AOL
           
static int UC_HIPTOP
           
static int UC_NORMAL
           
static int UC_UNAVAILABLE
           
static int UC_UNCONFIRMED
           
static int UC_WIRELESS
           
 
Fields inherited from class org.walluck.oscar.tools.Tool
listeners
 
Constructor Summary
BuddyListTool()
          Creates a new BuddyList tool.
 
Method Summary
 boolean addBuddy(String name, String group)
          Add a buddy to the buddy list.
 void addListener(DaimBuddyListener l)
          Add a listener to get useful events from this tool.
 void bosConnectionAvailable()
          Method called by the LoginTool once the BOS connection is available.
 void buddyChange(AIMSession sess, AIMFrame frame, UserInfo info)
          Describe buddyChange method here.
 void buddylistRights(AIMSession sess, AIMFrame frame, int maxbuddies, int maxwatchers)
          Describe buddylistRights method here.
static String capsToText(int caps)
          Print user capabilities as text.
 Buddy findBuddy(String sn)
          Find a Buddy by name.
 Buddy findBuddy(String name, BuddyGroup bg)
          Find a buddy by name in a specific group
 BuddyGroup findGroupForBuddy(String sn)
          Find a BuddyGroup by a buddy.
 ArrayList getBuddyGroups()
          Describe getBuddyGroups method here.
 boolean moveBuddy(String name, String oldGroup, String newGroup)
          Move a Buddy to another buddy group.
 void printBuddyList()
          Describe printBuddyList method here.
 boolean removeBuddy(String name, String group)
          Remove a buddy from the buddy list.
 void removeListener(DaimBuddyListener l)
          Remove a listener.
 boolean renameGroup(String oldGroup, String newGroup)
          Rename a group.
 void shutdown(AIMSession sess)
          Called when the tool is shutting down.
 Buddy[] ssiSetBuddyList(List list)
          Set the buddy list/

Called by SSITool when the server sends us the server-side buddylist.

 
Methods inherited from class org.walluck.oscar.tools.Tool
getFamily, getId, getSession, getToolData, getVersion, setFamily, setId, setSession, setToolData, setVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UC_UNAVAILABLE

public static final int UC_UNAVAILABLE
See Also:
Constant Field Values

UC_AOL

public static final int UC_AOL
See Also:
Constant Field Values

UC_ADMIN

public static final int UC_ADMIN
See Also:
Constant Field Values

UC_UNCONFIRMED

public static final int UC_UNCONFIRMED
See Also:
Constant Field Values

UC_NORMAL

public static final int UC_NORMAL
See Also:
Constant Field Values

UC_AB

public static final int UC_AB
See Also:
Constant Field Values

UC_WIRELESS

public static final int UC_WIRELESS
See Also:
Constant Field Values

UC_HIPTOP

public static final int UC_HIPTOP
See Also:
Constant Field Values
Constructor Detail

BuddyListTool

public BuddyListTool()
Creates a new BuddyList tool. Family 0x0003.

Method Detail

getBuddyGroups

public ArrayList getBuddyGroups()
Describe getBuddyGroups method here.

Returns:
a ArrayList value

ssiSetBuddyList

public Buddy[] ssiSetBuddyList(List list)
Set the buddy list/

Called by SSITool when the server sends us the server-side buddylist.

DO NOT USE THIS FROM CLIENT CODE!

Parameters:
list - List of SSIItems
Returns:
Buddy array for further processing

printBuddyList

public void printBuddyList()
Describe printBuddyList method here.


findBuddy

public Buddy findBuddy(String name,
                       BuddyGroup bg)
Find a buddy by name in a specific group

Parameters:
name - the buddy name
bg - the group
Returns:
Buddy or null

findBuddy

public Buddy findBuddy(String sn)
Find a Buddy by name.

Parameters:
sn - the screenname of the buddy
Returns:
the buddy or null

findGroupForBuddy

public BuddyGroup findGroupForBuddy(String sn)
Find a BuddyGroup by a buddy.

Parameters:
sn - the screenname of the buddy
Returns:
the group

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

buddyChange

public void buddyChange(AIMSession sess,
                        AIMFrame frame,
                        UserInfo info)
Describe buddyChange method here.

Specified by:
buddyChange in interface BuddyListListener
Parameters:
sess - an AIMSession value
frame - an AIMFrame value
info - an UserInfo value

capsToText

public static String capsToText(int caps)
Print user capabilities as text.

Parameters:
caps - the capabilities
Returns:
the string

buddylistRights

public void buddylistRights(AIMSession sess,
                            AIMFrame frame,
                            int maxbuddies,
                            int maxwatchers)
Describe buddylistRights method here.

Specified by:
buddylistRights in interface BuddyListListener
Parameters:
sess - an AIMSession value
frame - an AIMFrame value
maxbuddies - an int value
maxwatchers - an int value

shutdown

public void shutdown(AIMSession sess)
Called when the tool is shutting down.

Specified by:
shutdown in class Tool
Parameters:
sess - the oscar session

bosConnectionAvailable

public void bosConnectionAvailable()
Method called by the LoginTool once the BOS connection is available. This allows the other tools to get registered and get involved in the process.

Specified by:
bosConnectionAvailable in class Tool

addListener

public void addListener(DaimBuddyListener l)
Add a listener to get useful events from this tool.

Parameters:
l - DaimBuddyListener

removeListener

public void removeListener(DaimBuddyListener l)
Remove a listener.

Parameters:
l - DaimBuddyListener