mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-12-13 00:21:07 +01:00
Prefix subprojects with 'smack-'
instead of using the old baseName=smack appendix=project.name approach, we are now going convention over configuration and renaming the subprojects directories to the proper name. Having a prefix is actually very helpful, because the resulting libraries will be named like the subproject. And a core-4.0.0-rc1.jar is not as explicit about what it actually *is* as a smack-core-4.0.0-rc1.jar. SMACK-265
This commit is contained in:
parent
b6fb1f3743
commit
91fd15ad86
758 changed files with 42 additions and 42 deletions
|
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
*
|
||||
* Copyright the original author or authors
|
||||
*
|
||||
* 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.delay.packet;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.util.XmppDateTime;
|
||||
|
||||
/**
|
||||
* A decorator for the {@link DelayInformation} class to transparently support
|
||||
* both the new <b>Delay Delivery</b> specification <a href="http://xmpp.org/extensions/xep-0203.html">XEP-0203</a> and
|
||||
* the old one <a href="http://xmpp.org/extensions/xep-0091.html">XEP-0091</a>.
|
||||
*
|
||||
* Existing code can be backward compatible.
|
||||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class DelayInfo extends DelayInformation
|
||||
{
|
||||
|
||||
DelayInformation wrappedInfo;
|
||||
|
||||
/**
|
||||
* Creates a new instance with given delay information.
|
||||
* @param delay the delay information
|
||||
*/
|
||||
public DelayInfo(DelayInformation delay)
|
||||
{
|
||||
super(delay.getStamp());
|
||||
wrappedInfo = delay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFrom()
|
||||
{
|
||||
return wrappedInfo.getFrom();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReason()
|
||||
{
|
||||
return wrappedInfo.getReason();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getStamp()
|
||||
{
|
||||
return wrappedInfo.getStamp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrom(String from)
|
||||
{
|
||||
wrappedInfo.setFrom(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReason(String reason)
|
||||
{
|
||||
wrappedInfo.setReason(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName()
|
||||
{
|
||||
return "delay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace()
|
||||
{
|
||||
return "urn:xmpp:delay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
|
||||
"\"");
|
||||
buf.append(" stamp=\"");
|
||||
buf.append(XmppDateTime.formatXEP0082Date(getStamp()));
|
||||
buf.append("\"");
|
||||
if (getFrom() != null && getFrom().length() > 0) {
|
||||
buf.append(" from=\"").append(getFrom()).append("\"");
|
||||
}
|
||||
buf.append(">");
|
||||
if (getReason() != null && getReason().length() > 0) {
|
||||
buf.append(getReason());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
/**
|
||||
*
|
||||
* Copyright the original author or authors
|
||||
*
|
||||
* 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.delay.packet;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
|
||||
/**
|
||||
* Represents timestamp information about data stored for later delivery. A DelayInformation will
|
||||
* always includes the timestamp when the packet was originally sent and may include more
|
||||
* information such as the JID of the entity that originally sent the packet as well as the reason
|
||||
* for the delay.<p>
|
||||
*
|
||||
* For more information see <a href="http://xmpp.org/extensions/xep-0091.html">XEP-0091</a>
|
||||
* and <a href="http://xmpp.org/extensions/xep-0203.html">XEP-0203</a>.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class DelayInformation implements PacketExtension {
|
||||
|
||||
/**
|
||||
* Date format according to the obsolete XEP-0091 specification.
|
||||
* XEP-0091 recommends to use this old format for date-time instead of
|
||||
* the one specified in XEP-0082.
|
||||
* <p>
|
||||
* Date formats are not synchronized. Since multiple threads access the format concurrently,
|
||||
* it must be synchronized externally.
|
||||
*/
|
||||
public static final DateFormat XEP_0091_UTC_FORMAT = new SimpleDateFormat(
|
||||
"yyyyMMdd'T'HH:mm:ss");
|
||||
static {
|
||||
XEP_0091_UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
|
||||
private Date stamp;
|
||||
private String from;
|
||||
private String reason;
|
||||
|
||||
/**
|
||||
* Creates a new instance with the specified timestamp.
|
||||
* @param stamp the timestamp
|
||||
*/
|
||||
public DelayInformation(Date stamp) {
|
||||
super();
|
||||
this.stamp = stamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JID of the entity that originally sent the packet or that delayed the
|
||||
* delivery of the packet or <tt>null</tt> if this information is not available.
|
||||
*
|
||||
* @return the JID of the entity that originally sent the packet or that delayed the
|
||||
* delivery of the packet.
|
||||
*/
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JID of the entity that originally sent the packet or that delayed the
|
||||
* delivery of the packet or <tt>null</tt> if this information is not available.
|
||||
*
|
||||
* @param from the JID of the entity that originally sent the packet.
|
||||
*/
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timestamp when the packet was originally sent. The returned Date is
|
||||
* be understood as UTC.
|
||||
*
|
||||
* @return the timestamp when the packet was originally sent.
|
||||
*/
|
||||
public Date getStamp() {
|
||||
return stamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a natural-language description of the reason for the delay or <tt>null</tt> if
|
||||
* this information is not available.
|
||||
*
|
||||
* @return a natural-language description of the reason for the delay or <tt>null</tt>.
|
||||
*/
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a natural-language description of the reason for the delay or <tt>null</tt> if
|
||||
* this information is not available.
|
||||
*
|
||||
* @param reason a natural-language description of the reason for the delay or <tt>null</tt>.
|
||||
*/
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public String getElementName() {
|
||||
return "x";
|
||||
}
|
||||
|
||||
public String getNamespace() {
|
||||
return "jabber:x:delay";
|
||||
}
|
||||
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
|
||||
"\"");
|
||||
buf.append(" stamp=\"");
|
||||
synchronized (XEP_0091_UTC_FORMAT) {
|
||||
buf.append(XEP_0091_UTC_FORMAT.format(stamp));
|
||||
}
|
||||
buf.append("\"");
|
||||
if (from != null && from.length() > 0) {
|
||||
buf.append(" from=\"").append(from).append("\"");
|
||||
}
|
||||
buf.append(">");
|
||||
if (reason != null && reason.length() > 0) {
|
||||
buf.append(reason);
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
*
|
||||
* Copyright the original author or authors
|
||||
*
|
||||
* 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.delay.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInfo;
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* This provider simply creates a {@link DelayInfo} decorator for the {@link DelayInformation} that
|
||||
* is returned by the superclass. This allows the new code using
|
||||
* <a href="http://xmpp.org/extensions/xep-0203.html">Delay Information XEP-0203</a> to be
|
||||
* backward compatible with <a href="http://xmpp.org/extensions/xep-0091.html">XEP-0091</a>.
|
||||
*
|
||||
* <p>This provider must be registered in the <b>smack.properties</b> file for the element
|
||||
* <b>delay</b> with namespace <b>urn:xmpp:delay</b></p>
|
||||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class DelayInfoProvider extends DelayInformationProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception
|
||||
{
|
||||
return new DelayInfo((DelayInformation)super.parseExtension(parser));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
*
|
||||
* Copyright the original author or authors
|
||||
*
|
||||
* 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.delay.provider;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.util.XmppDateTime;
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* The DelayInformationProvider parses DelayInformation packets.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class DelayInformationProvider implements PacketExtensionProvider {
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
String stampString = (parser.getAttributeValue("", "stamp"));
|
||||
Date stamp = null;
|
||||
|
||||
try {
|
||||
stamp = XmppDateTime.parseDate(stampString);
|
||||
}
|
||||
catch (ParseException parseExc) {
|
||||
/*
|
||||
* if date could not be parsed but XML is valid, don't shutdown
|
||||
* connection by throwing an exception instead set timestamp to epoch
|
||||
* so that it is obviously wrong.
|
||||
*/
|
||||
if (stamp == null) {
|
||||
stamp = new Date(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DelayInformation delayInformation = new DelayInformation(stamp);
|
||||
delayInformation.setFrom(parser.getAttributeValue("", "from"));
|
||||
String reason = parser.nextText();
|
||||
|
||||
/*
|
||||
* parser.nextText() returns empty string if there is no reason.
|
||||
* DelayInformation API specifies that null should be returned in that
|
||||
* case.
|
||||
*/
|
||||
reason = "".equals(reason) ? null : reason;
|
||||
delayInformation.setReason(reason);
|
||||
|
||||
return delayInformation;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue