use of cx.ring.daemon.DataTransferInfo in project ring-client-android by savoirfairelinux.
the class AccountService method dataTransferEvent.
public void dataTransferEvent(final long transferId, int eventCode) {
DataTransferEventCode dataEvent = getDataTransferEventCode(eventCode);
DataTransferInfo info = new DataTransferInfo();
dataTransferInfo(transferId, info);
boolean outgoing = info.getFlags() == 0;
DataTransfer transfer = mDataTransfers.get(transferId);
if (transfer == null && outgoing && mStartingTransfer != null) {
transfer = mStartingTransfer;
mStartingTransfer = null;
transfer.setDataTransferId(transferId);
mDataTransfers.put(transferId, transfer);
}
if (transfer == null) {
transfer = new DataTransfer(transferId, info.getDisplayName(), outgoing, info.getTotalSize(), info.getBytesProgress(), info.getPeer(), info.getAccountId());
mHistoryService.insertDataTransfer(transfer);
mDataTransfers.put(transferId, transfer);
} else {
DataTransferEventCode oldState = transfer.getEventCode();
if (oldState != dataEvent) {
if (dataEvent == DataTransferEventCode.ONGOING) {
if (mTransferRefreshTimer == null) {
mTransferRefreshTimer = new Timer();
}
mTransferRefreshTimer.scheduleAtFixedRate(new DataTransferRefreshTask(transfer), DATA_TRANSFER_REFRESH_PERIOD, DATA_TRANSFER_REFRESH_PERIOD);
}
}
transfer.setEventCode(dataEvent);
transfer.setBytesProgress(info.getBytesProgress());
mHistoryService.updateDataTransfer(transfer);
}
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.DATA_TRANSFER);
event.addEventInput(ServiceEvent.EventInput.TRANSFER_EVENT_CODE, dataEvent);
event.addEventInput(ServiceEvent.EventInput.TRANSFER_INFO, transfer);
notifyObservers(event);
}
use of cx.ring.daemon.DataTransferInfo in project ring-client-android by savoirfairelinux.
the class AccountService method sendFile.
public DataTransferError sendFile(final DataTransfer dataTransfer, File file) {
mStartingTransfer = dataTransfer;
DataTransferInfo dataTransferInfo = new DataTransferInfo();
dataTransferInfo.setAccountId(dataTransfer.getAccountId());
dataTransferInfo.setPeer(dataTransfer.getPeerId());
dataTransferInfo.setPath(file.getPath());
dataTransferInfo.setDisplayName(dataTransfer.getDisplayName());
Long errorCode = FutureUtils.executeDaemonThreadCallable(mExecutor, mDeviceRuntimeService.provideDaemonThreadId(), true, () -> {
Log.i(TAG, "sendFile() thread running... id=" + dataTransfer.getId() + " accountId=" + dataTransferInfo.getAccountId() + ", peer=" + dataTransferInfo.getPeer() + ", filePath=" + dataTransferInfo.getPath());
return Ringservice.sendFile(dataTransferInfo, 0);
});
return getDataTransferError(errorCode);
}
Aggregations