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
|
|
|
|
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;
|
2014-02-15 11:35:08 +01:00
|
|
|
import org.jivesoftware.smackx.muc.packet.MUCOwner;
|
2004-03-29 23:29:55 +02:00
|
|
|
import org.xmlpull.v1.XmlPullParser;
|
|
|
|
|
|
|
|
/**
|
2004-04-05 18:24:44 +02:00
|
|
|
* The MUCOwnerProvider parses MUCOwner packets. (@see MUCOwner)
|
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
|
|
|
|
public MUCOwner parse(XmlPullParser parser, int initialDepth)
|
2015-03-13 09:27:18 +01:00
|
|
|
throws Exception {
|
2004-03-29 23:29:55 +02:00
|
|
|
MUCOwner mucOwner = new MUCOwner();
|
|
|
|
boolean done = false;
|
|
|
|
while (!done) {
|
|
|
|
int eventType = parser.next();
|
|
|
|
if (eventType == XmlPullParser.START_TAG) {
|
|
|
|
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 {
|
2015-02-26 18:41:17 +01:00
|
|
|
PacketParserUtils.addExtensionElement(mucOwner, parser);
|
2004-03-29 23:29:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (eventType == XmlPullParser.END_TAG) {
|
|
|
|
if (parser.getName().equals("query")) {
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return mucOwner;
|
|
|
|
}
|
|
|
|
}
|