Search in sources :

Example 1 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class BytestreamsProvider method parse.

@Override
public Bytestream parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
    boolean done = false;
    Bytestream toReturn = new Bytestream();
    String id = parser.getAttributeValue("", "sid");
    String mode = parser.getAttributeValue("", "mode");
    // streamhost
    Jid JID = null;
    String host = null;
    String port = null;
    int eventType;
    String elementName;
    while (!done) {
        eventType = parser.next();
        elementName = parser.getName();
        if (eventType == XmlPullParser.START_TAG) {
            if (elementName.equals(Bytestream.StreamHost.ELEMENTNAME)) {
                JID = ParserUtils.getJidAttribute(parser);
                host = parser.getAttributeValue("", "host");
                port = parser.getAttributeValue("", "port");
            } else if (elementName.equals(Bytestream.StreamHostUsed.ELEMENTNAME)) {
                toReturn.setUsedHost(ParserUtils.getJidAttribute(parser));
            } else if (elementName.equals(Bytestream.Activate.ELEMENTNAME)) {
                toReturn.setToActivate(ParserUtils.getJidAttribute(parser));
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (elementName.equals("streamhost")) {
                if (port == null) {
                    toReturn.addStreamHost(JID, host);
                } else {
                    toReturn.addStreamHost(JID, host, Integer.parseInt(port));
                }
                JID = null;
                host = null;
                port = null;
            } else if (elementName.equals("query")) {
                done = true;
            }
        }
    }
    if (mode == null) {
        toReturn.setMode(Mode.tcp);
    } else {
        toReturn.setMode((Bytestream.Mode.fromName(mode)));
    }
    toReturn.setSessionID(id);
    return toReturn;
}
Also used : Bytestream(org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream) Jid(org.jxmpp.jid.Jid)

Example 2 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class DiscoverItemsProvider method parse.

@Override
public DiscoverItems parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
    DiscoverItems discoverItems = new DiscoverItems();
    boolean done = false;
    DiscoverItems.Item item;
    Jid jid = null;
    String name = "";
    String action = "";
    String node = "";
    discoverItems.setNode(parser.getAttributeValue("", "node"));
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG && "item".equals(parser.getName())) {
            // Initialize the variables from the parsed XML
            jid = ParserUtils.getJidAttribute(parser);
            name = parser.getAttributeValue("", "name");
            node = parser.getAttributeValue("", "node");
            action = parser.getAttributeValue("", "action");
        } else if (eventType == XmlPullParser.END_TAG && "item".equals(parser.getName())) {
            // Create a new Item and add it to DiscoverItems.
            item = new DiscoverItems.Item(jid);
            item.setName(name);
            item.setNode(node);
            item.setAction(action);
            discoverItems.addItem(item);
        } else if (eventType == XmlPullParser.END_TAG && "query".equals(parser.getName())) {
            done = true;
        }
    }
    return discoverItems;
}
Also used : Jid(org.jxmpp.jid.Jid) DiscoverItems(org.jivesoftware.smackx.disco.packet.DiscoverItems)

Example 3 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class MultiUserChat method changeAffiliationByAdmin.

private void changeAffiliationByAdmin(Collection<? extends Jid> jids, MUCAffiliation affiliation) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    MUCAdmin iq = new MUCAdmin();
    iq.setTo(room);
    iq.setType(IQ.Type.set);
    for (Jid jid : jids) {
        // Set the new affiliation.
        MUCItem item = new MUCItem(affiliation, jid);
        iq.addItem(item);
    }
    connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
}
Also used : MUCItem(org.jivesoftware.smackx.muc.packet.MUCItem) EntityJid(org.jxmpp.jid.EntityJid) DomainBareJid(org.jxmpp.jid.DomainBareJid) EntityBareJid(org.jxmpp.jid.EntityBareJid) Jid(org.jxmpp.jid.Jid) EntityFullJid(org.jxmpp.jid.EntityFullJid) MUCAdmin(org.jivesoftware.smackx.muc.packet.MUCAdmin)

