2007-03-08 00:38:36 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Copyright 2003-2007 Jive Software.
|
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2007-03-08 00:38:36 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.jivesoftware.smackx.workgroup.settings;
|
|
|
|
|
2014-10-07 21:15:20 +02:00
|
|
|
import java.io.IOException;
|
|
|
|
|
2007-03-08 00:38:36 +01:00
|
|
|
import org.jivesoftware.smack.packet.IQ;
|
|
|
|
import org.jivesoftware.smack.provider.IQProvider;
|
2015-09-25 13:43:20 +02:00
|
|
|
import org.jivesoftware.smack.util.StringUtils;
|
2017-06-14 17:12:43 +02:00
|
|
|
|
2007-03-08 00:38:36 +01:00
|
|
|
import org.xmlpull.v1.XmlPullParser;
|
2014-10-07 21:15:20 +02:00
|
|
|
import org.xmlpull.v1.XmlPullParserException;
|
2007-03-08 00:38:36 +01:00
|
|
|
|
|
|
|
public class WorkgroupProperties extends IQ {
|
|
|
|
|
|
|
|
private boolean authRequired;
|
|
|
|
private String email;
|
|
|
|
private String fullName;
|
|
|
|
private String jid;
|
|
|
|
|
|
|
|
public boolean isAuthRequired() {
|
|
|
|
return authRequired;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setAuthRequired(boolean authRequired) {
|
|
|
|
this.authRequired = authRequired;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getEmail() {
|
|
|
|
return email;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setEmail(String email) {
|
|
|
|
this.email = email;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getFullName() {
|
|
|
|
return fullName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFullName(String fullName) {
|
|
|
|
this.fullName = fullName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getJid() {
|
|
|
|
return jid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setJid(String jid) {
|
|
|
|
this.jid = jid;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Element name of the stanza extension.
|
2007-03-08 00:38:36 +01:00
|
|
|
*/
|
|
|
|
public static final String ELEMENT_NAME = "workgroup-properties";
|
|
|
|
|
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Namespace of the stanza extension.
|
2007-03-08 00:38:36 +01:00
|
|
|
*/
|
|
|
|
public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
|
|
|
|
|
2014-11-07 21:12:01 +01:00
|
|
|
public WorkgroupProperties() {
|
|
|
|
super(ELEMENT_NAME, NAMESPACE);
|
|
|
|
}
|
2007-03-08 00:38:36 +01:00
|
|
|
|
2014-11-07 21:12:01 +01:00
|
|
|
@Override
|
|
|
|
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) {
|
2015-09-25 13:43:20 +02:00
|
|
|
if (StringUtils.isNotEmpty(getJid())) {
|
2007-03-08 00:38:36 +01:00
|
|
|
buf.append("jid=\"" + getJid() + "\" ");
|
|
|
|
}
|
2014-11-07 21:12:01 +01:00
|
|
|
buf.setEmptyElement();
|
|
|
|
return buf;
|
2007-03-08 00:38:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-04-23 21:06:35 +02:00
|
|
|
* Stanza extension provider for SoundSetting Packets.
|
2007-03-08 00:38:36 +01:00
|
|
|
*/
|
2014-10-07 21:15:20 +02:00
|
|
|
public static class InternalProvider extends IQProvider<WorkgroupProperties> {
|
2007-03-08 00:38:36 +01:00
|
|
|
|
2014-10-07 21:15:20 +02:00
|
|
|
@Override
|
|
|
|
public WorkgroupProperties parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
2007-03-08 00:38:36 +01:00
|
|
|
WorkgroupProperties props = new WorkgroupProperties();
|
|
|
|
|
|
|
|
boolean done = false;
|
|
|
|
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
int eventType = parser.next();
|
|
|
|
if ((eventType == XmlPullParser.START_TAG) && ("authRequired".equals(parser.getName()))) {
|
2018-11-29 22:38:11 +01:00
|
|
|
// CHECKSTYLE:OFF
|
2017-02-11 16:16:41 +01:00
|
|
|
props.setAuthRequired(Boolean.valueOf(parser.nextText()).booleanValue());
|
2018-11-29 22:38:11 +01:00
|
|
|
// CHECKSTYLE:ON
|
2007-03-08 00:38:36 +01:00
|
|
|
}
|
|
|
|
else if ((eventType == XmlPullParser.START_TAG) && ("email".equals(parser.getName()))) {
|
|
|
|
props.setEmail(parser.nextText());
|
|
|
|
}
|
|
|
|
else if ((eventType == XmlPullParser.START_TAG) && ("name".equals(parser.getName()))) {
|
|
|
|
props.setFullName(parser.nextText());
|
|
|
|
}
|
|
|
|
else if (eventType == XmlPullParser.END_TAG && "workgroup-properties".equals(parser.getName())) {
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return props;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|