mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-06 05:01:12 +01:00
Adding workgroup API (SMACK-185).
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7400 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
939feb9017
commit
fe545abeae
64 changed files with 9744 additions and 0 deletions
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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;
|
||||
|
||||
public class ChatSetting {
|
||||
private String key;
|
||||
private String value;
|
||||
private int type;
|
||||
|
||||
public ChatSetting(String key, String value, int type){
|
||||
setKey(key);
|
||||
setValue(value);
|
||||
setType(type);
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,179 @@
|
|||
/**
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ChatSettings extends IQ {
|
||||
|
||||
/**
|
||||
* Defined as image type.
|
||||
*/
|
||||
public static final int IMAGE_SETTINGS = 0;
|
||||
|
||||
/**
|
||||
* Defined as Text settings type.
|
||||
*/
|
||||
public static final int TEXT_SETTINGS = 1;
|
||||
|
||||
/**
|
||||
* Defined as Bot settings type.
|
||||
*/
|
||||
public static final int BOT_SETTINGS = 2;
|
||||
|
||||
private List settings;
|
||||
private String key;
|
||||
private int type = -1;
|
||||
|
||||
public ChatSettings() {
|
||||
settings = new ArrayList();
|
||||
}
|
||||
|
||||
public ChatSettings(String key) {
|
||||
setKey(key);
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void addSetting(ChatSetting setting) {
|
||||
settings.add(setting);
|
||||
}
|
||||
|
||||
public Collection getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public ChatSetting getChatSetting(String key) {
|
||||
Collection col = getSettings();
|
||||
if (col != null) {
|
||||
Iterator iter = col.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ChatSetting chatSetting = (ChatSetting)iter.next();
|
||||
if (chatSetting.getKey().equals(key)) {
|
||||
return chatSetting;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ChatSetting getFirstEntry() {
|
||||
if (settings.size() > 0) {
|
||||
return (ChatSetting)settings.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Element name of the packet extension.
|
||||
*/
|
||||
public static final String ELEMENT_NAME = "chat-settings";
|
||||
|
||||
/**
|
||||
* Namespace of the packet extension.
|
||||
*/
|
||||
public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
|
||||
|
||||
public String getChildElementXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
buf.append("<").append(ELEMENT_NAME).append(" xmlns=");
|
||||
buf.append('"');
|
||||
buf.append(NAMESPACE);
|
||||
buf.append('"');
|
||||
if (key != null) {
|
||||
buf.append(" key=\"" + key + "\"");
|
||||
}
|
||||
|
||||
if (type != -1) {
|
||||
buf.append(" type=\"" + type + "\"");
|
||||
}
|
||||
|
||||
buf.append("></").append(ELEMENT_NAME).append("> ");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Packet extension provider for AgentStatusRequest packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
|
||||
ChatSettings chatSettings = new ChatSettings();
|
||||
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if ((eventType == XmlPullParser.START_TAG) && ("chat-setting".equals(parser.getName()))) {
|
||||
chatSettings.addSetting(parseChatSetting(parser));
|
||||
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG && ELEMENT_NAME.equals(parser.getName())) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
return chatSettings;
|
||||
}
|
||||
|
||||
private ChatSetting parseChatSetting(XmlPullParser parser) throws Exception {
|
||||
|
||||
boolean done = false;
|
||||
String key = null;
|
||||
String value = null;
|
||||
int type = 0;
|
||||
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if ((eventType == XmlPullParser.START_TAG) && ("key".equals(parser.getName()))) {
|
||||
key = parser.nextText();
|
||||
}
|
||||
else if ((eventType == XmlPullParser.START_TAG) && ("value".equals(parser.getName()))) {
|
||||
value = parser.nextText();
|
||||
}
|
||||
else if ((eventType == XmlPullParser.START_TAG) && ("type".equals(parser.getName()))) {
|
||||
type = Integer.parseInt(parser.nextText());
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG && "chat-setting".equals(parser.getName())) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
return new ChatSetting(key, value, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
/**
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.util.ModelUtil;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class GenericSettings extends IQ {
|
||||
|
||||
private Map map = new HashMap();
|
||||
|
||||
private String query;
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(String query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public Map getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setMap(Map map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Element name of the packet extension.
|
||||
*/
|
||||
public static final String ELEMENT_NAME = "generic-metadata";
|
||||
|
||||
/**
|
||||
* Namespace of the packet extension.
|
||||
*/
|
||||
public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
|
||||
|
||||
public String getChildElementXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
buf.append("<").append(ELEMENT_NAME).append(" xmlns=");
|
||||
buf.append('"');
|
||||
buf.append(NAMESPACE);
|
||||
buf.append('"');
|
||||
buf.append(">");
|
||||
if (ModelUtil.hasLength(getQuery())) {
|
||||
buf.append("<query>" + getQuery() + "</query>");
|
||||
}
|
||||
buf.append("</").append(ELEMENT_NAME).append("> ");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Packet extension provider for SoundSetting Packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
|
||||
GenericSettings setting = new GenericSettings();
|
||||
|
||||
boolean done = false;
|
||||
|
||||
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if ((eventType == XmlPullParser.START_TAG) && ("entry".equals(parser.getName()))) {
|
||||
eventType = parser.next();
|
||||
String name = parser.nextText();
|
||||
eventType = parser.next();
|
||||
String value = parser.nextText();
|
||||
setting.getMap().put(name, value);
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG && ELEMENT_NAME.equals(parser.getName())) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
return setting;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
/**
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.util.ModelUtil;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class OfflineSettings extends IQ {
|
||||
private String redirectURL;
|
||||
|
||||
private String offlineText;
|
||||
private String emailAddress;
|
||||
private String subject;
|
||||
|
||||
public String getRedirectURL() {
|
||||
if (!ModelUtil.hasLength(redirectURL)) {
|
||||
return "";
|
||||
}
|
||||
return redirectURL;
|
||||
}
|
||||
|
||||
public void setRedirectURL(String redirectURL) {
|
||||
this.redirectURL = redirectURL;
|
||||
}
|
||||
|
||||
public String getOfflineText() {
|
||||
if (!ModelUtil.hasLength(offlineText)) {
|
||||
return "";
|
||||
}
|
||||
return offlineText;
|
||||
}
|
||||
|
||||
public void setOfflineText(String offlineText) {
|
||||
this.offlineText = offlineText;
|
||||
}
|
||||
|
||||
public String getEmailAddress() {
|
||||
if (!ModelUtil.hasLength(emailAddress)) {
|
||||
return "";
|
||||
}
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
public void setEmailAddress(String emailAddress) {
|
||||
this.emailAddress = emailAddress;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
if (!ModelUtil.hasLength(subject)) {
|
||||
return "";
|
||||
}
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public boolean redirects() {
|
||||
return (ModelUtil.hasLength(getRedirectURL()));
|
||||
}
|
||||
|
||||
public boolean isConfigured(){
|
||||
return ModelUtil.hasLength(getEmailAddress()) &&
|
||||
ModelUtil.hasLength(getSubject()) &&
|
||||
ModelUtil.hasLength(getOfflineText());
|
||||
}
|
||||
|
||||
/**
|
||||
* Element name of the packet extension.
|
||||
*/
|
||||
public static final String ELEMENT_NAME = "offline-settings";
|
||||
|
||||
/**
|
||||
* Namespace of the packet extension.
|
||||
*/
|
||||
public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
|
||||
|
||||
public String getChildElementXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
buf.append("<").append(ELEMENT_NAME).append(" xmlns=");
|
||||
buf.append('"');
|
||||
buf.append(NAMESPACE);
|
||||
buf.append('"');
|
||||
buf.append("></").append(ELEMENT_NAME).append("> ");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Packet extension provider for AgentStatusRequest packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
|
||||
OfflineSettings offlineSettings = new OfflineSettings();
|
||||
|
||||
boolean done = false;
|
||||
String redirectPage = null;
|
||||
String subject = null;
|
||||
String offlineText = null;
|
||||
String emailAddress = null;
|
||||
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if ((eventType == XmlPullParser.START_TAG) && ("redirectPage".equals(parser.getName()))) {
|
||||
redirectPage = parser.nextText();
|
||||
}
|
||||
else if ((eventType == XmlPullParser.START_TAG) && ("subject".equals(parser.getName()))) {
|
||||
subject = parser.nextText();
|
||||
}
|
||||
else if ((eventType == XmlPullParser.START_TAG) && ("offlineText".equals(parser.getName()))) {
|
||||
offlineText = parser.nextText();
|
||||
}
|
||||
else if ((eventType == XmlPullParser.START_TAG) && ("emailAddress".equals(parser.getName()))) {
|
||||
emailAddress = parser.nextText();
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG && "offline-settings".equals(parser.getName())) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
offlineSettings.setEmailAddress(emailAddress);
|
||||
offlineSettings.setRedirectURL(redirectPage);
|
||||
offlineSettings.setSubject(subject);
|
||||
offlineSettings.setOfflineText(offlineText);
|
||||
return offlineSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
* $RCSfile$
|
||||
* $Revision: 38648 $
|
||||
* $Date: 2006-12-27 01:46:18 -0800 (Wed, 27 Dec 2006) $
|
||||
*
|
||||
* Copyright (C) 1999-2005 Jive Software. All rights reserved.
|
||||
*
|
||||
* This software is the proprietary information of Jive Software. Use is
|
||||
subject to license terms.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smackx.workgroup.settings;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.util.ModelUtil;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class SearchSettings extends IQ {
|
||||
private String forumsLocation;
|
||||
private String kbLocation;
|
||||
|
||||
public boolean isSearchEnabled() {
|
||||
return ModelUtil.hasLength(getForumsLocation()) && ModelUtil.hasLength(getKbLocation());
|
||||
}
|
||||
|
||||
public String getForumsLocation() {
|
||||
return forumsLocation;
|
||||
}
|
||||
|
||||
public void setForumsLocation(String forumsLocation) {
|
||||
this.forumsLocation = forumsLocation;
|
||||
}
|
||||
|
||||
public String getKbLocation() {
|
||||
return kbLocation;
|
||||
}
|
||||
|
||||
public void setKbLocation(String kbLocation) {
|
||||
this.kbLocation = kbLocation;
|
||||
}
|
||||
|
||||
public boolean hasKB(){
|
||||
return ModelUtil.hasLength(getKbLocation());
|
||||
}
|
||||
|
||||
public boolean hasForums(){
|
||||
return ModelUtil.hasLength(getForumsLocation());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Element name of the packet extension.
|
||||
*/
|
||||
public static final String ELEMENT_NAME = "search-settings";
|
||||
|
||||
/**
|
||||
* Namespace of the packet extension.
|
||||
*/
|
||||
public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
|
||||
|
||||
public String getChildElementXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
buf.append("<").append(ELEMENT_NAME).append(" xmlns=");
|
||||
buf.append('"');
|
||||
buf.append(NAMESPACE);
|
||||
buf.append('"');
|
||||
buf.append("></").append(ELEMENT_NAME).append("> ");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Packet extension provider for AgentStatusRequest packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
|
||||
SearchSettings settings = new SearchSettings();
|
||||
|
||||
boolean done = false;
|
||||
String kb = null;
|
||||
String forums = null;
|
||||
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if ((eventType == XmlPullParser.START_TAG) && ("forums".equals(parser.getName()))) {
|
||||
forums = parser.nextText();
|
||||
}
|
||||
else if ((eventType == XmlPullParser.START_TAG) && ("kb".equals(parser.getName()))) {
|
||||
kb = parser.nextText();
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG && "search-settings".equals(parser.getName())) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
settings.setForumsLocation(forums);
|
||||
settings.setKbLocation(kb);
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class SoundSettings extends IQ {
|
||||
private String outgoingSound;
|
||||
private String incomingSound;
|
||||
|
||||
|
||||
public void setOutgoingSound(String outgoingSound) {
|
||||
this.outgoingSound = outgoingSound;
|
||||
}
|
||||
|
||||
public void setIncomingSound(String incomingSound) {
|
||||
this.incomingSound = incomingSound;
|
||||
}
|
||||
|
||||
public byte[] getIncomingSoundBytes() {
|
||||
return StringUtils.decodeBase64(incomingSound);
|
||||
}
|
||||
|
||||
public byte[] getOutgoingSoundBytes() {
|
||||
return StringUtils.decodeBase64(outgoingSound);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Element name of the packet extension.
|
||||
*/
|
||||
public static final String ELEMENT_NAME = "sound-settings";
|
||||
|
||||
/**
|
||||
* Namespace of the packet extension.
|
||||
*/
|
||||
public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
|
||||
|
||||
public String getChildElementXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
buf.append("<").append(ELEMENT_NAME).append(" xmlns=");
|
||||
buf.append('"');
|
||||
buf.append(NAMESPACE);
|
||||
buf.append('"');
|
||||
buf.append("></").append(ELEMENT_NAME).append("> ");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Packet extension provider for SoundSetting Packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
|
||||
SoundSettings soundSettings = new SoundSettings();
|
||||
|
||||
boolean done = false;
|
||||
|
||||
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if ((eventType == XmlPullParser.START_TAG) && ("outgoingSound".equals(parser.getName()))) {
|
||||
soundSettings.setOutgoingSound(parser.nextText());
|
||||
}
|
||||
else if ((eventType == XmlPullParser.START_TAG) && ("incomingSound".equals(parser.getName()))) {
|
||||
soundSettings.setIncomingSound(parser.nextText());
|
||||
}
|
||||
else if (eventType == XmlPullParser.END_TAG && "sound-settings".equals(parser.getName())) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
return soundSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
/**
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.util.ModelUtil;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Element name of the packet extension.
|
||||
*/
|
||||
public static final String ELEMENT_NAME = "workgroup-properties";
|
||||
|
||||
/**
|
||||
* Namespace of the packet extension.
|
||||
*/
|
||||
public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
|
||||
|
||||
public String getChildElementXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
buf.append("<").append(ELEMENT_NAME).append(" xmlns=");
|
||||
buf.append('"');
|
||||
buf.append(NAMESPACE);
|
||||
buf.append('"');
|
||||
if (ModelUtil.hasLength(getJid())) {
|
||||
buf.append("jid=\"" + getJid() + "\" ");
|
||||
}
|
||||
buf.append("></").append(ELEMENT_NAME).append("> ");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Packet extension provider for SoundSetting Packets.
|
||||
*/
|
||||
public static class InternalProvider implements IQProvider {
|
||||
|
||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
if (parser.getEventType() != XmlPullParser.START_TAG) {
|
||||
throw new IllegalStateException("Parser not in proper position, or bad XML.");
|
||||
}
|
||||
|
||||
WorkgroupProperties props = new WorkgroupProperties();
|
||||
|
||||
boolean done = false;
|
||||
|
||||
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if ((eventType == XmlPullParser.START_TAG) && ("authRequired".equals(parser.getName()))) {
|
||||
props.setAuthRequired(new Boolean(parser.nextText()).booleanValue());
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue