2004-03-29 23:29:55 +02:00
|
|
|
/**
|
2004-11-03 00:37:00 +01:00
|
|
|
*
|
2007-02-12 01:59:05 +01:00
|
|
|
* Copyright 2003-2007 Jive Software.
|
2004-11-03 00:37:00 +01:00
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2004-11-03 00:37:00 +01:00
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2004-03-29 23:29:55 +02:00
|
|
|
|
2014-02-15 11:35:08 +01:00
|
|
|
package org.jivesoftware.smackx.muc.provider;
|
2004-03-29 23:29:55 +02:00
|
|
|
|
2019-02-05 10:41:50 +01:00
|
|
|
import java.io.IOException;
|
|
|
|
|
2019-02-15 23:21:30 +01:00
|
|
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
2019-02-10 19:01:47 +01:00
|
|
|
import org.jivesoftware.smack.parsing.SmackParsingException;
|
2014-08-15 23:16:18 +02:00
|
|
|
import org.jivesoftware.smack.provider.IQProvider;
|
2004-03-29 23:29:55 +02:00
|
|
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
2019-05-06 22:06:13 +02:00
|
|
|
import org.jivesoftware.smack.xml.XmlPullParser;
|
|
|
|
import org.jivesoftware.smack.xml.XmlPullParserException;
|
2017-06-14 17:12:43 +02:00
|
|
|
|
2014-02-15 11:35:08 +01:00
|
|
|
import org.jivesoftware.smackx.muc.packet.MUCOwner;
|
2017-06-14 17:12:43 +02:00
|
|
|
|
2004-03-29 23:29:55 +02:00
|
|
|
/**
|
2004-04-05 18:24:44 +02:00
|
|
|
* The MUCOwnerProvider parses MUCOwner packets. (@see MUCOwner)
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2004-03-29 23:29:55 +02:00
|
|
|
* @author Gaston Dombiak
|
|
|
|
*/
|
2014-10-07 21:15:20 +02:00
|
|
|
public class MUCOwnerProvider extends IQProvider<MUCOwner> {
|
2004-03-29 23:29:55 +02:00
|
|
|
|
2014-10-07 21:15:20 +02:00
|
|
|
@Override
|
2019-02-15 23:21:30 +01:00
|
|
|
public MUCOwner parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
|
2004-03-29 23:29:55 +02:00
|
|
|
MUCOwner mucOwner = new MUCOwner();
|
|
|
|
boolean done = false;
|
|
|
|
while (!done) {
|
2019-05-06 22:06:13 +02:00
|
|
|
XmlPullParser.Event eventType = parser.next();
|
|
|
|
if (eventType == XmlPullParser.Event.START_ELEMENT) {
|
2004-03-29 23:29:55 +02:00
|
|
|
if (parser.getName().equals("item")) {
|
2014-07-14 19:22:02 +02:00
|
|
|
mucOwner.addItem(MUCParserUtils.parseItem(parser));
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
2004-09-12 04:12:38 +02:00
|
|
|
else if (parser.getName().equals("destroy")) {
|
2014-07-14 19:22:02 +02:00
|
|
|
mucOwner.setDestroy(MUCParserUtils.parseDestroy(parser));
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
|
|
|
// Otherwise, it must be a packet extension.
|
|
|
|
else {
|
2019-02-15 23:21:30 +01:00
|
|
|
PacketParserUtils.addExtensionElement(mucOwner, parser, xmlEnvironment);
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-06 22:06:13 +02:00
|
|
|
else if (eventType == XmlPullParser.Event.END_ELEMENT) {
|
2004-03-29 23:29:55 +02:00
|
|
|
if (parser.getName().equals("query")) {
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return mucOwner;
|
|
|
|
}
|
|
|
|
}
|