Java 类org.jivesoftware.smackx.filetransfer.FileTransfer.Status 实例源码

项目:android-1    文件:OperationSetFileTransferJabberImpl.java   
/**
 * Parses the given Jabber status to a <tt>FileTransfer</tt> interface
 * status.
 *
 * @param jabberStatus the Jabber status to parse
 * @return the parsed status
 */
private static int parseJabberStatus(Status jabberStatus)
{
    if (jabberStatus.equals(Status.complete))
        return FileTransferStatusChangeEvent.COMPLETED;
    else if (jabberStatus.equals(Status.cancelled))
        return FileTransferStatusChangeEvent.CANCELED;
    else if (jabberStatus.equals(Status.in_progress)
            || jabberStatus.equals(Status.negotiated))
        return FileTransferStatusChangeEvent.IN_PROGRESS;
    else if (jabberStatus.equals(Status.error))
        return FileTransferStatusChangeEvent.FAILED;
    else if (jabberStatus.equals(Status.refused))
        return FileTransferStatusChangeEvent.REFUSED;
    else if (jabberStatus.equals(Status.negotiating_transfer)
            || jabberStatus.equals(Status.negotiating_stream))
        return FileTransferStatusChangeEvent.PREPARING;
    else
         // FileTransfer.Status.initial
        return FileTransferStatusChangeEvent.WAITING;
}
项目:jitsi    文件:OperationSetFileTransferJabberImpl.java   
/**
 * Parses the given Jabber status to a <tt>FileTransfer</tt> interface
 * status.
 *
 * @param jabberStatus the Jabber status to parse
 * @return the parsed status
 */
