use of org.jxmpp.jid.Jid in project Smack by igniterealtime.
the class RemoteDisablingProvider method parse.
@Override
public RemoteDisablingExtension parse(XmlPullParser parser, int initialDepth) throws Exception {
Jid userJid = null;
String node = parser.getAttributeValue("", "node");
outerloop: while (true) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("affiliation")) {
userJid = JidCreate.from(parser.getAttributeValue("", "jid"));
String affiliation = parser.getAttributeValue("", "affiliation");
if (affiliation == null || !affiliation.equals("none")) {
return null;
}
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getDepth() == initialDepth) {
break outerloop;
}
}
}
return new RemoteDisablingExtension(node, userJid);
}
use of org.jxmpp.jid.Jid in project Smack by igniterealtime.
the class IoTDiscoveryManager method removeThing.
public void removeThing(BareJid thing, NodeInfo nodeInfo) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Jid registry = findRegistry();
removeThing(registry, thing, nodeInfo);
}
use of org.jxmpp.jid.Jid in project Smack by igniterealtime.
the class IoTDiscoveryManager method isRegistry.
// Registry utility methods
public boolean isRegistry(BareJid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Objects.requireNonNull(jid, "JID argument must not be null");
// At some point 'usedRegistries' will also contain the registry returned by findRegistry(), but since this is
// not the case from the beginning, we perform findRegistry().equals(jid) too.
Jid registry = findRegistry();
if (jid.equals(registry)) {
return true;
}
if (usedRegistries.contains(jid)) {
return true;
}
return false;
}
use of org.jxmpp.jid.Jid in project Smack by igniterealtime.
the class IoTDiscoveryIntegrationTest method checkPrerequisites.
static void checkPrerequisites(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, TestNotPossibleException {
IoTDiscoveryManager discoveryManager = IoTDiscoveryManager.getInstanceFor(connection);
Jid registry = discoveryManager.findRegistry();
if (registry == null) {
throw new TestNotPossibleException("Could not find IoT Registry");
}
}
use of org.jxmpp.jid.Jid in project Smack by igniterealtime.
the class RosterIntegrationTest method ensureSubscribedTo.
private static void ensureSubscribedTo(final XMPPConnection conOne, final XMPPConnection conTwo, long timeout) throws TimeoutException, Exception {
Roster rosterOne = Roster.getInstanceFor(conOne);
Roster rosterTwo = Roster.getInstanceFor(conTwo);
if (rosterOne.isSubscribedToMyPresence(conTwo.getUser())) {
return;
}
final SubscribeListener subscribeListener = new SubscribeListener() {
@Override
public SubscribeAnswer processSubscribe(Jid from, Presence subscribeRequest) {
if (from.equals(conTwo.getUser().asBareJid())) {
return SubscribeAnswer.Approve;
}
return SubscribeAnswer.Deny;
}
};
rosterOne.addSubscribeListener(subscribeListener);
final SimpleResultSyncPoint syncPoint = new SimpleResultSyncPoint();
rosterTwo.addPresenceEventListener(new AbstractPresenceEventListener() {
@Override
public void presenceSubscribed(BareJid address, Presence subscribedPresence) {
if (!address.equals(conOne.getUser().asBareJid())) {
return;
}
syncPoint.signal();
}
});
rosterTwo.sendSubscriptionRequest(conOne.getUser().asBareJid());
try {
syncPoint.waitForResult(timeout);
} finally {
rosterOne.removeSubscribeListener(subscribeListener);
}
}
Aggregations