Fix checkstyle

This commit is contained in:
vanitasvitae 2017-06-09 23:16:15 +02:00
parent df69c8a81c
commit 327e63f52d
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
25 changed files with 249 additions and 123 deletions

View File

@ -29,7 +29,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.jingle.JingleBytestreamManager;
import org.jivesoftware.smackx.jingle.AbstractJingleTransportManager;
import org.jivesoftware.smackx.jingle.JingleContentProviderManager;
import org.jivesoftware.smackx.jingle.JingleHandler;
import org.jivesoftware.smackx.jingle.JingleManager;
@ -38,14 +38,14 @@ import org.jivesoftware.smackx.jingle.element.Jingle;
import org.jivesoftware.smackx.jingle.element.JingleAction;
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
import org.jivesoftware.smackx.jingle.exception.UnsupportedJingleTransportException;
import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingJingleFileTransferCallback;
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
import org.jivesoftware.smackx.jingle_filetransfer.callback.JingleFileTransferCallback;
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferContentDescription;
import org.jivesoftware.smackx.jingle_filetransfer.handler.IncomingFileTransferResponded;
import org.jivesoftware.smackx.jingle_filetransfer.handler.OutgoingFileTransferInitiator;
import org.jivesoftware.smackx.jingle_filetransfer.handler.ResponderIncomingFileTransferAccepted;
import org.jivesoftware.smackx.jingle_filetransfer.handler.InitiatorOutgoingFileTransferInitiated;
import org.jivesoftware.smackx.jingle_filetransfer.listener.IncomingJingleFileTransferListener;
import org.jivesoftware.smackx.jingle_filetransfer.provider.JingleFileTransferContentDescriptionProvider;
import org.jivesoftware.smackx.jingle_ibb2.JingleIBBTransportManager;
import org.jivesoftware.smackx.jingle_ibb.JingleIBBTransportManager;
import org.jxmpp.jid.FullJid;
/**
@ -105,7 +105,7 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
incomingJingleFileTransferListeners.remove(listener);
}
void notifyIncomingFileTransferListeners(Jingle jingle, IncomingJingleFileTransferCallback callback) {
void notifyIncomingFileTransferListeners(Jingle jingle, JingleFileTransferCallback callback) {
for (IncomingJingleFileTransferListener l : incomingJingleFileTransferListeners) {
l.onIncomingJingleFileTransfer(jingle, callback);
}
@ -120,10 +120,10 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
* @param file
*/
public void sendFile(File file, final FullJid recipient) throws IOException, SmackException, InterruptedException, XMPPException {
JingleBytestreamManager<?> tm = JingleTransportManager.getInstanceFor(connection())
AbstractJingleTransportManager<?> tm = JingleTransportManager.getInstanceFor(connection())
.getAvailableJingleBytestreamManagers().iterator().next();
JingleFileTransferChildElement.Builder b = JingleFileTransferChildElement.getBuilder();
JingleFileTransferChild.Builder b = JingleFileTransferChild.getBuilder();
b.setFile(file);
b.setDescription("File");
b.setMediaType("application/octet-stream");
@ -136,7 +136,7 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
new JingleManager.FullJidAndSessionId(recipient, initiate.getSid());
jingleManager.registerJingleSessionHandler(recipient, initiate.getSid(),
new OutgoingFileTransferInitiator(this, fullJidAndSessionId, file));
new InitiatorOutgoingFileTransferInitiated(this, fullJidAndSessionId, file));
connection().sendStanza(initiate);
}
@ -155,8 +155,8 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
JingleTransportManager tm = JingleTransportManager.getInstanceFor(connection());
String transportNamespace = jingle.getContents().get(0).getJingleTransports().get(0).getNamespace();
JingleBytestreamManager<?> transportManager = null;
for (JingleBytestreamManager<?> b : tm.getAvailableJingleBytestreamManagers()) {
AbstractJingleTransportManager<?> transportManager = null;
for (AbstractJingleTransportManager<?> b : tm.getAvailableJingleBytestreamManagers()) {
if (b.getNamespace().equals(transportNamespace)) {
transportManager = b;
}
@ -167,20 +167,20 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
return null;
}
final JingleBytestreamManager<?> finalTransportManager = transportManager;
final AbstractJingleTransportManager<?> finalTransportManager = transportManager;
notifyIncomingFileTransferListeners(jingle, new IncomingJingleFileTransferCallback() {
notifyIncomingFileTransferListeners(jingle, new JingleFileTransferCallback() {
@Override
public void acceptFileTransfer(File target) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, UnsupportedJingleTransportException, SmackException.NoResponseException {
public void accept(File target) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, UnsupportedJingleTransportException, SmackException.NoResponseException {
connection().sendStanza(finalTransportManager.createSessionAccept(jingle));
IncomingFileTransferResponded responded = new IncomingFileTransferResponded(JingleFileTransferManager.this, jingle, target);
ResponderIncomingFileTransferAccepted responded = new ResponderIncomingFileTransferAccepted(JingleFileTransferManager.this, jingle, target);
jingleManager.registerJingleSessionHandler(jingle.getFrom().asFullJidIfPossible(), jingle.getSid(),
responded);
finalTransportManager.setIncomingRespondedSessionListener(jingle, responded);
}
@Override
public void cancelFileTransfer() throws SmackException.NotConnectedException, InterruptedException {
public void decline() throws SmackException.NotConnectedException, InterruptedException {
//TODO
}
});

View File

@ -14,27 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.jingle;
import java.io.InputStream;
package org.jivesoftware.smackx.jingle_filetransfer.callback;
/**
* Wrapper object that binds together an inputStream with a blockSize.
* Callback for the client to decide whether to accept or decline a content-add action.
*/
public class JingleInputStream {
private final InputStream inputStream;
private final int blockSize;
public interface JingleContentAddCallback {
void accept();
public JingleInputStream(InputStream inputStream, int blockSize) {
this.inputStream = inputStream;
this.blockSize = blockSize;
}
public InputStream getInputStream() {
return inputStream;
}
public int getBlockSize() {
return blockSize;
}
void decline();
}

View File

@ -25,9 +25,9 @@ import org.jivesoftware.smackx.jingle.exception.UnsupportedJingleTransportExcept
/**
* Callback that allows the user to accept or cancel file transfers.
*/
public interface IncomingJingleFileTransferCallback {
public interface JingleFileTransferCallback {
void acceptFileTransfer(File target) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, UnsupportedJingleTransportException, SmackException.NoResponseException;
void accept(File target) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, UnsupportedJingleTransportException, SmackException.NoResponseException;
void cancelFileTransfer() throws SmackException.NotConnectedException, InterruptedException;
void decline() throws SmackException.NotConnectedException, InterruptedException;
}

View File

@ -32,13 +32,13 @@ public class Checksum implements ExtensionElement {
private final JingleContent.Creator creator;
private final String name;
private JingleFileTransferChildElement file;
private final JingleFileTransferChild file;
public Checksum(JingleContent.Creator creator, String name, JingleFileTransferChildElement file) {
public Checksum(JingleContent.Creator creator, String name, JingleFileTransferChild file) {
this.creator = creator;
this.name = name;
Objects.requireNonNull(file.getHash(), "file MUST contain at least one hash element.");
this.file = Objects.requireNonNull(file, "file MUST NOT be null.");
Objects.requireNonNull(file.getHash(), "file MUST contain at least one hash element.");
}
@Override

View File

@ -26,7 +26,7 @@ import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildEleme
/**
* Content of type File.
*/
public class JingleFileTransferChildElement extends JingleContentDescriptionChildElement {
public class JingleFileTransferChild extends JingleContentDescriptionChildElement {
public static final String ELEMENT = "file";
public static final String ELEM_DATE = "date";
public static final String ELEM_DESC = "desc";
@ -42,7 +42,7 @@ public class JingleFileTransferChildElement extends JingleContentDescriptionChil
private final int size;
private final Range range;
public JingleFileTransferChildElement(Date date, String desc, HashElement hash, String mediaType, String name, int size, Range range) {
public JingleFileTransferChild(Date date, String desc, HashElement hash, String mediaType, String name, int size, Range range) {
this.date = date;
this.desc = desc;
this.hash = hash;
@ -154,8 +154,8 @@ public class JingleFileTransferChildElement extends JingleContentDescriptionChil
return this;
}
public JingleFileTransferChildElement build() {
return new JingleFileTransferChildElement(date, desc, hash, mediaType, name, size, range);
public JingleFileTransferChild build() {
return new JingleFileTransferChild(date, desc, hash, mediaType, name, size, range);
}
public Builder setFile(File file) {

View File

@ -1,3 +1,19 @@
/**
*
* 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.handler;
import java.io.File;
@ -8,7 +24,7 @@ import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
import org.jivesoftware.smackx.hashes.HashManager;
import org.jivesoftware.smackx.hashes.element.HashElement;
import org.jivesoftware.smackx.jingle.JingleBytestreamManager;
import org.jivesoftware.smackx.jingle.AbstractJingleTransportManager;
import org.jivesoftware.smackx.jingle.JingleManager;
import org.jivesoftware.smackx.jingle.JingleSessionHandler;
import org.jivesoftware.smackx.jingle.JingleTransportManager;
@ -18,15 +34,15 @@ import org.jivesoftware.smackx.jingle_filetransfer.FileAndHashReader;
import org.jivesoftware.smackx.jingle_filetransfer.JingleFileTransferManager;
/**
* Created by vanitas on 09.06.17.
* This handler represents the state of the initiators jingle session after session-initiate was sent.
*/
public class OutgoingFileTransferInitiator implements JingleSessionHandler {
public class InitiatorOutgoingFileTransferInitiated implements JingleSessionHandler {
private final WeakReference<JingleFileTransferManager> manager;
private final JingleManager.FullJidAndSessionId fullJidAndSessionId;
private final File file;
public OutgoingFileTransferInitiator(JingleFileTransferManager manager, JingleManager.FullJidAndSessionId fullJidAndSessionId, File file) {
public InitiatorOutgoingFileTransferInitiated(JingleFileTransferManager manager, JingleManager.FullJidAndSessionId fullJidAndSessionId, File file) {
this.fullJidAndSessionId = fullJidAndSessionId;
this.file = file;
this.manager = new WeakReference<>(manager);
@ -34,7 +50,7 @@ public class OutgoingFileTransferInitiator implements JingleSessionHandler {
@Override
public IQ handleJingleSessionRequest(Jingle jingle, String sessionId) {
JingleBytestreamManager<?> bm;
AbstractJingleTransportManager<?> bm;
try {
bm = JingleTransportManager.getInstanceFor(manager.get().getConnection())
.getJingleContentTransportManager(jingle);

View File

@ -1,3 +1,19 @@
/**
*
* 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.handler;
import java.io.File;
@ -14,18 +30,19 @@ import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.bytestreams.BytestreamListener;
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
import org.jivesoftware.smackx.jingle.JingleSessionHandler;
import org.jivesoftware.smackx.jingle.element.Jingle;
import org.jivesoftware.smackx.jingle_filetransfer.JingleFileTransferManager;
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
import org.jxmpp.jid.FullJid;
/**
* Created by vanitas on 09.06.17.
* This handler represents the state of the responders jingle session after the responder sent session-accept.
*/
public class IncomingFileTransferResponded implements JingleSessionHandler, BytestreamListener {
public class ResponderIncomingFileTransferAccepted implements JingleSessionHandler, BytestreamListener {
private static final Logger LOGGER = Logger.getLogger(IncomingFileTransferResponded.class.getName());
private static final Logger LOGGER = Logger.getLogger(ResponderIncomingFileTransferAccepted.class.getName());
private final WeakReference<JingleFileTransferManager> manager;
private final File target;
@ -33,10 +50,10 @@ public class IncomingFileTransferResponded implements JingleSessionHandler, Byte
private final FullJid initiator;
private final String sessionId;
public IncomingFileTransferResponded(JingleFileTransferManager manager, Jingle initiate, File target) {
public ResponderIncomingFileTransferAccepted(JingleFileTransferManager manager, Jingle initiate, File target) {
this.manager = new WeakReference<>(manager);
this.target = target;
this.size = ((JingleFileTransferChildElement) initiate.getContents().get(0).getDescription()
this.size = ((JingleFileTransferChild) initiate.getContents().get(0).getDescription()
.getJingleContentDescriptionChildren().get(0)).getSize();
this.initiator = initiate.getInitiator();
this.sessionId = initiate.getSid();
@ -93,8 +110,8 @@ public class IncomingFileTransferResponded implements JingleSessionHandler, Byte
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Caught Exception while closing streams: " + e, e);
}
InBandBytestreamManager.getByteStreamManager(manager.get().getConnection()).removeIncomingBytestreamListener(this);
}
return;
}
@Override

View File

@ -0,0 +1,23 @@
/**
*
* 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.handler;
/**
* This handler represents the state of the responders jingle session after the responder sent session-replace.
*/
public class ResponderIncomingFileTransferTransportReplaced {
}

View File

@ -16,9 +16,14 @@
*/
package org.jivesoftware.smackx.jingle_filetransfer.listener;
import org.jivesoftware.smackx.jingle.element.Jingle;
import org.jivesoftware.smackx.jingle_filetransfer.callback.JingleContentAddCallback;
/**
* Listener for content-add actions.
*/
public interface IncomingFileTransferContentAddListener extends IncomingJingleFileTransferListener {
public interface IncomingFileTransferContentAddListener {
void onJingleContentAdd(Jingle jingle, JingleContentAddCallback callback);
}

View File

@ -17,12 +17,12 @@
package org.jivesoftware.smackx.jingle_filetransfer.listener;
import org.jivesoftware.smackx.jingle.element.Jingle;
import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingJingleFileTransferCallback;
import org.jivesoftware.smackx.jingle_filetransfer.callback.JingleFileTransferCallback;
/**
* Listener for incoming file transfers.
*/
public interface IncomingJingleFileTransferListener {
void onIncomingJingleFileTransfer(Jingle jingle, IncomingJingleFileTransferCallback callback);
void onIncomingJingleFileTransfer(Jingle jingle, JingleFileTransferCallback callback);
}

View File

@ -16,9 +16,16 @@
*/
package org.jivesoftware.smackx.jingle_filetransfer.provider;
import static org.xmlpull.v1.XmlPullParser.END_TAG;
import static org.xmlpull.v1.XmlPullParser.START_TAG;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.hashes.element.HashElement;
import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
import org.jivesoftware.smackx.jingle.element.JingleContent;
import org.jivesoftware.smackx.jingle_filetransfer.element.Checksum;
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
import org.xmlpull.v1.XmlPullParser;
/**
@ -33,8 +40,50 @@ public class ChecksumProvider extends ExtensionElementProvider<Checksum> {
creator = JingleContent.Creator.valueOf(creatorString);
}
String name = parser.getAttributeValue(null, Checksum.ATTR_NAME);
//TODO JingleFileTransferPayload file = new JingleFileTransferPayloadProvider().parse(parser);
return new Checksum(creator, name, null);
JingleFileTransferChild.Builder cb = JingleFileTransferChild.getBuilder();
HashElement hashElement = null;
Range range = null;
boolean go = true;
while (go) {
int tag = parser.nextTag();
String n = parser.getText();
if (tag == START_TAG) {
switch (n) {
case HashElement.ELEMENT:
hashElement = new HashElementProvider().parse(parser);
break;
case Range.ELEMENT:
String offset = parser.getAttributeValue(null, Range.ATTR_OFFSET);
String length = parser.getAttributeValue(null, Range.ATTR_LENGTH);
int o = offset == null ? 0 : Integer.parseInt(offset);
int l = length == null ? -1 : Integer.parseInt(length);
range = new Range(o, l);
}
} else if (tag == END_TAG) {
switch (n) {
case Range.ELEMENT:
if (hashElement != null && range != null) {
range = new Range(range.getOffset(), range.getLength(), hashElement);
hashElement = null;
}
break;
case JingleFileTransferChild.ELEMENT:
if (hashElement != null) {
cb.setHash(hashElement);
}
if (range != null) {
cb.setRange(range);
}
go = false;
}
}
}
return new Checksum(creator, name, cb.build());
}
}

View File

@ -25,7 +25,7 @@ import org.jivesoftware.smackx.hashes.element.HashElement;
import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
import org.jivesoftware.smackx.jingle.provider.JingleContentDescriptionProvider;
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferContentDescription;
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
import org.jxmpp.util.XmppDateTime;
@ -41,7 +41,7 @@ public class JingleFileTransferContentDescriptionProvider
public JingleFileTransferContentDescription parse(XmlPullParser parser, int initialDepth) throws Exception {
ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>();
boolean inRange = false;
JingleFileTransferChildElement.Builder builder = JingleFileTransferChildElement.getBuilder();
JingleFileTransferChild.Builder builder = JingleFileTransferChild.getBuilder();
HashElement inRangeHash = null;
int offset = 0;
@ -54,23 +54,23 @@ public class JingleFileTransferContentDescriptionProvider
if (tag == START_TAG) {
switch (elem) {
case JingleFileTransferChildElement.ELEM_DATE:
case JingleFileTransferChild.ELEM_DATE:
builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText()));
break;
case JingleFileTransferChildElement.ELEM_DESC:
case JingleFileTransferChild.ELEM_DESC:
builder.setDescription(parser.nextText());
break;
case JingleFileTransferChildElement.ELEM_MEDIA_TYPE:
case JingleFileTransferChild.ELEM_MEDIA_TYPE:
builder.setMediaType(parser.nextText());
break;
case JingleFileTransferChildElement.ELEM_NAME:
case JingleFileTransferChild.ELEM_NAME:
builder.setName(parser.nextText());
break;
case JingleFileTransferChildElement.ELEM_SIZE:
case JingleFileTransferChild.ELEM_SIZE:
builder.setSize(Integer.parseInt(parser.nextText()));
break;
@ -105,9 +105,9 @@ public class JingleFileTransferContentDescriptionProvider
inRangeHash = null;
break;
case JingleFileTransferChildElement.ELEMENT:
case JingleFileTransferChild.ELEMENT:
payloads.add(builder.build());
builder = JingleFileTransferChildElement.getBuilder();
builder = JingleFileTransferChild.getBuilder();
break;
case JingleFileTransferContentDescription.ELEMENT:

View File

@ -1,4 +1,20 @@
package org.jivesoftware.smackx.jingle_ibb2;
/**
*
* 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_ibb;
import java.io.IOException;
import java.util.WeakHashMap;
@ -10,21 +26,21 @@ import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.bytestreams.BytestreamListener;
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
import org.jivesoftware.smackx.jingle.JingleBytestreamManager;
import org.jivesoftware.smackx.jingle.AbstractJingleTransportManager;
import org.jivesoftware.smackx.jingle.JingleTransportManager;
import org.jivesoftware.smackx.jingle.element.Jingle;
import org.jivesoftware.smackx.jingle.element.JingleAction;
import org.jivesoftware.smackx.jingle.element.JingleContent;
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider;
import org.jivesoftware.smackx.jingle_ibb2.element.JingleIBBTransport;
import org.jivesoftware.smackx.jingle_ibb2.provider.JingleIBBTransportProvider;
import org.jivesoftware.smackx.jingle_ibb.element.JingleIBBTransport;
import org.jivesoftware.smackx.jingle_ibb.provider.JingleIBBTransportProvider;
import org.jxmpp.jid.FullJid;
/**
* BytestreamManager for Jingle InBandBytestream Transports.
*/
public final class JingleIBBTransportManager extends JingleBytestreamManager<JingleIBBTransport> {
public final class JingleIBBTransportManager extends AbstractJingleTransportManager<JingleIBBTransport> {
private static final WeakHashMap<XMPPConnection, JingleIBBTransportManager> INSTANCES = new WeakHashMap<>();

View File

@ -1,4 +1,20 @@
package org.jivesoftware.smackx.jingle_ibb2.element;
/**
*
* 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_ibb.element;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.jingle.JingleTransportManager;

View File

@ -14,12 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.jingle;
/**
* Created by vanitas on 06.06.17.
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0261: Jingle In-Band Bytestreams</a>.
* Element classes.
*/
public interface JingleTransportInputStreamCallback {
void onInputStream(JingleInputStream inputStream);
}
package org.jivesoftware.smackx.jingle_ibb.element;

View File

@ -18,4 +18,4 @@
/**
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0261: Jingle In-Band Bytestreams</a>.
*/
package org.jivesoftware.smackx.jingle_ibb2;
package org.jivesoftware.smackx.jingle_ibb;

View File

@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.jingle_ibb2.provider;
package org.jivesoftware.smackx.jingle_ibb.provider;
import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider;
import org.jivesoftware.smackx.jingle_ibb2.element.JingleIBBTransport;
import org.jivesoftware.smackx.jingle_ibb.element.JingleIBBTransport;
import org.xmlpull.v1.XmlPullParser;
/**

View File

@ -19,4 +19,4 @@
* Smack's API for <a href="https://xmpp.org/extensions/xep-0261.html">XEP-0261: Jingle In-Band Bytestreams</a>.
* Provider classes.
*/
package org.jivesoftware.smackx.jingle_ibb2.provider;
package org.jivesoftware.smackx.jingle_ibb.provider;

View File

@ -31,7 +31,7 @@ import org.jivesoftware.smackx.bytestreams.BytestreamSession;
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamManager;
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
import org.jivesoftware.smackx.hashes.HashManager;
import org.jivesoftware.smackx.jingle.JingleBytestreamManager;
import org.jivesoftware.smackx.jingle.AbstractJingleTransportManager;
import org.jivesoftware.smackx.jingle.JingleTransportManager;
import org.jivesoftware.smackx.jingle.element.Jingle;
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
@ -46,7 +46,7 @@ import org.jxmpp.jid.Jid;
/**
* Manager for JingleSocks5BytestreamTransports.
*/
public final class JingleSocks5BytestreamTransportManager extends JingleBytestreamManager<JingleSocks5BytestreamTransport> {
public final class JingleSocks5BytestreamTransportManager extends AbstractJingleTransportManager<JingleSocks5BytestreamTransport> {
private static final WeakHashMap<XMPPConnection, JingleSocks5BytestreamTransportManager> INSTANCES = new WeakHashMap<>();

View File

@ -29,7 +29,7 @@ import org.junit.Test;
/**
* Test the JingleContentFile class.
*/
public class JingleFileTransferChildElementTest extends SmackTestSuite {
public class JingleFileTransferChildTest extends SmackTestSuite {
@Test
public void rangeTest() throws Exception {

View File

@ -28,7 +28,7 @@ import org.jivesoftware.smackx.hashes.HashManager;
import org.jivesoftware.smackx.hashes.element.HashElement;
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChild;
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferContentDescription;
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
import org.jivesoftware.smackx.jingle_filetransfer.provider.JingleFileTransferContentDescriptionProvider;
@ -66,9 +66,9 @@ public class JingleFileTransferContentDescriptionTest extends SmackTestSuite {
HashElement hashElement = new HashElement(algorithm, hashB64);
Range range = new Range();
Date date = XmppDateTime.parseDate(dateString);
JingleFileTransferChildElement jingleFileTransferChildElement = new JingleFileTransferChildElement(date, descriptionString, hashElement, mediaTypeString, nameString, sizeInt, range);
JingleFileTransferChild jingleFileTransferChild = new JingleFileTransferChild(date, descriptionString, hashElement, mediaTypeString, nameString, sizeInt, range);
ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>();
payloads.add(jingleFileTransferChildElement);
payloads.add(jingleFileTransferChild);
JingleFileTransferContentDescription descriptionFileTransfer =
new JingleFileTransferContentDescription(payloads);
@ -78,7 +78,7 @@ public class JingleFileTransferContentDescriptionTest extends SmackTestSuite {
.parse(TestUtils.getParser(xml));
assertEquals(xml, parsed.toXML().toString());
JingleFileTransferChildElement payload = (JingleFileTransferChildElement) parsed.getJingleContentDescriptionChildren().get(0);
JingleFileTransferChild payload = (JingleFileTransferChild) parsed.getJingleContentDescriptionChildren().get(0);
assertEquals(date, payload.getDate());
assertEquals(descriptionString, payload.getDescription());
assertEquals(mediaTypeString, payload.getMediaType());
@ -107,7 +107,7 @@ public class JingleFileTransferContentDescriptionTest extends SmackTestSuite {
"</range>" +
"</file>" +
"</description>";
JingleFileTransferChildElement payload = new JingleFileTransferChildElement(null, null, null, null, null, -1, range);
JingleFileTransferChild payload = new JingleFileTransferChild(null, null, null, null, null, -1, range);
ArrayList<JingleContentDescriptionChildElement> list = new ArrayList<>();
list.add(payload);
JingleFileTransferContentDescription fileTransfer = new JingleFileTransferContentDescription(list);

View File

@ -24,8 +24,8 @@ import static junit.framework.TestCase.assertTrue;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.test.util.TestUtils;
import org.jivesoftware.smackx.jingle.JingleTransportManager;
import org.jivesoftware.smackx.jingle_ibb2.element.JingleIBBTransport;
import org.jivesoftware.smackx.jingle_ibb2.provider.JingleIBBTransportProvider;
import org.jivesoftware.smackx.jingle_ibb.element.JingleIBBTransport;
import org.jivesoftware.smackx.jingle_ibb.provider.JingleIBBTransportProvider;
import org.junit.Test;
/**

View File

@ -1,3 +1,19 @@
/**
*
* 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;
import java.io.IOException;
@ -16,12 +32,12 @@ import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider;
import org.jxmpp.jid.FullJid;
/**
* Created by vanitas on 09.06.17.
* This class defines the shape that JingleTransportManager must be of.
*/
public abstract class JingleBytestreamManager<D extends JingleContentTransport>
public abstract class AbstractJingleTransportManager<D extends JingleContentTransport>
extends Manager {
public JingleBytestreamManager(XMPPConnection connection) {
public AbstractJingleTransportManager(XMPPConnection connection) {
super(connection);
JingleTransportManager.getInstanceFor(connection).registerJingleContentTransportManager(this);
JingleContentProviderManager.addJingleContentTransportProvider(getNamespace(), createJingleContentTransportProvider());

View File

@ -34,7 +34,7 @@ public final class JingleTransportManager extends Manager {
public static final WeakHashMap<XMPPConnection, JingleTransportManager> INSTANCES = new WeakHashMap<>();
private final HashMap<String, JingleBytestreamManager<?>> contentTransportManagers = new HashMap<>();
private final HashMap<String, AbstractJingleTransportManager<?>> contentTransportManagers = new HashMap<>();
private JingleTransportManager(XMPPConnection connection) {
super(connection);
@ -49,27 +49,27 @@ public final class JingleTransportManager extends Manager {
return manager;
}
public JingleBytestreamManager<?> getJingleContentTransportManager(String namespace) throws UnsupportedJingleTransportException {
JingleBytestreamManager<?> manager = contentTransportManagers.get(namespace);
public AbstractJingleTransportManager<?> getJingleContentTransportManager(String namespace) throws UnsupportedJingleTransportException {
AbstractJingleTransportManager<?> manager = contentTransportManagers.get(namespace);
if (manager == null) {
throw new UnsupportedJingleTransportException("Cannot find registered JingleContentTransportManager for " + namespace);
}
return manager;
}
public JingleBytestreamManager<?> getJingleContentTransportManager(Jingle jingle) throws UnsupportedJingleTransportException {
public AbstractJingleTransportManager<?> getJingleContentTransportManager(Jingle jingle) throws UnsupportedJingleTransportException {
return getJingleContentTransportManager(jingle.getContents().get(0).getJingleTransports().get(0).getNamespace());
}
public void registerJingleContentTransportManager(JingleBytestreamManager<?> manager) {
public void registerJingleContentTransportManager(AbstractJingleTransportManager<?> manager) {
contentTransportManagers.put(manager.getNamespace(), manager);
}
public void unregisterJingleContentTransportManager(JingleBytestreamManager<?> manager) {
public void unregisterJingleContentTransportManager(AbstractJingleTransportManager<?> manager) {
contentTransportManagers.remove(manager.getNamespace());
}
public Collection<JingleBytestreamManager<?>> getAvailableJingleBytestreamManagers() {
public Collection<AbstractJingleTransportManager<?>> getAvailableJingleBytestreamManagers() {
return Collections.unmodifiableCollection(contentTransportManagers.values());
}

View File

@ -1,15 +0,0 @@
package org.jivesoftware.smackx.jingle;
import java.io.File;
import org.jivesoftware.smackx.jingle.element.Jingle;
/**
* Created by vanitas on 09.06.17.
*/
public class PendingJingleSession {
public PendingJingleSession(Jingle initiation, File file) {
}
}