Package com.calclab.emite.core.stanzas

Examples of com.calclab.emite.core.stanzas.IQ


  }

  @Override
  public void requestOwnVCard(final VCardResponseEvent.Handler handler) {
    final IQ iq = new IQ(IQ.Type.get);
    iq.addChild(VCard.VCARD, VCard.DATA_XMLS);
    iq.setFrom(session.getCurrentUserURI());
    session.sendIQ(ID_PREFIX, iq, new IQCallback() {
      @Override
      public void onIQ(final IQ iq) {
        handleVCard(iq, handler);
      }
View Full Code Here


  }

  @Override
  public void updateOwnVCard(final VCard vcard, final VCardResponseEvent.Handler handler) {
    final IQ iq = new IQ(IQ.Type.set);
    iq.addChild(vcard);
    session.sendIQ(ID_PREFIX, iq, new IQCallback() {
      @Override
      public void onIQ(final IQ iq) {
        handleVCard(iq, handler);
      }
View Full Code Here

        final String affiliation = item.getAttribute("affiliation");
        final String role = item.getAttribute("role");
        final XmppURI userUri = XmppURI.uri(item.getAttribute("jid"));
        setOccupantPresence(userUri, occupantURI, affiliation, role, presence.getShow(), presence.getStatus());
        if (hasStatus(xmuc, 201)) {
          final IQ iq = new IQ(IQ.Type.set);
          iq.setTo(roomUri.getJID());
          iq.addQuery(XmppNamespaces.MUC_OWNER).addChild(new Form(Form.Type.submit));

          session.sendIQ("rooms", iq, new IQCallback() {
            @Override
            public void onIQSuccess(final IQ iq) {
              status = RoomStatus.ready;
View Full Code Here

  }

  @Test
  public void shouldPerformBinding() {
    manager.bindResource("resource");
    assertTrue(connection.hasSent(new IQ(IQ.Type.set).Includes("bind", "urn:ietf:params:xml:ns:xmpp-bind")));
  }
View Full Code Here

  }

  @Test
  public void shouldSendRetrievalRequest() {
    manager.requestOwnVCard(null);
    final IQ iq = new IQ(IQ.Type.get);
    iq.setFrom(XmppURI.uri("test@domain"));
    iq.addChild("vCard", "vcard-temp");
    session.verifyIQSent(iq);
  }
View Full Code Here

  }

  private void shouldParseVCardImpl(final String vcard) {
    final VCardResponseTestHandler handler = new VCardResponseTestHandler();
    manager.requestOwnVCard(handler);
    session.verifyIQSent(new IQ(Type.get));
    session.answerSuccess(new IQ(XMLBuilder.fromXML(vcard)));
    assertTrue(handler.isCalledOnce());
    assertTrue(handler.getLastVCardResponse().hasVCard());
    assertNotNull(handler.getLastVCardResponse().getVCard().getNickName());
  }
View Full Code Here

  @Test
  public void shouldStore() {
    final PrivateStorageResponseTestHandler handler = new PrivateStorageResponseTestHandler();
    manager.store(XMLBuilder.fromXML(data), handler);
    session.verifyIQSent(storeData);
    session.answerSuccess(new IQ(XMLBuilder.fromXML(storeResponse)));
    assertTrue("handler called " + handler.getCalledTimes() + " times", handler.isCalledOnce());
  }
View Full Code Here

  @Test
  public void shoulGet() {
    final PrivateStorageResponseTestHandler handler = new PrivateStorageResponseTestHandler();
    manager.retrieve(XMLBuilder.create("exodus", "exodus:prefs"), handler);
    session.verifyIQSent(retriveData);
    session.answerSuccess(new IQ(XMLBuilder.fromXML(retrieveResponse)));
    assertTrue(handler.isCalledOnce());
    assertEquals("Hamlet", handler.getLastEvent().getResponseIQ().getChild("query", "jabber:iq:private").getFirstChild("exodus").getChildText("defaultnick"));
  }
View Full Code Here

    }
  }

  @Override
  public void onIQRequestReceived(final IQRequestReceivedEvent event) {
    final IQ iq = event.getIQ();
    if (IQ.Type.set.equals(iq.getType())) {
      final XMLPacket query = iq.getQuery(XmppNamespaces.ROSTER);
      if (query != null) {
        for (final XMLPacket child : query.getChildren()) {
          handleItemChanged(RosterItem.parse(child));
        }
      }

      final IQ result = new IQ(IQ.Type.result);
      result.setTo(iq.getFrom());
      result.setId(iq.getId());
      session.send(result);
    }
  }
View Full Code Here

  @Override
  public void requestRemoveItem(final XmppURI jid) {
    final RosterItem item = getItemByJID(jid.getJID());
    if (item != null) {
      final IQ iq = new IQ(IQ.Type.set);
      final XMLPacket itemNode = iq.addQuery(XmppNamespaces.ROSTER).addChild("item", null);
      itemNode.setAttribute("subscription", "remove");
      itemNode.setAttribute("jid", item.getJID().toString());

      session.sendIQ("roster", iq, new IQCallback() {
        @Override
View Full Code Here

TOP

Related Classes of com.calclab.emite.core.stanzas.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.