mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 18:59:41 +02:00
Initial version
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2260 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
6596515785
commit
a5b33b4118
13 changed files with 3300 additions and 0 deletions
193
source/org/jivesoftware/smackx/provider/DataFormProvider.java
Normal file
193
source/org/jivesoftware/smackx/provider/DataFormProvider.java
Normal file
|
@ -0,0 +1,193 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright (C) 2002-2003 Jive Software. All rights reserved.
|
||||
* ====================================================================
|
||||
* The Jive Software License (based on Apache Software License, Version 1.1)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution,
|
||||
* if any, must include the following acknowledgment:
|
||||
* "This product includes software developed by
|
||||
* Jive Software (http://www.jivesoftware.com)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "Smack" and "Jive Software" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please
|
||||
* contact webmaster@jivesoftware.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Smack",
|
||||
* nor may "Smack" appear in their name, without prior written
|
||||
* permission of Jive Software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smackx.provider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smackx.FormField;
|
||||
import org.jivesoftware.smackx.packet.DataForm;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* The DataFormProvider parses DataForm packets.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class DataFormProvider implements PacketExtensionProvider {
|
||||
|
||||
/**
|
||||
* Creates a new DataFormProvider.
|
||||
* ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor
|
||||
*/
|
||||
public DataFormProvider() {
|
||||
}
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
StringBuffer buffer = null;
|
||||
DataForm dataForm = new DataForm(parser.getAttributeValue("", "type"));
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("instructions")) {
|
||||
dataForm.setInstructions(parser.nextText());
|
||||
}
|
||||
else if (parser.getName().equals("title")) {
|
||||
dataForm.setTitle(parser.nextText());
|
||||
}
|
||||
else if (parser.getName().equals("field")) {
|
||||
dataForm.addField(parseField(parser));
|
||||
}
|
||||
else if (parser.getName().equals("item")) {
|
||||
dataForm.addItem(parseItem(parser));
|
||||
}
|
||||
else if (parser.getName().equals("reported")) {
|
||||
dataForm.setReportedData(parseReported(parser));
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals(dataForm.getElementName())) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return dataForm;
|
||||
}
|
||||
|
||||
private FormField parseField(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
FormField formField = new FormField();
|
||||
formField.setLabel(parser.getAttributeValue("", "label"));
|
||||
formField.setVariable(parser.getAttributeValue("", "var"));
|
||||
formField.setType(parser.getAttributeValue("", "type"));
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("desc")) {
|
||||
formField.setDescription(parser.nextText());
|
||||
}
|
||||
else if (parser.getName().equals("value")) {
|
||||
formField.addValue(parser.nextText());
|
||||
}
|
||||
else if (parser.getName().equals("required")) {
|
||||
formField.setRequired(true);
|
||||
}
|
||||
else if (parser.getName().equals("option")) {
|
||||
formField.addOption(parseOption(parser));
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("field")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return formField;
|
||||
}
|
||||
|
||||
private DataForm.Item parseItem(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
List fields = new ArrayList();
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("field")) {
|
||||
fields.add(parseField(parser));
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new DataForm.Item(fields);
|
||||
}
|
||||
|
||||
private DataForm.ReportedData parseReported(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
List fields = new ArrayList();
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("field")) {
|
||||
fields.add(parseField(parser));
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("reported")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new DataForm.ReportedData(fields);
|
||||
}
|
||||
|
||||
private FormField.Option parseOption(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
FormField.Option option = null;
|
||||
String label = parser.getAttributeValue("", "label");
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("value")) {
|
||||
option = new FormField.Option(label, parser.nextText());
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("option")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return option;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright (C) 2002-2003 Jive Software. All rights reserved.
|
||||
* ====================================================================
|
||||
* The Jive Software License (based on Apache Software License, Version 1.1)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution,
|
||||
* if any, must include the following acknowledgment:
|
||||
* "This product includes software developed by
|
||||
* Jive Software (http://www.jivesoftware.com)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "Smack" and "Jive Software" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please
|
||||
* contact webmaster@jivesoftware.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Smack",
|
||||
* nor may "Smack" appear in their name, without prior written
|
||||
* permission of Jive Software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smackx.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* Represents .....
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCAdminProvider implements IQProvider {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.jivesoftware.smack.provider.IQProvider#parseIQ(org.xmlpull.v1.XmlPullParser)
|
||||
*/
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
143
source/org/jivesoftware/smackx/provider/MUCOwnerProvider.java
Normal file
143
source/org/jivesoftware/smackx/provider/MUCOwnerProvider.java
Normal file
|
@ -0,0 +1,143 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright (C) 2002-2003 Jive Software. All rights reserved.
|
||||
* ====================================================================
|
||||
* The Jive Software License (based on Apache Software License, Version 1.1)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution,
|
||||
* if any, must include the following acknowledgment:
|
||||
* "This product includes software developed by
|
||||
* Jive Software (http://www.jivesoftware.com)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "Smack" and "Jive Software" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please
|
||||
* contact webmaster@jivesoftware.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Smack",
|
||||
* nor may "Smack" appear in their name, without prior written
|
||||
* permission of Jive Software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smackx.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.*;
|
||||
import org.jivesoftware.smack.provider.*;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.packet.MUCOwner;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* Represents .....
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCOwnerProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
MUCOwner mucOwner = new MUCOwner();
|
||||
boolean done = false;
|
||||
MUCOwner.Item item = null;
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
mucOwner.addItem(parseItem(parser));
|
||||
}
|
||||
if (parser.getName().equals("destroy")) {
|
||||
mucOwner.setDestroy(parseDestroy(parser));
|
||||
}
|
||||
// Otherwise, it must be a packet extension.
|
||||
else {
|
||||
mucOwner.addExtension(
|
||||
PacketParserUtils.parsePacketExtension(
|
||||
parser.getName(),
|
||||
parser.getNamespace(),
|
||||
parser));
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("query")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mucOwner;
|
||||
}
|
||||
|
||||
private MUCOwner.Item parseItem(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
MUCOwner.Item item = new MUCOwner.Item(parser.getAttributeValue("", "affiliation"));
|
||||
item.setNick(parser.getAttributeValue("", "nick"));
|
||||
item.setJid(parser.getAttributeValue("", "jid"));
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("actor")) {
|
||||
item.setActor(parser.getAttributeValue("", "jid"));
|
||||
}
|
||||
if (parser.getName().equals("reason")) {
|
||||
item.setReason(parser.getText());
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
private MUCOwner.Destroy parseDestroy(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
MUCOwner.Destroy destroy = new MUCOwner.Destroy();
|
||||
destroy.setJid(parser.getAttributeValue("", "jid"));
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("reason")) {
|
||||
destroy.setReason(parser.getText());
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("destroy")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return destroy;
|
||||
}
|
||||
}
|
135
source/org/jivesoftware/smackx/provider/MUCUserProvider.java
Normal file
135
source/org/jivesoftware/smackx/provider/MUCUserProvider.java
Normal file
|
@ -0,0 +1,135 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright (C) 2002-2003 Jive Software. All rights reserved.
|
||||
* ====================================================================
|
||||
* The Jive Software License (based on Apache Software License, Version 1.1)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution,
|
||||
* if any, must include the following acknowledgment:
|
||||
* "This product includes software developed by
|
||||
* Jive Software (http://www.jivesoftware.com)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "Smack" and "Jive Software" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please
|
||||
* contact webmaster@jivesoftware.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Smack",
|
||||
* nor may "Smack" appear in their name, without prior written
|
||||
* permission of Jive Software.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jivesoftware.smackx.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.*;
|
||||
import org.jivesoftware.smack.provider.*;
|
||||
import org.jivesoftware.smackx.packet.*;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* The MUCUserProvider parses packets with extended presence information about
|
||||
* roles and affiliations.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MUCUserProvider implements PacketExtensionProvider {
|
||||
|
||||
/**
|
||||
* Creates a new MUCUserProvider.
|
||||
* ProviderManager requires that every PacketExtensionProvider has a public, no-argument
|
||||
* constructor
|
||||
*/
|
||||
public MUCUserProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a MUCUser packet (extension sub-packet).
|
||||
*
|
||||
* @param parser the XML parser, positioned at the starting element of the extension.
|
||||
* @return a PacketExtension.
|
||||
* @throws Exception if a parsing error occurs.
|
||||
*/
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
MUCUser mucUser = new MUCUser();
|
||||
boolean done = false;
|
||||
MUCUser.Item item = null;
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
item =
|
||||
new MUCUser.Item(
|
||||
parser.getAttributeValue("", "affiliation"),
|
||||
parser.getAttributeValue("", "role"));
|
||||
item.setNick(parser.getAttributeValue("", "nick"));
|
||||
item.setJid(parser.getAttributeValue("", "jid"));
|
||||
}
|
||||
if (parser.getName().equals("actor")) {
|
||||
item.setActor(parser.getAttributeValue("", "jid"));
|
||||
}
|
||||
if (parser.getName().equals("reason")) {
|
||||
item.setReason(parser.getText());
|
||||
}
|
||||
if (parser.getName().equals("password")) {
|
||||
mucUser.setPassword(parser.getText());
|
||||
}
|
||||
if (parser.getName().equals("alt")) {
|
||||
// TODO Implement alt? Is it being used?
|
||||
System.out.println("alt - Not implemented yet!");
|
||||
}
|
||||
if (parser.getName().equals("invite")) {
|
||||
// TODO Implement invitation decoding
|
||||
System.out.println("invite - Not implemented yet!");
|
||||
}
|
||||
if (parser.getName().equals("decline")) {
|
||||
// TODO Implement decline decoding
|
||||
System.out.println("decline - Not implemented yet!");
|
||||
}
|
||||
if (parser.getName().equals("status")) {
|
||||
mucUser.setStatus(new MUCUser.Status(parser.getAttributeValue("", "code")));
|
||||
}
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
mucUser.setItem(item);
|
||||
}
|
||||
if (parser.getName().equals("x")) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mucUser;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue