public class ICBMHandler extends SNACHandler
Note the term ICBM (Inter-Client Basic Message) blankets all types of genericly routed through-server messages. Within the ICBM types (family 0x0004), a channel is defined. Each channel represents a different type of message. Channel 1 is used for what would commonly be called an "instant message". Channel 2 is used for negotiating "rendezvous". These transactions end in something more complex happening, such as a chat invitation, or a file transfer. Channel 4 is used for various ICQ messages.
In addition to the channel, every ICBM contains a cookie. For standard IM's, these are only used for error messages. However, the more complex rendezvous messages make suitably more complex use of this field.
SNACHandler
Constructor and Description |
---|
ICBMHandler()
Family 0x0004.
|
Modifier and Type | Method and Description |
---|---|
void |
clientAutoresp(AIMSession sess,
SNACHandler handler,
AIMFrame frame,
SNAC snac,
AIMInputStream buffer)
Subtype 0x000b - Client auto-response.
|
void |
delICBMParams(AIMSession sess)
Delete ICBM parameter information.
|
int |
fingerprintClient(byte[] msghdr)
Takes a msghdr (and a length) and returns a client type
code.
|
void |
handleSNAC(AIMSession sess,
SNACHandler handler,
AIMFrame frame,
SNAC snac,
AIMInputStream buffer)
Handles incoming SNAC's.
|
void |
incomingIMCH4(AIMSession sess,
SNACHandler handler,
AIMFrame frame,
SNAC snac,
int channel,
UserInfo userinfo,
TLVChain tlvchain,
byte[] cookie)
Incoming IM (Channel 4).
|
void |
reqICBMParams(AIMSession sess)
Subtype 0x0004 - Request ICBM parameter information.
|
void |
sendCH1(AIMSession sess,
String destSN,
int flags,
String msg)
Simple wrapper for sendIMExt.
|
void |
sendCH1Ext(AIMSession sess,
AOLIM args)
Subtype 0x0006 - Send an ICBM (instant message).
|
void |
sendCH4(AIMSession sess,
String sn,
int type,
String message)
Subtype 0x0006 - Send an ICQ-esque ICBM.
|
void |
sendMtn(AIMSession sess,
String sn,
int typing)
Send a mock typing notification.
|
void |
sendRendezvous(AIMSession sess,
String sn,
Rendezvous rv)
Send a rendezvous message.
|
void |
setICBMParams(AIMSession sess,
ICBMParams params)
Subtype 0x0002 - Set ICBM parameters.
|
void |
warn(AIMSession sess,
AIMConnection conn,
String destsn,
int flags)
Send a warning.
|
getFamily, getVersion, setFamily, setVersion
public int fingerprintClient(byte[] msghdr)
Takes a msghdr (and a length) and returns a client type code. Note that this is only a guess and has a low likelyhood of actually being accurate.
Example fingerprints:
Note that in this function, only the feature bytes are tested, since the rest will always be the same.
msghdr
- the message headerAIMConstants
public void setICBMParams(AIMSession sess, ICBMParams params) throws IOException
I definitely recommend sending this. If you don't, you'll be stuck with the rather unreasonable defaults. You don't want those. Send this.
sess
- the oscar sessionparams
- the icbm parametersIOException
- if an error occurspublic void reqICBMParams(AIMSession sess) throws IOException
sess
- the oscar sessionIOException
- if an error occurspublic void sendCH1Ext(AIMSession sess, AOLIM args) throws IOException
Possible flags in AIMConstants
:
Note that AIM_IMFLAGS_ACK
and
AIM_SESS_FLAGS_DONTTIMEOUTONICBM
will cause problems when
used together. if AIM_SESS_FLAGS_DONTTIMEOUTONICBM
is set,
the SNAC will not be cached, even if you set for the message
AIM_IM_FLAGS_ACK
.
Generally, you should use the lowest encoding possible to send your message. If you only use basic punctuation and the generic Latin alphabet, use ASCII7 (no flags). If you happen to use non-ASCII7 characters, but they are all clearly defined in ISO-8859-1, then use that. Keep in mind that not all characters in the PC ASCII8 character set are defined in the ISO standard. For those cases (most notably when the (R) symbol is used), you must use the full UNICODE encoding for your message. In UNICODE mode, _all_ characters must occupy 16bits, including ones that are not special. (Remember that the first 128 UNICODE symbols are equivelent to ASCII7, however they must be prefixed with a zero high order byte.)
I strongly discourage the use of UNICODE mode, mainly because none of the clients I use can parse those messages (and besides that, wchars are difficult and non-portable to handle in most UNIX environments). If you really need to include special characters, use the HTML UNICODE entities. These are of the form ߪ where 2026 is the hex representation of the UNICODE index (in this case, UNICODE "Horizontal Ellipsis", or 133 in in ASCII8).
Implementation note: Since this is one of the most-used functions in any IM client, it is written with performance in mind. As such, it is not as clear as it could be in respect to how this message is supposed to be layed out. Most obviously, tlv chains should be used instead of writing out the bytes manually.
sess
- the oscar sessionargs
- the AOL IM argsIOException
- if an error occurspublic void sendCH1(AIMSession sess, String destSN, int flags, String msg) throws IOException
You cannot use sendIM if you need the HASICON
flag. You
must use sendIMExt
directly for that.
sendIM
also cannot be used if you require UNICODE
messages, because that requires an explicit message length. Use
sendIMExt
.
sess
- the oscar sessiondestSN
- the destination screennameflags
- the message flagsmsg
- the ASCII encoded messageIOException
- if an error occurspublic void sendRendezvous(AIMSession sess, String sn, Rendezvous rv) throws IOException
sess
- the oscar sessionsn
- the screennamerv
- the rendezvous to sendIOException
- if an error occurspublic void sendCH4(AIMSession sess, String sn, int type, String message) throws IOException
This can be used to send an ICQ authorization reply (deny or grant). It is the "old way." The new way is to use SSI. I like the new way a lot better. This seems like such a hack mostly because it's in network byte order. Figuring this stuff out sometimes takes a while, but that's ok, because it gives me time to try to figure out what kind of drugs the AOL people were taking when they merged the two protocols.
sess
- the oscar sessionsn
- the destination screen nametype
- the type of message, 0x0007 for authorization denied and
0x0008 for authorization grantedmessage
- the message you want to send, it should be null
terminated.IOException
- if an error occurspublic void incomingIMCH4(AIMSession sess, SNACHandler handler, AIMFrame frame, SNAC snac, int channel, UserInfo userinfo, TLVChain tlvchain, byte[] cookie) throws IOException
sess
- the oscar sessionhandler
- the handlerframe
- the incoming framesnac
- the incoming SNACchannel
- the channeluserinfo
- user informationtlvchain
- TLV chaincookie
- the cookieIOException
- if an error occurspublic void warn(AIMSession sess, AIMConnection conn, String destsn, int flags) throws IOException
Flags:
sess
- the oscar sessionconn
- the bos connection for this sessiondestsn
- the screenname to warnflags
- the warning flagsIOException
- if an error occursAIMConstants
public void clientAutoresp(AIMSession sess, SNACHandler handler, AIMFrame frame, SNAC snac, AIMInputStream buffer) throws IOException
Receive the response from an ICQ status message request. This contains the ICQ status message.
sess
- the oscar sessionhandler
- the handlerframe
- the incoming framesnac
- the incoming SNACbuffer
- the incoming bufferIOException
- if an error occurspublic void sendMtn(AIMSession sess, String sn, int typing) throws IOException
MacAIM implements a typing notification that does not require a direct connection. When you begin typing, you send the "begin typing" message (type 0x0002). A few seconds later you send a "text has been typed" message (type 0x0001). After the message has been sent you send a "no more text has been typed" message (type 0x000).
The client and server SNAC's use the same subtype. Go figure.
sess
- the oscar sessionsn
- the screennametyping
- what typing state we are in when this message is sentIOException
- if an error occurspublic void delICBMParams(AIMSession sess) throws IOException
sess
- the oscar sessionIOException
- if an error occurspublic void handleSNAC(AIMSession sess, SNACHandler handler, AIMFrame frame, SNAC snac, AIMInputStream buffer) throws IOException
handleSNAC
in class SNACHandler
sess
- the oscar sessionhandler
- the handlerframe
- the incoming framesnac
- the incoming SNACbuffer
- the incoming bufferIOException
- if an error occurs