/** * Creates a new service request command requesting the given SNAC family and providing the given * chat room information block. While <code>snacFamily</code> should normally be {@link * ChatCommand#FAMILY_CHAT} if a room information block is sent, if you really want to you can * make it whatever you want. * * @param snacFamily the SNAC family being requested * @param roomInfo a chat room information block representing the room being joined */ public ServiceRequest(int snacFamily, MiniRoomInfo roomInfo) { super(CMD_SERVICE_REQ); DefensiveTools.checkRange(snacFamily, "snacFamily", 0); this.family = snacFamily; this.roomInfo = roomInfo; }
/** * Generates a new set-ICBM-parameter-information command from the given incoming SNAC packet. * * @param packet an incoming set-ICBM-parameters packet */ protected SetParamInfoCmd(SnacPacket packet) { super(CMD_SET_PARAM_INFO); DefensiveTools.checkNull(packet, "packet"); ByteBlock snacData = packet.getData(); paramInfo = ParamInfo.readParamInfo(snacData); }
/** * Generates a new item-based command from the given incoming SNAC packet. * * @param command the SNAC command subtype for this command * @param packet an incoming item-based command packet */ protected ItemsCmd(int command, SnacPacket packet) { super(command); DefensiveTools.checkNull(packet, "packet"); ByteBlock block = packet.getData(); List<SsiItem> itemList = new ArrayList<SsiItem>(); for (; ; ) { SsiItem item = SsiItem.readSsiItem(block); if (item == null) break; itemList.add(item); block = block.subBlock(item.getTotalSize()); } items = DefensiveTools.getUnmodifiable(itemList); }
/** * A SNAC command factory for the client-bound SNAC commands provided in this package, appropriate * for use in an AIM client. */ public class ClientMailCheckCmdFactory implements SnacCmdFactory { /** The supported SNAC command types. */ protected static final List<CmdType> SUPPORTED_TYPES = DefensiveTools.asUnmodifiableList( new CmdType(MailCheckCmd.FAMILY_MAILCHECK, MailCheckCmd.CMD_UPDATE)); public List<CmdType> getSupportedTypes() { return SUPPORTED_TYPES; } public SnacCommand genSnacCommand(SnacPacket packet) { if (packet.getFamily() != MailCheckCmd.FAMILY_MAILCHECK) return null; int command = packet.getCommand(); if (command == MailCheckCmd.CMD_UPDATE) { return new MailUpdate(packet); } else { return null; } } }
/** * Generates a new service request command from the given incoming SNAC packet. * * @param packet the incoming service request packet */ protected ServiceRequest(SnacPacket packet) { super(CMD_SERVICE_REQ); DefensiveTools.checkNull(packet, "packet"); ByteBlock snacData = packet.getData(); family = BinaryTools.getUShort(snacData, 0); ByteBlock tlvBlock = snacData.subBlock(2); TlvChain chatChain = TlvTools.readChain(tlvBlock); Tlv chatInfoTlv = chatChain.getLastTlv(TYPE_ROOM_INFO); if (chatInfoTlv != null) { ByteBlock chatBlock = chatInfoTlv.getData(); roomInfo = MiniRoomInfo.readMiniRoomInfo(chatBlock); } else { roomInfo = null; } }
/** * Generates a new SSI activation command from the given incoming SNAC packet. * * @param packet an incoming SSI activation packet */ protected ActivateSsiCmd(SnacPacket packet) { super(CMD_ACTIVATE); DefensiveTools.checkNull(packet, "packet"); }
/** * Creates a new outgoing item-based command with the given list of items. * * @param command the SNAC command subtype for this command * @param items the list of items to send in this commnad */ protected ItemsCmd(int command, Collection<? extends SsiItem> items) { super(command); this.items = DefensiveTools.getSafeNonnullListCopy(items, "items"); }
/** * Generates an SSI data request command from the given incoming SNAC packet. * * @param packet an incoming SSI data request packet */ protected SsiDataRequest(SnacPacket packet) { super(CMD_DATA_REQ); DefensiveTools.checkNull(packet, "packet"); }