Search in sources :

Example 11 with DomainBareJid

use of org.jxmpp.jid.DomainBareJid in project Smack by igniterealtime.

the class IoTProvisioningManager method findProvisioningServerComponent.

/**
     * Try to find a provisioning server component.
     * 
     * @return the XMPP address of the provisioning server component if one was found.
     * @throws NoResponseException
     * @throws XMPPErrorException
     * @throws NotConnectedException
     * @throws InterruptedException
     * @see <a href="http://xmpp.org/extensions/xep-0324.html#servercomponent">XEP-0324 ยง 3.1.2 Provisioning Server as a server component</a>
     */
public DomainBareJid findProvisioningServerComponent() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    final XMPPConnection connection = connection();
    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
    List<DiscoverInfo> discoverInfos = sdm.findServicesDiscoverInfo(Constants.IOT_PROVISIONING_NAMESPACE, true, true);
    if (discoverInfos.isEmpty()) {
        return null;
    }
    Jid jid = discoverInfos.get(0).getFrom();
    assert (jid.isDomainBareJid());
    return jid.asDomainBareJid();
}
Also used : DiscoverInfo(org.jivesoftware.smackx.disco.packet.DiscoverInfo) DomainBareJid(org.jxmpp.jid.DomainBareJid) Jid(org.jxmpp.jid.Jid) BareJid(org.jxmpp.jid.BareJid) XMPPConnection(org.jivesoftware.smack.XMPPConnection) ServiceDiscoveryManager(org.jivesoftware.smackx.disco.ServiceDiscoveryManager)

Example 12 with DomainBareJid

use of org.jxmpp.jid.DomainBareJid in project Smack by igniterealtime.

the class MultiUserChatLightManager method getUsersBlocked.

/**
     * Get users blocked.
     * 
     * @param mucLightService
     * @return the list of users blocked
     * @throws NoResponseException
     * @throws XMPPErrorException
     * @throws NotConnectedException
     * @throws InterruptedException
     */
public List<Jid> getUsersBlocked(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    MUCLightBlockingIQ muclIghtBlockingIQResult = getBlockingList(mucLightService);
    List<Jid> jids = new ArrayList<>();
    if (muclIghtBlockingIQResult.getUsers() != null) {
        jids.addAll(muclIghtBlockingIQResult.getUsers().keySet());
    }
    return jids;
}
Also used : Jid(org.jxmpp.jid.Jid) DomainBareJid(org.jxmpp.jid.DomainBareJid) EntityBareJid(org.jxmpp.jid.EntityBareJid) MUCLightBlockingIQ(org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ) ArrayList(java.util.ArrayList)

Example 13 with DomainBareJid

use of org.jxmpp.jid.DomainBareJid in project Smack by igniterealtime.

the class MultiUserChatLightManager method blockRooms.

/**
     * Block rooms.
     * 
     * @param mucLightService
     * @param roomsJids
     * @throws NoResponseException
     * @throws XMPPErrorException
     * @throws NotConnectedException
     * @throws InterruptedException
     */
public void blockRooms(DomainBareJid mucLightService, List<Jid> roomsJids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    HashMap<Jid, Boolean> rooms = new HashMap<>();
    for (Jid jid : roomsJids) {
        rooms.put(jid, false);
    }
    sendBlockRooms(mucLightService, rooms);
}
Also used : Jid(org.jxmpp.jid.Jid) DomainBareJid(org.jxmpp.jid.DomainBareJid) EntityBareJid(org.jxmpp.jid.EntityBareJid) HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap)

Example 14 with DomainBareJid

use of org.jxmpp.jid.DomainBareJid in project Smack by igniterealtime.

the class MultiUserChatLightManager method getUsersAndRoomsBlocked.

/**
     * Get users and rooms blocked.
     * 
     * @param mucLightService
     * @return the list of users and rooms blocked
     * @throws NoResponseException
     * @throws XMPPErrorException
     * @throws NotConnectedException
     * @throws InterruptedException
     */
public List<Jid> getUsersAndRoomsBlocked(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    MUCLightBlockingIQ muclIghtBlockingIQResult = getBlockingList(mucLightService);
    List<Jid> jids = new ArrayList<>();
    if (muclIghtBlockingIQResult.getRooms() != null) {
        jids.addAll(muclIghtBlockingIQResult.getRooms().keySet());
    }
    if (muclIghtBlockingIQResult.getUsers() != null) {
        jids.addAll(muclIghtBlockingIQResult.getUsers().keySet());
    }
    return jids;
}
Also used : Jid(org.jxmpp.jid.Jid) DomainBareJid(org.jxmpp.jid.DomainBareJid) EntityBareJid(org.jxmpp.jid.EntityBareJid) MUCLightBlockingIQ(org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ) ArrayList(java.util.ArrayList)

Example 15 with DomainBareJid

use of org.jxmpp.jid.DomainBareJid in project Smack by igniterealtime.

the class MultiUserChatLightManager method getOccupiedRooms.

/**
     * Returns a List of the rooms the user occupies.
     *
     * @param mucLightService
     * @return a List of the rooms the user occupies.
     * @throws XMPPErrorException
     * @throws NoResponseException
     * @throws NotConnectedException
     * @throws InterruptedException
     */
public List<Jid> getOccupiedRooms(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    DiscoverItems result = ServiceDiscoveryManager.getInstanceFor(connection()).discoverItems(mucLightService);
    List<DiscoverItems.Item> items = result.getItems();
    List<Jid> answer = new ArrayList<>(items.size());
    for (DiscoverItems.Item item : items) {
        Jid mucLight = item.getEntityID();
        answer.add(mucLight);
    }
    return answer;
}
Also used : Jid(org.jxmpp.jid.Jid) DomainBareJid(org.jxmpp.jid.DomainBareJid) EntityBareJid(org.jxmpp.jid.EntityBareJid) ArrayList(java.util.ArrayList) DiscoverItems(org.jivesoftware.smackx.disco.packet.DiscoverItems)

Aggregations

DomainBareJid (org.jxmpp.jid.DomainBareJid)19 Jid (org.jxmpp.jid.Jid)11 EntityBareJid (org.jxmpp.jid.EntityBareJid)10 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 WeakHashMap (java.util.WeakHashMap)4 DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)4 MUCLightBlockingIQ (org.jivesoftware.smackx.muclight.element.MUCLightBlockingIQ)3 NoResponseException (org.jivesoftware.smack.SmackException.NoResponseException)2 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)2 ServiceDiscoveryManager (org.jivesoftware.smackx.disco.ServiceDiscoveryManager)2 DiscoverItems (org.jivesoftware.smackx.disco.packet.DiscoverItems)2 EntityFullJid (org.jxmpp.jid.EntityFullJid)2 CallbackHandler (javax.security.auth.callback.CallbackHandler)1 SmackIntegrationTest (org.igniterealtime.smack.inttest.SmackIntegrationTest)1 TestNotPossibleException (org.igniterealtime.smack.inttest.TestNotPossibleException)1 FeatureNotSupportedException (org.jivesoftware.smack.SmackException.FeatureNotSupportedException)1 NotConnectedException (org.jivesoftware.smack.SmackException.NotConnectedException)1 XMPPConnection (org.jivesoftware.smack.XMPPConnection)1 XMPPException (org.jivesoftware.smack.XMPPException)1