Smack/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/JingleFileTransferSession.java

79 lines
2.4 KiB
Java
Raw Normal View History

2017-06-18 16:47:49 +02:00
/**
*
* Copyright 2017 Paul Schaub
*
* 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.jingle_filetransfer;
2017-06-19 14:44:35 +02:00
import org.jivesoftware.smack.XMPPConnection;
2017-06-18 16:47:49 +02:00
import org.jivesoftware.smackx.jingle.JingleSession;
2017-06-19 14:44:35 +02:00
import org.jivesoftware.smackx.jingle.JingleUtil;
2017-06-18 16:47:49 +02:00
import org.jivesoftware.smackx.jingle.Role;
2017-06-19 19:22:59 +02:00
import org.jivesoftware.smackx.jingle.element.JingleContent;
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
2017-06-21 00:16:47 +02:00
import org.jivesoftware.smackx.jingle.transports.JingleTransportManager;
2017-06-19 19:22:59 +02:00
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransfer;
2017-06-18 16:47:49 +02:00
import org.jxmpp.jid.FullJid;
/**
* Class representing a Jingle session in the context of Jingle File Transfer (XEP-0234).
*/
public abstract class JingleFileTransferSession extends JingleSession {
public enum Type {
offer,
request,
;
}
2017-06-19 14:44:35 +02:00
protected final XMPPConnection connection;
protected final JingleUtil jutil;
2017-06-19 19:22:59 +02:00
protected JingleContent.Creator creator;
protected String name;
protected JingleFileTransfer file;
protected JingleContentTransport transport;
2017-06-21 00:16:47 +02:00
protected JingleTransportManager<?> transportManager;
2017-06-19 19:22:59 +02:00
2017-06-18 16:47:49 +02:00
private final Type type;
2017-06-19 14:44:35 +02:00
public JingleFileTransferSession(XMPPConnection connection, FullJid initiator, FullJid responder, Role role, String sid, Type type) {
2017-06-18 16:47:49 +02:00
super(initiator, responder, role, sid);
this.type = type;
2017-06-19 14:44:35 +02:00
this.connection = connection;
this.jutil = new JingleUtil(connection);
2017-06-18 16:47:49 +02:00
}
public Type getType() {
return type;
}
public boolean isOffer() {
return this.type == Type.offer;
}
public boolean isRequest() {
return this.type == Type.request;
}
public boolean isSender() {
return (isOffer() && isInitiator()) || (isRequest() && isResponder());
}
public boolean isReceiver() {
return (isRequest() && isInitiator()) || (isOffer() && isResponder());
}
}