Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-android
Commits
c29758f6
Commit
c29758f6
authored
2 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
AccountService: add loadUntil
Change-Id: Ie815ae9116693616e09f9c7a590ba54778941e17
parent
26ca05cd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ring-android/libjamiclient/src/main/kotlin/net/jami/services/AccountService.kt
+20
-11
20 additions, 11 deletions
...lient/src/main/kotlin/net/jami/services/AccountService.kt
with
20 additions
and
11 deletions
ring-android/libjamiclient/src/main/kotlin/net/jami/services/AccountService.kt
+
20
−
11
View file @
c29758f6
...
...
@@ -168,6 +168,7 @@ class AccountService(
data class
ConversationSearchResult
(
val
results
:
List
<
Interaction
>)
private
val
conversationSearches
:
MutableMap
<
Long
,
Subject
<
ConversationSearchResult
>>
=
ConcurrentHashMap
()
private
val
loadingTasks
:
MutableMap
<
Long
,
SingleSubject
<
List
<
Interaction
>>>
=
ConcurrentHashMap
()
class
UserSearchResult
(
val
accountId
:
String
,
val
query
:
String
,
var
state
:
Int
=
0
)
{
var
results
:
List
<
Contact
>?
=
null
...
...
@@ -452,9 +453,8 @@ class AccountService(
Completable
.
fromAction
{
JamiService
.
removeConversation
(
accountId
,
conversationUri
.
rawRingId
)
}
.
subscribeOn
(
Schedulers
.
from
(
mExecutor
))
private
fun
loadConversationHistory
(
accountId
:
String
,
conversationUri
:
Uri
,
root
:
String
,
n
:
Long
)
{
private
fun
loadConversationHistory
(
accountId
:
String
,
conversationUri
:
Uri
,
root
:
String
,
n
:
Long
)
=
JamiService
.
loadConversationMessages
(
accountId
,
conversationUri
.
rawRingId
,
root
,
n
)
}
fun
loadMore
(
conversation
:
Conversation
,
n
:
Int
=
32
):
Single
<
Conversation
>
{
synchronized
(
conversation
)
{
...
...
@@ -481,6 +481,17 @@ class AccountService(
}
}
fun
loadUntil
(
conversation
:
Conversation
,
from
:
String
=
""
,
until
:
String
=
""
):
Single
<
List
<
Interaction
>>
{
val
mode
=
conversation
.
mode
.
blockingFirst
()
if
(
mode
==
Conversation
.
Mode
.
Syncing
||
mode
==
Conversation
.
Mode
.
Request
)
{
Log
.
w
(
TAG
,
"loadUntil: conversation is syncing"
)
return
Single
.
just
(
emptyList
())
}
return
SingleSubject
.
create
<
List
<
Interaction
>>().
apply
{
loadingTasks
[
JamiService
.
loadConversationUntil
(
conversation
.
accountId
,
conversation
.
uri
.
rawRingId
,
from
,
until
)]
=
this
}
}
fun
searchConversation
(
accountId
:
String
,
conversationUri
:
Uri
,
...
...
@@ -616,8 +627,8 @@ class AccountService(
/**
* Exports the account on the DHT (used for multi-devices feature)
*/
fun
exportOnRing
(
accountId
:
String
,
password
:
String
):
Single
<
String
>
{
return
mExportSubject
fun
exportOnRing
(
accountId
:
String
,
password
:
String
):
Single
<
String
>
=
mExportSubject
.
filter
{
r
:
ExportOnRingResult
->
r
.
accountId
==
accountId
}
.
firstOrError
()
.
map
{
result
:
ExportOnRingResult
->
...
...
@@ -633,7 +644,6 @@ class AccountService(
mExecutor
.
execute
{
JamiService
.
exportOnRing
(
accountId
,
password
)
}
}
.
subscribeOn
(
Schedulers
.
io
())
}
/**
* @return the list of the account's devices from the Daemon
...
...
@@ -1221,8 +1231,6 @@ class AccountService(
try
{
val
fileName
=
message
[
"displayName"
]
!!
val
fileId
=
message
[
"fileId"
]
//interaction = account.getDataTransfer(fileId);
//if (interaction == null) {
val
paths
=
arrayOfNulls
<
String
>(
1
)
val
progressA
=
LongArray
(
1
)
val
totalA
=
LongArray
(
1
)
...
...
@@ -1232,7 +1240,7 @@ class AccountService(
}
val
path
=
File
(
paths
[
0
]
!!
)
val
isComplete
=
path
.
exists
()
&&
progressA
[
0
]
==
totalA
[
0
]
Log
.
w
(
TAG
,
"add DataTransfer at
"
+
paths
[
0
]
+
"
with progress
"
+
progressA
[
0
]
+
"/"
+
totalA
[
0
])
Log
.
w
(
TAG
,
"add
$isComplete
DataTransfer at
${
paths[0]
}
with progress
${
progressA[0]
}/${
totalA[0]
}"
)
DataTransfer
(
fileId
,
account
.
accountId
,
author
,
fileName
,
contact
.
isUser
,
timestamp
,
totalA
[
0
],
progressA
[
0
]).
apply
{
daemonPath
=
path
status
=
if
(
isComplete
)
InteractionStatus
.
TRANSFER_FINISHED
else
InteractionStatus
.
FILE_AVAILABLE
...
...
@@ -1275,14 +1283,15 @@ class AccountService(
fun
conversationLoaded
(
id
:
Long
,
accountId
:
String
,
conversationId
:
String
,
messages
:
List
<
Map
<
String
,
String
>>)
{
try
{
val
task
=
loadingTasks
.
remove
(
id
)
// Log.w(TAG, "ConversationCallback: conversationLoaded " + accountId + "/" + conversationId + " " + messages.size());
getAccount
(
accountId
)
?.
let
{
account
->
account
.
getSwarm
(
conversationId
)
?.
let
{
conversation
->
val
interactions
:
List
<
Interaction
>
synchronized
(
conversation
)
{
for
(
message
in
messages
)
{
addMessage
(
account
,
conversation
,
message
,
false
)
}
interactions
=
messages
.
map
{
addMessage
(
account
,
conversation
,
it
,
false
)
}
conversation
.
stopLoading
()
}
task
?.
onSuccess
(
interactions
)
account
.
conversationChanged
()
}}
}
catch
(
e
:
Exception
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment