/** * Get the options for configuring the specified subscription. * * @param jid JID the subscription is registered under * @param subscriptionId The subscription id * @return The subscription option form * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public SubscribeForm getSubscriptionOptions(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException { PubSub packet = (PubSub) sendPubsubPacket(Type.get, new OptionsExtension(jid, getId(), subscriptionId)); FormNode ext = (FormNode) packet.getExtension(PubSubElementType.OPTIONS); return new SubscribeForm(ext.getForm()); }
/** * The user subscribes to the node using the supplied jid and subscription options. The bare jid * portion of this one must match the jid for the connection. * * <p>Please note that the {@link Subscription.State} should be checked on return since more * actions may be required by the caller. {@link Subscription.State#pending} - The owner must * approve the subscription request before messages will be received. {@link * Subscription.State#unconfigured} - If the {@link Subscription#isConfigRequired()} is true, the * caller must configure the subscription before messages will be received. If it is false the * caller can configure it but is not required to do so. * * @param jid The jid to subscribe as. * @return The subscription * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public Subscription subscribe(String jid, SubscribeForm subForm) throws NoResponseException, XMPPErrorException, NotConnectedException { PubSub request = createPubsubPacket(Type.set, new SubscribeExtension(jid, getId())); request.addExtension(new FormNode(FormNodeType.OPTIONS, subForm)); PubSub reply = (PubSub) PubSubManager.sendPubsubPacket(con, jid, Type.set, request); return (Subscription) reply.getExtension(PubSubElementType.SUBSCRIPTION); }
/** * Gets the affiliations on the root node. * * @return List of affiliations * @throws XMPPException */ public List<Affiliation> getAffiliations() throws XMPPException { PubSub reply = (PubSub) sendPubsubPacket(Type.GET, new NodeExtension(PubSubElementType.AFFILIATIONS)); AffiliationsExtension listElem = (AffiliationsExtension) reply.getExtension(PubSubElementType.AFFILIATIONS); return listElem.getAffiliations(); }
/** * Get the subscriptions currently associated with this node. * * @return List of {@link Subscription} * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException { PubSub reply = (PubSub) sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS, getId())); SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtension(PubSubElementType.SUBSCRIPTIONS); return subElem.getSubscriptions(); }
/** * Creates an instant node, if supported. * * @return The node that was created * @exception XMPPException */ public LeafNode createNode() throws XMPPException { PubSub reply = (PubSub) sendPubsubPacket(Type.SET, new NodeExtension(PubSubElementType.CREATE)); NodeExtension elem = (NodeExtension) reply.getExtension("create", PubSubNamespace.BASIC.getXmlns()); LeafNode newNode = new LeafNode(con, elem.getNode()); newNode.setTo(to); nodeMap.put(newNode.getId(), newNode); return newNode; }
/** * The user subscribes to the node using the supplied jid. The bare jid portion of this one must * match the jid for the connection. * * <p>Please note that the {@link Subscription.State} should be checked on return since more * actions may be required by the caller. {@link Subscription.State#pending} - The owner must * approve the subscription request before messages will be received. {@link * Subscription.State#unconfigured} - If the {@link Subscription#isConfigRequired()} is true, the * caller must configure the subscription before messages will be received. If it is false the * caller can configure it but is not required to do so. * * @param jid The jid to subscribe as. * @return The subscription * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException */ public Subscription subscribe(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException { PubSub reply = (PubSub) sendPubsubPacket(Type.set, new SubscribeExtension(jid, getId())); return (Subscription) reply.getExtension(PubSubElementType.SUBSCRIPTION); }