aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java
diff options
context:
space:
mode:
authorYana Stamcheva <yana@jitsi.org>2009-06-15 15:18:29 +0000
committerYana Stamcheva <yana@jitsi.org>2009-06-15 15:18:29 +0000
commit2f0db4d2d1ad77f058b352829a6494c7af5a16b3 (patch)
tree32ecf5f800417777fa473b8814dead041f6515c3 /src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java
parent3563fa97f679c2f8b29f2d2eb74fc0bbcaa698ab (diff)
downloadjitsi-2f0db4d2d1ad77f058b352829a6494c7af5a16b3.zip
jitsi-2f0db4d2d1ad77f058b352829a6494c7af5a16b3.tar.gz
jitsi-2f0db4d2d1ad77f058b352829a6494c7af5a16b3.tar.bz2
Adding support for file transfer for XMPP and graphical User Interface for file transfer (ongoing work). This first commit adds the needed gui that enables users to send and receive files, to
drag and drop files into chat windows. It displays incoming file notifications, file icons or previews (where possible, e.g. images). This work package also contains a first file transfer implementation over the XMPP protocol (using the smack implementation of xep-0096: http://xmpp.org/extensions/xep-0096.html). Unfortunately this implementation won't work very well with GoogleTalk accounts for now, as Google servers seem to block every file bigger than 60K. This commit contains also some improvements in the way we load the history and we manage error messages in the gui.
Diffstat (limited to 'src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java63
1 files changed, 48 insertions, 15 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java
index 69f2d76..f2bbcc1 100644
--- a/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/ssh/OperationSetFileTransferSSHImpl.java
@@ -11,6 +11,7 @@
*/
package net.java.sip.communicator.impl.protocol.ssh;
+import java.io.*;
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
@@ -31,7 +32,8 @@ public class OperationSetFileTransferSSHImpl
/**
* Currently registered message listeners.
*/
- private Vector fileTransferListeners = new Vector();
+ private Vector<FileTransferRequestListener> fileTransferListeners
+ = new Vector<FileTransferRequestListener>();
/**
* The protocol provider that created us.
@@ -52,12 +54,43 @@ public class OperationSetFileTransferSSHImpl
*
* @param listener the <tt>FileListener</tt> to register.
*/
- public void addFileListener(FileListener listener)
+ public void addFileTransferRequestListener(
+ FileTransferRequestListener listener)
{
- if(!fileTransferListeners.contains(listener))
- fileTransferListeners.add(listener);
+ synchronized (fileTransferListeners)
+ {
+ if(!fileTransferListeners.contains(listener))
+ fileTransferListeners.add(listener);
+ }
}
-
+
+ public void removeFileTransferRequestListener(
+ FileTransferRequestListener listener)
+ {
+ synchronized (fileTransferListeners)
+ {
+ fileTransferListeners.remove(listener);
+ }
+ }
+
+ /**
+ * Sends a file transfer request to the given <tt>toContact</tt> by
+ * specifying the local and remote file path and the <tt>fromContact</tt>,
+ * sending the file.
+ *
+ * @param toContact the contact that should receive the file
+ * @param fromContact the contact sending the file
+ * @param file the file to send
+ */
+ public FileTransfer sendFile( Contact toContact,
+ File file)
+ {
+ return this.sendFile( toContact,
+ null,
+ file.getAbsolutePath(),
+ file.getAbsolutePath());
+ }
+
/**
* The file transfer method to/from the remote machine
* either toContact is null(we are downloading file from remote machine
@@ -68,7 +101,7 @@ public class OperationSetFileTransferSSHImpl
* @param remotePath - the identifier for the remote file
* @param localPath - the identifier for the local file
*/
- public void sendFile(
+ public FileTransfer sendFile(
Contact toContact,
Contact fromContact,
String remotePath,
@@ -80,16 +113,16 @@ public class OperationSetFileTransferSSHImpl
= new SSHFileTransferDaemon(
(ContactSSH)fromContact,
parentProvider);
-
+
if(localPath.endsWith(System.getProperty("file.separator")))
localPath += remotePath.substring(remotePath.lastIndexOf(
System.getProperty("file.separator")) + 1);
-
+
fileTransferDaemon.downloadFile(
remotePath,
localPath);
-
- return;
+
+ return new FileTransferSSHImpl(fileTransferDaemon);
}
else if(fromContact == null)
{
@@ -97,17 +130,17 @@ public class OperationSetFileTransferSSHImpl
= new SSHFileTransferDaemon(
(ContactSSH) toContact,
parentProvider);
-
+
fileTransferDaemon.uploadFile(
remotePath,
localPath);
-
- return;
+
+ return new FileTransferSSHImpl(fileTransferDaemon);
}
-
+
// code should not reach here
// assert false;
logger.error("we should not be here !");
+ return null;
}
-
}