/** * 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); }
/** * 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); }
/** * 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); }
@SuppressWarnings("unchecked") private <T extends Bookmark> AsyncResult<List<T>> getBookmarks(Class<T> clazz) { return privateDataManager.getData(BookmarkStorage.class) .thenApply(bookmarkStorage -> bookmarkStorage.getBookmarks() .stream() .filter(bookmark -> bookmark.getClass() == clazz) .map(bookmark -> (T) bookmark).sorted() .collect(Collectors.toList())); } }
/** * Discovers the (sub-)nodes, which hierarchically reside under this node, e.g. the "second-level" nodes. * * @return The async result with the discovered pubsub nodes. * @see <a href="https://xmpp.org/extensions/xep-0060.html#entity-nodes">5.2 Discover Nodes</a> */ public AsyncResult<List<PubSubNode>> discoverNodes() { return serviceDiscoveryManager.discoverItems(pubSubServiceAddress, nodeId).thenApply(itemNode -> itemNode.getItems().stream() .map(item -> new PubSubNode(item.getNode(), pubSubServiceAddress, xmppSession)) .collect(Collectors.toList())); }
/** * Discovers the publish-subscribe services for the current connection. * * @return The async result with the list of publish-subscribe services. */ public AsyncResult<List<PubSubService>> discoverPubSubServices() { return serviceDiscoveryManager.discoverServices(Identity.pubsubService()) .thenApply(services -> services.stream() .map(service -> new PubSubService(service.getJid(), service.getName(), xmppSession, serviceDiscoveryManager)) .collect(Collectors.toList())); }
/** * Discovers the multi-user chat services hosted at the connected domain. * * @return The async result with the list of chat services. * @see <a href="https://xmpp.org/extensions/xep-0045.html#disco-service">6.1 Discovering a MUC Service</a> */ public AsyncResult<List<ChatService>> discoverChatServices() { return serviceDiscoveryManager.discoverServices(Identity.conferenceText()).thenApply(services -> services.stream() .map(service -> new ChatService(service.getJid(), service.getName(), xmppSession, serviceDiscoveryManager, this)) .collect(Collectors.toList())); }
/** * 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); }
/** * Subscribes to and configures this node. * * @param jid The JID which is subscribed. * @param subscribeOptions The configuration form. * @return The async result with the subscription. * @see <a href="https://xmpp.org/extensions/xep-0060.html#subscriber-configure-subandconfig">6.3.7 Subscribe and Configure</a> */ public final AsyncResult<Subscription> subscribe(final Jid jid, final SubscribeOptions subscribeOptions) { return xmppSession.query(IQ.set(pubSubServiceAddress, PubSub.withSubscribe(Objects.requireNonNull(nodeId, "nodeId must not be null"), Objects.requireNonNull(jid), subscribeOptions != null ? subscribeOptions.getDataForm() : null))).thenApply(result -> result.getExtension(PubSub.class).getSubscription()); }
/** * 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 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 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 the node configuration form. * * @return The async result with the configuration form. * @see <a href="https://xmpp.org/extensions/xep-0060.html#owner-configure-request">8.2.1 Request</a> */ public AsyncResult<NodeConfiguration> getNodeConfiguration() { return xmppSession.query(IQ.get(pubSubServiceAddress, PubSubOwner.withConfigure(nodeId))).thenApply(result -> { PubSubOwner pubSubOwner = result.getExtension(PubSubOwner.class); return new NodeConfiguration(pubSubOwner.getConfigurationForm()); }); }
/** * Gets the subscription options for this node. * * @param subId The subscription id. * @return The async result with the data form. * @see <a href="https://xmpp.org/extensions/xep-0060.html#subscriber-configure-request">6.3.2 Request</a> * @see #configureSubscription(rocks.xmpp.extensions.pubsub.model.SubscribeOptions) */ public AsyncResult<SubscribeOptions> getSubscriptionOptions(String subId) { return xmppSession.query(IQ.get(pubSubServiceAddress, PubSub.withOptions(nodeId, xmppSession.getConnectedResource().asBareJid(), subId, null))).thenApply(result -> new SubscribeOptions(result.getExtension(PubSub.class).getOptions().getDataForm())); }