Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-client-android
Commits
e7c9e570
Commit
e7c9e570
authored
May 10, 2021
by
Adrien Béraud
Committed by
Sébastien Blin
Jun 11, 2021
Browse files
datatransfer: use new API
Change-Id: I83efe6f46262d97c9051aa08338de3eb9c11660d
parent
51797317
Changes
13
Show whitespace changes
Inline
Side-by-side
build-daemon.sh
View file @
e7c9e570
...
...
@@ -181,8 +181,8 @@ STATIC_LIBS_ALL="-llog -lOpenSLES -landroid \
-lyaml-cpp -ljsoncpp -lhttp_parser -lfmt
\
-luuid -lz -ldl
\
-lvpx -lopus -lspeex -lspeexdsp -lx264
\
-largon2
\
-lgit2
\
-largon2
\
-liconv"
LIBRING_JNI_DIR
=
${
ANDROID_APP_DIR
}
/app/src/main/libs/
${
ANDROID_ABI
}
...
...
ring-android/app/src/main/java/cx/ring/fragments/ConversationFragment.java
View file @
e7c9e570
...
...
@@ -759,13 +759,13 @@ public class ConversationFragment extends BaseSupportFragment<ConversationPresen
return
;
}
requireActivity
().
startService
(
new
Intent
(
DRingService
.
ACTION_FILE_ACCEPT
,
ConversationPath
.
toUri
(
accountId
,
conversationUri
),
requireContext
(),
DRingService
.
class
)
.
putExtra
(
DRingService
.
KEY_TRANSFER_ID
,
transfer
.
get
Daemon
Id
()));
.
putExtra
(
DRingService
.
KEY_TRANSFER_ID
,
transfer
.
get
File
Id
()));
}
@Override
public
void
refuseFile
(
String
accountId
,
Uri
conversationUri
,
DataTransfer
transfer
)
{
requireActivity
().
startService
(
new
Intent
(
DRingService
.
ACTION_FILE_CANCEL
,
ConversationPath
.
toUri
(
accountId
,
conversationUri
),
requireContext
(),
DRingService
.
class
)
.
putExtra
(
DRingService
.
KEY_TRANSFER_ID
,
transfer
.
get
Daemon
Id
()));
.
putExtra
(
DRingService
.
KEY_TRANSFER_ID
,
transfer
.
get
File
Id
()));
}
@Override
...
...
ring-android/app/src/main/java/cx/ring/service/DRingService.java
View file @
e7c9e570
...
...
@@ -651,7 +651,7 @@ public class DRingService extends Service {
}
private
void
handleFileAction
(
android
.
net
.
Uri
uri
,
String
action
,
Bundle
extras
)
{
lo
ng
id
=
extras
.
get
Lo
ng
(
KEY_TRANSFER_ID
);
Stri
ng
id
=
extras
.
get
Stri
ng
(
KEY_TRANSFER_ID
);
ConversationPath
path
=
ConversationPath
.
fromUri
(
uri
);
if
(
action
.
equals
(
ACTION_FILE_ACCEPT
))
{
mNotificationService
.
removeTransferNotification
(
path
.
getAccountId
(),
path
.
getConversationUri
(),
id
);
...
...
ring-android/app/src/main/java/cx/ring/services/DeviceRuntimeServiceImpl.java
View file @
e7c9e570
...
...
@@ -71,7 +71,7 @@ public class DeviceRuntimeServiceImpl extends DeviceRuntimeService {
@Override
public
void
loadNativeLibrary
()
{
mExecutor
.
execute
(()
->
{
//
mExecutor.execute(() -> {
try
{
System
.
loadLibrary
(
"ring"
);
}
catch
(
Exception
e
)
{
...
...
@@ -79,7 +79,7 @@ public class DeviceRuntimeServiceImpl extends DeviceRuntimeService {
android
.
os
.
Process
.
killProcess
(
android
.
os
.
Process
.
myPid
());
System
.
exit
(
0
);
}
});
//
});
}
@Override
...
...
ring-android/app/src/main/java/cx/ring/services/NotificationServiceImpl.java
View file @
e7c9e570
...
...
@@ -471,12 +471,12 @@ public class NotificationServiceImpl implements NotificationService {
if
(!
remove
)
{
showFileTransferNotification
(
conversation
,
transfer
);
}
else
{
removeTransferNotification
(
ConversationPath
.
toUri
(
conversation
),
transfer
.
get
Daemon
Id
());
removeTransferNotification
(
ConversationPath
.
toUri
(
conversation
),
transfer
.
get
File
Id
());
}
}
@Override
public
void
removeTransferNotification
(
String
accountId
,
Uri
conversationUri
,
lo
ng
transferId
)
{
public
void
removeTransferNotification
(
String
accountId
,
Uri
conversationUri
,
Stri
ng
transferId
)
{
removeTransferNotification
(
ConversationPath
.
toUri
(
accountId
,
conversationUri
),
transferId
);
}
...
...
@@ -485,7 +485,7 @@ public class NotificationServiceImpl implements NotificationService {
*
* @param transferId the transfer id which is required to generate the notification id
*/
public
void
removeTransferNotification
(
android
.
net
.
Uri
path
,
lo
ng
transferId
)
{
public
void
removeTransferNotification
(
android
.
net
.
Uri
path
,
Stri
ng
transferId
)
{
int
id
=
getFileTransferNotificationId
(
path
,
transferId
);
dataTransferNotifications
.
remove
(
id
);
cancelFileNotification
(
id
,
false
);
...
...
@@ -749,7 +749,7 @@ public class NotificationServiceImpl implements NotificationService {
}
android
.
net
.
Uri
path
=
ConversationPath
.
toUri
(
conversation
);
Log
.
d
(
TAG
,
"showFileTransferNotification "
+
path
);
lo
ng
dataTransferId
=
info
.
get
Daemon
Id
();
Stri
ng
dataTransferId
=
info
.
get
File
Id
();
int
notificationId
=
getFileTransferNotificationId
(
path
,
dataTransferId
);
Intent
intentConversation
=
new
Intent
(
DRingService
.
ACTION_CONV_ACCEPT
,
path
,
mContext
,
DRingService
.
class
);
...
...
@@ -955,7 +955,7 @@ public class NotificationServiceImpl implements NotificationService {
return
(
NOTIF_MSG
+
accountId
+
contact
.
toString
()).
hashCode
();
}
private
int
getFileTransferNotificationId
(
android
.
net
.
Uri
path
,
lo
ng
dataTransferId
)
{
private
int
getFileTransferNotificationId
(
android
.
net
.
Uri
path
,
Stri
ng
dataTransferId
)
{
return
(
NOTIF_FILE_TRANSFER
+
path
.
toString
()
+
dataTransferId
).
hashCode
();
}
...
...
ring-android/app/src/main/java/cx/ring/tv/conversation/TvConversationAdapter.java
View file @
e7c9e570
...
...
@@ -632,13 +632,13 @@ public class TvConversationAdapter extends RecyclerView.Adapter<TvConversationVi
}
context
.
startService
(
new
Intent
(
DRingService
.
ACTION_FILE_ACCEPT
)
.
setClass
(
context
.
getApplicationContext
(),
DRingService
.
class
)
.
putExtra
(
DRingService
.
KEY_TRANSFER_ID
,
file
.
get
Daemon
Id
()));
.
putExtra
(
DRingService
.
KEY_TRANSFER_ID
,
file
.
get
File
Id
()));
});
viewHolder
.
btnRefuse
.
setOnClickListener
(
v
->
{
Context
context
=
v
.
getContext
();
context
.
startService
(
new
Intent
(
DRingService
.
ACTION_FILE_CANCEL
)
.
setClass
(
context
.
getApplicationContext
(),
DRingService
.
class
)
.
putExtra
(
DRingService
.
KEY_TRANSFER_ID
,
file
.
get
Daemon
Id
()));
.
putExtra
(
DRingService
.
KEY_TRANSFER_ID
,
file
.
get
File
Id
()));
});
}
else
{
viewHolder
.
mAnswerLayout
.
setVisibility
(
View
.
GONE
);
...
...
ring-android/app/src/main/java/cx/ring/tv/conversation/TvConversationFragment.java
View file @
e7c9e570
...
...
@@ -807,7 +807,7 @@ public class TvConversationFragment extends BaseSupportFragment<ConversationPres
requireActivity
().
startService
(
new
Intent
(
DRingService
.
ACTION_FILE_ACCEPT
)
.
setClass
(
requireContext
(),
DRingService
.
class
)
.
setData
(
ConversationPath
.
toUri
(
accountId
,
conversationUri
))
.
putExtra
(
DRingService
.
KEY_TRANSFER_ID
,
transfer
.
get
Daemon
Id
()));
.
putExtra
(
DRingService
.
KEY_TRANSFER_ID
,
transfer
.
get
File
Id
()));
}
@Override
...
...
@@ -815,7 +815,7 @@ public class TvConversationFragment extends BaseSupportFragment<ConversationPres
requireActivity
().
startService
(
new
Intent
(
DRingService
.
ACTION_FILE_CANCEL
)
.
setClass
(
requireContext
(),
DRingService
.
class
)
.
setData
(
ConversationPath
.
toUri
(
accountId
,
conversationUri
))
.
putExtra
(
DRingService
.
KEY_TRANSFER_ID
,
transfer
.
get
Daemon
Id
()));
.
putExtra
(
DRingService
.
KEY_TRANSFER_ID
,
transfer
.
get
File
Id
()));
}
}
ring-android/libringclient/src/main/java/net/jami/facades/ConversationFacade.java
View file @
e7c9e570
...
...
@@ -267,19 +267,25 @@ public class ConversationFacade {
}
public
Completable
sendFile
(
Conversation
conversation
,
Uri
to
,
File
file
)
{
return
Single
.
fromCallable
(()
->
{
if
(
file
==
null
||
!
file
.
exists
()
||
!
file
.
canRead
())
{
Log
.
w
(
TAG
,
"sendFile: file not found or not readable: "
+
file
);
return
null
;
}
DataTransfer
transfer
=
new
DataTransfer
(
conversation
,
to
.
getRawRingId
(),
conversation
.
getAccountId
(),
file
.
getName
(),
true
,
file
.
length
(),
0
,
0L
);
if
(
conversation
.
isSwarm
())
{
transfer
.
setSwarmInfo
(
conversation
.
getUri
().
getRawRingId
(),
null
,
null
);
}
else
{
mHistoryService
.
insertInteraction
(
conversation
.
getAccountId
(),
conversation
,
transfer
).
blockingAwait
();
mAccountService
.
sendFile
(
conversation
,
file
);
return
Completable
.
complete
();
}
return
Single
.
fromCallable
(()
->
{
/*if (file == null || !file.exists() || !file.canRead()) {
Log.w(TAG, "sendFile: file not found or not readable: " + file);
return null;
}*/
DataTransfer
transfer
=
new
DataTransfer
(
conversation
,
to
.
getRawRingId
(),
conversation
.
getAccountId
(),
file
.
getName
(),
true
,
file
.
length
(),
0
,
null
);
mHistoryService
.
insertInteraction
(
conversation
.
getAccountId
(),
conversation
,
transfer
).
blockingAwait
();
transfer
.
destination
=
mDeviceRuntimeService
.
getConversationDir
(
conversation
.
getUri
().
getRawRingId
());
return
transfer
;
})
...
...
@@ -297,7 +303,7 @@ public class ConversationFacade {
if
(
element
.
getType
()
==
Interaction
.
InteractionType
.
DATA_TRANSFER
)
{
DataTransfer
transfer
=
(
DataTransfer
)
element
;
if
(
transfer
.
getStatus
()
==
Interaction
.
InteractionStatus
.
TRANSFER_ONGOING
)
{
mAccountService
.
cancelDataTransfer
(
conversation
.
getAccountId
(),
conversation
.
getUri
().
getRawRingId
(),
transfer
.
get
Daemon
Id
());
mAccountService
.
cancelDataTransfer
(
conversation
.
getAccountId
(),
conversation
.
getUri
().
getRawRingId
(),
transfer
.
get
File
Id
());
}
else
{
File
file
=
mDeviceRuntimeService
.
getConversationPath
(
conversation
.
getUri
().
getRawRingId
(),
transfer
.
getStoragePath
());
mDisposableBag
.
add
(
Completable
.
mergeArrayDelayError
(
...
...
@@ -678,10 +684,10 @@ public class ConversationFacade {
});
}
public
void
cancelFileTransfer
(
String
accountId
,
Uri
conversationId
,
long
i
d
)
{
mAccountService
.
cancelDataTransfer
(
accountId
,
conversationId
.
isSwarm
()
?
conversationId
.
getRawRingId
()
:
""
,
i
d
);
mNotificationService
.
removeTransferNotification
(
accountId
,
conversationId
,
i
d
);
DataTransfer
transfer
=
mAccountService
.
getAccount
(
accountId
).
getDataTransfer
(
i
d
);
public
void
cancelFileTransfer
(
String
accountId
,
Uri
conversationId
,
String
fileI
d
)
{
mAccountService
.
cancelDataTransfer
(
accountId
,
conversationId
.
isSwarm
()
?
conversationId
.
getRawRingId
()
:
""
,
fileI
d
);
mNotificationService
.
removeTransferNotification
(
accountId
,
conversationId
,
fileI
d
);
DataTransfer
transfer
=
mAccountService
.
getAccount
(
accountId
).
getDataTransfer
(
fileI
d
);
if
(
transfer
!=
null
)
deleteConversationItem
((
Conversation
)
transfer
.
getConversation
(),
transfer
);
}
...
...
ring-android/libringclient/src/main/java/net/jami/model/Account.java
View file @
e7c9e570
...
...
@@ -65,7 +65,7 @@ public class Account {
private
final
Map
<
String
,
TrustRequest
>
mRequests
=
new
HashMap
<>();
private
final
Map
<
String
,
Contact
>
mContactCache
=
new
HashMap
<>();
private
final
Map
<
String
,
Conversation
>
swarmConversations
=
new
HashMap
<>();
private
final
HashMap
<
Lo
ng
,
DataTransfer
>
mDataTransfers
=
new
HashMap
<>();
private
final
HashMap
<
Stri
ng
,
DataTransfer
>
mDataTransfers
=
new
HashMap
<>();
private
final
Map
<
String
,
Conversation
>
conversations
=
new
HashMap
<>();
private
final
Map
<
String
,
Conversation
>
pending
=
new
HashMap
<>();
...
...
@@ -379,6 +379,7 @@ public class Account {
}
public
Conversation
onDataTransferEvent
(
DataTransfer
transfer
)
{
Log
.
d
(
TAG
,
"Accoount onDataTransferEvent"
);
Conversation
conversation
=
(
Conversation
)
transfer
.
getConversation
();
Interaction
.
InteractionStatus
transferEventCode
=
transfer
.
getStatus
();
if
(
transferEventCode
==
Interaction
.
InteractionStatus
.
TRANSFER_CREATED
)
{
...
...
@@ -1120,12 +1121,12 @@ public class Account {
mLoadedProfile
=
profile
;
}
public
DataTransfer
getDataTransfer
(
lo
ng
id
)
{
public
DataTransfer
getDataTransfer
(
Stri
ng
id
)
{
return
mDataTransfers
.
get
(
id
);
}
public
void
putDataTransfer
(
long
transfer
Id
,
DataTransfer
transfer
)
{
mDataTransfers
.
put
(
transfer
Id
,
transfer
);
public
void
putDataTransfer
(
String
file
Id
,
DataTransfer
transfer
)
{
mDataTransfers
.
put
(
file
Id
,
transfer
);
}
private
static
class
ConversationComparator
implements
Comparator
<
Conversation
>
{
...
...
ring-android/libringclient/src/main/java/net/jami/model/DataTransfer.java
View file @
e7c9e570
...
...
@@ -32,7 +32,7 @@ public class DataTransfer extends Interaction {
private
long
mBytesProgress
;
//private final String mPeerId;
private
String
mExtension
;
//
private String m
Transfer
Id;
private
String
m
File
Id
;
public
File
destination
;
private
static
final
Set
<
String
>
IMAGE_EXTENSIONS
=
HashUtils
.
asSet
(
"jpg"
,
"jpeg"
,
"png"
,
"gif"
);
...
...
@@ -41,7 +41,8 @@ public class DataTransfer extends Interaction {
private
static
final
int
MAX_SIZE
=
32
*
1024
*
1024
;
private
static
final
int
UNLIMITED_SIZE
=
256
*
1024
*
1024
;
public
DataTransfer
(
ConversationHistory
conversation
,
String
peer
,
String
account
,
String
displayName
,
boolean
isOutgoing
,
long
totalSize
,
long
bytesProgress
,
long
daemonId
)
{
/* Legacy constructor */
public
DataTransfer
(
ConversationHistory
conversation
,
String
peer
,
String
account
,
String
displayName
,
boolean
isOutgoing
,
long
totalSize
,
long
bytesProgress
,
String
fileId
)
{
mAuthor
=
isOutgoing
?
null
:
peer
;
mAccount
=
account
;
mConversation
=
conversation
;
...
...
@@ -52,8 +53,15 @@ public class DataTransfer extends Interaction {
mType
=
InteractionType
.
DATA_TRANSFER
.
toString
();
mTimestamp
=
System
.
currentTimeMillis
();
mIsRead
=
1
;
mDaemonId
=
daemonId
;
mIsIncoming
=
!
isOutgoing
;
if
(
fileId
!=
null
)
{
mFileId
=
fileId
;
try
{
mDaemonId
=
Long
.
parseUnsignedLong
(
fileId
);
}
catch
(
Exception
e
)
{
}
}
}
public
DataTransfer
(
Interaction
interaction
)
{
...
...
@@ -72,18 +80,15 @@ public class DataTransfer extends Interaction {
mIsIncoming
=
interaction
.
mIsIncoming
;
//mAuthor != null;
}
public
DataTransfer
(
long
transferId
,
String
accountId
,
String
peerUri
,
String
displayName
,
boolean
isOutgoing
,
long
timestamp
,
long
totalSize
,
long
bytesProgress
)
{
mDaemonId
=
transferId
;
public
DataTransfer
(
String
fileId
,
String
accountId
,
String
peerUri
,
String
displayName
,
boolean
isOutgoing
,
long
timestamp
,
long
totalSize
,
long
bytesProgress
)
{
mAccount
=
accountId
;
//mTransferId = transferId;
//mPeerId = peerUri;
mFileId
=
fileId
;
mBody
=
displayName
;
mAuthor
=
peerUri
;
mIsIncoming
=
!
isOutgoing
;
mTotalSize
=
totalSize
;
mBytesProgress
=
bytesProgress
;
mTimestamp
=
timestamp
;
//mDaemonId = Long.parseUnsignedLong(transferId);
mType
=
InteractionType
.
DATA_TRANSFER
.
toString
();
}
...
...
@@ -159,5 +164,8 @@ public class DataTransfer extends Interaction {
return
maxSize
==
UNLIMITED_SIZE
||
getTotalSize
()
<=
maxSize
;
}
public
String
getFileId
()
{
return
mFileId
;
}
}
ring-android/libringclient/src/main/java/net/jami/services/AccountService.java
View file @
e7c9e570
...
...
@@ -29,7 +29,6 @@ import net.jami.daemon.Blob;
import
net.jami.daemon.DataTransferInfo
;
import
net.jami.daemon.JamiService
;
import
net.jami.daemon.StringMap
;
import
net.jami.daemon.StringVect
;
import
net.jami.daemon.UintVect
;
import
net.jami.model.Account
;
import
net.jami.model.AccountConfig
;
...
...
@@ -1525,10 +1524,11 @@ public class AccountService {
String
transferId
=
message
.
get
(
"tid"
);
long
tid
=
Long
.
parseLong
(
transferId
);
String
fileName
=
message
.
get
(
"displayName"
);
String
fileId
=
message
.
get
(
"fileId"
);
long
fileSize
=
Long
.
parseLong
(
message
.
get
(
"totalSize"
));
interaction
=
account
.
getDataTransfer
(
ti
d
);
interaction
=
account
.
getDataTransfer
(
fileI
d
);
if
(
interaction
==
null
)
{
interaction
=
new
DataTransfer
(
tid
,
account
.
getAccountID
(),
author
,
fileName
,
contact
.
isUser
(),
timestamp
,
fileSize
,
0
);
interaction
=
new
DataTransfer
(
account
.
getAccountID
(),
fileId
,
author
,
fileName
,
contact
.
isUser
(),
timestamp
,
fileSize
,
0
);
File
path
=
mDeviceRuntimeService
.
getConversationPath
(
conversation
.
getUri
().
getRawRingId
(),
((
DataTransfer
)
interaction
).
getStoragePath
());
boolean
exists
=
path
.
exists
();
if
(
exists
)
...
...
@@ -1690,7 +1690,7 @@ public class AccountService {
Log
.
i
(
TAG
,
"sendFile() id="
+
dataTransfer
.
getId
()
+
" accountId="
+
dataTransferInfo
.
getAccountId
()
+
", peer="
+
dataTransferInfo
.
getPeer
()
+
", filePath="
+
dataTransferInfo
.
getPath
());
long
[]
id
=
new
long
[
1
];
DataTransferError
err
=
getDataTransferError
(
JamiService
.
sendFile
(
dataTransferInfo
,
id
));
DataTransferError
err
=
getDataTransferError
(
JamiService
.
sendFile
Legacy
(
dataTransferInfo
,
id
));
if
(
err
!=
DataTransferError
.
SUCCESS
)
{
throw
new
IOException
(
err
.
name
());
}
else
{
...
...
@@ -1701,6 +1701,10 @@ public class AccountService {
}).
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
)
{
try
{
return
mExecutor
.
submit
(()
->
SwigNativeConverter
.
toJava
(
JamiService
.
getLastMessages
(
accountId
,
baseTime
))).
get
();
...
...
@@ -1710,11 +1714,11 @@ public class AccountService {
return
new
ArrayList
<>();
}
public
void
acceptFileTransfer
(
final
String
accountId
,
final
Uri
conversationUri
,
long
i
d
)
{
public
void
acceptFileTransfer
(
final
String
accountId
,
final
Uri
conversationUri
,
String
fileI
d
)
{
Account
account
=
getAccount
(
accountId
);
if
(
account
!=
null
)
{
Conversation
conversation
=
account
.
getByUri
(
conversationUri
);
acceptFileTransfer
(
conversation
,
account
.
getDataTransfer
(
i
d
));
acceptFileTransfer
(
conversation
,
account
.
getDataTransfer
(
fileI
d
));
}
}
...
...
@@ -1722,18 +1726,18 @@ public class AccountService {
if
(
transfer
==
null
)
return
;
File
path
=
mDeviceRuntimeService
.
getTemporaryPath
(
conversation
.
getUri
().
getRawRingId
(),
transfer
.
getStoragePath
());
Log
.
i
(
TAG
,
"acceptFileTransfer() id="
+
transfer
.
getFileId
()
+
", path="
+
path
.
getAbsolutePath
());
if
(
conversation
.
isSwarm
())
{
String
conversationId
=
conversation
.
getUri
().
getRawRingId
();
acceptFileTransfer
(
conversation
.
getAccountId
(),
conversationId
,
transfer
.
getDaemonId
(),
path
.
getAbsolutePath
(),
0
);
JamiService
.
downloadFile
(
conversation
.
getAccountId
(),
conversationId
,
transfer
.
getFileId
(),
path
.
getAbsolutePath
());
}
else
{
JamiService
.
acceptFileTransfer
(
conversation
.
getAccountId
(),
transfer
.
getFileId
(),
path
.
getAbsolutePath
());
}
private
void
acceptFileTransfer
(
final
String
accountId
,
final
String
conversationId
,
final
Long
dataTransferId
,
final
String
filePath
,
long
offset
)
{
Log
.
i
(
TAG
,
"acceptFileTransfer() id="
+
dataTransferId
+
", path="
+
filePath
+
", offset="
+
offset
);
mExecutor
.
execute
(()
->
JamiService
.
acceptFileTransfer
(
accountId
,
conversationId
,
dataTransferId
,
filePath
,
offset
));
}
public
void
cancelDataTransfer
(
final
String
accountId
,
final
String
conversationId
,
long
dataTransfer
Id
)
{
Log
.
i
(
TAG
,
"cancelDataTransfer() id="
+
dataTransfer
Id
);
mExecutor
.
execute
(()
->
JamiService
.
cancelDataTransfer
(
accountId
,
conversationId
,
dataTransfer
Id
));
public
void
cancelDataTransfer
(
final
String
accountId
,
final
String
conversationId
,
final
String
file
Id
)
{
Log
.
i
(
TAG
,
"cancelDataTransfer() id="
+
file
Id
);
mExecutor
.
execute
(()
->
JamiService
.
cancelDataTransfer
(
accountId
,
conversationId
,
file
Id
));
}
private
class
DataTransferRefreshTask
implements
Runnable
{
...
...
@@ -1752,7 +1756,7 @@ public class AccountService {
public
void
run
()
{
synchronized
(
mToUpdate
)
{
if
(
mToUpdate
.
getStatus
()
==
Interaction
.
InteractionStatus
.
TRANSFER_ONGOING
)
{
dataTransferEvent
(
mAccount
,
mConversation
,
mToUpdate
.
get
Daemon
Id
(),
5
);
dataTransferEvent
(
mAccount
,
mConversation
,
mToUpdate
.
get
File
Id
(),
5
);
}
else
{
scheduledTask
.
cancel
(
false
);
scheduledTask
=
null
;
...
...
@@ -1761,7 +1765,7 @@ public class AccountService {
}
}
void
dataTransferEvent
(
String
accountId
,
String
conversationId
,
final
long
transfer
Id
,
int
eventCode
)
{
void
dataTransferEvent
(
String
accountId
,
String
conversationId
,
final
String
file
Id
,
int
eventCode
)
{
Account
account
=
getAccount
(
accountId
);
if
(
account
!=
null
)
{
Conversation
conversation
=
StringUtils
.
isEmpty
(
conversationId
)
?
null
:
account
.
getSwarm
(
conversationId
);
...
...
@@ -1769,33 +1773,37 @@ public class AccountService {
conversation
=
account
.
getByUri
(
conversationId
);
if
(
conversation
==
null
)
return
;
dataTransferEvent
(
account
,
conversation
,
transfer
Id
,
eventCode
);
dataTransferEvent
(
account
,
conversation
,
file
Id
,
eventCode
);
}
}
void
dataTransferEvent
(
Account
account
,
Conversation
conversation
,
final
long
transfer
Id
,
int
eventCode
)
{
void
dataTransferEvent
(
Account
account
,
Conversation
conversation
,
final
String
file
Id
,
int
eventCode
)
{
Interaction
.
InteractionStatus
transferStatus
=
getDataTransferEventCode
(
eventCode
);
Log
.
d
(
TAG
,
"Data Transfer "
+
transferStatus
);
DataTransferInfo
info
=
new
DataTransferInfo
();
if
(
getDataTransferError
(
JamiService
.
dataTransferInfo
(
account
.
getAccountID
(),
conversation
.
getUri
().
getRawRingId
(),
transferId
,
info
))
!=
DataTransferError
.
SUCCESS
)
DataTransferError
err
=
getDataTransferError
(
JamiService
.
dataTransferInfo
(
account
.
getAccountID
(),
fileId
,
info
));
if
(
err
!=
DataTransferError
.
SUCCESS
)
{
Log
.
d
(
TAG
,
"Data Transfer error getting details "
+
err
);
return
;
}
boolean
outgoing
=
info
.
getFlags
()
==
0
;
DataTransfer
transfer
=
account
.
getDataTransfer
(
transfer
Id
);
DataTransfer
transfer
=
account
.
getDataTransfer
(
file
Id
);
if
(
transfer
==
null
)
{
if
(
outgoing
&&
mStartingTransfer
!=
null
)
{
Log
.
d
(
TAG
,
"Data Transfer mStartingTransfer"
);
transfer
=
mStartingTransfer
;
mStartingTransfer
=
null
;
}
else
{
transfer
=
new
DataTransfer
(
conversation
,
info
.
getPeer
(),
account
.
getAccountID
(),
info
.
getDisplayName
(),
outgoing
,
info
.
getTotalSize
(),
info
.
getBytesProgress
(),
transfer
Id
);
info
.
getBytesProgress
(),
file
Id
);
if
(
conversation
.
isSwarm
())
{
transfer
.
setSwarmInfo
(
conversation
.
getUri
().
getRawRingId
(),
null
,
null
);
}
else
{
mHistoryService
.
insertInteraction
(
account
.
getAccountID
(),
conversation
,
transfer
).
blockingAwait
();
}
}
account
.
putDataTransfer
(
transfer
Id
,
transfer
);
account
.
putDataTransfer
(
file
Id
,
transfer
);
}
else
synchronized
(
transfer
)
{
InteractionStatus
oldState
=
transfer
.
getStatus
();
if
(
oldState
!=
transferStatus
)
{
...
...
@@ -1824,6 +1832,7 @@ public class AccountService {
}
}
Log
.
d
(
TAG
,
"Data Transfer dataTransferSubject.onNext"
);
dataTransferSubject
.
onNext
(
transfer
);
}
...
...
ring-android/libringclient/src/main/java/net/jami/services/DaemonService.java
View file @
e7c9e570
...
...
@@ -380,9 +380,9 @@ public class DaemonService {
class
DaemonDataTransferCallback
extends
DataTransferCallback
{
@Override
public
void
dataTransferEvent
(
String
accountId
,
String
conversationId
,
long
transfer
Id
,
int
eventCode
)
{
Log
.
d
(
TAG
,
"dataTransferEvent: conversationId="
+
conversationId
+
",
transferId="
+
transfer
Id
+
", eventCode="
+
eventCode
);
mAccountService
.
dataTransferEvent
(
accountId
,
conversationId
,
transfer
Id
,
eventCode
);
public
void
dataTransferEvent
(
String
accountId
,
String
conversationId
,
String
file
Id
,
int
eventCode
)
{
Log
.
d
(
TAG
,
"dataTransferEvent: conversationId="
+
conversationId
+
",
fileId="
+
file
Id
+
", eventCode="
+
eventCode
);
mAccountService
.
dataTransferEvent
(
accountId
,
conversationId
,
file
Id
,
eventCode
);
}
}
...
...
ring-android/libringclient/src/main/java/net/jami/services/NotificationService.java
View file @
e7c9e570
...
...
@@ -52,7 +52,7 @@ public interface NotificationService {
void
showFileTransferNotification
(
Conversation
conversation
,
DataTransfer
info
);
void
cancelFileNotification
(
int
id
,
boolean
isMigratingToService
);
void
handleDataTransferNotification
(
DataTransfer
transfer
,
Conversation
contact
,
boolean
remove
);
void
removeTransferNotification
(
String
accountId
,
Uri
conversationUri
,
long
transfer
Id
);
void
removeTransferNotification
(
String
accountId
,
Uri
conversationUri
,
String
file
Id
);
Object
getDataTransferNotification
(
int
notificationId
);
void
updateNotification
(
Object
notification
,
int
notificationId
);
...
...
Adrien Béraud
@aberaud
mentioned in commit
3c50ba67
·
Jun 11, 2021
mentioned in commit
3c50ba67
mentioned in commit 3c50ba672af0a6057c837d9158cfba9753a8ce7a
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment