diff options
author | Damian Minkov <damencho@jitsi.org> | 2014-09-03 10:52:38 +0300 |
---|---|---|
committer | paweldomas <pawel.domas@jitsi.org> | 2014-09-08 17:17:08 +0200 |
commit | 8f03b8181b6716d1f2477bc54eff1c176daad521 (patch) | |
tree | a5e69cb840aaaf892db9ccce8a59e7b506f7c3f0 | |
parent | ca4c320de9ccb3dce96601bb620d21b62a23bab1 (diff) | |
download | jitsi-8f03b8181b6716d1f2477bc54eff1c176daad521.zip jitsi-8f03b8181b6716d1f2477bc54eff1c176daad521.tar.gz jitsi-8f03b8181b6716d1f2477bc54eff1c176daad521.tar.bz2 |
Adds file transfer for multimedia msgs to operation set sms.
7 files changed, 125 insertions, 8 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java index a4f50c5..643ff6f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java @@ -1506,8 +1506,13 @@ public class ChatPanel public Object construct() throws Exception { - final FileTransfer fileTransfer - = sendFileTransport.sendFile(file); + FileTransfer ft; + if (writeMessagePanel.isSmsSelected()) + ft = sendFileTransport.sendMultimediaFile(file); + else + ft = sendFileTransport.sendFile(file); + + final FileTransfer fileTransfer = ft; addActiveFileTransfer(fileTransfer.getID(), fileTransfer); diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransport.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransport.java index b9d2359..f55a0ce 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransport.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransport.java @@ -177,6 +177,16 @@ public interface ChatTransport throws Exception; /** + * Sends the given SMS multimedia message trough this chat transport, + * leaving the transport to choose the destination. + * + * @param file the file to send + * @throws Exception if the send doesn't succeed + */ + public FileTransfer sendMultimediaFile(File file) + throws Exception; + + /** * Sends a typing notification state. * * @param typingState the typing notification state to send diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java b/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java index c3fbf9f..ee40c78 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java @@ -551,16 +551,24 @@ public class MetaContactChatTransport public FileTransfer sendFile(File file) throws Exception { + return sendFile(file, false); + } + + /** + * Sends the given file through this chat transport file transfer operation + * set. + * @param file the file to send + * @return the <tt>FileTransfer</tt> object charged to transfer the file + * @throws Exception if anything goes wrong + */ + private FileTransfer sendFile(File file, boolean isMultimediaMessage) + throws Exception + { // If this chat transport does not support instant messaging we do // nothing here. if (!allowsFileTransfer()) return null; - OperationSetFileTransfer ftOpSet - = contact - .getProtocolProvider() - .getOperationSet(OperationSetFileTransfer.class); - if (FileUtils.isImage(file.getName())) { // Create a thumbnailed file if possible. @@ -582,7 +590,36 @@ public class MetaContactChatTransport } } } - return ftOpSet.sendFile(contact, file); + + if(isMultimediaMessage) + { + OperationSetSmsMessaging smsOpSet = contact.getProtocolProvider() + .getOperationSet(OperationSetSmsMessaging.class); + + if(smsOpSet == null) + return null; + + return smsOpSet.sendMultimediaFile(contact, file); + } + else + { + OperationSetFileTransfer ftOpSet = contact.getProtocolProvider() + .getOperationSet(OperationSetFileTransfer.class); + return ftOpSet.sendFile(contact, file); + } + } + + /** + * Sends the given SMS multimedia message trough this chat transport, + * leaving the transport to choose the destination. + * + * @param file the file to send + * @throws Exception if the send doesn't succeed + */ + public FileTransfer sendMultimediaFile(File file) + throws Exception + { + return sendFile(file, true); } /** diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocConferenceChatTransport.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocConferenceChatTransport.java index 0a36982..e0aeb57 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocConferenceChatTransport.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocConferenceChatTransport.java @@ -199,6 +199,16 @@ public class AdHocConferenceChatTransport {} /** + * Sending file in sms messages is not supported by this chat transport + * implementation. + */ + public FileTransfer sendMultimediaFile(File file) + throws Exception + { + return null; + } + + /** * Not used. * @return */ diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatTransport.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatTransport.java index c7abc97..9f40cbd 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatTransport.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatTransport.java @@ -198,6 +198,16 @@ public class ConferenceChatTransport {} /** + * Sending file in sms messages is not supported by this chat transport + * implementation. + */ + public FileTransfer sendMultimediaFile(File file) + throws Exception + { + return null; + } + + /** * Not used. * @return */ diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java index ddd97ad..a6515c1 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetFileTransferJabberImpl.java @@ -112,6 +112,25 @@ public class OperationSetFileTransferJabberImpl IllegalArgumentException, OperationNotSupportedException { + return sendFile(toContact, file, null); + } + + /** + * Sends a file transfer request to the given <tt>toContact</tt>. + * @return the transfer object + * + * @param toContact the contact that should receive the file + * @param file file to send + * @param gw special gateway to be used for receiver if its jid + * misses the domain part + */ + FileTransfer sendFile(Contact toContact, + File file, + String gw) + throws IllegalStateException, + IllegalArgumentException, + OperationNotSupportedException + { OutgoingFileTransferJabberImpl outgoingTransfer = null; try @@ -185,6 +204,13 @@ public class OperationSetFileTransferJabberImpl "Contact client or server does not support file transfers."); } + if(gw != null + && !fullJid.contains("@") + && !fullJid.endsWith(gw)) + { + fullJid = fullJid + "@" + gw; + } + OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(fullJid); diff --git a/src/net/java/sip/communicator/service/protocol/OperationSetSmsMessaging.java b/src/net/java/sip/communicator/service/protocol/OperationSetSmsMessaging.java index 25a025f..c102b39 100644 --- a/src/net/java/sip/communicator/service/protocol/OperationSetSmsMessaging.java +++ b/src/net/java/sip/communicator/service/protocol/OperationSetSmsMessaging.java @@ -8,6 +8,8 @@ package net.java.sip.communicator.service.protocol; import net.java.sip.communicator.service.protocol.event.*; +import java.io.*; + /** * Provides basic functionality for sending and receiving SMS Messages. * @@ -73,6 +75,23 @@ public interface OperationSetSmsMessaging throws IllegalStateException, IllegalArgumentException; /** + * Sends the <tt>file</tt> to the destination indicated by the + * <tt>to</tt> parameter. + * @param to the destination to send <tt>message</tt> to + * @param file the <tt>file</tt> to send. + * @throws java.lang.IllegalStateException if the underlying stack is + * not registered and initialized. + * @throws java.lang.IllegalArgumentException if <tt>to</tt> is not an + * instance belonging to the underlying implementation. + * @throws OperationNotSupportedException if the given contact client or + * server does not support file transfers + */ + public FileTransfer sendMultimediaFile(Contact to, File file) + throws IllegalStateException, + IllegalArgumentException, + OperationNotSupportedException; + + /** * Registers a MessageListener with this operation set so that it gets * notifications of successful message delivery, failure or reception of * incoming messages.. |