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);
}
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;
}
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);
}
}
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 + '\'');
}
}
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);
}
}
Aggregations