use of net.kano.joscar.snaccmd.ssi.BuddyAddedYouCmd in project Openfire by igniterealtime.
the class BOSConnection method handleSnacPacket.
@Override
protected void handleSnacPacket(SnacPacketEvent e) {
// Log.debug("OSCAR bos snac packet received: "+e);
super.handleSnacPacket(e);
SnacCommand cmd = e.getSnacCommand();
if (cmd instanceof ServerReadyCmd) {
request(new ParamInfoRequest());
request(new LocRightsRequest());
request(new SsiRightsRequest());
request(new SsiDataRequest());
} else if (cmd instanceof BuddyAddedYouCmd) {
BuddyAddedYouCmd bay = (BuddyAddedYouCmd) cmd;
Presence p = new Presence();
p.setType(Presence.Type.subscribe);
p.setTo(getMainSession().getJID());
p.setFrom(getMainSession().getTransport().convertIDToJID(bay.getUin()));
getMainSession().getTransport().sendPacket(p);
} else if (cmd instanceof BuddyAuthRequest) {
BuddyAuthRequest bar = (BuddyAuthRequest) cmd;
Presence p = new Presence();
p.setType(Presence.Type.subscribe);
p.setTo(getMainSession().getJID());
p.setFrom(getMainSession().getTransport().convertIDToJID(bar.getScreenname()));
getMainSession().getTransport().sendPacket(p);
// Auto-accept auth request. (for now)
// TODO: Evaluate handling this in a non-automated fashion.
request(new AuthReplyCmd(bar.getScreenname(), null, true));
} else if (cmd instanceof AuthReplyCmd) {
AuthReplyCmd ar = (AuthReplyCmd) cmd;
if (ar.isAccepted()) {
Presence p = new Presence();
p.setType(Presence.Type.subscribed);
p.setTo(getMainSession().getJID());
p.setFrom(getMainSession().getTransport().convertIDToJID(ar.getSender()));
getMainSession().getTransport().sendPacket(p);
} else {
Presence p = new Presence();
p.setType(Presence.Type.unsubscribed);
p.setTo(getMainSession().getJID());
p.setFrom(getMainSession().getTransport().convertIDToJID(ar.getSender()));
getMainSession().getTransport().sendPacket(p);
}
} else if (cmd instanceof ModifyItemsCmd) {
ModifyItemsCmd mic = (ModifyItemsCmd) cmd;
List<SsiItem> items = mic.getItems();
for (SsiItem item : items) {
SsiItemObj obj = itemFactory.getItemObj(item);
if (obj instanceof BuddyItem) {
BuddyItem bi = (BuddyItem) obj;
Log.debug("AIM got buddy item " + bi);
getMainSession().getSsiHierarchy().gotBuddy(bi);
} else if (obj instanceof GroupItem) {
GroupItem gi = (GroupItem) obj;
Log.debug("AIM got group item " + gi);
getMainSession().getSsiHierarchy().gotGroup(gi);
}
}
}
}
Aggregations