Package com.calclab.emite.core.stanzas

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


   *            the other entity jid
   * @param order
   *            i din't read the spec... is that necessary?
   */
  public void blockUserBasedOnJID(final String listName, final XmppURI uri, final int order) {
    final IQ iq = new IQ(IQ.Type.set);
    final XMLPacket list = iq.addQuery(XmppNamespaces.PRIVACY).addChild("list", null);
    list.setAttribute("name", listName);
    final XMLPacket item = list.addChild("item", null);
    item.setAttribute("type", "jid");
    item.setAttribute("value", uri.getJID().toString());
    item.setAttribute("action", "deny");
View Full Code Here


    this.session = session;
  }

  @Override
  public void retrieve(final HasXML data, final PrivateStorageResponseEvent.Handler handler) {
    final IQ iq = new IQ(IQ.Type.get);
    iq.addQuery(XmppNamespaces.PRIVATE).addChild(data);

    session.sendIQ("priv", iq, new IQCallback() {
      @Override
      public void onIQSuccess(final IQ iq) {
        handler.onStorageResponse(new PrivateStorageResponseEvent(iq));
View Full Code Here

    });
  }

  @Override
  public void store(final HasXML data, final PrivateStorageResponseEvent.Handler handler) {
    final IQ iq = new IQ(IQ.Type.set);
    iq.addQuery(XmppNamespaces.PRIVATE).addChild(data);

    session.sendIQ("priv", iq, new IQCallback() {
      @Override
      public void onIQSuccess(final IQ iq) {
        handler.onStorageResponse(new PrivateStorageResponseEvent(iq));
View Full Code Here

    session.addIQRequestReceivedHandler(this);
  }
 
  @Override
  public void onIQRequestReceived(IQRequestReceivedEvent event) {
    final IQ iq = event.getIQ();
   
    if (IQ.Type.get.equals(iq.getType()) && iq.getQuery(XmppNamespaces.DISCO_INFO) != null) {
      // TODO
    } else if (IQ.Type.get.equals(iq.getType()) && iq.getQuery(XmppNamespaces.DISCO_ITEMS) != null) {
      // TODO
    }
  }
View Full Code Here

    if (useCache && featureCache.containsKey(targetUri) && identityCache.containsKey(targetUri)) {
      handler.onDiscoveryInfoResult(featureCache.get(targetUri), identityCache.get(targetUri));
      return;
    }
   
    final IQ iq = new IQ(IQ.Type.get);
    iq.setTo(targetUri);
    iq.addQuery(XmppNamespaces.DISCO_INFO);
   
    session.sendIQ("disco", iq, new IQCallback() {
      @Override
      public void onIQSuccess(final IQ iq) {
        final ImmutableSet<Feature> features = parseFeatures(iq.getQuery(XmppNamespaces.DISCO_INFO));
        final ImmutableSet<Identity> identities = parseIdentities(iq.getQuery(XmppNamespaces.DISCO_INFO));
        featureCache.put(targetUri, features);
        identityCache.put(targetUri, identities);
        handler.onDiscoveryInfoResult(features, identities);
      }

      @Override
      public void onIQFailure(final IQ iq) {
        featureCache.remove(targetUri);
        identityCache.remove(targetUri);
        handler.onDiscoveryInfoError(iq.getExtension("error", XmppNamespaces.DISCO_INFO));
      }
    });
  }
View Full Code Here

    if (useCache && itemCache.containsKey(targetUri)) {
      handler.onDiscoveryItemsResult(itemCache.get(targetUri));
      return;
    }
   
    final IQ iq = new IQ(IQ.Type.get);
    iq.setTo(targetUri);
    iq.addQuery(XmppNamespaces.DISCO_ITEMS);
   
    session.sendIQ("disco", iq, new IQCallback() {
      @Override
      public void onIQSuccess(final IQ iq) {
        final ImmutableSet<Item> items = parseItems(iq.getQuery(XmppNamespaces.DISCO_ITEMS));
        itemCache.put(targetUri, items);
        handler.onDiscoveryItemsResult(items);
      }

      @Override
      public void onIQFailure(final IQ iq) {
        itemCache.remove(targetUri);
        handler.onDiscoveryItemsError(iq.getExtension("error", XmppNamespaces.DISCO_ITEMS));
      }
    });
  }
View Full Code Here

  public void shouldCreateInstantRoomIfNeeded() {
    manager.open(uri("newroomtest1@rooms.localhost/nick"));
    session.receives("<presence from='newroomtest1@rooms.localhost/nick' to='user@localhost/resource' >" + "<priority>5</priority>"
        + "<x xmlns='http://jabber.org/protocol/muc#user'>" + "<item affiliation='owner' role='moderator' jid='vjrj@localhost/Psi' />"
        + "<status code='201' />" + "</x>" + "</presence>");
    session.verifyIQSent(new IQ(IQ.Type.set));
  }
View Full Code Here

import com.calclab.emite.im.roster.RosterItem;

public class XmppRosterHelper {
  public static void setRosterItems(final XmppSessionTester session, final RosterItem... items) {
    session.setStatus(SessionStatus.loggedIn);
    final IQ iq = new IQ(IQ.Type.result);
    final XMLPacket query = iq.addChild("query", "jabber:iq:roster");
    for (final RosterItem item : items) {
      item.addStanzaTo(query);
    }
    session.answerSuccess(iq);
  }
View Full Code Here

  public void shouldFireEventOnlyWhenRosterReady() {
    final RosterRetrievedTestHandler handler = new RosterRetrievedTestHandler();
    roster.addRosterRetrievedHandler(handler);

    shouldRequestRosterOnLogin();
    session.answerFailure(new IQ(Type.error));
    assertTrue(handler.isNotCalled());
  }
View Full Code Here

    array.addAll(items);
    return array;
  }

  private IQ serverRoster() {
    return new IQ(XMLBuilder.fromXML("<iq to='juliet@example.com/balcony' type='result'><query xmlns='jabber:iq:roster'>"
        + "<item jid='romeo@example.net' name='R' subscription='both'><group>Friends</group><group>X</group></item>"
        + "<item jid='mercutio@example.org' name='M' subscription='from'> <group>Friends</group></item>"
        + "<item jid='benvolio@example.org' name='B' subscription='both'><group>Work</group></item></query></iq>"));
  }
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.