/** * Discovers the rooms, where a contact is in. * * @param contact The contact, which must be a full JID. * @return The async result with the items, {@link rocks.xmpp.extensions.disco.model.items.Item#getJid()} has the room address, and {@link rocks.xmpp.extensions.disco.model.items.Item#getName()}} has the nickname. * @see <a href="https://xmpp.org/extensions/xep-0045.html#disco-client">6.7 Discovering Client Support for MUC</a> */ public AsyncResult<List<Item>> discoverEnteredRooms(Jid contact) { return serviceDiscoveryManager.discoverItems(contact, ROOMS_NODE).thenApply(ItemNode::getItems); }
/** * Becomes invisible. * * @return The async result. */ public AsyncResult<Void> becomeInvisible() { return xmppSession.query(IQ.set(InvisibleCommand.INVISIBLE)).thenRun(() -> { synchronized (InvisibilityManager.this) { invisible = true; } }); }
/** * Stores the roster group delimiter in the private storage and afterwards sets it. * * @param groupDelimiter The group delimiter. * @return The async result. * @see #setGroupDelimiter(String) * @see <a href="https://xmpp.org/extensions/xep-0083.html">XEP-0083: Nested Roster Groups</a> */ public final AsyncResult<Void> storeGroupDelimiter(String groupDelimiter) { return privateDataManager.storeData(RosterDelimiter.of(groupDelimiter)) .thenAccept(result -> setGroupDelimiter(groupDelimiter)); }
/** * Discovers the features, which are supported by the pubsub service. * * @return The async result with the set of supported features. * @see <a href="https://xmpp.org/extensions/xep-0060.html#entity-features">5.1 Discover Features</a> */ public AsyncResult<Collection<PubSubFeature>> discoverFeatures() { return serviceDiscoveryManager.discoverInformation(service).thenApply(this::getFeatures); }
/** * Becomes visible. * * @return The async result. */ public AsyncResult<Void> becomeVisible() { return xmppSession.query(IQ.set(InvisibleCommand.VISIBLE)).thenRun(() -> { synchronized (InvisibilityManager.this) { invisible = false; } }); }
/** * Discovers the allowable traffic, i.e. the allowed extensions. * * @return The async result with the list of allowable features. * @see <a href="http://www.xmpp.org/extensions/xep-0045.html#impl-service-traffic">17.1.1 Allowable Traffic</a> */ public AsyncResult<Set<String>> discoverAllowableTraffic() { return serviceDiscoveryManager.discoverInformation(roomJid, "http://jabber.org/protocol/muc#traffic").thenApply(InfoNode::getFeatures); }
/** * Sends an {@code <iq/>} stanza and returns an async result, which can be used to wait for the response. The result is completed if the response IQ has arrived or the default timeout has exceeded, in which case the result completes with a {@link NoResponseException}. * The payload of the response IQ is returned in the async result class. * * @param <T> The type. * @param iq The {@code <iq/>} stanza, which must be of type {@linkplain rocks.xmpp.core.stanza.model.IQ.Type#GET get} or {@linkplain rocks.xmpp.core.stanza.model.IQ.Type#SET set}. * @param clazz The class which is IQ response's payload. * @return The async result with the IQ response's payload. */ public final <T> AsyncResult<T> query(IQ iq, Class<T> clazz) { return query(iq).thenApply( result -> result.getExtension(clazz)); }
/** * Discovers language support for a translation provider. * * @param translationProvider The translation provider. * @return The list of supported languages with details. * @see <a href="https://xmpp.org/extensions/xep-0171.html#disco-lang">4.2.3 Discovering Language Support</a> */ public AsyncResult<List<LanguageSupport.Item>> discoverLanguageSupport(Jid translationProvider) { return xmppSession.query(IQ.get(translationProvider, new LanguageSupport()), LanguageSupport.class).thenApply(LanguageSupport::getItems); }
/** * Gets the subscriptions for this node. * * @return The async result with the subscriptions for the node. * @see <a href="https://xmpp.org/extensions/xep-0060.html#entity-subscriptions">5.6 Retrieve Subscriptions</a> */ public AsyncResult<List<Subscription>> getSubscriptions() { return xmppSession.query(IQ.get(pubSubServiceAddress, PubSub.withSubscriptions(nodeId))).thenApply(result -> result.getExtension(PubSub.class).getSubscriptions()); }
/** * Gets the affiliations for this node. * * @return The async result with the affiliations for all nodes. * @see <a href="https://xmpp.org/extensions/xep-0060.html#entity-affiliations">5.7 Retrieve Affiliations</a> */ public AsyncResult<List<Affiliation>> getAffiliations() { return xmppSession.query(IQ.get(pubSubServiceAddress, PubSub.withAffiliations(nodeId))).thenApply(result -> result.getExtension(PubSub.class).getAffiliations()); }
/** * Gets the subscriptions for all nodes. * * @return The async result with the subscriptions for all nodes. * @see <a href="https://xmpp.org/extensions/xep-0060.html#entity-subscriptions">5.6 Retrieve Subscriptions</a> */ public AsyncResult<List<Subscription>> getSubscriptions() { return xmppSession.query(IQ.get(service, PubSub.withSubscriptions())).thenApply(result -> { PubSub pubSub = result.getExtension(PubSub.class); return pubSub.getSubscriptions(); }); }
/** * Gets the affiliations for all nodes. * * @return The async result with the affiliations for all nodes. * @see <a href="https://xmpp.org/extensions/xep-0060.html#entity-affiliations">5.7 Retrieve Affiliations</a> */ public AsyncResult<List<Affiliation>> getAffiliations() { return xmppSession.query(IQ.get(service, PubSub.withAffiliations())).thenApply(result -> { PubSub pubSub = result.getExtension(PubSub.class); return pubSub.getAffiliations(); }); }
private AsyncResult<List<Item>> getByAffiliation(Affiliation affiliation) { return xmppSession.query(IQ.get(roomJid, MucAdmin.withItem(affiliation, null, null))).thenApply(result -> { MucAdmin mucAdmin = result.getExtension(MucAdmin.class); return mucAdmin.getItems(); }); }
/** * Gets the default node configuration form for this pubsub service. * * @return The async result with the configuration form. * @see <a href="https://xmpp.org/extensions/xep-0060.html#owner-default">8.3 Request Default Node Configuration Options</a> */ public AsyncResult<DataForm> getDefaultNodeConfiguration() { return xmppSession.query(IQ.get(service, PubSubOwner.withDefault())).thenApply(result -> { PubSubOwner pubSubOwner = result.getExtension(PubSubOwner.class); return pubSubOwner.getConfigurationForm(); }); }
/** * Gets all items for this node. * * @return The async result with the items. * @see <a href="https://xmpp.org/extensions/xep-0060.html#subscriber-retrieve-requestall">6.5.2 Requesting All Items</a> */ public AsyncResult<List<Item>> getItems() { return xmppSession.query(IQ.get(pubSubServiceAddress, PubSub.withItems(nodeId))).thenApply(result -> result.getExtension(PubSub.class).getItems()); }
/** * Gets the ban list. * * @return The async result with the ban list. * @see <a href="https://xmpp.org/extensions/xep-0045.html#modifyban">9.2 Modifying the Ban List</a> */ public AsyncResult<List<rocks.xmpp.extensions.muc.model.Item>> getBanList() { return xmppSession.query(IQ.get(roomJid, MucAdmin.withItem(Affiliation.OUTCAST, null, null))).thenApply(result -> { MucAdmin mucAdmin = result.getExtension(MucAdmin.class); return mucAdmin.getItems(); }); }
/** * Gets the moderators. * * @return The async result with the moderators. * @see <a href="https://xmpp.org/extensions/xep-0045.html#modifymod">9.8 Modifying the Moderator List</a> */ public AsyncResult<List<Item>> getModerators() { return xmppSession.query(IQ.get(roomJid, MucAdmin.withItem(Role.MODERATOR, null, null))).thenApply(result -> { MucAdmin mucAdmin = result.getExtension(MucAdmin.class); return mucAdmin.getItems(); }); }
/** * Gets one or more items with a given item id for a specific node. * * @param ids The item ids. * @return The async result with the items. * @see <a href="https://xmpp.org/extensions/xep-0060.html#subscriber-retrieve-returnnotify">6.5.6 Returning Notifications Only</a> * @see <a href="https://xmpp.org/extensions/xep-0060.html#subscriber-retrieve-requestone">6.5.8 Requesting a Particular Item</a> */ public AsyncResult<List<Item>> getItems(String... ids) { return xmppSession.query(IQ.get(pubSubServiceAddress, PubSub.withItems(nodeId, ids))).thenApply(result -> result.getExtension(PubSub.class).getItems()); }
/** * Gets the most recent items. * * @param maxItems The maximal number of items. * @return The async result with the items. * @see <a href="https://xmpp.org/extensions/xep-0060.html#subscriber-retrieve-requestrecent">6.5.7 Requesting the Most Recent Items</a> */ public AsyncResult<List<Item>> getItems(int maxItems) { return xmppSession.query(IQ.get(pubSubServiceAddress, PubSub.withItems(nodeId, maxItems))).thenApply(result -> result.getExtension(PubSub.class).getItems()); }
/** * Gets the voice list. * * @return The async result with the voice list. * @see <a href="https://xmpp.org/extensions/xep-0045.html#modifyvoice">8.5 Modifying the Voice List</a> */ public AsyncResult<List<rocks.xmpp.extensions.muc.model.Item>> getVoiceList() { return xmppSession.query(IQ.get(roomJid, MucAdmin.withItem(Role.PARTICIPANT, null, null))).thenApply(result -> { MucAdmin mucAdmin = result.getExtension(MucAdmin.class); return mucAdmin.getItems(); }); }