From 665825b656ba052697165de58cddb9f4806df438 Mon Sep 17 00:00:00 2001 From: Matt Tucker Date: Mon, 4 Aug 2003 21:05:44 +0000 Subject: [PATCH] Fixes for private data support. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2006 b35dd754-fafc-0310-a699-88a17e54d16e --- .../smackx/PrivateDataManager.java | 24 +++++++++++++++---- .../smackx/packet/PrivateData.java | 2 +- .../smackx/provider/PrivateDataProvider.java | 3 +++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/source/org/jivesoftware/smackx/PrivateDataManager.java b/source/org/jivesoftware/smackx/PrivateDataManager.java index dd76b27ab..30d948d8d 100644 --- a/source/org/jivesoftware/smackx/PrivateDataManager.java +++ b/source/org/jivesoftware/smackx/PrivateDataManager.java @@ -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(""); buf.append("<").append(elementName).append(" xmlns=\"").append(namespace).append("\"/>"); + buf.append(""); 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(""); + buf.append(privateData.toXML()); + buf.append(""); + 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("")) { + 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(""); + if (privateData != null) { + privateData.toXML(); + } + buf.append(""); + return buf.toString(); } } } diff --git a/source/org/jivesoftware/smackx/packet/PrivateData.java b/source/org/jivesoftware/smackx/packet/PrivateData.java index c933a3108..78a1a3cf7 100644 --- a/source/org/jivesoftware/smackx/packet/PrivateData.java +++ b/source/org/jivesoftware/smackx/packet/PrivateData.java @@ -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 diff --git a/source/org/jivesoftware/smackx/provider/PrivateDataProvider.java b/source/org/jivesoftware/smackx/provider/PrivateDataProvider.java index 6c15ffbb3..3e23201b9 100644 --- a/source/org/jivesoftware/smackx/provider/PrivateDataProvider.java +++ b/source/org/jivesoftware/smackx/provider/PrivateDataProvider.java @@ -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 must have a public, no-argument constructor. * * @author Matt Tucker */