-
Notifications
You must be signed in to change notification settings - Fork 885
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Jingle changes to smack-experimental
- Loading branch information
Showing
36 changed files
with
2,207 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...n/java/org/jivesoftware/smackx/jingle_filetransfer/adapter/JingleFileTransferAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* | ||
* 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.adapter; | ||
|
||
import java.util.List; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import org.jivesoftware.smack.packet.NamedElement; | ||
import org.jivesoftware.smackx.jingle.adapter.JingleDescriptionAdapter; | ||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement; | ||
import org.jivesoftware.smackx.jingle.element.JingleContentElement; | ||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleFileTransfer; | ||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleIncomingFileOffer; | ||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleIncomingFileRequest; | ||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement; | ||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferElement; | ||
|
||
/** | ||
* Adapter to convert JingleFileTransferElements (element) to JingleFileTransfer objects (component). | ||
*/ | ||
public class JingleFileTransferAdapter implements JingleDescriptionAdapter<JingleFileTransfer> { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(JingleFileTransferAdapter.class.getName()); | ||
|
||
@Override | ||
public JingleFileTransfer descriptionFromElement(JingleContentElement.Creator creator, JingleContentElement.Senders senders, | ||
String contentName, String contentDisposition, JingleContentDescriptionElement element) { | ||
JingleFileTransferElement description = (JingleFileTransferElement) element; | ||
List<NamedElement> children = description.getJingleContentDescriptionChildren(); | ||
assert children.size() == 1; | ||
JingleFileTransferChildElement file = (JingleFileTransferChildElement) children.get(0); | ||
|
||
if (senders == JingleContentElement.Senders.initiator) { | ||
return new JingleIncomingFileOffer(file); | ||
} else if (senders == JingleContentElement.Senders.responder) { | ||
return new JingleIncomingFileRequest(file); | ||
} else { | ||
if (senders == null) { | ||
LOGGER.log(Level.INFO, "Senders is null. Gajim workaround: assume 'initiator'."); | ||
return new JingleIncomingFileOffer(file); | ||
} | ||
throw new AssertionError("Senders attribute MUST be either initiator or responder. Is: " + senders); | ||
} | ||
} | ||
|
||
@Override | ||
public String getNamespace() { | ||
return JingleFileTransfer.NAMESPACE; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/adapter/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* Smack's API for <a href="https://xmpp.org/extensions/xep-0234.html">XEP-0234: Jingle File Transfer</a>. | ||
* Adapters. | ||
*/ | ||
package org.jivesoftware.smackx.jingle_filetransfer.adapter; |
27 changes: 27 additions & 0 deletions
27
...n/java/org/jivesoftware/smackx/jingle_filetransfer/component/AbstractJingleFileOffer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* | ||
* 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.component; | ||
|
||
/** | ||
* This class represents the base of a JingleFileOffer. | ||
*/ | ||
public abstract class AbstractJingleFileOffer extends JingleFileTransfer { | ||
|
||
AbstractJingleFileOffer(JingleFile fileTransferFile) { | ||
super(fileTransferFile); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...java/org/jivesoftware/smackx/jingle_filetransfer/component/AbstractJingleFileRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* | ||
* 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.component; | ||
|
||
/** | ||
* Class representing the base of a JingleFileRequest. | ||
* TODO: Implement. | ||
*/ | ||
public abstract class AbstractJingleFileRequest extends JingleFileTransfer { | ||
|
||
AbstractJingleFileRequest(JingleFile fileTransferFile) { | ||
super(fileTransferFile); | ||
} | ||
} |
Oops, something went wrong.