Commit 3c50ba67 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

Revert "datatransfer: use new API"

This reverts commit e7c9e570.

Reason for revert: wip

Change-Id: If03c88b17fd02f740e8a9b01b18768cc328533bf
parent a40bac52
...@@ -181,8 +181,8 @@ STATIC_LIBS_ALL="-llog -lOpenSLES -landroid \ ...@@ -181,8 +181,8 @@ STATIC_LIBS_ALL="-llog -lOpenSLES -landroid \
-lyaml-cpp -ljsoncpp -lhttp_parser -lfmt\ -lyaml-cpp -ljsoncpp -lhttp_parser -lfmt\
-luuid -lz -ldl \ -luuid -lz -ldl \
-lvpx -lopus -lspeex -lspeexdsp -lx264 \ -lvpx -lopus -lspeex -lspeexdsp -lx264 \
-lgit2 \
-largon2 \ -largon2 \
-lgit2 \
-liconv" -liconv"
LIBRING_JNI_DIR=${ANDROID_APP_DIR}/app/src/main/libs/${ANDROID_ABI} LIBRING_JNI_DIR=${ANDROID_APP_DIR}/app/src/main/libs/${ANDROID_ABI}
......
...@@ -759,13 +759,13 @@ public class ConversationFragment extends BaseSupportFragment<ConversationPresen ...@@ -759,13 +759,13 @@ public class ConversationFragment extends BaseSupportFragment<ConversationPresen
return; return;
} }
requireActivity().startService(new Intent(DRingService.ACTION_FILE_ACCEPT, ConversationPath.toUri(accountId, conversationUri), requireContext(), DRingService.class) requireActivity().startService(new Intent(DRingService.ACTION_FILE_ACCEPT, ConversationPath.toUri(accountId, conversationUri), requireContext(), DRingService.class)
.putExtra(DRingService.KEY_TRANSFER_ID, transfer.getFileId())); .putExtra(DRingService.KEY_TRANSFER_ID, transfer.getDaemonId()));
} }
@Override @Override
public void refuseFile(String accountId, Uri conversationUri, DataTransfer transfer) { public void refuseFile(String accountId, Uri conversationUri, DataTransfer transfer) {
requireActivity().startService(new Intent(DRingService.ACTION_FILE_CANCEL, ConversationPath.toUri(accountId, conversationUri), requireContext(), DRingService.class) requireActivity().startService(new Intent(DRingService.ACTION_FILE_CANCEL, ConversationPath.toUri(accountId, conversationUri), requireContext(), DRingService.class)
.putExtra(DRingService.KEY_TRANSFER_ID, transfer.getFileId())); .putExtra(DRingService.KEY_TRANSFER_ID, transfer.getDaemonId()));
} }
@Override @Override
......
...@@ -651,7 +651,7 @@ public class DRingService extends Service { ...@@ -651,7 +651,7 @@ public class DRingService extends Service {
} }
private void handleFileAction(android.net.Uri uri, String action, Bundle extras) { private void handleFileAction(android.net.Uri uri, String action, Bundle extras) {
String id = extras.getString(KEY_TRANSFER_ID); long id = extras.getLong(KEY_TRANSFER_ID);
ConversationPath path = ConversationPath.fromUri(uri); ConversationPath path = ConversationPath.fromUri(uri);
if (action.equals(ACTION_FILE_ACCEPT)) { if (action.equals(ACTION_FILE_ACCEPT)) {
mNotificationService.removeTransferNotification(path.getAccountId(), path.getConversationUri(), id); mNotificationService.removeTransferNotification(path.getAccountId(), path.getConversationUri(), id);
......
...@@ -71,7 +71,7 @@ public class DeviceRuntimeServiceImpl extends DeviceRuntimeService { ...@@ -71,7 +71,7 @@ public class DeviceRuntimeServiceImpl extends DeviceRuntimeService {
@Override @Override
public void loadNativeLibrary() { public void loadNativeLibrary() {
//mExecutor.execute(() -> { mExecutor.execute(() -> {
try { try {
System.loadLibrary("ring"); System.loadLibrary("ring");
} catch (Exception e) { } catch (Exception e) {
...@@ -79,7 +79,7 @@ public class DeviceRuntimeServiceImpl extends DeviceRuntimeService { ...@@ -79,7 +79,7 @@ public class DeviceRuntimeServiceImpl extends DeviceRuntimeService {
android.os.Process.killProcess(android.os.Process.myPid()); android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0); System.exit(0);
} }
//}); });
} }
@Override @Override
......
...@@ -471,12 +471,12 @@ public class NotificationServiceImpl implements NotificationService { ...@@ -471,12 +471,12 @@ public class NotificationServiceImpl implements NotificationService {
if (!remove) { if (!remove) {
showFileTransferNotification(conversation, transfer); showFileTransferNotification(conversation, transfer);
} else { } else {
removeTransferNotification(ConversationPath.toUri(conversation), transfer.getFileId()); removeTransferNotification(ConversationPath.toUri(conversation), transfer.getDaemonId());
} }
} }
@Override @Override
public void removeTransferNotification(String accountId, Uri conversationUri, String transferId) { public void removeTransferNotification(String accountId, Uri conversationUri, long transferId) {
removeTransferNotification(ConversationPath.toUri(accountId, conversationUri), transferId); removeTransferNotification(ConversationPath.toUri(accountId, conversationUri), transferId);
} }
...@@ -485,7 +485,7 @@ public class NotificationServiceImpl implements NotificationService { ...@@ -485,7 +485,7 @@ public class NotificationServiceImpl implements NotificationService {
* *
* @param transferId the transfer id which is required to generate the notification id * @param transferId the transfer id which is required to generate the notification id
*/ */
public void removeTransferNotification(android.net.Uri path, String transferId) { public void removeTransferNotification(android.net.Uri path, long transferId) {
int id = getFileTransferNotificationId(path, transferId); int id = getFileTransferNotificationId(path, transferId);
dataTransferNotifications.remove(id); dataTransferNotifications.remove(id);
cancelFileNotification(id, false); cancelFileNotification(id, false);
...@@ -749,7 +749,7 @@ public class NotificationServiceImpl implements NotificationService { ...@@ -749,7 +749,7 @@ public class NotificationServiceImpl implements NotificationService {
} }
android.net.Uri path = ConversationPath.toUri(conversation); android.net.Uri path = ConversationPath.toUri(conversation);
Log.d(TAG, "showFileTransferNotification " + path); Log.d(TAG, "showFileTransferNotification " + path);
String dataTransferId = info.getFileId(); long dataTransferId = info.getDaemonId();
int notificationId = getFileTransferNotificationId(path, dataTransferId); int notificationId = getFileTransferNotificationId(path, dataTransferId);
Intent intentConversation = new Intent(DRingService.ACTION_CONV_ACCEPT, path, mContext, DRingService.class); Intent intentConversation = new Intent(DRingService.ACTION_CONV_ACCEPT, path, mContext, DRingService.class);
...@@ -955,7 +955,7 @@ public class NotificationServiceImpl implements NotificationService { ...@@ -955,7 +955,7 @@ public class NotificationServiceImpl implements NotificationService {
return (NOTIF_MSG + accountId + contact.toString()).hashCode(); return (NOTIF_MSG + accountId + contact.toString()).hashCode();
} }
private int getFileTransferNotificationId(android.net.Uri path, String dataTransferId) { private int getFileTransferNotificationId(android.net.Uri path, long dataTransferId) {
return (NOTIF_FILE_TRANSFER + path.toString() + dataTransferId).hashCode(); return (NOTIF_FILE_TRANSFER + path.toString() + dataTransferId).hashCode();
} }
......
...@@ -632,13 +632,13 @@ public class TvConversationAdapter extends RecyclerView.Adapter<TvConversationVi ...@@ -632,13 +632,13 @@ public class TvConversationAdapter extends RecyclerView.Adapter<TvConversationVi
} }
context.startService(new Intent(DRingService.ACTION_FILE_ACCEPT) context.startService(new Intent(DRingService.ACTION_FILE_ACCEPT)
.setClass(context.getApplicationContext(), DRingService.class) .setClass(context.getApplicationContext(), DRingService.class)
.putExtra(DRingService.KEY_TRANSFER_ID, file.getFileId())); .putExtra(DRingService.KEY_TRANSFER_ID, file.getDaemonId()));
}); });
viewHolder.btnRefuse.setOnClickListener(v -> { viewHolder.btnRefuse.setOnClickListener(v -> {
Context context = v.getContext(); Context context = v.getContext();
context.startService(new Intent(DRingService.ACTION_FILE_CANCEL) context.startService(new Intent(DRingService.ACTION_FILE_CANCEL)
.setClass(context.getApplicationContext(), DRingService.class) .setClass(context.getApplicationContext(), DRingService.class)
.putExtra(DRingService.KEY_TRANSFER_ID, file.getFileId())); .putExtra(DRingService.KEY_TRANSFER_ID, file.getDaemonId()));
}); });
} else { } else {
viewHolder.mAnswerLayout.setVisibility(View.GONE); viewHolder.mAnswerLayout.setVisibility(View.GONE);
......
...@@ -807,7 +807,7 @@ public class TvConversationFragment extends BaseSupportFragment<ConversationPres ...@@ -807,7 +807,7 @@ public class TvConversationFragment extends BaseSupportFragment<ConversationPres
requireActivity().startService(new Intent(DRingService.ACTION_FILE_ACCEPT) requireActivity().startService(new Intent(DRingService.ACTION_FILE_ACCEPT)
.setClass(requireContext(), DRingService.class) .setClass(requireContext(), DRingService.class)
.setData(ConversationPath.toUri(accountId, conversationUri)) .setData(ConversationPath.toUri(accountId, conversationUri))
.putExtra(DRingService.KEY_TRANSFER_ID, transfer.getFileId())); .putExtra(DRingService.KEY_TRANSFER_ID, transfer.getDaemonId()));
} }
@Override @Override
...@@ -815,7 +815,7 @@ public class TvConversationFragment extends BaseSupportFragment<ConversationPres ...@@ -815,7 +815,7 @@ public class TvConversationFragment extends BaseSupportFragment<ConversationPres
requireActivity().startService(new Intent(DRingService.ACTION_FILE_CANCEL) requireActivity().startService(new Intent(DRingService.ACTION_FILE_CANCEL)
.setClass(requireContext(), DRingService.class) .setClass(requireContext(), DRingService.class)
.setData(ConversationPath.toUri(accountId, conversationUri)) .setData(ConversationPath.toUri(accountId, conversationUri))
.putExtra(DRingService.KEY_TRANSFER_ID, transfer.getFileId())); .putExtra(DRingService.KEY_TRANSFER_ID, transfer.getDaemonId()));
} }
} }
...@@ -267,24 +267,18 @@ public class ConversationFacade { ...@@ -267,24 +267,18 @@ public class ConversationFacade {
} }
public Completable sendFile(Conversation conversation, Uri to, File file) { public Completable sendFile(Conversation conversation, Uri to, File file) {
if (file == null || !file.exists() || !file.canRead()) {
Log.w(TAG, "sendFile: file not found or not readable: " + file);
return null;
}
if (conversation.isSwarm()) {
mAccountService.sendFile(conversation, file);
return Completable.complete();
}
return Single.fromCallable(() -> { return Single.fromCallable(() -> {
/*if (file == null || !file.exists() || !file.canRead()) { if (file == null || !file.exists() || !file.canRead()) {
Log.w(TAG, "sendFile: file not found or not readable: " + file); Log.w(TAG, "sendFile: file not found or not readable: " + file);
return null; return null;
}*/ }
DataTransfer transfer = new DataTransfer(conversation, to.getRawRingId(), conversation.getAccountId(), file.getName(), true, file.length(), 0, null); DataTransfer transfer = new DataTransfer(conversation, to.getRawRingId(), conversation.getAccountId(), file.getName(), true, file.length(), 0, 0L);
mHistoryService.insertInteraction(conversation.getAccountId(), conversation, transfer).blockingAwait(); if (conversation.isSwarm()) {
transfer.setSwarmInfo(conversation.getUri().getRawRingId(), null, null);
} else {
mHistoryService.insertInteraction(conversation.getAccountId(), conversation, transfer).blockingAwait();
}
transfer.destination = mDeviceRuntimeService.getConversationDir(conversation.getUri().getRawRingId()); transfer.destination = mDeviceRuntimeService.getConversationDir(conversation.getUri().getRawRingId());
return transfer; return transfer;
...@@ -303,7 +297,7 @@ public class ConversationFacade { ...@@ -303,7 +297,7 @@ public class ConversationFacade {
if (element.getType() == Interaction.InteractionType.DATA_TRANSFER) { if (element.getType() == Interaction.InteractionType.DATA_TRANSFER) {
DataTransfer transfer = (DataTransfer) element; DataTransfer transfer = (DataTransfer) element;
if (transfer.getStatus() == Interaction.InteractionStatus.TRANSFER_ONGOING) { if (transfer.getStatus() == Interaction.InteractionStatus.TRANSFER_ONGOING) {
mAccountService.cancelDataTransfer(conversation.getAccountId(), conversation.getUri().getRawRingId(), transfer.getFileId()); mAccountService.cancelDataTransfer(conversation.getAccountId(), conversation.getUri().getRawRingId(), transfer.getDaemonId());
} else { } else {
File file = mDeviceRuntimeService.getConversationPath(conversation.getUri().getRawRingId(), transfer.getStoragePath()); File file = mDeviceRuntimeService.getConversationPath(conversation.getUri().getRawRingId(), transfer.getStoragePath());
mDisposableBag.add(Completable.mergeArrayDelayError( mDisposableBag.add(Completable.mergeArrayDelayError(
...@@ -684,10 +678,10 @@ public class ConversationFacade { ...@@ -684,10 +678,10 @@ public class ConversationFacade {
}); });
} }
public void cancelFileTransfer(String accountId, Uri conversationId, String fileId) { public void cancelFileTransfer(String accountId, Uri conversationId, long id) {
mAccountService.cancelDataTransfer(accountId, conversationId.isSwarm() ? conversationId.getRawRingId() : "", fileId); mAccountService.cancelDataTransfer(accountId, conversationId.isSwarm() ? conversationId.getRawRingId() : "", id);
mNotificationService.removeTransferNotification(accountId, conversationId, fileId); mNotificationService.removeTransferNotification(accountId, conversationId, id);
DataTransfer transfer = mAccountService.getAccount(accountId).getDataTransfer(fileId); DataTransfer transfer = mAccountService.getAccount(accountId).getDataTransfer(id);
if (transfer != null) if (transfer != null)
deleteConversationItem((Conversation) transfer.getConversation(), transfer); deleteConversationItem((Conversation) transfer.getConversation(), transfer);
} }
......
...@@ -65,7 +65,7 @@ public class Account { ...@@ -65,7 +65,7 @@ public class Account {
private final Map<String, TrustRequest> mRequests = new HashMap<>(); private final Map<String, TrustRequest> mRequests = new HashMap<>();
private final Map<String, Contact> mContactCache = new HashMap<>(); private final Map<String, Contact> mContactCache = new HashMap<>();
private final Map<String, Conversation> swarmConversations = new HashMap<>(); private final Map<String, Conversation> swarmConversations = new HashMap<>();
private final HashMap<String, DataTransfer> mDataTransfers = new HashMap<>(); private final HashMap<Long, DataTransfer> mDataTransfers = new HashMap<>();
private final Map<String, Conversation> conversations = new HashMap<>(); private final Map<String, Conversation> conversations = new HashMap<>();
private final Map<String, Conversation> pending = new HashMap<>(); private final Map<String, Conversation> pending = new HashMap<>();
...@@ -379,7 +379,6 @@ public class Account { ...@@ -379,7 +379,6 @@ public class Account {
} }
public Conversation onDataTransferEvent(DataTransfer transfer) { public Conversation onDataTransferEvent(DataTransfer transfer) {
Log.d(TAG, "Accoount onDataTransferEvent");
Conversation conversation = (Conversation) transfer.getConversation(); Conversation conversation = (Conversation) transfer.getConversation();
Interaction.InteractionStatus transferEventCode = transfer.getStatus(); Interaction.InteractionStatus transferEventCode = transfer.getStatus();
if (transferEventCode == Interaction.InteractionStatus.TRANSFER_CREATED) { if (transferEventCode == Interaction.InteractionStatus.TRANSFER_CREATED) {
...@@ -1121,12 +1120,12 @@ public class Account { ...@@ -1121,12 +1120,12 @@ public class Account {
mLoadedProfile = profile; mLoadedProfile = profile;
} }
public DataTransfer getDataTransfer(String id) { public DataTransfer getDataTransfer(long id) {
return mDataTransfers.get(id); return mDataTransfers.get(id);
} }
public void putDataTransfer(String fileId, DataTransfer transfer) { public void putDataTransfer(long transferId, DataTransfer transfer) {
mDataTransfers.put(fileId, transfer); mDataTransfers.put(transferId, transfer);
} }
private static class ConversationComparator implements Comparator<Conversation> { private static class ConversationComparator implements Comparator<Conversation> {
......
...@@ -32,7 +32,7 @@ public class DataTransfer extends Interaction { ...@@ -32,7 +32,7 @@ public class DataTransfer extends Interaction {
private long mBytesProgress; private long mBytesProgress;
//private final String mPeerId; //private final String mPeerId;
private String mExtension; private String mExtension;
private String mFileId; //private String mTransferId;
public File destination; public File destination;
private static final Set<String> IMAGE_EXTENSIONS = HashUtils.asSet("jpg", "jpeg", "png", "gif"); private static final Set<String> IMAGE_EXTENSIONS = HashUtils.asSet("jpg", "jpeg", "png", "gif");
...@@ -41,8 +41,7 @@ public class DataTransfer extends Interaction { ...@@ -41,8 +41,7 @@ public class DataTransfer extends Interaction {
private static final int MAX_SIZE = 32 * 1024 * 1024; private static final int MAX_SIZE = 32 * 1024 * 1024;
private static final int UNLIMITED_SIZE = 256 * 1024 * 1024; private static final int UNLIMITED_SIZE = 256 * 1024 * 1024;
/* Legacy constructor */ public DataTransfer(ConversationHistory conversation, String peer, String account, String displayName, boolean isOutgoing, long totalSize, long bytesProgress, long daemonId) {
public DataTransfer(ConversationHistory conversation, String peer, String account, String displayName, boolean isOutgoing, long totalSize, long bytesProgress, String fileId) {
mAuthor = isOutgoing ? null : peer; mAuthor = isOutgoing ? null : peer;
mAccount = account; mAccount = account;
mConversation = conversation; mConversation = conversation;
...@@ -53,15 +52,8 @@ public class DataTransfer extends Interaction { ...@@ -53,15 +52,8 @@ public class DataTransfer extends Interaction {
mType = InteractionType.DATA_TRANSFER.toString(); mType = InteractionType.DATA_TRANSFER.toString();
mTimestamp = System.currentTimeMillis(); mTimestamp = System.currentTimeMillis();
mIsRead = 1; mIsRead = 1;
mDaemonId = daemonId;
mIsIncoming = !isOutgoing; mIsIncoming = !isOutgoing;
if (fileId != null) {
mFileId = fileId;
try {
mDaemonId = Long.parseUnsignedLong(fileId);
} catch (Exception e) {
}
}
} }
public DataTransfer(Interaction interaction) { public DataTransfer(Interaction interaction) {
...@@ -80,15 +72,18 @@ public class DataTransfer extends Interaction { ...@@ -80,15 +72,18 @@ public class DataTransfer extends Interaction {
mIsIncoming = interaction.mIsIncoming;//mAuthor != null; mIsIncoming = interaction.mIsIncoming;//mAuthor != null;
} }
public DataTransfer(String fileId, String accountId, String peerUri, String displayName, boolean isOutgoing, long timestamp, long totalSize, long bytesProgress) { public DataTransfer(long transferId, String accountId, String peerUri, String displayName, boolean isOutgoing, long timestamp, long totalSize, long bytesProgress) {
mDaemonId = transferId;
mAccount = accountId; mAccount = accountId;
mFileId = fileId; //mTransferId = transferId;
//mPeerId = peerUri;
mBody = displayName; mBody = displayName;
mAuthor = peerUri; mAuthor = peerUri;
mIsIncoming = !isOutgoing; mIsIncoming = !isOutgoing;
mTotalSize = totalSize; mTotalSize = totalSize;
mBytesProgress = bytesProgress; mBytesProgress = bytesProgress;
mTimestamp = timestamp; mTimestamp = timestamp;
//mDaemonId = Long.parseUnsignedLong(transferId);
mType = InteractionType.DATA_TRANSFER.toString(); mType = InteractionType.DATA_TRANSFER.toString();
} }
...@@ -164,8 +159,5 @@ public class DataTransfer extends Interaction { ...@@ -164,8 +159,5 @@ public class DataTransfer extends Interaction {
return maxSize == UNLIMITED_SIZE || getTotalSize() <= maxSize; return maxSize == UNLIMITED_SIZE || getTotalSize() <= maxSize;
} }
public String getFileId() {
return mFileId;
}
} }
...@@ -29,6 +29,7 @@ import net.jami.daemon.Blob; ...@@ -29,6 +29,7 @@ import net.jami.daemon.Blob;
import net.jami.daemon.DataTransferInfo; import net.jami.daemon.DataTransferInfo;
import net.jami.daemon.JamiService; import net.jami.daemon.JamiService;
import net.jami.daemon.StringMap; import net.jami.daemon.StringMap;
import net.jami.daemon.StringVect;
import net.jami.daemon.UintVect; import net.jami.daemon.UintVect;
import net.jami.model.Account; import net.jami.model.Account;
import net.jami.model.AccountConfig; import net.jami.model.AccountConfig;
...@@ -1524,11 +1525,10 @@ public class AccountService { ...@@ -1524,11 +1525,10 @@ public class AccountService {
String transferId = message.get("tid"); String transferId = message.get("tid");
long tid = Long.parseLong(transferId); long tid = Long.parseLong(transferId);
String fileName = message.get("displayName"); String fileName = message.get("displayName");
String fileId = message.get("fileId");
long fileSize = Long.parseLong(message.get("totalSize")); long fileSize = Long.parseLong(message.get("totalSize"));
interaction = account.getDataTransfer(fileId); interaction = account.getDataTransfer(tid);
if (interaction == null) { if (interaction == null) {
interaction = new DataTransfer(account.getAccountID(), fileId, author, fileName, contact.isUser(), timestamp, fileSize, 0); interaction = new DataTransfer(tid, account.getAccountID(), author, fileName, contact.isUser(), timestamp, fileSize, 0);
File path = mDeviceRuntimeService.getConversationPath(conversation.getUri().getRawRingId(), ((DataTransfer) interaction).getStoragePath()); File path = mDeviceRuntimeService.getConversationPath(conversation.getUri().getRawRingId(), ((DataTransfer) interaction).getStoragePath());
boolean exists = path.exists(); boolean exists = path.exists();
if (exists) if (exists)
...@@ -1690,7 +1690,7 @@ public class AccountService { ...@@ -1690,7 +1690,7 @@ public class AccountService {
Log.i(TAG, "sendFile() id=" + dataTransfer.getId() + " accountId=" + dataTransferInfo.getAccountId() + ", peer=" + dataTransferInfo.getPeer() + ", filePath=" + dataTransferInfo.getPath()); Log.i(TAG, "sendFile() id=" + dataTransfer.getId() + " accountId=" + dataTransferInfo.getAccountId() + ", peer=" + dataTransferInfo.getPeer() + ", filePath=" + dataTransferInfo.getPath());
long[] id = new long[1]; long[] id = new long[1];
DataTransferError err = getDataTransferError(JamiService.sendFileLegacy(dataTransferInfo, id)); DataTransferError err = getDataTransferError(JamiService.sendFile(dataTransferInfo, id));
if (err != DataTransferError.SUCCESS) { if (err != DataTransferError.SUCCESS) {
throw new IOException(err.name()); throw new IOException(err.name());
} else { } else {
...@@ -1701,10 +1701,6 @@ public class AccountService { ...@@ -1701,10 +1701,6 @@ public class AccountService {
}).subscribeOn(Schedulers.from(mExecutor)); }).subscribeOn(Schedulers.from(mExecutor));
} }
public void sendFile(Conversation conversation, final File file) {
mExecutor.execute(() -> JamiService.sendFile(conversation.getAccountId(), conversation.getUri().getRawRingId(), file.getAbsolutePath(), file.getName(), ""));
}
public List<net.jami.daemon.Message> getLastMessages(String accountId, long baseTime) { public List<net.jami.daemon.Message> getLastMessages(String accountId, long baseTime) {
try { try {
return mExecutor.submit(() -> SwigNativeConverter.toJava(JamiService.getLastMessages(accountId, baseTime))).get(); return mExecutor.submit(() -> SwigNativeConverter.toJava(JamiService.getLastMessages(accountId, baseTime))).get();
...@@ -1714,11 +1710,11 @@ public class AccountService { ...@@ -1714,11 +1710,11 @@ public class AccountService {
return new ArrayList<>(); return new ArrayList<>();
} }
public void acceptFileTransfer(final String accountId, final Uri conversationUri, String fileId) { public void acceptFileTransfer(final String accountId, final Uri conversationUri, long id) {
Account account = getAccount(accountId); Account account = getAccount(accountId);
if (account != null) { if (account != null) {
Conversation conversation = account.getByUri(conversationUri); Conversation conversation = account.getByUri(conversationUri);
acceptFileTransfer(conversation, account.getDataTransfer(fileId)); acceptFileTransfer(conversation, account.getDataTransfer(id));
} }
} }
...@@ -1726,18 +1722,18 @@ public class AccountService { ...@@ -1726,18 +1722,18 @@ public class AccountService {
if (transfer == null) if (transfer == null)
return; return;
File path = mDeviceRuntimeService.getTemporaryPath(conversation.getUri().getRawRingId(), transfer.getStoragePath()); File path = mDeviceRuntimeService.getTemporaryPath(conversation.getUri().getRawRingId(), transfer.getStoragePath());
Log.i(TAG, "acceptFileTransfer() id=" + transfer.getFileId() + ", path=" + path.getAbsolutePath()); String conversationId = conversation.getUri().getRawRingId();
if (conversation.isSwarm()) { acceptFileTransfer(conversation.getAccountId(), conversationId, transfer.getDaemonId(), path.getAbsolutePath(), 0);
String conversationId = conversation.getUri().getRawRingId();
JamiService.downloadFile(conversation.getAccountId(), conversationId, transfer.getFileId(), path.getAbsolutePath());
} else {
JamiService.acceptFileTransfer(conversation.getAccountId(), transfer.getFileId(), path.getAbsolutePath());
}
} }
public void cancelDataTransfer(final String accountId, final String conversationId, final String fileId) { private void acceptFileTransfer(final String accountId, final String conversationId, final Long dataTransferId, final String filePath, long offset) {
Log.i(TAG, "cancelDataTransfer() id=" + fileId); Log.i(TAG, "acceptFileTransfer() id=" + dataTransferId + ", path=" + filePath + ", offset=" + offset);
mExecutor.execute(() -> JamiService.cancelDataTransfer(accountId, conversationId, fileId)); mExecutor.execute(() -> JamiService.acceptFileTransfer(accountId, conversationId, dataTransferId, filePath, offset));
}
public void cancelDataTransfer(final String accountId, final String conversationId, long dataTransferId) {
Log.i(TAG, "cancelDataTransfer() id=" + dataTransferId);
mExecutor.execute(() -> JamiService.cancelDataTransfer(accountId, conversationId, dataTransferId));
} }
private class DataTransferRefreshTask implements Runnable { private class DataTransferRefreshTask implements Runnable {
...@@ -1756,7 +1752,7 @@ public class AccountService { ...@@ -1756,7 +1752,7 @@ public class AccountService {
public void run() { public void run() {
synchronized (mToUpdate) { synchronized (mToUpdate) {
if (mToUpdate.getStatus() == Interaction.InteractionStatus.TRANSFER_ONGOING) { if (mToUpdate.getStatus() == Interaction.InteractionStatus.TRANSFER_ONGOING) {
dataTransferEvent(mAccount, mConversation, mToUpdate.getFileId(), 5); dataTransferEvent(mAccount, mConversation, mToUpdate.getDaemonId(), 5);
} else { } else {
scheduledTask.cancel(false); scheduledTask.cancel(false);
scheduledTask = null; scheduledTask = null;
...@@ -1765,7 +1761,7 @@ public class AccountService { ...@@ -1765,7 +1761,7 @@ public class AccountService {
} }