private static int parseJabberStatus(Status jabberStatus)
{
    if (jabberStatus.equals(Status.complete))
        return FileTransferStatusChangeEvent.COMPLETED;
    else if (jabberStatus.equals(Status.cancelled))
        return FileTransferStatusChangeEvent.CANCELED;
    else if (jabberStatus.equals(Status.in_progress)
            || jabberStatus.equals(Status.negotiated))
        return FileTransferStatusChangeEvent.IN_PROGRESS;
    else if (jabberStatus.equals(Status.error))
        return FileTransferStatusChangeEvent.FAILED;
    else if (jabberStatus.equals(Status.refused))
        return FileTransferStatusChangeEvent.REFUSED;
    else if (jabberStatus.equals(Status.negotiating_transfer)
            || jabberStatus.equals(Status.negotiating_stream))
        return FileTransferStatusChangeEvent.PREPARING;
    else
         // FileTransfer.Status.initial
        return FileTransferStatusChangeEvent.WAITING;
}
项目:commune    文件:TransferProgress.java   
public TransferProgress(TransferHandle handle, String fileName, long fileSize, Status newStatus, long amountWritten, 
        double progress, double transferRate, boolean outgoing) {

    this.handle = handle;
    this.fileName = fileName;
    this.fileSize = fileSize;
    this.newStatus = newStatus;
    this.amountWritten = amountWritten;
    this.progress = progress;
    this.transferRate = transferRate;
    this.outgoing = outgoing;
}
项目:commune    文件:TransferData.java   
public TransferData(DeploymentID destinationID, DeploymentID listenerID, Status status, File file, long id,
        long inactivityTimeout, int queuePosition, boolean receiveProgressUpdate, boolean isIncoming) {

    this.destinationID = destinationID;
    this.listenerID = listenerID;
    this.status = status;
    this.file = file;
    this.id = id;
    this.inactivityTimeout = inactivityTimeout;
    this.queuePosition = queuePosition;
    this.receiveProgressUpdate = receiveProgressUpdate;
    this.isIncoming = isIncoming;
}
项目:commune    文件:TransferDataMatcher.java   
public TransferDataMatcher(DeploymentID destinationID, DeploymentID listenerID, Status status, File file, 
        int queuePosition, boolean isIncoming) {
    Collection<TransferData> transferDatas = new ArrayList<TransferData>();
    transferDatas.add(new TransferData(destinationID, listenerID, status, file, 0, 0,
            queuePosition, true, isIncoming));

    this.transferDatas = transferDatas;
}
项目:commune    文件:TestGetFileTransfers.java   
@Test
public void testGetAnsweredTransfer() throws Exception {
    module = deployMonitorUtil.createAndStartApplication(module);

    SenderClass senderObject = new SenderClass();
    module.deploy(SenderClass.OBJECT_NAME, senderObject);

    DeploymentID destinationID = testGetFileTransfersUtil.getObjectDeployment(module, SenderClass.OBJECT_NAME).getDeploymentID();
    DeploymentID listenerID = testGetFileTransfersUtil.getObjectDeployment(module, SenderClass.OBJECT_NAME).getDeploymentID();

    OutgoingTransferHandle handle = new OutgoingTransferHandle(TRANSFER_FILE_LOG_NAME, 
            new File(TRANSFER_FILE), "", destinationID);

    Message message = new Message(listenerID, destinationID, "sendFile");
    message.addParameter(OutgoingTransferHandle.class, handle);

    module.deliverMessage(message);

    //expect send start transfer msg to FileTransfer
    module.getServiceConsumer().consumeMessage();

    module.getFileTransferConsumer().consumeMessage();

    testGetFileTransfersUtil.getFileTransfers(module, destinationID, 
            listenerID, null, new File(TRANSFER_FILE), 0, false);

    TestableFileTransferProcessor fileTransferProcessor = (TestableFileTransferProcessor) module.getFileTransferProcessor();
    fileTransferProcessor.setOutgoingTransferStatus(handle, Status.initial);

    testGetFileTransfersUtil.getFileTransfers(module, destinationID, 
            listenerID, Status.initial, new File(TRANSFER_FILE), 0, false);
}
项目:commune    文件:TestGetFileTransfersUtil.java   
public void getFileTransfers(Module application, DeploymentID destinationID, DeploymentID listenerID, Status status, File file,
        int queuePosition, boolean isIncoming) {
    CommuneMonitor monitor = getMonitorController(application);

    CommuneMonitorClient client = EasyMock.createMock(CommuneMonitorClient.class);

    client.hereAreFileTransfers(TransferDataMatcher.eqMatcher(destinationID, listenerID, status, file, queuePosition, isIncoming));

    EasyMock.replay(client);
    monitor.getFileTransfers(client);
    EasyMock.verify(client);        
}
项目:yiim_v2    文件:FileUpload.java   
public void transDone(Context context, String toUser, final Uri uri,
MsgType msgType, String path, final Status status);
项目:yiim_v2    文件:FileUpload.java   
/**
     * 发送文件
     * 
     * @param connection
     * @param user
     * @param toUserName
     * @param file
     */
    public static void sendFile(final Context context,
            final Connection connection, final String toUser, final Uri uri,
            final String filePath, final MsgType msgType) {
        new Thread() {
            public void run() {
                XMPPConnection.DEBUG_ENABLED = true;
                // AccountManager accountManager;
                try {
                    // accountManager = connection.getAccountManager();
                    Presence pre = connection.getRoster().getPresence(toUser);
                    if (pre.getType() != Presence.Type.unavailable) {
                        if (connection.isConnected()) {
                            Log.d(TAG, "connection con");
                        }
                        // 创建文件传输管理器
//                      ServiceDiscoveryManager sdm = ServiceDiscoveryManager
//                              .getInstanceFor(connection);
//                      if (sdm == null)
//                          sdm = new ServiceDiscoveryManager(connection);

                        FileTransferManager manager = new FileTransferManager(
                                connection);
                        // 创建输出的文件传输
                        OutgoingFileTransfer transfer = manager
                                .createOutgoingFileTransfer(pre.getFrom());
                        // 发送文件
                        transfer.sendFile(new File(filePath),
                                msgType.toString());
                        while (!transfer.isDone()) {
                            if (transfer.getStatus() == FileTransfer.Status.in_progress) {
                                // 可以调用transfer.getProgress();获得传输的进度 
                                // Log.d(TAG,
                                // "send status:" + transfer.getStatus());
                                // Log.d(TAG,
                                // "send progress:"
                                // + transfer.getProgress());
                                if (mFileUploadListener != null) {
                                    mFileUploadListener.transProgress(context,
                                            uri, filePath,
                                            transfer.getProgress());
                                }
                            }
                        }
                        // YiLog.getInstance().i("send file error: %s",
                        // transfer.);
                        Log.d(TAG, "send status 1 " + transfer.getStatus());
                        if (transfer.isDone()) {
                            if (mFileUploadListener != null) {
                                mFileUploadListener.transDone(context, toUser,
                                        uri, msgType, filePath,
                                        transfer.getStatus());
                            }
                        }
                    }
                } catch (Exception e) {
                    Log.d(TAG, "send exception");
                    if (mFileUploadListener != null) {
                        mFileUploadListener.transDone(context, toUser, uri,
                                msgType, filePath, Status.error);
                    }
                }
            }
        }.start();
    }
