mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 21:42:07 +01:00
Move ChatStateExtension Provider in its own class
This commit is contained in:
parent
af1bde4fd0
commit
33371cffaf
4 changed files with 61 additions and 22 deletions
|
@ -19,9 +19,7 @@ package org.jivesoftware.smackx.chatstates.packet;
|
|||
|
||||
import org.jivesoftware.smackx.chatstates.ChatState;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* Represents a chat state which is an extension to message packets which is used to indicate
|
||||
|
@ -66,18 +64,4 @@ public class ChatStateExtension implements ExtensionElement {
|
|||
return xml;
|
||||
}
|
||||
|
||||
public static class Provider extends ExtensionElementProvider<ChatStateExtension> {
|
||||
|
||||
@Override
|
||||
public ChatStateExtension parse(XmlPullParser parser, int initialDepth) {
|
||||
ChatState state;
|
||||
try {
|
||||
state = ChatState.valueOf(parser.getName());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
state = ChatState.active;
|
||||
}
|
||||
return new ChatStateExtension(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017 Florian Schmaus
|
||||
*
|
||||
* 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.chatstates.provider;
|
||||
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.chatstates.ChatState;
|
||||
import org.jivesoftware.smackx.chatstates.packet.ChatStateExtension;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
public class ChatStateExtensionProvider extends ExtensionElementProvider<ChatStateExtension> {
|
||||
|
||||
@Override
|
||||
public ChatStateExtension parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||
String chatStateString = parser.getName();
|
||||
ChatState state = ChatState.valueOf(chatStateString);
|
||||
|
||||
return new ChatStateExtension(state);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017 Florian Schmaus
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provider classes for Chat State Notifications (XEP-0085).
|
||||
*/
|
||||
package org.jivesoftware.smackx.chatstates.provider;
|
|
@ -16,35 +16,35 @@
|
|||
<className>org.jivesoftware.smackx.time.provider.TimeProvider</className>
|
||||
</iqProvider>
|
||||
|
||||
<!-- Chat State -->
|
||||
<!-- XEP-0085: Chat State -->
|
||||
<extensionProvider>
|
||||
<elementName>active</elementName>
|
||||
<namespace>http://jabber.org/protocol/chatstates</namespace>
|
||||
<className>org.jivesoftware.smackx.chatstates.packet.ChatStateExtension$Provider</className>
|
||||
<className>org.jivesoftware.smackx.chatstates.provider.ChatStateExtensionProvider</className>
|
||||
</extensionProvider>
|
||||
|
||||
<extensionProvider>
|
||||
<elementName>composing</elementName>
|
||||
<namespace>http://jabber.org/protocol/chatstates</namespace>
|
||||
<className>org.jivesoftware.smackx.chatstates.packet.ChatStateExtension$Provider</className>
|
||||
<className>org.jivesoftware.smackx.chatstates.provider.ChatStateExtensionProvider</className>
|
||||
</extensionProvider>
|
||||
|
||||
<extensionProvider>
|
||||
<elementName>paused</elementName>
|
||||
<namespace>http://jabber.org/protocol/chatstates</namespace>
|
||||
<className>org.jivesoftware.smackx.chatstates.packet.ChatStateExtension$Provider</className>
|
||||
<className>org.jivesoftware.smackx.chatstates.provider.ChatStateExtensionProvider</className>
|
||||
</extensionProvider>
|
||||
|
||||
<extensionProvider>
|
||||
<elementName>inactive</elementName>
|
||||
<namespace>http://jabber.org/protocol/chatstates</namespace>
|
||||
<className>org.jivesoftware.smackx.chatstates.packet.ChatStateExtension$Provider</className>
|
||||
<className>org.jivesoftware.smackx.chatstates.provider.ChatStateExtensionProvider</className>
|
||||
</extensionProvider>
|
||||
|
||||
<extensionProvider>
|
||||
<elementName>gone</elementName>
|
||||
<namespace>http://jabber.org/protocol/chatstates</namespace>
|
||||
<className>org.jivesoftware.smackx.chatstates.packet.ChatStateExtension$Provider</className>
|
||||
<className>org.jivesoftware.smackx.chatstates.provider.ChatStateExtensionProvider</className>
|
||||
</extensionProvider>
|
||||
|
||||
<!-- XHTML -->
|
||||
|
|
Loading…
Reference in a new issue