Msn Filetransfer and tests.

cusax-fix
Damian Minkov 17 years ago
parent 5e9b537723
commit 057fd9f385

@ -1237,6 +1237,8 @@ javax.swing.event, javax.swing.border"/>
<zipfileset dir="${dest}/net/java/sip/communicator/slick/protocol/msn"
prefix="net/java/sip/communicator/slick/protocol/msn"/>
<zipfileset src="${lib.noinst}/jml-1.0b2.jar" prefix=""/>
<zipfileset dir="${dest}/net/java/sip/communicator/slick/protocol/generic"
prefix="net/java/sip/communicator/slick/protocol/generic"/>
</jar>
</target>

@ -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.

@ -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

@ -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;
}
}

@ -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 <tt>FileTransfer</tt> 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;
}
}

@ -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<FileTransferListener> fileTransferListeners
= new ArrayList<FileTransferListener>();
/**
* A list of active fileTransfers.
*/
private Hashtable<String, Object> activeFileTransfers
= new Hashtable<String, Object>();
/**
* 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 <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
{
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 <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
{
return this.sendFile(toContact, new File(localPath));
}
/**
* Adds the given <tt>FileTransferListener</tt> that would listen for
* file transfer requests and created file transfers.
*
* @param listener the <tt>FileTransferListener</tt> to add
*/
public void addFileTransferListener(
FileTransferListener listener)
{
synchronized(fileTransferListeners)
{
if(!fileTransferListeners.contains(listener))
{
this.fileTransferListeners.add(listener);
}
}
}
/**
* Removes the given <tt>FileTransferListener</tt> that listens for
* file transfer requests and created file transfers.
*
* @param listener the <tt>FileTransferListener</tt> 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 <tt>EventObject</tt> that we'd like delivered to all
* registered file transfer listeners.
*/
private void fireFileTransferRequest(FileTransferRequestEvent event)
{
Iterator<FileTransferListener> listeners = null;
synchronized (fileTransferListeners)
{
listeners = new ArrayList<FileTransferListener>
(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 <tt>EventObject</tt> that we'd like delivered to all
* registered file transfer listeners.
*/
void fireFileTransferRequestRejected(FileTransferRequestEvent event)
{
Iterator<FileTransferListener> listeners = null;
synchronized (fileTransferListeners)
{
listeners = new ArrayList<FileTransferListener>
(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 <tt>EventObject</tt> that we'd like delivered to all
* registered file transfer listeners.
*/
void fireFileTransferRequestCanceled(FileTransferRequestEvent event)
{
Iterator<FileTransferListener> listeners = null;
synchronized (fileTransferListeners)
{
listeners = new ArrayList<FileTransferListener>
(fileTransferListeners).iterator();
}
while (listeners.hasNext())
{
FileTransferListener listener = listeners.next();
listener.fileTransferRequestCanceled(event);
}
}
/**
* Delivers the file transfer to all registered listeners.
*
* @param fileTransfer the <tt>FileTransfer</tt> that we'd like delivered to
* all registered file transfer listeners.
*/
void fireFileTransferCreated(FileTransferCreatedEvent event)
{
activeFileTransfers.put(
event.getFileTransfer().getID(), event.getFileTransfer());
Iterator<FileTransferListener> listeners = null;
synchronized (fileTransferListeners)
{
listeners = new ArrayList<FileTransferListener>
(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());
}
}
}

@ -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;
}
}

@ -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.");

@ -85,6 +85,8 @@ public void start(BundleContext context)
addTest(TestOperationSetBasicInstantMessaging.suite());
addTest(TestOperationSetTypingNotifications.suite());
addTestSuite(TestOperationSetFileTransferImpl.class);
}
addTest(TestAccountUninstallation.suite());

@ -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<String, OperationSet> 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<String, OperationSet> 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());
}
}
}

@ -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

Loading…
Cancel
Save