mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-23 04:57:58 +01:00
Fixes for private data support.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2006 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
b8602b80c0
commit
665825b656
3 changed files with 23 additions and 6 deletions
|
@ -68,6 +68,7 @@ import java.util.Map;
|
|||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* Manages private data.
|
||||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
|
@ -145,7 +146,9 @@ public class PrivateDataManager {
|
|||
IQ privateDataGet = new IQ() {
|
||||
public String getChildElementXML() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("<query xmlns=\"jabber:iq:private\">");
|
||||
buf.append("<").append(elementName).append(" xmlns=\"").append(namespace).append("\"/>");
|
||||
buf.append("</query>");
|
||||
return buf.toString();
|
||||
}
|
||||
};
|
||||
|
@ -174,7 +177,11 @@ public class PrivateDataManager {
|
|||
// Create an IQ packet to set the private data.
|
||||
IQ privateDataSet = new IQ() {
|
||||
public String getChildElementXML() {
|
||||
return privateData.toXML();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("<query xmlns=\"jabber:iq:private\">");
|
||||
buf.append(privateData.toXML());
|
||||
buf.append("</query>");
|
||||
return buf.toString();
|
||||
}
|
||||
};
|
||||
privateDataSet.setType(IQ.Type.SET);
|
||||
|
@ -215,7 +222,7 @@ public class PrivateDataManager {
|
|||
*/
|
||||
public static class PrivateDataIQProvider implements IQProvider {
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
PrivateData privateData = null;;
|
||||
PrivateData privateData = null;
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
|
@ -266,12 +273,13 @@ public class PrivateDataManager {
|
|||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("</query>")) {
|
||||
if (parser.getName().equals("query")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new PrivateDataResult(privateData);
|
||||
IQ result = new PrivateDataResult(privateData);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -352,7 +360,13 @@ public class PrivateDataManager {
|
|||
}
|
||||
|
||||
public String getChildElementXML() {
|
||||
return privateData.toXML();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("<query xmlns=\"jabber:iq:private\">");
|
||||
if (privateData != null) {
|
||||
privateData.toXML();
|
||||
}
|
||||
buf.append("</query>");
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
package org.jivesoftware.smackx.packet;
|
||||
|
||||
/**
|
||||
* Interface to represent private data. Each private data chunk is an XML subdocument
|
||||
* Interface to represent private data. Each private data chunk is an XML sub-document
|
||||
* with a root element name and namespace.
|
||||
*
|
||||
* @see org.jivesoftware.smackx.PrivateDataManager
|
||||
|
|
|
@ -56,6 +56,9 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
import org.jivesoftware.smackx.packet.PrivateData;
|
||||
|
||||
/**
|
||||
* An interface for parsing custom private data. Each PrivateDataProvider must
|
||||
* be registered with the PrivateDataManager class for it to be used. Every implementation
|
||||
* of this interface <b>must</b> have a public, no-argument constructor.
|
||||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue