org.walluck.oscar.handlers
Class ServiceHandler

java.lang.Object
  extended by org.walluck.oscar.handlers.SNACHandler
      extended by org.walluck.oscar.handlers.ServiceHandler

public class ServiceHandler
extends SNACHandler

Family 0x0001 - This is a very special group. All connections support this group, as it does some particularly good things (like rate limiting).

Since:
1.0
Version:
1.0
Author:
David Walluck
See Also:
SNACHandler

Constructor Summary
ServiceHandler()
          Family 0x0001.
 
Method Summary
 void clientReady(AIMSession sess, AIMConnection conn)
          Subtype 0x0002 - Client online.
 void handleSNAC(AIMSession sess, SNACHandler handler, AIMFrame frame, SNAC snac, AIMInputStream buffer)
          Handles incoming SNAC's.
 void nop(AIMSession sess, AIMConnection conn)
          Subtype 0x0016 - Nop.
 void ratesAddParam(AIMSession sess, AIMConnection conn)
          Subtype 0x0008 - Add rate parameters.
 void ratesDelParam(AIMSession sess, AIMConnection conn)
          Subtype 0x0009 - Delete rate parameters.
 void reqPersonalInfo(AIMSession sess, AIMConnection conn)
          Subtype 0x000e - Request self information.
 void reqService(AIMSession sess, AIMConnection conn, int serviceID)
          Subtype 0x0004 - Service request.
 void sendMemBlock(AIMSession sess, AIMConnection conn, int offset, int len, byte[] buf, int flag)
          Subtype 0x0020 - Client verification reply.
 void sendPauseAck(AIMSession sess, AIMConnection conn)
          Subtype 0x000c - Service Pause Acknowledgement.
 void setAvailableMsg(AIMSession sess, String msg, String enc)
          Subtype 0x001e - Extended Status.
 void setExtStatus(AIMSession sess, int status)
          Subtype 0x001e - Sets your ICQ status (available, away, do not disturb, etc.).
 void setIdle(AIMSession sess, int idleTime)
          Subtype 0x0011 - Idle Notification.
 void setPrivacyFlags(AIMSession sess, AIMConnection conn, int flags)
          Subtype 0x0014 - Set privacy flags.
 void setSecureIM(AIMSession sess)
          Subtype 0x0022 - Set SecureIM.
 
Methods inherited from class org.walluck.oscar.handlers.SNACHandler
getFamily, getVersion, setFamily, setVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceHandler

public ServiceHandler()
Family 0x0001.

Method Detail

clientReady

public void clientReady(AIMSession sess,
                        AIMConnection conn)
                 throws IOException
Subtype 0x0002 - Client online.

Parameters:
sess - the oscar session
conn - the connection
Throws:
IOException - if an error occurs

reqService

public void reqService(AIMSession sess,
                       AIMConnection conn,
                       int serviceID)
                throws IOException
Subtype 0x0004 - Service request.

Parameters:
sess - the oscar session
conn - the connection
serviceID - the service ID
Throws:
IOException - if an error occurs

ratesAddParam

public void ratesAddParam(AIMSession sess,
                          AIMConnection conn)
                   throws IOException
Subtype 0x0008 - Add rate parameters.

Parameters:
sess - the oscar session
conn - the connection
Throws:
IOException - if an error occurs

ratesDelParam

public void ratesDelParam(AIMSession sess,
                          AIMConnection conn)
                   throws IOException
Subtype 0x0009 - Delete rate parameters.

Parameters:
sess - the oscar session
conn - the connection
Throws:
IOException - if an error occurs

sendPauseAck

public void sendPauseAck(AIMSession sess,
                         AIMConnection conn)
                  throws IOException
Subtype 0x000c - Service Pause Acknowledgement.

It is rather important that sendPauseAck gets called for the exact same connection that Server Pause was called for, since we extract the & data for the SNAC from the connection structure.

Of course, if you don't do that, more bad things happen than just what we can cause here.

Parameters:
sess - the oscar session
conn - the connection
Throws:
IOException - if an error occurs

reqPersonalInfo

public void reqPersonalInfo(AIMSession sess,
                            AIMConnection conn)
                     throws IOException
Subtype 0x000e - Request self information.

Parameters:
sess - the oscar session
conn - the connection
Throws:
IOException - if an error occurs

setIdle

public void setIdle(AIMSession sess,
                    int idleTime)
             throws IOException
Subtype 0x0011 - Idle Notification.

This should set your current idle time in seconds. Note that this should never be called consecutively with a non-zero idle time. That makes OSCAR do funny things. Instead, just set it once you go idle, and then call it again with zero when you're back.

Parameters:
sess - the oscar session
idleTime - the idle time
Throws:
IOException - if an error occurs

setPrivacyFlags

public void setPrivacyFlags(AIMSession sess,
                            AIMConnection conn,
                            int flags)
                     throws IOException
Subtype 0x0014 - Set privacy flags.

Normally 0x03.

Bit 1
Allows other AIM users to see how long you've been idle.
Bit 2
Allows other AIM users to see how long you've been a member.

Parameters:
sess - the oscar session
conn - the connection
flags - the privacy flags
Throws:
IOException - if an error occurs
See Also:
AIMConstants

nop

public void nop(AIMSession sess,
                AIMConnection conn)
         throws IOException
Subtype 0x0016 - Nop.

WinAIM sends these every 4 minutes or so to keep the connection alive. It's not really necessary.

Parameters:
sess - the oscar session
conn - the connection
Throws:
IOException - if an error occurs

setExtStatus

public void setExtStatus(AIMSession sess,
                         int status)
                  throws IOException
Subtype 0x001e - Sets your ICQ status (available, away, do not disturb, etc.).

These are the same TLV's seen in user info. You can also set 0x0008 and 0x000c.

Parameters:
sess - the oscar session
status - the extended status
Throws:
IOException - if an error occurs

setAvailableMsg

public void setAvailableMsg(AIMSession sess,
                            String msg,
                            String enc)
                     throws IOException
Subtype 0x001e - Extended Status.

Sets your "available" message. This is currently only supported by iChat, gaim, and daim.

Parameters:
sess - the oscar session
msg - the "available" message
enc - the "available" message encoding
Throws:
IOException - if an error occurs

sendMemBlock

public void sendMemBlock(AIMSession sess,
                         AIMConnection conn,
                         int offset,
                         int len,
                         byte[] buf,
                         int flag)
                  throws IOException
Subtype 0x0020 - Client verification reply.

NOTE: If you need to make use of the sendMemBlock method, then the client information specified here is what you need to pull data from. Currently, we only internally support AIM 3.5, but we could use some additional versions.

Parameters:
sess - the oscar session
conn - the connection
offset - the offset
len - the length
buf - the buffer
flag - the flags
Throws:
IOException - if an error occurs
See Also:
AIMConstants

setSecureIM

public void setSecureIM(AIMSession sess)
                 throws IOException
Subtype 0x0022 - Set SecureIM.

The MD5 sum sent here appears to be a null checksum.

Parameters:
sess - the oscar session
Throws:
IOException - if an error occurs

handleSNAC

public void handleSNAC(AIMSession sess,
                       SNACHandler handler,
                       AIMFrame frame,
                       SNAC snac,
                       AIMInputStream buffer)
                throws IOException
Handles incoming SNAC's.

Specified by:
handleSNAC in class SNACHandler
Parameters:
sess - the oscar session
handler - the handler
frame - the incoming frame
snac - the incoming SNAC
buffer - the incoming buffer
Throws:
IOException - if an error occurs