Search in sources :

Example 1 with BuddyAddedYouCmd

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);
            }
        }
    }
}
Also used : BuddyAddedYouCmd(net.kano.joscar.snaccmd.ssi.BuddyAddedYouCmd) AuthReplyCmd(net.kano.joscar.snaccmd.ssi.AuthReplyCmd) SsiDataRequest(net.kano.joscar.snaccmd.ssi.SsiDataRequest) ParamInfoRequest(net.kano.joscar.snaccmd.icbm.ParamInfoRequest) LocRightsRequest(net.kano.joscar.snaccmd.loc.LocRightsRequest) BuddyAuthRequest(net.kano.joscar.snaccmd.ssi.BuddyAuthRequest) SsiItem(net.kano.joscar.snaccmd.ssi.SsiItem) ServerReadyCmd(net.kano.joscar.snaccmd.conn.ServerReadyCmd) BuddyItem(net.kano.joscar.ssiitem.BuddyItem) Presence(org.xmpp.packet.Presence) GroupItem(net.kano.joscar.ssiitem.GroupItem) SnacCommand(net.kano.joscar.flapcmd.SnacCommand) SsiRightsRequest(net.kano.joscar.snaccmd.ssi.SsiRightsRequest) ModifyItemsCmd(net.kano.joscar.snaccmd.ssi.ModifyItemsCmd) SsiItemObj(net.kano.joscar.ssiitem.SsiItemObj)

Aggregations

SnacCommand (net.kano.joscar.flapcmd.SnacCommand)1 ServerReadyCmd (net.kano.joscar.snaccmd.conn.ServerReadyCmd)1 ParamInfoRequest (net.kano.joscar.snaccmd.icbm.ParamInfoRequest)1 LocRightsRequest (net.kano.joscar.snaccmd.loc.LocRightsRequest)1 AuthReplyCmd (net.kano.joscar.snaccmd.ssi.AuthReplyCmd)1 BuddyAddedYouCmd (net.kano.joscar.snaccmd.ssi.BuddyAddedYouCmd)1 BuddyAuthRequest (net.kano.joscar.snaccmd.ssi.BuddyAuthRequest)1 ModifyItemsCmd (net.kano.joscar.snaccmd.ssi.ModifyItemsCmd)1 SsiDataRequest (net.kano.joscar.snaccmd.ssi.SsiDataRequest)1 SsiItem (net.kano.joscar.snaccmd.ssi.SsiItem)1 SsiRightsRequest (net.kano.joscar.snaccmd.ssi.SsiRightsRequest)1 BuddyItem (net.kano.joscar.ssiitem.BuddyItem)1 GroupItem (net.kano.joscar.ssiitem.GroupItem)1 SsiItemObj (net.kano.joscar.ssiitem.SsiItemObj)1 Presence (org.xmpp.packet.Presence)1