Example 4 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class UnblockContactsIQ method getIQChildElementBuilder.

@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
    if (jids == null) {
        xml.setEmptyElement();
        return xml;
    }
    xml.rightAngleBracket();
    for (Jid jid : jids) {
        xml.halfOpenElement("item");
        xml.attribute("jid", jid);
        xml.closeEmptyElement();
    }
    return xml;
}
Also used : Jid(org.jxmpp.jid.Jid)

Example 5 with Jid

use of org.jxmpp.jid.Jid in project Smack by igniterealtime.

the class EnhancedDebugger method addReadPacketToTable.

/**
     * Adds the received stanza(/packet) detail to the messages table.
     *
     * @param dateFormatter the SimpleDateFormat to use to format Dates
     * @param packet        the read stanza(/packet) to add to the table
     */
private void addReadPacketToTable(final SimpleDateFormat dateFormatter, final Stanza packet) {
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            String messageType;
            Jid from = packet.getFrom();
            String type = "";
            Icon packetTypeIcon;
            receivedPackets++;
            if (packet instanceof IQ) {
                packetTypeIcon = iqPacketIcon;
                messageType = "IQ Received (class=" + packet.getClass().getName() + ")";
                type = ((IQ) packet).getType().toString();
                receivedIQPackets++;
            } else if (packet instanceof Message) {
                packetTypeIcon = messagePacketIcon;
                messageType = "Message Received";
                type = ((Message) packet).getType().toString();
                receivedMessagePackets++;
            } else if (packet instanceof Presence) {
                packetTypeIcon = presencePacketIcon;
                messageType = "Presence Received";
                type = ((Presence) packet).getType().toString();
                receivedPresencePackets++;
            } else {
                packetTypeIcon = unknownPacketTypeIcon;
                messageType = packet.getClass().getName() + " Received";
                receivedOtherPackets++;
            }
            // Check if we need to remove old rows from the table to keep memory consumption low
            if (EnhancedDebuggerWindow.MAX_TABLE_ROWS > 0 && messagesTable.getRowCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) {
                messagesTable.removeRow(0);
            }
            messagesTable.addRow(new Object[] { formatXML(packet.toXML().toString()), dateFormatter.format(new Date()), packetReceivedIcon, packetTypeIcon, messageType, packet.getStanzaId(), type, "", from });
            // Update the statistics table
            updateStatistics();
        }
    });
}
Also used : Jid(org.jxmpp.jid.Jid) EntityFullJid(org.jxmpp.jid.EntityFullJid) Message(org.jivesoftware.smack.packet.Message) IQ(org.jivesoftware.smack.packet.IQ) Presence(org.jivesoftware.smack.packet.Presence) Icon(javax.swing.Icon) ImageIcon(javax.swing.ImageIcon) Date(java.util.Date)

Aggregations

Jid (org.jxmpp.jid.Jid)78 EntityBareJid (org.jxmpp.jid.EntityBareJid)18 ArrayList (java.util.ArrayList)15 HashMap (java.util.HashMap)14 Test (org.junit.Test)14 DomainBareJid (org.jxmpp.jid.DomainBareJid)14 EntityFullJid (org.jxmpp.jid.EntityFullJid)12 BareJid (org.jxmpp.jid.BareJid)11 IQ (org.jivesoftware.smack.packet.IQ)7 Presence (org.jivesoftware.smack.packet.Presence)7 MUCLightBlockingIQ (org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ)7 SmackException (org.jivesoftware.smack.SmackException)6 Message (org.jivesoftware.smack.packet.Message)6 WeakHashMap (java.util.WeakHashMap)4 XMPPConnection (org.jivesoftware.smack.XMPPConnection)4 Map (java.util.Map)3 SimpleResultSyncPoint (org.igniterealtime.smack.inttest.util.SimpleResultSyncPoint)3 FeatureNotSupportedException (org.jivesoftware.smack.SmackException.FeatureNotSupportedException)3 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)3 Bytestream (org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream)3