use of org.jxmpp.jid.Jid 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.Jid in project Smack by igniterealtime.
the class MamPrefsIQProvider method parse.
@Override
public MamPrefsIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
String iqType = parser.getAttributeValue("", "type");
String defaultBehaviorString = parser.getAttributeValue("", "default");
DefaultBehavior defaultBehavior = null;
if (defaultBehaviorString != null) {
defaultBehavior = DefaultBehavior.valueOf(defaultBehaviorString);
}
if (iqType == null) {
iqType = "result";
}
List<Jid> alwaysJids = null;
List<Jid> neverJids = null;
outerloop: while (true) {
final int eventType = parser.next();
final String name = parser.getName();
switch(eventType) {
case XmlPullParser.START_TAG:
switch(name) {
case "always":
alwaysJids = iterateJids(parser);
break;
case "never":
neverJids = iterateJids(parser);
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
}
}
return new MamPrefsIQ(alwaysJids, neverJids, defaultBehavior);
}
use of org.jxmpp.jid.Jid in project Smack by igniterealtime.
the class MUCLightChangeAffiliationsIQ method getIQChildElementBuilder.
@Override
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
xml.rightAngleBracket();
if (affiliations != null) {
Iterator<Map.Entry<Jid, MUCLightAffiliation>> it = affiliations.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Jid, MUCLightAffiliation> pair = it.next();
xml.element(new UserWithAffiliationElement(pair.getKey(), pair.getValue()));
}
}
return xml;
}
use of org.jxmpp.jid.Jid in project Smack by igniterealtime.
the class MUCLightBlockingIQProvider method parse.
@Override
public MUCLightBlockingIQ parse(XmlPullParser parser, int initialDepth) throws Exception {
HashMap<Jid, Boolean> rooms = null;
HashMap<Jid, Boolean> users = null;
outerloop: while (true) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("room")) {
rooms = parseBlocking(parser, rooms);
}
if (parser.getName().equals("user")) {
users = parseBlocking(parser, users);
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getDepth() == initialDepth) {
break outerloop;
}
}
}
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, users);
mucLightBlockingIQ.setType(Type.result);
return mucLightBlockingIQ;
}
use of org.jxmpp.jid.Jid in project Smack by igniterealtime.
the class MultiUserChatLightManager method blockUsers.
/**
* Block users.
*
* @param mucLightService
* @param usersJids
* @throws NoResponseException
* @throws XMPPErrorException
* @throws NotConnectedException
* @throws InterruptedException
*/
public void blockUsers(DomainBareJid mucLightService, List<Jid> usersJids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
HashMap<Jid, Boolean> users = new HashMap<>();
for (Jid jid : usersJids) {
users.put(jid, false);
}
sendBlockUsers(mucLightService, users);
}
Aggregations