1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-12-12 14:01:08 +01:00

Cleanup carbons, forwarded and a few others API

Adopt to common design patterns in Smack:

- getFrom(Packet) in Packetextensions
- INSTANCES.put() in getInstanceFor()
- ELEMENT instead of ELEMENT_NAME
- Use XmlStringBuilder
This commit is contained in:
Florian Schmaus 2014-07-16 11:46:30 +02:00
parent 1ed5c48bcc
commit 49ee058c38
14 changed files with 105 additions and 90 deletions

View file

@ -54,11 +54,10 @@ public class LastActivity extends IQ {
@Override
public XmlStringBuilder getChildElementXML() {
XmlStringBuilder xml = new XmlStringBuilder();
xml.halfOpenElement("query");
xml.halfOpenElement(IQ.QUERY_ELEMENT);
xml.xmlnsAttribute(NAMESPACE);
if (lastActivity != -1) {
xml.attribute("seconds", Long.toString(lastActivity));
}
xml.optLongAttribute("seconds", lastActivity);
// We don't support adding the optional message attribute, because it is usually only added
// by XMPP servers and not by client entities.
xml.closeEmptyElement();
@ -108,10 +107,6 @@ public class LastActivity extends IQ {
}
public IQ parseIQ(XmlPullParser parser) throws SmackException, XmlPullParserException {
if (parser.getEventType() != XmlPullParser.START_TAG) {
throw new SmackException("Parser not in proper position, or bad XML.");
}
LastActivity lastActivity = new LastActivity();
String seconds = parser.getAttributeValue("", "seconds");
if (seconds != null) {