Search in sources :

Example 6 with EntityBareJid

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

the class MUCUserProvider method parseDecline.

private static MUCUser.Decline parseDecline(XmlPullParser parser) throws XmlPullParserException, IOException {
    String reason = null;
    EntityBareJid to = ParserUtils.getBareJidAttribute(parser, "to");
    EntityBareJid from = ParserUtils.getBareJidAttribute(parser, "from");
    outerloop: while (true) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("reason")) {
                reason = parser.nextText();
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("decline")) {
                break outerloop;
            }
        }
    }
    return new MUCUser.Decline(reason, from, to);
}
Also used : EntityBareJid(org.jxmpp.jid.EntityBareJid)

Example 7 with EntityBareJid

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

the class MultiUserChatManager method getJoinedRooms.

/**
     * Returns a List of the rooms where the requested user has joined. The Iterator will contain Strings where each
     * String represents a room (e.g. room@muc.jabber.org).
     *
     * @param user the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.
     * @return a List of the rooms where the requested user has joined.
     * @throws XMPPErrorException
     * @throws NoResponseException
     * @throws NotConnectedException
     * @throws InterruptedException 
     */
public List<EntityBareJid> getJoinedRooms(EntityJid user) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    // Send the disco packet to the user
    DiscoverItems result = ServiceDiscoveryManager.getInstanceFor(connection()).discoverItems(user, DISCO_NODE);
    List<DiscoverItems.Item> items = result.getItems();
    List<EntityBareJid> answer = new ArrayList<>(items.size());
    // Collect the entityID for each returned item
    for (DiscoverItems.Item item : items) {
        EntityBareJid muc = item.getEntityID().asEntityBareJidIfPossible();
        if (muc == null) {
            LOGGER.warning("Not a bare JID: " + item.getEntityID());
            continue;
        }
        answer.add(muc);
    }
    return answer;
}
Also used : ArrayList(java.util.ArrayList) DiscoverItems(org.jivesoftware.smackx.disco.packet.DiscoverItems) EntityBareJid(org.jxmpp.jid.EntityBareJid)

Example 8 with EntityBareJid

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

the class MultiUserChat method fireInvitationRejectionListeners.

/**
     * Fires invitation rejection listeners.
     *
     * @param invitee the user being invited.
     * @param reason the reason for the rejection
     */
private void fireInvitationRejectionListeners(Message message, MUCUser.Decline rejection) {
    EntityBareJid invitee = rejection.getFrom();
    String reason = rejection.getReason();
    InvitationRejectionListener[] listeners;
    synchronized (invitationRejectionListeners) {
        listeners = new InvitationRejectionListener[invitationRejectionListeners.size()];
        invitationRejectionListeners.toArray(listeners);
    }
    for (InvitationRejectionListener listener : listeners) {
        listener.invitationDeclined(invitee, reason, message, rejection);
    }
}
Also used : EntityBareJid(org.jxmpp.jid.EntityBareJid)

Example 9 with EntityBareJid

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

the class MamManager method ensureMamQueryResultMatchesThisManager.

private void ensureMamQueryResultMatchesThisManager(MamQueryResult mamQueryResult) {
    EntityFullJid localAddress = connection().getUser();
    EntityBareJid localBareAddress = null;
    if (localAddress != null) {
        localBareAddress = localAddress.asEntityBareJid();
    }
    boolean isLocalUserArchive = archiveAddress == null || archiveAddress.equals(localBareAddress);
    Jid finIqFrom = mamQueryResult.mamFin.getFrom();
    if (finIqFrom != null) {
        if (finIqFrom.equals(archiveAddress) || (isLocalUserArchive && finIqFrom.equals(localBareAddress))) {
            return;
        }
        throw new IllegalArgumentException("The given MamQueryResult is from the MAM archive '" + finIqFrom + "' whereas this MamManager is responsible for '" + archiveAddress + '\'');
    } else if (!isLocalUserArchive) {
        throw new IllegalArgumentException("The given MamQueryResult is from the local entity (user) MAM archive, whereas this MamManager is responsible for '" + archiveAddress + '\'');
    }
}
Also used : EntityBareJid(org.jxmpp.jid.EntityBareJid) Jid(org.jxmpp.jid.Jid) EntityFullJid(org.jxmpp.jid.EntityFullJid) EntityFullJid(org.jxmpp.jid.EntityFullJid) EntityBareJid(org.jxmpp.jid.EntityBareJid)

Example 10 with EntityBareJid

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

the class IntTestUtil method deleteViaServiceAdministration.

public static void deleteViaServiceAdministration(XMPPTCPConnection connection, Configuration config) {
    EntityBareJid accountToDelete = connection.getUser().asEntityBareJid();
    final int maxAttempts = 3;
    int attempts;
    for (attempts = 0; attempts < maxAttempts; attempts++) {
        connection.disconnect();
        try {
            connection.connect().login(config.adminAccountUsername, config.adminAccountPassword);
        } catch (XMPPException | SmackException | IOException | InterruptedException e) {
            LOGGER.log(Level.WARNING, "Exception deleting account for " + connection, e);
            continue;
        }
        ServiceAdministrationManager adminManager = ServiceAdministrationManager.getInstanceFor(connection);
        try {
            adminManager.deleteUser(accountToDelete);
        } catch (NoResponseException | XMPPErrorException | NotConnectedException | InterruptedException e) {
            LOGGER.log(Level.WARNING, "Exception deleting account for " + connection, e);
            continue;
        }
    }
    if (attempts > maxAttempts) {
        LOGGER.log(Level.SEVERE, "Could not delete account for connection: " + connection);
    }
}
Also used : ServiceAdministrationManager(org.jivesoftware.smackx.admin.ServiceAdministrationManager) XMPPErrorException(org.jivesoftware.smack.XMPPException.XMPPErrorException) NotConnectedException(org.jivesoftware.smack.SmackException.NotConnectedException) SmackException(org.jivesoftware.smack.SmackException) IOException(java.io.IOException) NoResponseException(org.jivesoftware.smack.SmackException.NoResponseException) XMPPException(org.jivesoftware.smack.XMPPException) EntityBareJid(org.jxmpp.jid.EntityBareJid)

Aggregations

EntityBareJid (org.jxmpp.jid.EntityBareJid)15 EntityFullJid (org.jxmpp.jid.EntityFullJid)3 Jid (org.jxmpp.jid.Jid)3 ArrayList (java.util.ArrayList)2 AbstractSmackIntegrationTest (org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest)2 SmackIntegrationTest (org.igniterealtime.smack.inttest.SmackIntegrationTest)2 SmackException (org.jivesoftware.smack.SmackException)2 NoResponseException (org.jivesoftware.smack.SmackException.NoResponseException)2 NotConnectedException (org.jivesoftware.smack.SmackException.NotConnectedException)2 XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)2 Message (org.jivesoftware.smack.packet.Message)2 ServiceAdministrationManager (org.jivesoftware.smackx.admin.ServiceAdministrationManager)2 EntityJid (org.jxmpp.jid.EntityJid)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 TimeoutException (java.util.concurrent.TimeoutException)1 TestNotPossibleException (org.igniterealtime.smack.inttest.TestNotPossibleException)1 ResultSyncPoint (org.igniterealtime.smack.inttest.util.ResultSyncPoint)1 MessageListener (org.jivesoftware.smack.MessageListener)1 XMPPException (org.jivesoftware.smack.XMPPException)1