public boolean supportsFeatures(Jid jid, Collection<? extends CharSequence> features) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverInfo result = discoverInfo(jid); for (CharSequence feature : features) { if (!result.containsFeature(feature)) { return false; } } return true; }
/** * Returns the discovered information of a given XMPP entity addressed by its JID. * Use null as entityID to query the server * * @param entityID the address of the XMPP entity or null. * @return the discovered information. * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException * @throws InterruptedException */ public DiscoverInfo discoverInfo(Jid entityID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { if (entityID == null) return discoverInfo(null, null); synchronized (discoInfoLookupShortcutMechanisms) { for (DiscoInfoLookupShortcutMechanism discoInfoLookupShortcutMechanism : discoInfoLookupShortcutMechanisms) { DiscoverInfo info = discoInfoLookupShortcutMechanism.getDiscoverInfoByUser(this, entityID); if (info != null) { // We were able to retrieve the information from Entity Caps and // avoided a disco request, hurray! return info; } } } // Last resort: Standard discovery. return discoverInfo(entityID, null); }
@Override public boolean evaluate() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverInfo info = sdmOne.discoverInfo(conTwo.getUser()); return info.containsFeature(dummyFeature); } });
/** * Gets the supported features of the servers pubsub implementation * as a standard {@link DiscoverInfo} instance. * * @return The supported features * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException * @throws InterruptedException */ public DiscoverInfo getSupportedFeatures() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ServiceDiscoveryManager mgr = ServiceDiscoveryManager.getInstanceFor(connection()); return mgr.discoverInfo(pubSubService); }
/** * Returns true, if the Server supports PEP. * * @param connection XMPPConnection * @param server domainBareJid of the server to test * @return true if server supports pep * @throws XMPPException.XMPPErrorException * @throws SmackException.NotConnectedException * @throws InterruptedException * @throws SmackException.NoResponseException */ public static boolean serverSupportsOmemo(XMPPConnection connection, DomainBareJid server) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException { return ServiceDiscoveryManager.getInstanceFor(connection) .discoverInfo(server).containsFeature(PubSub.NAMESPACE); }
/** * Returns true if Multi-User Chat Light feature is supported by the server. * * @param mucLightService * @return true if Multi-User Chat Light feature is supported by the server. * @throws NotConnectedException * @throws XMPPErrorException * @throws NoResponseException * @throws InterruptedException */ public boolean isFeatureSupported(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection()).discoverInfo(mucLightService) .containsFeature(MultiUserChatLight.NAMESPACE); }
/** * Returns the discovered information of a given room without actually having to join the room. The server will * provide information only for rooms that are public. * * @param room the name of the room in the form "roomName@service" of which we want to discover its information. * @return the discovered information of a given room without actually having to join the room. * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException * @throws InterruptedException */ public RoomInfo getRoomInfo(EntityBareJid room) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection()).discoverInfo(room); return new RoomInfo(info); }
/** * Returns the reserved room nickname for the user in the room. A user may have a reserved * nickname, for example through explicit room registration or database integration. In such * cases it may be desirable for the user to discover the reserved nickname before attempting * to enter the room. * * @return the reserved room nickname or <tt>null</tt> if none. * @throws SmackException if there was no response from the server. * @throws InterruptedException */ public String getReservedNickname() throws SmackException, InterruptedException { try { DiscoverInfo result = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo( room, "x-roomuser-item"); // Look for an Identity that holds the reserved nickname and return its name for (DiscoverInfo.Identity identity : result.getIdentities()) { return identity.getName(); } } catch (XMPPException e) { LOGGER.log(Level.SEVERE, "Error retrieving room nickname", e); } // If no Identity was found then the user does not have a reserved room nickname return null; }
/** * The workgroup service may be configured to send email. This queries the Workgroup Service * to see if the email service has been configured and is available. * * @return true if the email service is available, otherwise return false. * @throws SmackException * @throws InterruptedException */ public boolean isEmailAvailable() throws SmackException, InterruptedException { ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection); try { DomainBareJid workgroupService = workgroupJID.asDomainBareJid(); DiscoverInfo infoResult = discoManager.discoverInfo(workgroupService); return infoResult.containsFeature("jive:email:provider"); } catch (XMPPException e) { return false; } }
/** * Returns the number of offline messages for the user of the connection. * * @return the number of offline messages for the user of the connection. * @throws XMPPErrorException If the user is not allowed to make this request or the server does * not support offline message retrieval. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException * @throws InterruptedException */ public int getMessageCount() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null, namespace); Form extendedInfo = Form.getFormFrom(info); if (extendedInfo != null) { String value = extendedInfo.getField("number_of_messages").getFirstValue(); return Integer.parseInt(value); } return 0; }
info = discoverInfo(serviceName); } catch (XMPPErrorException e) { if (encounteredExceptions != null) { info = discoverInfo(address);
DiscoverInfo discoInfo = disco.discoverInfo(connection.getXMPPServiceDomain()); for (DiscoverInfo.Identity identity : discoInfo.getIdentities()) { if (identity.getName() != null && identity.getName().startsWith("rtpbridge")) {
/** * Check if the server support STUN Service. * * @param connection the connection * @return true if the server support STUN * @throws SmackException * @throws XMPPException * @throws InterruptedException */ public static boolean serviceAvailable(XMPPConnection connection) throws XMPPException, SmackException, InterruptedException { if (!connection.isConnected()) { return false; } LOGGER.fine("Service listing"); ServiceDiscoveryManager disco = ServiceDiscoveryManager.getInstanceFor(connection); DiscoverItems items = disco.discoverItems(connection.getXMPPServiceDomain()); for (DiscoverItems.Item item : items.getItems()) { DiscoverInfo info = disco.discoverInfo(item.getEntityID()); for (DiscoverInfo.Identity identity : info.getIdentities()) { if (identity.getCategory().equals("proxy") && identity.getType().equals("stun")) if (info.containsFeature(NAMESPACE)) return true; } LOGGER.fine(item.getName() + "-" + info.getType()); } return false; }
proxyInfo = serviceDiscoveryManager.discoverInfo(item.getEntityID());
DiscoverInfo info = sdmOne.discoverInfo(conTwo.getUser()); info = sdmOne.discoverInfo(conTwo.getUser());
@Override public DiscoverInfo getDiscoverInfoByUser(ServiceDiscoveryManager serviceDiscoveryManager, Jid jid) { DiscoverInfo info = EntityCapsManager.getDiscoverInfoByUser(jid); if (info != null) { return info; } NodeVerHash nodeVerHash = getNodeVerHashByJid(jid); if (nodeVerHash == null) { return null; } try { info = serviceDiscoveryManager.discoverInfo(jid, nodeVerHash.getNodeVer()); } catch (NoResponseException | XMPPErrorException | NotConnectedException | InterruptedException e) { // TODO log return null; } if (verifyDiscoverInfoVersion(nodeVerHash.getVer(), nodeVerHash.getHash(), info)) { addDiscoverInfoByNode(nodeVerHash.getNodeVer(), info); } else { // TODO log } return info; } });
DiscoverInfo discoverInfo = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(uploadServiceAddress); if (!containsHttpFileUploadNamespace(discoverInfo)) { throw new IllegalArgumentException("There is no HTTP upload service running at the given address '"
@SmackIntegrationTest public void testEntityCaps() throws XMPPException, InterruptedException, NoResponseException, NotConnectedException, TimeoutException { final String dummyFeature = getNewDummyFeature(); dropWholeEntityCapsCache(); performActionAndWaitUntilStanzaReceived(new Runnable() { @Override public void run() { sdmTwo.addFeature(dummyFeature); } }, connection, new AndFilter(PresenceTypeFilter.AVAILABLE, FromMatchesFilter.create(conTwo.getUser()))); waitUntilTrue(new Condition() { @Override public boolean evaluate() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverInfo info = sdmOne.discoverInfo(conTwo.getUser()); return info.containsFeature(dummyFeature); } }); DiscoverInfo info = sdmOne.discoverInfo(conTwo.getUser()); String u1ver = EntityCapsManager.getNodeVersionByJid(conTwo.getUser()); assertNotNull(u1ver); DiscoverInfo entityInfo = EntityCapsManager.CAPS_CACHE.lookup(u1ver); assertNotNull(entityInfo); assertEquals(info.toXML(null), entityInfo.toXML(null)); }
/** * Returns true if Multi-User Chat Light feature is supported by the server. * * @param mucLightService * @return true if Multi-User Chat Light feature is supported by the server. * @throws NotConnectedException * @throws XMPPErrorException * @throws NoResponseException * @throws InterruptedException */ public boolean isFeatureSupported(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection()).discoverInfo(mucLightService) .containsFeature(MultiUserChatLight.NAMESPACE); }
@Override public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception { String entID = sampler.getPropertyAsString(ENTITY_ID); res.setSamplerData("Entity ID: " + entID); ServiceDiscoveryManager discoMgr = ServiceDiscoveryManager.getInstanceFor(sampler.getXMPPConnection()); IQ info; if (Type.valueOf(sampler.getPropertyAsString(TYPE)) == Type.info) { info = discoMgr.discoverInfo(entID); } else { info = discoMgr.discoverItems(entID); } res.setResponseData(info.toXML().toString().getBytes()); return res; }