diff --git a/build.xml b/build.xml
index 42ccb7d52..c62b59079 100644
--- a/build.xml
+++ b/build.xml
@@ -1237,6 +1237,8 @@ javax.swing.event, javax.swing.border"/>
+
diff --git a/lib/installer-exclude/jml-1.0b2.jar b/lib/installer-exclude/jml-1.0b2.jar
index 98b58d889..791378619 100644
Binary files a/lib/installer-exclude/jml-1.0b2.jar and b/lib/installer-exclude/jml-1.0b2.jar differ
diff --git a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetFileTransferIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetFileTransferIcqImpl.java
index a36f4c1ea..1f768909c 100644
--- a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetFileTransferIcqImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetFileTransferIcqImpl.java
@@ -31,7 +31,7 @@ public class OperationSetFileTransferIcqImpl
RvConnectionManagerListener
{
private static final Logger logger =
- Logger.getLogger(OperationSetPersistentPresenceIcqImpl.class);
+ Logger.getLogger(OperationSetFileTransferIcqImpl.class);
/**
* A call back to the ICQ provider that created us.
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java
index 6cdb119c8..f28093443 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java
@@ -796,6 +796,21 @@ public void connectionClosedOnError(Exception exception)
logger.error("connectionClosedOnError " +
exception.getLocalizedMessage());
+ if(exception instanceof XMPPException)
+ {
+ StreamError err = ((XMPPException)exception).getStreamError();
+
+ if(err != null && err.getCode().equals(
+ XMPPError.Condition.conflict.toString()))
+ {
+ fireRegistrationStateChanged(getRegistrationState(),
+ RegistrationState.CONNECTION_FAILED,
+ RegistrationStateChangeEvent.REASON_MULTIPLE_LOGINS,
+ "Connecting multiple times with the same resource");
+ return;
+ }
+ }
+
if(!reconnecting)
reregister(SecurityAuthority.CONNECTION_FAILED);
else
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/FileTransferImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/FileTransferImpl.java
new file mode 100644
index 000000000..46ff7f88f
--- /dev/null
+++ b/src/net/java/sip/communicator/impl/protocol/msn/FileTransferImpl.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.impl.protocol.msn;
+
+import java.io.*;
+
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
+import net.sf.jml.*;
+
+/**
+ * The Filetransfer imeplementation for msn.
+ * @author Damian Minkov
+ */
+public class FileTransferImpl
+ extends AbstractFileTransfer
+{
+ /**
+ * Logger
+ */
+ private static final Logger logger =
+ Logger.getLogger(FileTransferImpl.class);
+
+ private String id = null;
+ private Contact contact = null;
+ private File file = null;
+ private int direction = -1;
+ private long transferedBytes;
+ private MsnFileTransfer fileTransfer;
+
+ public FileTransferImpl(
+ MsnFileTransfer fileTransfer,
+ Contact contact, File file, int direction)
+ {
+ this.fileTransfer = fileTransfer;
+ this.id = fileTransfer.getID();
+ this.contact = contact;
+ this.file = file;
+ this.direction = direction;
+ }
+
+ /**
+ * Cancels this file transfer. When this method is called transfer should
+ * be interrupted.
+ */
+ public void cancel()
+ {
+ fileTransfer.cancel();
+ }
+
+ /**
+ * 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()
+ {
+ return transferedBytes;
+ }
+
+ /**
+ * Uniquie ID that is identifying the FileTransfer
+ * if the request has been accepted.
+ *
+ * @return the id.
+ */
+ public String getID()
+ {
+ return id;
+ }
+
+ /**
+ * The file transfer direction.
+ * @return returns the direction of the file transfer : IN or OUT.
+ */
+ public int getDirection()
+ {
+ return direction;
+ }
+
+ /**
+ * Returns the file that is transfered.
+ *
+ * @return the file
+ */
+ public File getLocalFile()
+ {
+ return file;
+ }
+
+ /**
+ * Returns the contact that we are transfering files with.
+ * @return the contact.
+ */
+ public Contact getContact()
+ {
+ return contact;
+ }
+
+ /**
+ * @param transferedBytes the transferedBytes to set
+ */
+ public void setTransferedBytes(long transferedBytes)
+ {
+ this.transferedBytes = transferedBytes;
+ }
+}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/IncomingFileTransferRequestMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/IncomingFileTransferRequestMsnImpl.java
new file mode 100644
index 000000000..5f5fd90f0
--- /dev/null
+++ b/src/net/java/sip/communicator/impl/protocol/msn/IncomingFileTransferRequestMsnImpl.java
@@ -0,0 +1,194 @@
+/*
+ * 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.impl.protocol.msn;
+
+import java.io.File;
+import java.util.*;
+
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.protocol.event.*;
+import net.java.sip.communicator.util.*;
+import net.sf.jml.*;
+
+/**
+ * Msn implementation of the incoming file transfer request
+ *
+ * @author Damian Minkov
+ */
+public class IncomingFileTransferRequestMsnImpl
+ implements IncomingFileTransferRequest
+{
+ /**
+ * Logger
+ */
+ private static final Logger logger =
+ Logger.getLogger(IncomingFileTransferRequestMsnImpl.class);
+
+ private OperationSetFileTransferMsnImpl fileTransferOpSet;
+
+ /**
+ * The msn file transfer received
+ */
+ private MsnFileTransfer incomingFileTransfer = null;
+
+ private Contact sender = null;
+
+ private Date date;
+
+ private String id;
+
+ private boolean rejected = false;
+
+ /**
+ * Constructor
+ *
+ * @param fileTransfer msn file transfer request that was received
+ */
+ public IncomingFileTransferRequestMsnImpl(
+ OperationSetFileTransferMsnImpl fileTransferOpSet,
+ MsnFileTransfer incomingFileTransfer,
+ Contact sender,
+ Date date)
+ {
+ this.fileTransferOpSet = fileTransferOpSet;
+ this.incomingFileTransfer = incomingFileTransfer;
+ this.sender = sender;
+ this.date = date;
+
+ id = incomingFileTransfer.getID();
+ }
+
+ /**
+ * Uniquie ID that is identifying the request and then the FileTransfer
+ * if the request has been accepted.
+ *
+ * @return the id.
+ */
+ public String getID()
+ {
+ return id;
+ }
+
+ /**
+ * 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()
+ {
+ return incomingFileTransfer.getFile().getName();
+ }
+
+ /**
+ * 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()
+ {
+ return "";
+ }
+
+ /**
+ * 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()
+ {
+ return incomingFileTransfer.getFileTotalSize();
+ }
+
+ /**
+ * 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()
+ {
+ return sender;
+ }
+
+ /**
+ * Function called to accept and receive the file.
+ *
+ * @param file the file to accept
+ * @return the FileTransfer object managing the transfer
+ */
+ public FileTransfer acceptFile(File file)
+ {
+ incomingFileTransfer.setFile(file);
+
+ FileTransferImpl inFileTransfer =
+ new FileTransferImpl(
+ incomingFileTransfer,
+ sender,
+ file,
+ FileTransfer.IN);
+
+ FileTransferCreatedEvent event
+ = new FileTransferCreatedEvent(inFileTransfer, date);
+
+ fileTransferOpSet.fireFileTransferCreated(event);
+
+ inFileTransfer.fireStatusChangeEvent(
+ FileTransferStatusChangeEvent.PREPARING);
+
+ incomingFileTransfer.start();
+
+ return inFileTransfer;
+ }
+
+ /**
+ * Function called to refuse the file.
+ */
+ public void rejectFile()
+ {
+ try
+ {
+ rejected = true;
+
+ incomingFileTransfer.cancel();
+
+ fileTransferOpSet.fireFileTransferRequestRejected(
+ new FileTransferRequestEvent(fileTransferOpSet, this, date));
+ }
+ catch(IllegalStateException e)
+ {
+ logger.debug("Error rejecting file",e);
+ return;
+ }
+ }
+
+ public byte[] getThumbnail()
+ {
+ return null;
+ }
+
+ /**
+ * @return the date
+ */
+ public Date getDate()
+ {
+ return date;
+ }
+
+ /**
+ * @return the rejected
+ */
+ public boolean isRejected()
+ {
+ return rejected;
+ }
+}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetFileTransferMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetFileTransferMsnImpl.java
new file mode 100644
index 000000000..7d3fdc5ce
--- /dev/null
+++ b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetFileTransferMsnImpl.java
@@ -0,0 +1,412 @@
+/*
+ * 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.impl.protocol.msn;
+
+import java.io.*;
+import java.util.*;
+
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.protocol.event.*;
+import net.java.sip.communicator.util.*;
+import net.sf.jml.*;
+import net.sf.jml.event.*;
+
+/**
+ * The Msn protocol filetransfer OperationSet.
+ *
+ * @author Damian Minkov
+ */
+public class OperationSetFileTransferMsnImpl
+ implements OperationSetFileTransfer
+{
+ private static final Logger logger =
+ Logger.getLogger(OperationSetFileTransferMsnImpl.class);
+
+ /**
+ * A call back to the Msn provider that created us.
+ */
+ private ProtocolProviderServiceMsnImpl msnProvider = null;
+
+ /**
+ * A list of listeners registered for file transfer events.
+ */
+ private ArrayList fileTransferListeners
+ = new ArrayList();
+
+ /**
+ * A list of active fileTransfers.
+ */
+ private Hashtable activeFileTransfers
+ = new Hashtable();
+
+ /**
+ * Create a new FileTransfer OperationSet over the specified Msn provider
+ * @param provider
+ */
+ public OperationSetFileTransferMsnImpl(
+ ProtocolProviderServiceMsnImpl msnProvider)
+ {
+ this.msnProvider = msnProvider;
+
+ msnProvider.addRegistrationStateChangeListener(
+ new RegistrationStateListener());
+ }
+
+
+ /**
+ * Sends a file transfer request to the given toContact by
+ * specifying the local and remote file path and the fromContact,
+ * 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
+ {
+ assertConnected();
+
+ if( !(toContact instanceof ContactMsnImpl) )
+ throw new IllegalArgumentException(
+ "The specified contact is not an msn contact." + toContact);
+
+ MsnFileTransfer ft = msnProvider.getMessenger().
+ getFileTransferManager().
+ sendFile(
+ ((ContactMsnImpl)toContact).getSourceContact().getEmail(),
+ file);
+
+ if(ft == null)
+ new IllegalStateException(
+ "A problem occured sending file, contact not found or offline");
+
+ FileTransferImpl outFileTransfer = new FileTransferImpl(
+ ft, toContact, file, FileTransfer.OUT);
+
+
+ // Notify all interested listeners that a file transfer has been
+ // created.
+ FileTransferCreatedEvent event
+ = new FileTransferCreatedEvent(outFileTransfer, new Date());
+
+ fireFileTransferCreated(event);
+
+ outFileTransfer.fireStatusChangeEvent(
+ FileTransferStatusChangeEvent.PREPARING);
+
+ return outFileTransfer;
+ }
+
+ /**
+ * Sends a file transfer request to the given toContact by
+ * specifying the local and remote file path and the fromContact,
+ * 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
+ {
+ return this.sendFile(toContact, new File(localPath));
+ }
+
+ /**
+ * Adds the given FileTransferListener that would listen for
+ * file transfer requests and created file transfers.
+ *
+ * @param listener the FileTransferListener to add
+ */
+ public void addFileTransferListener(
+ FileTransferListener listener)
+ {
+ synchronized(fileTransferListeners)
+ {
+ if(!fileTransferListeners.contains(listener))
+ {
+ this.fileTransferListeners.add(listener);
+ }
+ }
+ }
+
+ /**
+ * Removes the given FileTransferListener that listens for
+ * file transfer requests and created file transfers.
+ *
+ * @param listener the FileTransferListener to remove
+ */
+ public void removeFileTransferListener(
+ FileTransferListener listener)
+ {
+ synchronized(fileTransferListeners)
+ {
+ this.fileTransferListeners.remove(listener);
+ }
+ }
+
+ /**
+ * Utility method throwing an exception if the stack is not properly
+ * initialized.
+ * @throws java.lang.IllegalStateException if the underlying stack is
+ * not registered and initialized.
+ */
+ private void assertConnected()
+ throws IllegalStateException
+ {
+ if (msnProvider == null)
+ throw new IllegalStateException(
+ "The provider must be non-null and signed on the "
+ +"service before being able to send a file.");
+ else if (!msnProvider.isRegistered())
+ throw new IllegalStateException(
+ "The provider must be signed on the service before "
+ +"being able to send a file.");
+ }
+
+ /**
+ * Delivers the specified event to all registered file transfer listeners.
+ *
+ * @param event the EventObject that we'd like delivered to all
+ * registered file transfer listeners.
+ */
+ private void fireFileTransferRequest(FileTransferRequestEvent event)
+ {
+ Iterator listeners = null;
+ synchronized (fileTransferListeners)
+ {
+ listeners = new ArrayList
+ (fileTransferListeners).iterator();
+ }
+
+ while (listeners.hasNext())
+ {
+ FileTransferListener listener = listeners.next();
+
+ listener.fileTransferRequestReceived(event);
+ }
+ }
+
+ /**
+ * Delivers the specified event to all registered file transfer listeners.
+ *
+ * @param event the EventObject that we'd like delivered to all
+ * registered file transfer listeners.
+ */
+ void fireFileTransferRequestRejected(FileTransferRequestEvent event)
+ {
+ Iterator listeners = null;
+ synchronized (fileTransferListeners)
+ {
+ listeners = new ArrayList
+ (fileTransferListeners).iterator();
+ }
+
+ while (listeners.hasNext())
+ {
+ FileTransferListener listener = listeners.next();
+
+ listener.fileTransferRequestRejected(event);
+ }
+ }
+
+ /**
+ * Delivers the specified event to all registered file transfer listeners.
+ *
+ * @param event the EventObject that we'd like delivered to all
+ * registered file transfer listeners.
+ */
+ void fireFileTransferRequestCanceled(FileTransferRequestEvent event)
+ {
+ Iterator listeners = null;
+ synchronized (fileTransferListeners)
+ {
+ listeners = new ArrayList
+ (fileTransferListeners).iterator();
+ }
+
+ while (listeners.hasNext())
+ {
+ FileTransferListener listener = listeners.next();
+
+ listener.fileTransferRequestCanceled(event);
+ }
+ }
+
+ /**
+ * Delivers the file transfer to all registered listeners.
+ *
+ * @param fileTransfer the FileTransfer that we'd like delivered to
+ * all registered file transfer listeners.
+ */
+ void fireFileTransferCreated(FileTransferCreatedEvent event)
+ {
+ activeFileTransfers.put(
+ event.getFileTransfer().getID(), event.getFileTransfer());
+
+ Iterator listeners = null;
+ synchronized (fileTransferListeners)
+ {
+ listeners = new ArrayList
+ (fileTransferListeners).iterator();
+ }
+
+ while (listeners.hasNext())
+ {
+ FileTransferListener listener = listeners.next();
+ listener.fileTransferCreated(event);
+ }
+ }
+
+ /**
+ * Our listener that will tell us when we're registered to
+ */
+ private class RegistrationStateListener
+ implements RegistrationStateChangeListener
+ {
+ /**
+ * The method is called by a ProtocolProvider implementation whenever
+ * a change in the registration state of the corresponding provider had
+ * occurred.
+ * @param evt ProviderStatusChangeEvent the event describing the status
+ * change.
+ */
+ public void registrationStateChanged(RegistrationStateChangeEvent evt)
+ {
+ logger.debug("The provider changed state from: "
+ + evt.getOldState()
+ + " to: " + evt.getNewState());
+
+ if (evt.getNewState() == RegistrationState.REGISTERED)
+ {
+ msnProvider.getMessenger().addFileTransferListener(
+ new FileTransferProtocolListener());
+ }
+ }
+ }
+
+ /**
+ * Receives notifications from the slick about new filetransfers
+ * and filetransfer changes.
+ */
+ private class FileTransferProtocolListener
+ implements MsnFileTransferListener
+ {
+ public void fileTransferRequestReceived(MsnFileTransfer ft)
+ {
+ OperationSetPersistentPresenceMsnImpl opSetPersPresence
+ = (OperationSetPersistentPresenceMsnImpl)
+ msnProvider.getOperationSet(
+ OperationSetPersistentPresence.class);
+
+ Contact sender = opSetPersPresence.findContactByID(
+ ft.getContact().getEmail().getEmailAddress());
+
+ if(sender == null)
+ return;
+
+ Date recvDate = new Date();
+
+ IncomingFileTransferRequest req =
+ new IncomingFileTransferRequestMsnImpl(
+ OperationSetFileTransferMsnImpl.this,
+ ft, sender, recvDate);
+
+ activeFileTransfers.put(ft.getID(), req);
+
+ fireFileTransferRequest(
+ new FileTransferRequestEvent(
+ OperationSetFileTransferMsnImpl.this, req, recvDate));
+ }
+
+ public void fileTransferStarted(MsnFileTransfer ft)
+ {
+ Object ftObj = activeFileTransfers.get(ft.getID());
+
+ if(ftObj != null && ftObj instanceof FileTransferImpl)
+ {
+ FileTransferImpl fileTransfer = (FileTransferImpl)ftObj;
+
+ fileTransfer.fireStatusChangeEvent(
+ FileTransferStatusChangeEvent.IN_PROGRESS);
+ }
+ }
+
+ public void fileTransferProcess(MsnFileTransfer ft)
+ {
+ Object ftObj = activeFileTransfers.get(ft.getID());
+
+ if(ftObj != null && ftObj instanceof FileTransferImpl)
+ {
+ FileTransferImpl fileTransfer = (FileTransferImpl)ftObj;
+
+ fileTransfer.setTransferedBytes(ft.getTransferredSize());
+ fileTransfer.fireProgressChangeEvent(
+ System.currentTimeMillis(), ft.getTransferredSize());
+ }
+ }
+
+ public void fileTransferFinished(MsnFileTransfer ft)
+ {
+ Object ftObj = activeFileTransfers.get(ft.getID());
+
+ if(ftObj == null)
+ return;
+
+ if(ftObj instanceof FileTransferImpl)
+ {
+ FileTransferImpl fileTransfer = (FileTransferImpl)ftObj;
+
+ if(ft.getState() == MsnFileTransferState.COMPLETED)
+ fileTransfer.fireStatusChangeEvent(
+ FileTransferStatusChangeEvent.COMPLETED);
+ else if(ft.getState() == MsnFileTransferState.CANCELED)
+ fileTransfer.fireStatusChangeEvent(
+ FileTransferStatusChangeEvent.CANCELED);
+ else if(ft.getState() == MsnFileTransferState.REFUSED)
+ fileTransfer.fireStatusChangeEvent(
+ FileTransferStatusChangeEvent.REFUSED);
+ }
+ else if(ftObj instanceof IncomingFileTransferRequest)
+ {
+ IncomingFileTransferRequestMsnImpl inReq =
+ (IncomingFileTransferRequestMsnImpl)ftObj;
+
+ if(!inReq.isRejected()
+ && ft.getState() == MsnFileTransferState.CANCELED)
+ fireFileTransferRequestCanceled(
+ new FileTransferRequestEvent(
+ OperationSetFileTransferMsnImpl.this,
+ inReq,
+ inReq.getDate()));
+ }
+
+ activeFileTransfers.remove(ft.getID());
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java
index f98ea8d66..14a3327e8 100644
--- a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java
@@ -297,6 +297,12 @@ protected void initialize(String screenname,
OperationSetTypingNotifications.class.getName(),
typingNotifications);
+ OperationSetFileTransferMsnImpl fileTransferOpSet =
+ new OperationSetFileTransferMsnImpl(this);
+ supportedOperationSets.put(
+ OperationSetFileTransfer.class.getName(),
+ fileTransferOpSet);
+
isInitialized = true;
}
}
diff --git a/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetFileTransfer.java b/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetFileTransfer.java
index 9ee5dafdd..ad3f9dd1d 100644
--- a/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetFileTransfer.java
+++ b/test/net/java/sip/communicator/slick/protocol/generic/TestOperationSetFileTransfer.java
@@ -85,7 +85,7 @@ public void testSendAndReceive()
logger.trace("Start test : send and receive ok.");
- File fileToTransfer = getTempFileToTransfer(1234567);
+ File fileToTransfer = getTempFileToTransfer(123456);
OperationSetFileTransfer ftOpSet1 = getOpSetFilTransfer1();
OperationSetFileTransfer ftOpSet2 = getOpSetFilTransfer2();
@@ -108,7 +108,7 @@ public void testSendAndReceive()
ftOpSet1.sendFile(getContact1(), fileToTransfer);
senderFTListerner.waitForEvent(2000);
- receiverFTListerner.waitForEvent(2000);
+ receiverFTListerner.waitForEvent(8000);
senderStatusListener.waitForEvent(2000);
// sender
@@ -305,7 +305,7 @@ public void testSenderCancelBeforeAccepted()
,fileTransferStatusEvent.getNewStatus());
// the receiver must receive event refused
- assertEquals("A file transfer rejected must be received on receiver side"
+ assertEquals("A file transfer cancel must be received on receiver side"
, 1, receiverFTListerner.collectedEvents.size());
fileTransferRequestEvent
@@ -350,7 +350,7 @@ public void testReceiverDecline()
ftOpSet1.sendFile(getContact1(), fileToTransfer);
senderFTListerner.waitForEvent(2000);
- receiverFTListerner.waitForEvent(2000);
+ receiverFTListerner.waitForEvent(6000);
senderStatusListener.waitForEvent(2000);
// sender
@@ -581,7 +581,7 @@ public void testReceiverCancelsWhileTransfering()
public void testSenderCancelsWhileTransfering()
throws Exception
{
- if(!enableTestReceiverCancelsWhileTransfering())
+ if(!enableTestSenderCancelsWhileTransfering())
return;
logger.trace("Start test : Sender will cancel fileTransfer while transfering.");
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/MsnProtocolProviderServiceLick.java b/test/net/java/sip/communicator/slick/protocol/msn/MsnProtocolProviderServiceLick.java
index a652fbba7..1002e7695 100644
--- a/test/net/java/sip/communicator/slick/protocol/msn/MsnProtocolProviderServiceLick.java
+++ b/test/net/java/sip/communicator/slick/protocol/msn/MsnProtocolProviderServiceLick.java
@@ -85,6 +85,8 @@ public void start(BundleContext context)
addTest(TestOperationSetBasicInstantMessaging.suite());
addTest(TestOperationSetTypingNotifications.suite());
+
+ addTestSuite(TestOperationSetFileTransferImpl.class);
}
addTest(TestAccountUninstallation.suite());
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetFileTransferImpl.java b/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetFileTransferImpl.java
new file mode 100644
index 000000000..dc9cedf7a
--- /dev/null
+++ b/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetFileTransferImpl.java
@@ -0,0 +1,262 @@
+/*
+ * 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.slick.protocol.msn;
+
+import java.util.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.slick.protocol.generic.*;
+import net.java.sip.communicator.util.*;
+import org.osgi.framework.*;
+
+/**
+ * Implementation for generic file transfer.
+ * @author Damian Minkov
+ */
+public class TestOperationSetFileTransferImpl
+ extends TestOperationSetFileTransfer
+{
+ private static final Logger logger =
+ Logger.getLogger(TestOperationSetFileTransferImpl.class);
+
+ private MsnSlickFixture fixture = new MsnSlickFixture();
+
+ private OperationSetPresence opSetPresence1 = null;
+ private OperationSetPresence opSetPresence2 = null;
+
+ private OperationSetFileTransfer opSetFT1 = null;
+ private OperationSetFileTransfer opSetFT2 = null;
+
+ private static Contact contact1 = null;
+ private static Contact contact2 = null;
+
+ public Contact getContact1()
+ {
+ if(contact1 == null)
+ {
+ contact1 = opSetPresence1.findContactByID(fixture.userID2);
+ }
+
+ return contact1;
+ }
+
+ public Contact getContact2()
+ {
+ if(contact2 == null)
+ {
+ contact2 = opSetPresence2.findContactByID(fixture.userID1);
+ }
+
+ return contact2;
+ }
+
+ public void start()
+ throws Exception
+ {
+ fixture.setUp();
+
+ Map supportedOperationSets1 =
+ fixture.provider1.getSupportedOperationSets();
+
+ if ( supportedOperationSets1 == null
+ || supportedOperationSets1.size() < 1)
+ throw new NullPointerException(
+ "No OperationSet implementations are supported by "
+ +"this implementation. ");
+
+ //we also need the presence op set in order to retrieve contacts.
+ opSetPresence1 =
+ (OperationSetPresence)supportedOperationSets1.get(
+ OperationSetPresence.class.getName());
+
+ //if the op set is null show that we're not happy.
+ if (opSetPresence1 == null)
+ {
+ throw new NullPointerException(
+ "An implementation of the service must provide an "
+ + "implementation of at least one of the PresenceOperationSets");
+ }
+
+ opSetFT1 =
+ (OperationSetFileTransfer)supportedOperationSets1.get(
+ OperationSetFileTransfer.class.getName());
+
+ //if the op set is null show that we're not happy.
+ if (opSetFT1 == null)
+ {
+ throw new NullPointerException(
+ "An implementation of the service must provide an "
+ + "implementation of at least one of the FileTransferOperationSets");
+ }
+
+ Map supportedOperationSets2 =
+ fixture.provider2.getSupportedOperationSets();
+
+ if ( supportedOperationSets2 == null
+ || supportedOperationSets2.size() < 1)
+ throw new NullPointerException(
+ "No OperationSet implementations are supported by "
+ +"this implementation. ");
+
+ opSetPresence2 =
+ (OperationSetPresence) supportedOperationSets2.get(
+ OperationSetPresence.class.getName());
+
+ //if the op set is null show that we're not happy.
+ if (opSetPresence2 == null)
+ {
+ throw new NullPointerException(
+ "An implementation of the service must provide an "
+ + "implementation of at least one of the PresenceOperationSets");
+ }
+
+ opSetFT2 =
+ (OperationSetFileTransfer)supportedOperationSets2.get(
+ OperationSetFileTransfer.class.getName());
+
+ //if the op set is null show that we're not happy.
+ if (opSetFT2 == null)
+ {
+ throw new NullPointerException(
+ "An implementation of the service must provide an "
+ + "implementation of at least one of the FileTransferOperationSets");
+ }
+
+ prepareContactList();
+ }
+
+ public void stop()
+ throws Exception
+ {
+ fixture.tearDown();
+ }
+
+ /**
+ * Create the list to be sure that contacts exchanging messages
+ * exists in each other lists
+ * @throws Exception
+ */
+ public void prepareContactList()
+ throws Exception
+ {
+ // clear the provider the first time we run a filetransfer list
+ if(getContact1() == null && getContact2() == null)
+ fixture.clearProvidersLists();
+
+ if(getContact1() == null)
+ {
+ Object o = new Object();
+ synchronized(o)
+ {
+ o.wait(2000);
+ }
+
+ try
+ {
+ opSetPresence1.setAuthorizationHandler(new AuthHandler());
+ opSetPresence1.subscribe(fixture.userID2);
+ }
+ catch (OperationFailedException ex)
+ {
+ // the contact already exist its OK
+ }
+ }
+
+ if(getContact2() == null)
+ {
+ try
+ {
+ opSetPresence2.setAuthorizationHandler(new AuthHandler());
+ opSetPresence2.subscribe(fixture.userID1);
+ }
+ catch (OperationFailedException ex1)
+ {
+ // the contact already exist its OK
+ }
+
+ logger.info("will wait till the list prepare is completed");
+ Object o = new Object();
+ synchronized(o)
+ {
+ o.wait(2000);
+ }
+ }
+ }
+
+ public OperationSetFileTransfer getOpSetFilTransfer1()
+ {
+ return opSetFT1;
+ }
+
+ public OperationSetFileTransfer getOpSetFilTransfer2()
+ {
+ return opSetFT2;
+ }
+
+ public BundleContext getContext()
+ {
+ return fixture.bc;
+ }
+
+ public boolean enableTestSendAndReceive()
+ {
+ // as this is the first test to be executed
+ // make it wait for a while in order user to become online
+ Object o = new Object();
+ synchronized(o)
+ {
+ try{o.wait(4000);}catch (Exception e){}
+ }
+
+ return true;
+ }
+
+ public boolean enableTestSenderCancelBeforeAccepted()
+ {
+ return true;
+ }
+
+ public boolean enableTestReceiverDecline()
+ {
+ return true;
+ }
+
+ public boolean enableTestReceiverCancelsWhileTransfering()
+ {
+ return true;
+ }
+
+ public boolean enableTestSenderCancelsWhileTransfering()
+ {
+ return true;
+ }
+
+ private class AuthHandler
+ implements AuthorizationHandler
+ {
+
+ public AuthorizationResponse processAuthorisationRequest(AuthorizationRequest req, Contact sourceContact)
+ {
+ logger.trace("processAuthorisationRequest " + req + " " +
+ sourceContact);
+
+ return new AuthorizationResponse(AuthorizationResponse.ACCEPT, "");
+ }
+
+ public AuthorizationRequest createAuthorizationRequest(Contact contact)
+ {
+ logger.trace("createAuthorizationRequest " + contact);
+ return new AuthorizationRequest();
+ }
+
+ public void processAuthorizationResponse(AuthorizationResponse response, Contact sourceContact)
+ {
+ logger.debug("auth response from: " +
+ sourceContact.getAddress() + " " +
+ response.getResponseCode().getCode());
+ }
+ }
+}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/msn.provider.slick.manifest.mf b/test/net/java/sip/communicator/slick/protocol/msn/msn.provider.slick.manifest.mf
index 3f6f00a0e..872a50534 100755
--- a/test/net/java/sip/communicator/slick/protocol/msn/msn.provider.slick.manifest.mf
+++ b/test/net/java/sip/communicator/slick/protocol/msn/msn.provider.slick.manifest.mf
@@ -13,4 +13,5 @@ Import-Package: junit.framework,
net.java.sip.communicator.service.protocol,
net.java.sip.communicator.service.protocol.event,
net.java.sip.communicator.service.protocol.msnconstants,
- net.java.sip.communicator.util
+ net.java.sip.communicator.util,
+ net.java.sip.communicator.service.fileaccess