@Override public Subscription parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { String jid = parser.getAttributeValue(null, "jid"); String nodeId = parser.getAttributeValue(null, "node"); String subId = parser.getAttributeValue(null, "subid"); String state = parser.getAttributeValue(null, "subscription"); boolean isRequired = false; int tag = parser.next(); if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("subscribe-options")) { tag = parser.next(); if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("required")) isRequired = true; while (tag != XmlPullParser.END_TAG && !parser.getName().equals("subscribe-options")) tag = parser.next(); } while (parser.getEventType() != XmlPullParser.END_TAG) parser.next(); return new Subscription(jid, nodeId, subId, (state == null ? null : Subscription.State.valueOf(state)), isRequired); }
public PacketExtension parseExtension(XmlPullParser parser) throws Exception { String jid = parser.getAttributeValue(null, "jid"); String nodeId = parser.getAttributeValue(null, "node"); String subId = parser.getAttributeValue(null, "subid"); String state = parser.getAttributeValue(null, "subscription"); boolean isRequired = false; int tag = parser.next(); if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("subscribe-options")) { tag = parser.next(); if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("required")) isRequired = true; while (parser.next() != XmlPullParser.END_TAG && parser.getName() != "subscribe-options"); } while (parser.getEventType() != XmlPullParser.END_TAG) parser.next(); return new Subscription(jid, nodeId, subId, (state == null ? null : Subscription.State.valueOf(state)), isRequired); }
@Override protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content) { return new SubscriptionsExtension(attributeMap.get("node"), (List<Subscription>) content); }
public PacketExtension parseExtension(XmlPullParser parser) throws Exception { String jid = parser.getAttributeValue(null, "jid"); String nodeId = parser.getAttributeValue(null, "node"); String subId = parser.getAttributeValue(null, "subid"); String state = parser.getAttributeValue(null, "subscription"); boolean isRequired = false; int tag = parser.next(); if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("subscribe-options")) { tag = parser.next(); if ((tag == XmlPullParser.START_TAG) && parser.getName().equals("required")) isRequired = true; while (parser.next() != XmlPullParser.END_TAG && parser.getName() != "subscribe-options") ; } while (parser.getEventType() != XmlPullParser.END_TAG) parser.next(); return new Subscription(jid, nodeId, subId, (state == null ? null : Subscription.State.valueOf(state)), isRequired); }
private boolean isSubscribed(Node node, String user_jid) { boolean result = false; try { for (Subscription s: node.getSubscriptions()) { Log.i(TAG, "subscription: " + s.getJid()); if (s.getJid().equalsIgnoreCase(user_jid) && s.getState().equals(Subscription.State.subscribed)) { result = true; break; } } } catch (Exception e) {} logs.info("checking if user subscribet to xmpp pubsub node: " + String.valueOf(result)); return result; }
@SuppressWarnings("unchecked") @Override protected SubscriptionsExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends ExtensionElement> content) { return new SubscriptionsExtension(attributeMap.get("node"), (List<Subscription>)content); }
@Override protected PacketExtension createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends PacketExtension> content) { return new SubscriptionsExtension(attributeMap.get("node"), (List<Subscription>)content); }