@Override
  public void fileTransferRequest(FileTransferRequest request) {
    // Check to see if the request should be accepted
    if (shouldAccept(request)) {
      // Accept it
      IncomingFileTransfer transfer = request.accept();
      try {
        transfer.recieveFile(new File("shakespeare_complete_works.txt"));

        while (!transfer.isDone()) {
          if (transfer.getStatus().equals(Status.error)) {
            System.out.println("ERROR!!! " + transfer.getError());
          } else {
            System.out.println(transfer.getStatus());
            System.out.println(transfer.getProgress());
          }
          // sleep(1000);
        }

      } catch (XMPPException e) {
        log.error(e.getMessage());
      }
    } else {
      // Reject it
      request.reject();
    }
  }
示例#2
0
 public void getOtherMsg(String lccno, String operate, Message msg) throws Exception {
   if (Constants.OTHERMSG_OPERATE_CANCELSENDFILE.equals(operate)) {
     String streamID = (String) msg.getProperty("streamID");
     Date sendDate = new Date((Long) msg.getProperty("sendDate"));
     FileTransferRequest req = DataUtil.getFileTransferRequest(streamID);
     MessageFrame msgFrame = getMessageFrame();
     MemberBean memberBean = TreeUtil.getMemberBeanByLccno(lccno);
     final FriendChatPanel panel = getFriendChatPanel(memberBean);
     String info =
         StringUtil.getFormatString(
             getUIString("sendFile.otherCancel"), "\"" + req.getFileName() + "\"");
     panel.otherCancelSendFile(streamID, sendDate, info);
     msgFrame.setVisible(true);
   }
 }