Package rocks.xmpp.core.stanza.model.client

Examples of rocks.xmpp.core.stanza.model.client.IQ


    public void removeMessages(String... ids) throws XmppException {
        List<OfflineMessage.Item> items = new ArrayList<>();
        for (String id : ids) {
            items.add(new OfflineMessage.Item(id, OfflineMessage.Item.Action.REMOVE));
        }
        xmppSession.query(new IQ(IQ.Type.SET, new OfflineMessage(items)));
    }
View Full Code Here


     * @throws rocks.xmpp.core.stanza.model.StanzaException If the server returned a stanza error.
     * @throws rocks.xmpp.core.session.NoResponseException  If the server did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0013.html#retrieve-all">2.6 Retrieving All Messages</a>
     */
    public void requestAllMessages() throws XmppException {
        xmppSession.query(new IQ(IQ.Type.GET, new OfflineMessage(true, false)));
    }
View Full Code Here

        });

        xmppSession.addIQListener(new IQListener() {
            @Override
            public void handle(IQEvent e) {
                IQ iq = e.getIQ();
                if (e.isIncoming() && isEnabled() && !e.isConsumed() && iq.getType() == IQ.Type.SET) {
                    ContactExchange contactExchange = iq.getExtension(ContactExchange.class);
                    if (contactExchange != null) {
                        if (xmppSession.getRosterManager().getContact(iq.getFrom().asBareJid()) == null) {
                            // If the receiving entity will not process the suggested action(s) because the sending entity is not in the receiving entity's roster, the receiving entity MUST return an error to the sending entity, which error SHOULD be <not-authorized/>.
                            xmppSession.send(iq.createError(new StanzaError(new NotAuthorized())));
                        } else {
                            List<ContactExchange.Item> items = getItemsToProcess(contactExchange.getItems());
                            if (!items.isEmpty()) {
                                processItems(items, iq.getFrom(), null, new Date());
                            }
                            xmppSession.send(iq.createResult());
                        }
                        e.consume();
                    }
                }
            }
View Full Code Here

                "    <last/>\n" +
                "    <nick/>\n" +
                "    <email/>\n" +
                "  </query>\n" +
                "</iq>\n";
        IQ iq = unmarshal(xml, IQ.class);
        Search search = iq.getExtension(Search.class);
        Assert.assertEquals("\n" +
                "      Fill in one or more fields to search\n" +
                "      for any matching Jabber users.\n" +
                "    ", search.getInstructions());
View Full Code Here

     * @throws rocks.xmpp.core.stanza.model.StanzaException If the server returned a stanza error.
     * @throws rocks.xmpp.core.session.NoResponseException  If the server did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0013.html#remove-all">2.7 Removing All Messages</a>
     */
    public void removeAllMessages() throws XmppException {
        xmppSession.query(new IQ(IQ.Type.SET, new OfflineMessage(false, true)));
    }
View Full Code Here

                "      <email>tybalt@shakespeare.lit</email>\n" +
                "    </item>\n" +
                "  </query>\n" +
                "</iq>\n";

        IQ iq = unmarshal(xml, IQ.class);
        Search search = iq.getExtension(Search.class);

        Assert.assertNotNull(search);
        Assert.assertEquals(search.getItems().size(), 2);
        Assert.assertEquals(search.getItems().get(0).getJid(), Jid.valueOf("juliet@capulet.com"));
        Assert.assertEquals(search.getItems().get(0).getFirst(), "Juliet");
View Full Code Here

                "  <error type='modify'>\n" +
                "    <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>\n" +
                "    <payload-too-big xmlns='http://jabber.org/protocol/pubsub#errors'/>\n" +
                "  </error>\n" +
                "</iq>\n";
        IQ iq = unmarshal(xml, IQ.class);
        Assert.assertTrue(iq.getError().getExtension() instanceof PayloadTooBig);
    }
View Full Code Here

                "      </field>\n" +
                "    </x>\n" +
                "  </query>\n" +
                "</iq>\n";

        IQ iq = unmarshal(xml, IQ.class);
        Search search = iq.getExtension(Search.class);

        Assert.assertNotNull(search);
        Assert.assertNotNull(search.getAdditionalInformation());
        Assert.assertEquals("User Directory Search", search.getAdditionalInformation().getTitle());
        // The rest should be covered by data form test.
View Full Code Here

    private SoftwareVersionManager(final XmppSession xmppSession) {
        super(xmppSession, SoftwareVersion.NAMESPACE);
        xmppSession.addIQListener(new IQListener() {
            @Override
            public void handle(IQEvent e) {
                IQ iq = e.getIQ();
                // If an entity asks us for our software version, reply.
                if (e.isIncoming() && isEnabled() && !e.isConsumed() && iq.getType() == IQ.Type.GET && iq.getExtension(SoftwareVersion.class) != null) {
                    synchronized (SoftwareVersionManager.this) {
                        if (softwareVersion != null) {
                            IQ result = iq.createResult();
                            result.setExtension(softwareVersion);
                            xmppSession.send(result);
                            e.consume();
                        }
                    }
                }
View Full Code Here

                "  <error type='modify'>\n" +
                "    <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>\n" +
                "    <invalid-payload xmlns='http://jabber.org/protocol/pubsub#errors'/>\n" +
                "  </error>\n" +
                "</iq>\n";
        IQ iq = unmarshal(xml, IQ.class);
        Assert.assertTrue(iq.getError().getExtension() instanceof InvalidPayload);
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.core.stanza.model.client.IQ

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.