diff options
author | Yana Stamcheva <yana@jitsi.org> | 2009-06-15 15:18:29 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2009-06-15 15:18:29 +0000 |
commit | 2f0db4d2d1ad77f058b352829a6494c7af5a16b3 (patch) | |
tree | 32ecf5f800417777fa473b8814dead041f6515c3 /src/net/java/sip/communicator/service | |
parent | 3563fa97f679c2f8b29f2d2eb74fc0bbcaa698ab (diff) | |
download | jitsi-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/service')
13 files changed, 825 insertions, 30 deletions
diff --git a/src/net/java/sip/communicator/service/desktop/DesktopService.java b/src/net/java/sip/communicator/service/desktop/DesktopService.java new file mode 100644 index 0000000..c214299 --- /dev/null +++ b/src/net/java/sip/communicator/service/desktop/DesktopService.java @@ -0,0 +1,111 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.desktop; + +import java.io.*; +import java.net.*; + +/** + * The <tt>DesktopService</tt> manages the . + * + * @author Yana Stamcheva + */ +public interface DesktopService +{ + /** + * Launches the associated application to open the file. + * + * @param file the file to be opened + * + * @throws NullPointerException if file is null + * @throws IllegalArgumentException if the specified file dosen't exist + * @throws UnsupportedOperationException if the current platform does not + * support the Desktop.Action.OPEN action + * @throws IOException if the specified file has no associated application + * or the associated application fails to be launched + * @throws SecurityException if a security manager exists and its + * SecurityManager.checkRead(java.lang.String) method denies read access to + * the file, or it denies the AWTPermission("showWindowWithoutWarningBanner") + * permission, or the calling thread is not allowed to create a subprocess + */ + public void open(File file) + throws NullPointerException, + IllegalArgumentException, + UnsupportedOperationException, + IOException, + SecurityException; + + /** + * Prints a file with the native desktop printing facility, using the + * associated application's print command. + * + * @param file the file to be opened + * + * @throws NullPointerException if file is null + * @throws IllegalArgumentException if the specified file dosen't exist + * @throws UnsupportedOperationException if the current platform does not + * support the Desktop.Action.OPEN action + * @throws IOException if the specified file has no associated application + * or the associated application fails to be launched + * @throws SecurityException if a security manager exists and its + * SecurityManager.checkRead(java.lang.String) method denies read access to + * the file, or it denies the AWTPermission("showWindowWithoutWarningBanner") + * permission, or the calling thread is not allowed to create a subprocess + */ + public void print(File file) + throws NullPointerException, + IllegalArgumentException, + UnsupportedOperationException, + IOException, + SecurityException; + + /** + * Launches the associated editor application and opens a file for editing. + * + * @param file the file to open for editing + * + * @throws NullPointerException if file is null + * @throws IllegalArgumentException if the specified file dosen't exist + * @throws UnsupportedOperationException if the current platform does not + * support the Desktop.Action.OPEN action + * @throws IOException if the specified file has no associated application + * or the associated application fails to be launched + * @throws SecurityException if a security manager exists and its + * SecurityManager.checkRead(java.lang.String) method denies read access to + * the file, or it denies the AWTPermission("showWindowWithoutWarningBanner") + * permission, or the calling thread is not allowed to create a subprocess + */ + public void edit(File file) + throws NullPointerException, + IllegalArgumentException, + UnsupportedOperationException, + IOException, + SecurityException; + + /** + * Launches the default browser to display a URI. + * + * @param uri the URI to be displayed in the user default browser + * + * @throws NullPointerException if file is null + * @throws IllegalArgumentException if the specified file dosen't exist + * @throws UnsupportedOperationException if the current platform does not + * support the Desktop.Action.OPEN action + * @throws IOException if the specified file has no associated application + * or the associated application fails to be launched + * @throws SecurityException if a security manager exists and its + * SecurityManager.checkRead(java.lang.String) method denies read access to + * the file, or it denies the AWTPermission("showWindowWithoutWarningBanner") + * permission, or the calling thread is not allowed to create a subprocess + */ + public void browse(URI uri) + throws NullPointerException, + IllegalArgumentException, + UnsupportedOperationException, + IOException, + SecurityException; +} diff --git a/src/net/java/sip/communicator/service/fileaccess/FileAccessService.java b/src/net/java/sip/communicator/service/fileaccess/FileAccessService.java index 634932f..4fa567a 100644 --- a/src/net/java/sip/communicator/service/fileaccess/FileAccessService.java +++ b/src/net/java/sip/communicator/service/fileaccess/FileAccessService.java @@ -106,7 +106,14 @@ public interface FileAccessService { * directory. */ File getPrivatePersistentDirectory(String[] dirNames) throws Exception; - + + /** + * Returns the default download directory depending on the operating system. + * + * @return the default download directory depending on the operating system + */ + File getDefaultDownloadDirectory() throws IOException; + /** * Creates a failsafe transaction which can be used to safely store * informations into a file. diff --git a/src/net/java/sip/communicator/service/protocol/AbstractFileTransfer.java b/src/net/java/sip/communicator/service/protocol/AbstractFileTransfer.java new file mode 100644 index 0000000..18a85f9 --- /dev/null +++ b/src/net/java/sip/communicator/service/protocol/AbstractFileTransfer.java @@ -0,0 +1,180 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.protocol; + +import java.util.*; + +import net.java.sip.communicator.service.protocol.event.*; + +/** + * An abstract implementation of the <tt>FileTransfer</tt> interface providing + * implementation of status and progress events related methods and leaving all + * protocol specific methods abstract. A protocol specific implementation could + * extend this class and implement only <tt>cancel()</tt> and + * <tt>getTransferredBytes()</tt>. + * + * @author Yana Stamcheva + */ +public abstract class AbstractFileTransfer + implements FileTransfer +{ + /** + * A list of listeners registered for file transfer status events. + */ + private Vector<FileTransferStatusListener> statusListeners + = new Vector<FileTransferStatusListener>(); + + /** + * A list of listeners registered for file transfer status events. + */ + private Vector<FileTransferProgressListener> progressListeners + = new Vector<FileTransferProgressListener>(); + + private int status; + + /** + * Cancels this file transfer. When this method is called transfer should + * be interrupted. + */ + abstract public void cancel(); + + /** + * Returns the number of bytes already transfered through this file transfer. + * + * @return the number of bytes already transfered through this file transfer + */ + abstract public long getTransferedBytes(); + + /** + * Adds the given <tt>FileTransferProgressListener</tt> to listen for + * status changes on this file transfer. + * + * @param listener the listener to add + */ + public void addProgressListener(FileTransferProgressListener listener) + { + synchronized(progressListeners) + { + if(!progressListeners.contains(listener)) + { + this.progressListeners.add(listener); + } + } + } + + /** + * Adds the given <tt>FileTransferStatusListener</tt> to listen for + * status changes on this file transfer. + * + * @param listener the listener to add + */ + public void addStatusListener(FileTransferStatusListener listener) + { + synchronized(statusListeners) + { + if(!statusListeners.contains(listener)) + { + this.statusListeners.add(listener); + } + } + } + + /** + * Removes the given <tt>FileTransferProgressListener</tt>. + * + * @param listener the listener to remove + */ + public void removeProgressListener(FileTransferProgressListener listener) + { + synchronized(progressListeners) + { + this.progressListeners.remove(listener); + } + } + + /** + * Removes the given <tt>FileTransferStatusListener</tt>. + * + * @param listener the listener to remove + */ + public void removeStatusListener(FileTransferStatusListener listener) + { + synchronized(statusListeners) + { + this.statusListeners.remove(listener); + } + } + + /** + * Returns the current status of the transfer. This information could be + * used from the user interface to show a progress bar indicating the + * file transfer status. + * + * @return the current status of the transfer + */ + public int getStatus() + { + return status; + } + + /** + * Notifies all status listeners that a new + * <tt>FileTransferStatusChangeEvent</tt> occured. + */ + public void fireStatusChangeEvent(int newStatus) + { + Collection<FileTransferStatusListener> listeners = null; + synchronized (statusListeners) + { + listeners + = new ArrayList<FileTransferStatusListener>(statusListeners); + } + + FileTransferStatusChangeEvent statusEvent + = new FileTransferStatusChangeEvent(this, status, newStatus); + + // Updates the status. + this.status = newStatus; + + Iterator<FileTransferStatusListener> listenersIter + = listeners.iterator(); + + while (listenersIter.hasNext()) + { + FileTransferStatusListener statusListener = listenersIter.next(); + + statusListener.statusChanged(statusEvent); + } + } + + /** + * Notifies all status listeners that a new + * <tt>FileTransferProgressEvent</tt> occured. + */ + public void fireProgressChangeEvent(int progress) + { + Collection<FileTransferProgressListener> listeners = null; + synchronized (progressListeners) + { + listeners + = new ArrayList<FileTransferProgressListener>(progressListeners); + } + + FileTransferProgressEvent progressEvent + = new FileTransferProgressEvent(this, progress); + + Iterator<FileTransferProgressListener> listenersIter + = listeners.iterator(); + + while (listenersIter.hasNext()) + { + FileTransferProgressListener statusListener = listenersIter.next(); + + statusListener.progressChanged(progressEvent); + } + } +} diff --git a/src/net/java/sip/communicator/service/protocol/FileTransfer.java b/src/net/java/sip/communicator/service/protocol/FileTransfer.java new file mode 100644 index 0000000..d0f7d23 --- /dev/null +++ b/src/net/java/sip/communicator/service/protocol/FileTransfer.java @@ -0,0 +1,109 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.protocol; + +import net.java.sip.communicator.service.protocol.event.*; + +/** + * The <tt>FileTransfer</tt> interface is meant to be used by parties interested + * in the file transfer process. It contains information about the status and + * the progress of the transfer as well as the bytes that have been transfered. + * + * @author Yana Stamcheva + */ +public interface FileTransfer +{ + /** + * Indicates that the file transfer has been completed. + */ + public static final int COMPLETED = 0; + + /** + * Indicates that the file transfer has been canceled. + */ + public static final int CANCELED = 1; + + /** + * Indicates that the file transfer has failed. + */ + public static final int FAILED = 2; + + /** + * Indicates that the file transfer has been refused. + */ + public static final int REFUSED = 3; + + /** + * Indicates that the file transfer is in progress. + */ + public static final int IN_PROGRESS = 4; + + /** + * Indicates that the file transfer waits for the recipient to accept the + * file. + */ + public static final int WAITING = 5; + + /** + * Indicates that the file transfer is in negotiation. + */ + public static final int PREPARING = 6; + + /** + * Cancels this file transfer. When this method is called transfer should + * be interrupted. + */ + public void cancel(); + + /** + * Returns the current status of the transfer. This information could be + * used from the user interface to show the current status of the transfer. + * The status is returned as an <tt>int</tt> and could be equal to one of + * the static constants declared in this interface (i.e. COMPLETED, + * CANCELED, FAILED, etc.). + * + * @return the current status of the transfer + */ + public int getStatus(); + + /** + * Returns the number of bytes already transfered through this file transfer. + * + * @return the number of bytes already transfered through this file transfer + */ + public long getTransferedBytes(); + + /** + * Adds the given <tt>FileTransferStatusListener</tt> to listen for + * status changes on this file transfer. + * + * @param listener the listener to add + */ + public void addStatusListener(FileTransferStatusListener listener); + + /** + * Removes the given <tt>FileTransferStatusListener</tt>. + * + * @param listener the listener to remove + */ + public void removeStatusListener(FileTransferStatusListener listener); + + /** + * Adds the given <tt>FileTransferProgressListener</tt> to listen for + * status changes on this file transfer. + * + * @param listener the listener to add + */ + public void addProgressListener(FileTransferProgressListener listener); + + /** + * Removes the given <tt>FileTransferProgressListener</tt>. + * + * @param listener the listener to remove + */ + public void removeProgressListener(FileTransferProgressListener listener); +} diff --git a/src/net/java/sip/communicator/service/protocol/IncomingFileTransferRequest.java b/src/net/java/sip/communicator/service/protocol/IncomingFileTransferRequest.java new file mode 100644 index 0000000..73e17cf --- /dev/null +++ b/src/net/java/sip/communicator/service/protocol/IncomingFileTransferRequest.java @@ -0,0 +1,67 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +package net.java.sip.communicator.service.protocol; + +import java.io.*; + +/** + * Used for incoming file transfer request. + * + * @author Nicolas Riegel + * @author Yana Stamcheva + */ +public interface IncomingFileTransferRequest +{ + /** + * Returns a String that represents the name of the file that is being + * received. + * If there is no name, returns null. + * @return a String that represents the name of the file + */ + public String getFileName(); + + /** + * Returns a String that represents the description of the file that is + * being received. + * If there is no description available, returns null. + * + * @return a String that represents the description of the file + */ + public String getFileDescription(); + + /** + * Returns a long that represents the size of the file that is being + * received. + * If there is no file size available, returns null. + * + * @return a long that represents the size of the file + */ + public long getFileSize(); + + /** + * Returns a String that represents the name of the sender of the file + * being received. + * If there is no sender name available, returns null. + * + * @return a String that represents the name of the sender + */ + public Contact getSender(); + + /** + * Function called to accept and receive the file. + * + * @param file the file to accept + * @return the <tt>FileTransfer</tt> object managing the transfer + */ + public FileTransfer acceptFile(File file); + + /** + * Function called to refuse the file. + */ + public void rejectFile(); +} diff --git a/src/net/java/sip/communicator/service/protocol/OperationSetFileTransfer.java b/src/net/java/sip/communicator/service/protocol/OperationSetFileTransfer.java index 12517ec..6b006a7 100644 --- a/src/net/java/sip/communicator/service/protocol/OperationSetFileTransfer.java +++ b/src/net/java/sip/communicator/service/protocol/OperationSetFileTransfer.java @@ -6,24 +6,81 @@ */ package net.java.sip.communicator.service.protocol; +import java.io.*; + import net.java.sip.communicator.service.protocol.event.*; /** * The File Transfer Operation Set provides an interface towards those functions - * of a given protocl, that allow transferring files among users. - * - * @todo say that meta contacts must be implemented by the user interface + * of a given protocol, that allow transferring files among users. * * @author Emil Ivov + * @author Yana Stamcheva */ public interface OperationSetFileTransfer extends OperationSet { - public void sendFile( - Contact toContact, - Contact fromContact, - String remotePath, - String localPath); + /** + * 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 file the file to send + * + * @return the transfer object + * + * @throws IllegalStateException if the protocol provider is not registered + * or connected + * @throws IllegalArgumentException if some of the arguments doesn't fit the + * protocol requirements + */ + public FileTransfer sendFile( Contact toContact, + File file) + throws IllegalStateException, + IllegalArgumentException; + + /** + * 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 remotePath the remote file path + * @param localPath the local file path + * + * @return the transfer object + * + * @throws IllegalStateException if the protocol provider is not registered + * or connected + * @throws IllegalArgumentException if some of the arguments doesn't fit the + * protocol requirements + */ + public FileTransfer sendFile( Contact toContact, + Contact fromContact, + String remotePath, + String localPath) + throws IllegalStateException, + IllegalArgumentException; + + /** + * Adds the given <tt>FileTransferRequestListener</tt> that would listen for + * <tt>FileTransferRequestEvent</tt>-s and that should be notified every + * time a file transfer request has been received. + * + * @param listener the <tt>FileTransferRequestListener</tt> to add + */ + public void addFileTransferRequestListener( + FileTransferRequestListener listener); - public void addFileListener(FileListener listener); + /** + * Removes the given <tt>FileTransferRequestListener</tt> that listens for + * <tt>FileTransferRequestEvent</tt>-s and is notified every time a file + * transfer request has been received. + * + * @param listener the <tt>FileTransferRequestListener</tt> to remove + */ + public void removeFileTransferRequestListener( + FileTransferRequestListener listener); } diff --git a/src/net/java/sip/communicator/service/protocol/event/FileListener.java b/src/net/java/sip/communicator/service/protocol/event/FileListener.java deleted file mode 100644 index cc19ba3..0000000 --- a/src/net/java/sip/communicator/service/protocol/event/FileListener.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package net.java.sip.communicator.service.protocol.event; - -import java.util.*; - -/** - * - * - * @author Emil Ivov - */ -public interface FileListener - extends EventListener -{ - -} diff --git a/src/net/java/sip/communicator/service/protocol/event/FileTransferProgressEvent.java b/src/net/java/sip/communicator/service/protocol/event/FileTransferProgressEvent.java new file mode 100644 index 0000000..600275e --- /dev/null +++ b/src/net/java/sip/communicator/service/protocol/event/FileTransferProgressEvent.java @@ -0,0 +1,63 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.protocol.event; + +import java.util.*; + +import net.java.sip.communicator.service.protocol.*; + +/** + * The <tt>FileTransferProgressEvent</tt> indicates the progress of a file + * transfer. + * + * @author Yana Stamcheva + */ +public class FileTransferProgressEvent + extends EventObject +{ + /** + * Indicates the progress of a file transfer in bytes. + */ + private int progress; + + /** + * Creates a <tt>FileTransferProgressEvent</tt> by specifying the source + * file transfer object, that triggered the event and the new progress + * value. + * + * @param fileTransfer the source file transfer object, that triggered the + * event + * @param progress the new progress value + */ + public FileTransferProgressEvent( FileTransfer fileTransfer, + int progress) + { + super(fileTransfer); + + this.progress = progress; + } + + /** + * Returns the source <tt>FileTransfer</tt> that triggered this event. + * + * @return the source <tt>FileTransfer</tt> that triggered this event + */ + public FileTransfer getFileTransfer() + { + return (FileTransfer) source; + } + + /** + * Returns the progress of the file transfer. + * + * @return the progress of the file transfer + */ + public int getProgress() + { + return progress; + } +} diff --git a/src/net/java/sip/communicator/service/protocol/event/FileTransferProgressListener.java b/src/net/java/sip/communicator/service/protocol/event/FileTransferProgressListener.java new file mode 100644 index 0000000..b3d3f50 --- /dev/null +++ b/src/net/java/sip/communicator/service/protocol/event/FileTransferProgressListener.java @@ -0,0 +1,24 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.protocol.event; + +/** + * The <tt>FileTransferStatusListener</tt> listens for + * <tt>FileTransferStatusChangeEvent</tt> in order to indicate a change in the + * current progress of a file transfer. + * + * @author Yana Stamcheva + */ +public interface FileTransferProgressListener +{ + /** + * Indicates a change in the file transfer progress. + * + * @param event the event containing information about the change + */ + public void progressChanged(FileTransferProgressEvent event); +} diff --git a/src/net/java/sip/communicator/service/protocol/event/FileTransferRequestEvent.java b/src/net/java/sip/communicator/service/protocol/event/FileTransferRequestEvent.java new file mode 100644 index 0000000..ed38c77 --- /dev/null +++ b/src/net/java/sip/communicator/service/protocol/event/FileTransferRequestEvent.java @@ -0,0 +1,65 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.protocol.event; + +import java.util.*; + +import net.java.sip.communicator.service.protocol.*; + +/** + * The <tt>FileTransferRequestEvent</tt> indicates the reception of a file + * transfer request. + * + * @author Nicolas Riegel + * @author Yana Stamcheva + */ +public class FileTransferRequestEvent + extends EventObject +{ + /** + * The timestamp indicating the exact date when the event occurred. + */ + private final Date timestamp; + + /** + * Creates a <tt>FileTransferRequestEvent</tt> representing reception + * of an incoming file transfer request. + * + * @param request the <tt>IncomingFileTranferRequest</tt> whose reception + * this event represents. + * @param timestamp the timestamp indicating the exact date when the event + * occurred + */ + public FileTransferRequestEvent(IncomingFileTransferRequest request, + Date timestamp) + { + super(request); + + this.timestamp = timestamp; + } + + /** + * Returns the incoming file transfer request that triggered this event. + * + * @return the <tt>IncomingFileTransferRequest</tt> that triggered this + * event. + */ + public IncomingFileTransferRequest getRequest() + { + return (IncomingFileTransferRequest) getSource(); + } + + /** + * A timestamp indicating the exact date when the event occurred. + * + * @return a Date indicating when the event occurred. + */ + public Date getTimestamp() + { + return timestamp; + } +} diff --git a/src/net/java/sip/communicator/service/protocol/event/FileTransferRequestListener.java b/src/net/java/sip/communicator/service/protocol/event/FileTransferRequestListener.java new file mode 100644 index 0000000..718aaca --- /dev/null +++ b/src/net/java/sip/communicator/service/protocol/event/FileTransferRequestListener.java @@ -0,0 +1,28 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.protocol.event; + +import java.util.*; + +/** + * A listener that would gather events notifying of incoming file transfer + * requests. + * + * @author Emil Ivov + * @author Yana Stamcheva + */ +public interface FileTransferRequestListener + extends EventListener +{ + /** + * Called when a new <tt>IncomingFileTransferRequest</tt> has been received. + * + * @param event the <tt>FileTransferRequestEvent</tt> containing the newly + * received request and other details. + */ + public void incomingRequestReceived(FileTransferRequestEvent event); +} diff --git a/src/net/java/sip/communicator/service/protocol/event/FileTransferStatusChangeEvent.java b/src/net/java/sip/communicator/service/protocol/event/FileTransferStatusChangeEvent.java new file mode 100644 index 0000000..b3056ba --- /dev/null +++ b/src/net/java/sip/communicator/service/protocol/event/FileTransferStatusChangeEvent.java @@ -0,0 +1,80 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.protocol.event; + +import java.util.*; + +import net.java.sip.communicator.service.protocol.*; + +/** + * The <tt>FileTransferStatusChangeEvent</tt> is the event indicating of a + * change in the state of a file transfer. + * + * @author Yana Stamcheva + */ +public class FileTransferStatusChangeEvent + extends EventObject +{ + /** + * The state of the file transfer before this event occured. + */ + private final int oldStatus; + + /** + * The new state of the file transfer. + */ + private final int newStatus; + + /** + * Creates a <tt>FileTransferStatusChangeEvent</tt> by specifying the + * source <tt>fileTransfer</tt>, the old transfer status and the new status. + * + * @param fileTransfer the source file transfer, for which this status + * change occured + * @param oldStatus the old status + * @param newStatus the new status + */ + public FileTransferStatusChangeEvent( FileTransfer fileTransfer, + int oldStatus, + int newStatus) + { + super(fileTransfer); + + this.oldStatus = oldStatus; + this.newStatus = newStatus; + } + + /** + * Returns the source <tt>FileTransfer</tt> that triggered this event. + * + * @return the source <tt>FileTransfer</tt> that triggered this event + */ + public FileTransfer getFileTransfer() + { + return (FileTransfer) source; + } + + /** + * Returns the state of the file transfer before this event occured. + * + * @return the old state + */ + public int getOldStatus() + { + return oldStatus; + } + + /** + * The new state of the file transfer. + * + * @return the new state + */ + public int getNewStatus() + { + return newStatus; + } +} diff --git a/src/net/java/sip/communicator/service/protocol/event/FileTransferStatusListener.java b/src/net/java/sip/communicator/service/protocol/event/FileTransferStatusListener.java new file mode 100644 index 0000000..d7b36da --- /dev/null +++ b/src/net/java/sip/communicator/service/protocol/event/FileTransferStatusListener.java @@ -0,0 +1,24 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.protocol.event; + +/** + * The <tt>FileTransferStatusListener</tt> listens for + * <tt>FileTransferStatusChangeEvent</tt> in order to indicate a change in the + * current status of a file transfer. + * + * @author Yana Stamcheva + */ +public interface FileTransferStatusListener +{ + /** + * Indicates a change in the file transfer status. + * + * @param event the event containing information about the change + */ + public void statusChanged(FileTransferStatusChangeEvent event); +} |