mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-26 16:22:06 +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.smackx.chatstates.ChatState;
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
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
|
* 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;
|
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>
|
<className>org.jivesoftware.smackx.time.provider.TimeProvider</className>
|
||||||
</iqProvider>
|
</iqProvider>
|
||||||
|
|
||||||
<!-- Chat State -->
|
<!-- XEP-0085: Chat State -->
|
||||||
<extensionProvider>
|
<extensionProvider>
|
||||||
<elementName>active</elementName>
|
<elementName>active</elementName>
|
||||||
<namespace>http://jabber.org/protocol/chatstates</namespace>
|
<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>
|
||||||
|
|
||||||
<extensionProvider>
|
<extensionProvider>
|
||||||
<elementName>composing</elementName>
|
<elementName>composing</elementName>
|
||||||
<namespace>http://jabber.org/protocol/chatstates</namespace>
|
<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>
|
||||||
|
|
||||||
<extensionProvider>
|
<extensionProvider>
|
||||||
<elementName>paused</elementName>
|
<elementName>paused</elementName>
|
||||||
<namespace>http://jabber.org/protocol/chatstates</namespace>
|
<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>
|
||||||
|
|
||||||
<extensionProvider>
|
<extensionProvider>
|
||||||
<elementName>inactive</elementName>
|
<elementName>inactive</elementName>
|
||||||
<namespace>http://jabber.org/protocol/chatstates</namespace>
|
<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>
|
||||||
|
|
||||||
<extensionProvider>
|
<extensionProvider>
|
||||||
<elementName>gone</elementName>
|
<elementName>gone</elementName>
|
||||||
<namespace>http://jabber.org/protocol/chatstates</namespace>
|
<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>
|
||||||
|
|
||||||
<!-- XHTML -->
|
<!-- XHTML -->
|
||||||
|
|
Loading…
Reference in a new issue