OutgoingFileTransfer rejected?

Hi all,

About OutgoingFileTransfer:

If user1 creates an OutgoingFileTransfer and calls the sendFile(File file, String description) method on it to send the file to user2; if user2 rejects the transfer, how does user1 can handle this event?

thx.

JTecks.

Hi,

You can just check if the status is REFUSED with something like this:

FileTransferManager manager = new FileTransferManager(conn);
OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer("user@domian/resource");
try {
     transfer.sendFile(new File("c:/testSend.txt";), "Testing a file");
     while(!transfer.isDone()) {
          if (transfer.getStatus().equals(Status.REFUSED)) {
               //Don''t forget this break
               break;
          }
          try {
               Thread.sleep(100);
          } catch (InterruptedException e)  {
               e.printStackTrace();
          }
     }
} catch (XMPPException e) {
     e.printStackTrace();
}

I think there’'s no event that you can listen to.

Another thing is that you must check the REFUSED inside the “while is not done” and “break” the iteration because the isDone still false when the status is REFUSED, otherwise the iteration will never end. I mean

!transfer.isDone() && transfer.getStatus().equals(Status.REFUSED)

Is the final state of an OutgoingFileTransfer instance when the file transfer is rejected.

Hi gguardin,

Thx for your reply…

I’'will try this solution and I will give you a feed back…

JTecks.

Hi gguardin,

It is working fine…

Thx for your help…

JTecks