public void setStatusFromConfig() { // TODO: only call this when carbons changed, not on every presence change CarbonManager.getInstanceFor(mXMPPConnection).sendCarbonsEnabled(mConfig.messageCarbons); Presence presence = new Presence(Presence.Type.available); Mode mode = Mode.valueOf(mConfig.statusMode); presence.setMode(mode); presence.setStatus(mConfig.statusMessage); presence.setPriority(mConfig.priority); mXMPPConnection.sendPacket(presence); mConfig.presence_required = false; }
public void setStatusFromConfig() { CarbonManager.getInstanceFor(extXMPPConnection) .sendCarbonsEnabled(configuration.messageCarbons); Presence presence = new Presence(Presence.Type.available); Mode mode = Mode.valueOf(configuration.statusMode); presence.setMode(mode); presence.setStatus(configuration.statusMessage); presence.setPriority(configuration.priority); extXMPPConnection.sendPacket(presence); configuration.presence_required = false; }
public static Presence parsePresence(XmlPullParser xmlPullParser) throws XmlPullParserException, IOException, SmackException { ParserUtils.assertAtStartTag(xmlPullParser); int depth = xmlPullParser.getDepth(); Presence.Type type = Presence.Type.available; String attributeValue = xmlPullParser.getAttributeValue("", "type"); if (!(attributeValue == null || attributeValue.equals(""))) { type = Presence.Type.fromString(attributeValue); } Stanza presence = new Presence(type); presence.setTo(xmlPullParser.getAttributeValue("", PrivacyItem.SUBSCRIPTION_TO)); presence.setFrom(xmlPullParser.getAttributeValue("", PrivacyItem.SUBSCRIPTION_FROM)); presence.setStanzaId(xmlPullParser.getAttributeValue("", "id")); String languageAttribute = getLanguageAttribute(xmlPullParser); if (!(languageAttribute == null || "".equals(languageAttribute.trim()))) { presence.setLanguage(languageAttribute); } while (true) { switch (xmlPullParser.next()) { case VideoSize.HVGA /*2*/: String name = xmlPullParser.getName(); String namespace = xmlPullParser.getNamespace(); Object obj = -1; switch (name.hashCode()) { case -1165461084: if (name.equals("priority")) { obj = 1; break; } break; case -892481550: if (name.equals(Status.ELEMENT)) { obj = null; break; } break; case 3529469: if (name.equals("show")) { obj = 2; break; } break; case 96784904: if (name.equals(XMPPError.ERROR)) { obj = 3; break; } break; } switch (obj) { case VideoSize.QCIF /*0*/: presence.setStatus(xmlPullParser.nextText()); break; case VideoSize.CIF /*1*/: presence.setPriority(Integer.parseInt(xmlPullParser.nextText())); break; case VideoSize.HVGA /*2*/: obj = xmlPullParser.nextText(); if (!StringUtils.isNotEmpty(obj)) { LOGGER.warning( "Empty or null mode text in presence show element form " + presence.getFrom() + " with id '" + presence.getStanzaId() + "' which is invalid according to RFC6121 4.7.2.1"); break; } presence.setMode(Mode.fromString(obj)); break; case Version.API03_CUPCAKE_15 /*3*/: presence.setError(parseError(xmlPullParser)); break; default: try { addExtensionElement(presence, xmlPullParser, name, namespace); break; } catch (Throwable e) { LOGGER.log( Level.WARNING, "Failed to parse extension packet in Presence packet. Attributes: from=" + presence.getFrom() + " id=" + presence.getStanzaId(), e); break; } } case Version.API03_CUPCAKE_15 /*3*/: if (xmlPullParser.getDepth() != depth) { break; } return presence; default: break; } } }