项目:commune    文件:TransferProgress.java   
public Status getNewStatus() {
    return this.newStatus;
}
项目:commune    文件:AbstractTransfer.java   
public Status getCurrentStatus() {
    return this.currentStatus;
}
项目:commune    文件:AbstractTransfer.java   
public void setCurrentStatus(Status currentStatus) {
    this.currentStatus = currentStatus;
}
项目:commune    文件:TestableFileTransferProcessor.java   
public void setOutgoingTransferStatus(OutgoingTransferHandle handle, Status newStatus) {
    OutgoingTransfer transfer = getTransferManager().getOutgoingManager().getTransfer(handle);
    transfer.setCurrentStatus(newStatus);
    transfer.updateStatus();
}
项目:commune    文件:TransferData.java   
public Status getStatus() {
    return status;
}
项目:commune    文件:TransferData.java   
public void setStatus(Status status) {
    this.status = status;
}
项目:commune    文件:TransferDataMatcher.java   
private boolean equalsStatus(Status status, Status otherStatus) {
    return status == null ? otherStatus == null : status.equals(otherStatus);
}
项目:commune    文件:TransferDataMatcher.java   
public static Collection<TransferData> eqMatcher(DeploymentID destinationID, DeploymentID listenerID, Status status, File file,
        int queuePosition, boolean isIncoming) {
    EasyMock.reportMatcher(new TransferDataMatcher(destinationID, listenerID, status, file, queuePosition, isIncoming));
    return null;
}
项目:spark-svn-mirror    文件:SendFileTransfer.java   
private void updateBar(final OutgoingFileTransfer transfer, String nickname, String kBperSecond) {
    FileTransfer.Status status = transfer.getStatus();
    if (status == Status.negotiating_stream) {
        titleLabel.setText(Res.getString("message.negotiation.file.transfer", nickname));
    }
    else if (status == Status.error) {
        if (transfer.getException() != null) {
            Log.error("Error occured during file transfer.", transfer.getException());
        }
        progressBar.setVisible(false);
        progressLabel.setVisible(false);
        titleLabel.setText(Res.getString("message.unable.to.send.file", nickname));
        cancelButton.setVisible(false);
        retryButton.setVisible(true);
        showAlert(true);
    }
    else if (status == Status.in_progress) {
        titleLabel.setText(Res.getString("message.sending.file.to", nickname));
        showAlert(false);
        if (!progressBar.isVisible()) {
            progressBar.setVisible(true);
            progressLabel.setVisible(true);
        }

        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    // 100 % = Filesize
                // x %   = Currentsize      
                    long p = (transfer.getBytesSent() * 100 / transfer.getFileSize() );
                    progressBar.setValue(Math.round(p));
                }
            });
        }
        catch (Exception e) {
            Log.error(e);
        }

        ByteFormat format = new ByteFormat();
        String bytesSent = format.format(transfer.getBytesSent());
        String est = TransferUtils.calculateEstimate(transfer.getBytesSent(), transfer.getFileSize(), _starttime, System.currentTimeMillis());

        progressLabel.setText(Res.getString("message.transfer.progressbar.text.sent", bytesSent, kBperSecond, est));
    }
    else if (status == Status.complete) {
        progressBar.setVisible(false);

        String fin = TransferUtils.convertSecondstoHHMMSS(Math.round(System.currentTimeMillis()-_starttime)/1000);
        progressLabel.setText(Res.getString("label.time", fin));
        titleLabel.setText(Res.getString("message.you.have.sent", nickname));
        cancelButton.setVisible(false);
        showAlert(true);
    }
    else if (status == Status.cancelled) {
        progressBar.setVisible(false);
        progressLabel.setVisible(false);
        titleLabel.setText(Res.getString("message.file.transfer.canceled"));
        cancelButton.setVisible(false);
        retryButton.setVisible(true);
        showAlert(true);
    }
    else if (status == Status.refused) {
        progressBar.setVisible(false);
        progressLabel.setVisible(false);
        titleLabel.setText(Res.getString("message.file.transfer.rejected", nickname));
        cancelButton.setVisible(false);
        retryButton.setVisible(true);
        showAlert(true);
    }

}