Search in sources :

Example 91 with Presence

use of org.xmpp.packet.Presence in project Openfire by igniterealtime.

the class ClusterListener method cleanupDirectedPresences.

private void cleanupDirectedPresences(NodeID nodeID) {
    // Remove traces of directed presences sent from node that is gone to entities hosted in this JVM
    Map<String, Collection<String>> senders = nodePresences.remove(nodeID);
    if (senders != null) {
        for (Map.Entry<String, Collection<String>> entry : senders.entrySet()) {
            String sender = entry.getKey();
            Collection<String> receivers = entry.getValue();
            for (String receiver : receivers) {
                try {
                    Presence presence = new Presence(Presence.Type.unavailable);
                    presence.setFrom(sender);
                    presence.setTo(receiver);
                    XMPPServer.getInstance().getPresenceRouter().route(presence);
                } catch (PacketException e) {
                    logger.error("Failed to cleanup directed presences", e);
                }
            }
        }
    }
}
Also used : Collection(java.util.Collection) Presence(org.xmpp.packet.Presence) DirectedPresence(org.jivesoftware.openfire.handler.DirectedPresence) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 92 with Presence

use of org.xmpp.packet.Presence in project Openfire by igniterealtime.

the class RemotePacketExecution method readExternal.

public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    recipient = (JID) ExternalizableUtil.getInstance().readSerializable(in);
    int packetType = ExternalizableUtil.getInstance().readInt(in);
    Element packetElement = (Element) ExternalizableUtil.getInstance().readSerializable(in);
    switch(packetType) {
        case 1:
            packet = new IQ(packetElement, true);
            break;
        case 2:
            packet = new Message(packetElement, true);
            break;
        case 3:
            packet = new Presence(packetElement, true);
            break;
    }
}
Also used : Message(org.xmpp.packet.Message) DefaultElement(org.dom4j.tree.DefaultElement) Element(org.dom4j.Element) IQ(org.xmpp.packet.IQ) Presence(org.xmpp.packet.Presence)

Example 93 with Presence

use of org.xmpp.packet.Presence 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)

Example 94 with Presence

use of org.xmpp.packet.Presence in project Openfire by igniterealtime.

the class YahooListener method contactAcceptedReceived.

/**
     * A contact has accepted our subscription request
     */
public void contactAcceptedReceived(SessionFriendAcceptedEvent event) {
    final Set<String> groups = new HashSet<String>();
    groups.add(event.getGroupName());
    final YahooUser user = new YahooUser(event.getFrom());
    // TODO clean up the next line. This implementation of constructor for YahooBuddy seems to be inappropriate here.
    final YahooBuddy buddy = new YahooBuddy(getSession().getBuddyManager(), user, null, groups, null);
    getSession().getBuddyManager().storeBuddy(buddy);
    final Presence p = new Presence(Presence.Type.subscribed);
    p.setTo(getSession().getJID());
    p.setFrom(getSession().getTransport().convertIDToJID(event.getFrom()));
    getSession().getTransport().sendPacket(p);
}
Also used : Presence(org.xmpp.packet.Presence) HashSet(java.util.HashSet)

Example 95 with Presence

use of org.xmpp.packet.Presence in project Openfire by igniterealtime.

the class YahooListener method contactRejectionReceived.

/**
     * @see org.openymsg.network.event.SessionAdapter#contactRequestReceived(org.openymsg.network.event.SessionEvent)
     */
/** is gone??
    @Override
    public void contactRequestReceived(SessionEvent event) {
        final Presence p = new Presence(Presence.Type.subscribe);
        p.setTo(getSession().getJID());
        p.setFrom(getSession().getTransport().convertIDToJID(event.getFrom()));
        getSession().getTransport().sendPacket(p);
    }
    */
/**
     * @see org.openymsg.network.event.SessionAdapter#contactRejectionReceived(org.openymsg.network.event.SessionFriendRejectedEvent)
     */
public void contactRejectionReceived(SessionFriendRejectedEvent event) {
    // TODO: Is this correct?  unsubscribed for a rejection?
    Log.debug(event.toString());
    Presence p = new Presence(Presence.Type.unsubscribed);
    p.setTo(getSession().getJID());
    p.setFrom(getSession().getTransport().convertIDToJID(event.getFrom()));
    getSession().getTransport().sendPacket(p);
}
Also used : Presence(org.xmpp.packet.Presence)

Aggregations

Presence (org.xmpp.packet.Presence)109 JID (org.xmpp.packet.JID)38 Element (org.dom4j.Element)34 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)20 Message (org.xmpp.packet.Message)17 IQ (org.xmpp.packet.IQ)16 UpdatePresence (org.jivesoftware.openfire.muc.cluster.UpdatePresence)14 NotFoundException (org.jivesoftware.util.NotFoundException)12 ArrayList (java.util.ArrayList)11 MUCRole (org.jivesoftware.openfire.muc.MUCRole)10 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)9 DefaultElement (org.dom4j.tree.DefaultElement)8 IOException (java.io.IOException)7 SQLException (java.sql.SQLException)7 GroupJID (org.jivesoftware.openfire.group.GroupJID)7 NotAllowedException (org.jivesoftware.openfire.muc.NotAllowedException)7 Date (java.util.Date)6 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)6 ConflictException (org.jivesoftware.openfire.muc.ConflictException)6 ForbiddenException (org.jivesoftware.openfire.muc.ForbiddenException)6