2013-02-07 15:19:47 +01:00
|
|
|
/**
|
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Copyright the original author or authors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2013-02-07 15:19:47 +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.
|
|
|
|
*/
|
2014-02-17 23:58:40 +01:00
|
|
|
package org.jivesoftware.smackx.bytestreams.ibb;
|
|
|
|
|
2014-11-07 21:12:01 +01:00
|
|
|
import org.jivesoftware.smack.packet.EmptyResultIQ;
|
|
|
|
import org.jivesoftware.smack.packet.ErrorIQ;
|
2014-02-17 23:58:40 +01:00
|
|
|
import org.jivesoftware.smack.packet.IQ;
|
2018-04-07 21:25:40 +02:00
|
|
|
import org.jivesoftware.smack.packet.StanzaError;
|
2017-06-14 17:12:43 +02:00
|
|
|
|
2015-02-14 17:15:02 +01:00
|
|
|
import org.jxmpp.jid.Jid;
|
2014-02-17 23:58:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Utility methods to create packets.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2014-02-17 23:58:40 +01:00
|
|
|
* @author Henning Staib
|
|
|
|
*/
|
|
|
|
public class IBBPacketUtils {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an error IQ.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2014-02-17 23:58:40 +01:00
|
|
|
* @param from the senders JID
|
|
|
|
* @param to the recipients JID
|
2015-12-08 08:22:50 +01:00
|
|
|
* @param condition the XMPP error condition
|
2014-02-17 23:58:40 +01:00
|
|
|
* @return an error IQ
|
|
|
|
*/
|
2018-04-07 21:25:40 +02:00
|
|
|
public static IQ createErrorIQ(Jid from, Jid to, StanzaError.Condition condition) {
|
2019-10-24 15:45:08 +02:00
|
|
|
StanzaError xmppError = StanzaError.getBuilder(condition).build();
|
2014-11-07 21:12:01 +01:00
|
|
|
IQ errorIQ = new ErrorIQ(xmppError);
|
2014-06-06 02:20:45 +02:00
|
|
|
errorIQ.setType(IQ.Type.error);
|
2014-02-17 23:58:40 +01:00
|
|
|
errorIQ.setFrom(from);
|
|
|
|
errorIQ.setTo(to);
|
|
|
|
return errorIQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a result IQ.
|
2018-05-09 23:06:12 +02:00
|
|
|
*
|
2014-02-17 23:58:40 +01:00
|
|
|
* @param from the senders JID
|
|
|
|
* @param to the recipients JID
|
|
|
|
* @return a result IQ
|
|
|
|
*/
|
2015-02-14 17:15:02 +01:00
|
|
|
public static IQ createResultIQ(Jid from, Jid to) {
|
2014-11-07 21:12:01 +01:00
|
|
|
IQ result = new EmptyResultIQ();
|
2014-06-06 02:20:45 +02:00
|
|
|
result.setType(IQ.Type.result);
|
2014-02-17 23:58:40 +01:00
|
|
|
result.setFrom(from);
|
|
|
|
result.setTo(to);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|