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;
|
|
|
|
|
2014-11-07 21:12:01 +01:00
|
|
|
import org.jivesoftware.smack.packet.SimpleIQ;
|
2019-02-15 23:21:30 +01:00
|
|
|
import org.jivesoftware.smack.packet.XmlEnvironment;
|
2007-03-08 00:38:36 +01:00
|
|
|
import org.jivesoftware.smack.provider.IQProvider;
|
2014-09-04 11:04:51 +02:00
|
|
|
import org.jivesoftware.smack.util.stringencoder.Base64;
|
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
|
|
|
|
2014-11-07 21:12:01 +01:00
|
|
|
public class SoundSettings extends SimpleIQ {
|
2007-03-08 00:38:36 +01:00
|
|
|
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() {
|
2014-09-04 11:04:51 +02:00
|
|
|
return Base64.decode(incomingSound);
|
2007-03-08 00:38:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public byte[] getOutgoingSoundBytes() {
|
2014-09-04 11:04:51 +02:00
|
|
|
return Base64.decode(outgoingSound);
|
2007-03-08 00:38:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
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 = "sound-settings";
|
|
|
|
|
|
|
|
/**
|
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 SoundSettings() {
|
|
|
|
super(ELEMENT_NAME, NAMESPACE);
|
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<SoundSettings> {
|
2007-03-08 00:38:36 +01:00
|
|
|
|
2014-10-07 21:15:20 +02:00
|
|
|
@Override
|
2019-02-15 23:21:30 +01:00
|
|
|
public SoundSettings parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
|
2007-03-08 00:38:36 +01:00
|
|
|
SoundSettings soundSettings = new SoundSettings();
|
|
|
|
|
|
|
|
boolean done = false;
|
|
|
|
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
int eventType = parser.next();
|
2018-10-31 16:06:31 +01:00
|
|
|
if (eventType == XmlPullParser.START_TAG && "outgoingSound".equals(parser.getName())) {
|
2007-03-08 00:38:36 +01:00
|
|
|
soundSettings.setOutgoingSound(parser.nextText());
|
|
|
|
}
|
2018-10-31 16:06:31 +01:00
|
|
|
else if ((eventType == XmlPullParser.START_TAG) && "incomingSound".equals(parser.getName())) {
|
2007-03-08 00:38:36 +01:00
|
|
|
soundSettings.setIncomingSound(parser.nextText());
|
|
|
|
}
|
|
|
|
else if (eventType == XmlPullParser.END_TAG && "sound-settings".equals(parser.getName())) {
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return soundSettings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|