Improved call and message implementation
This commit is contained in:
@@ -452,7 +452,7 @@ class BaresipService: Service() {
|
|||||||
new.stopTime = old.stopTime
|
new.stopTime = old.stopTime
|
||||||
new.startTime = old.startTime
|
new.startTime = old.startTime
|
||||||
new.recording = old.recording
|
new.recording = old.recording
|
||||||
callHistory.add(new)
|
new.add()
|
||||||
}
|
}
|
||||||
CallHistoryNew.save()
|
CallHistoryNew.save()
|
||||||
}
|
}
|
||||||
@@ -826,8 +826,7 @@ class BaresipService: Service() {
|
|||||||
Log.e(TAG, "Callwaiting tone $name.wav not found\")")
|
Log.e(TAG, "Callwaiting tone $name.wav not found\")")
|
||||||
}
|
}
|
||||||
if (ua.account.callHistory) {
|
if (ua.account.callHistory) {
|
||||||
CallHistoryNew.add(CallHistoryNew(aor, peerUri, "in"))
|
CallHistoryNew(aor, peerUri, "in").add()
|
||||||
CallHistoryNew.save()
|
|
||||||
ua.account.missedCalls = true
|
ua.account.missedCalls = true
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -839,7 +838,7 @@ class BaresipService: Service() {
|
|||||||
"call incoming" -> {
|
"call incoming" -> {
|
||||||
val peerUri = ev[1]
|
val peerUri = ev[1]
|
||||||
Log.d(TAG, "Incoming call $uap/$callp/$peerUri")
|
Log.d(TAG, "Incoming call $uap/$callp/$peerUri")
|
||||||
Call(callp, ua, peerUri, "in", "incoming", null).add()
|
Call(callp, ua, peerUri, "in", "incoming").add()
|
||||||
if (speakerPhone && !Utils.isSpeakerPhoneOn(am))
|
if (speakerPhone && !Utils.isSpeakerPhoneOn(am))
|
||||||
Utils.toggleSpeakerPhone(ContextCompat.getMainExecutor(this), am)
|
Utils.toggleSpeakerPhone(ContextCompat.getMainExecutor(this), am)
|
||||||
if (ua.account.answerMode == Api.ANSWERMODE_MANUAL) {
|
if (ua.account.answerMode == Api.ANSWERMODE_MANUAL) {
|
||||||
@@ -1036,8 +1035,7 @@ class BaresipService: Service() {
|
|||||||
history.rejected = call.rejected
|
history.rejected = call.rejected
|
||||||
if (call.startTime != null && call.dumpfiles[0] != "")
|
if (call.startTime != null && call.dumpfiles[0] != "")
|
||||||
history.recording = call.dumpfiles
|
history.recording = call.dumpfiles
|
||||||
CallHistoryNew.add(history)
|
history.add()
|
||||||
CallHistoryNew.save()
|
|
||||||
ua.account.missedCalls = ua.account.missedCalls || missed
|
ua.account.missedCalls = ua.account.missedCalls || missed
|
||||||
}
|
}
|
||||||
if (!Utils.isVisible()) {
|
if (!Utils.isVisible()) {
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package com.tutpro.baresip
|
package com.tutpro.baresip
|
||||||
|
|
||||||
import android.text.TextWatcher
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class Call(val callp: Long, val ua: UserAgent, val peerUri: String, val dir: String,
|
class Call(val callp: Long, val ua: UserAgent, val peerUri: String, val dir: String, var status: String) {
|
||||||
var status: String, val dtmfWatcher: TextWatcher?) {
|
|
||||||
|
|
||||||
var onhold = false
|
var onhold = false
|
||||||
var held = false
|
var held = false
|
||||||
|
|||||||
@@ -16,22 +16,35 @@ class CallHistoryNew(val aor: String, val peerUri: String, val direction: String
|
|||||||
var rejected = false
|
var rejected = false
|
||||||
var recording = arrayOf("", "") // Encoder and decoder recording files
|
var recording = arrayOf("", "") // Encoder and decoder recording files
|
||||||
|
|
||||||
|
fun add() {
|
||||||
|
BaresipService.callHistory.add(this)
|
||||||
|
var count = 0
|
||||||
|
var remove: CallHistoryNew? = null
|
||||||
|
for (h in BaresipService.callHistory)
|
||||||
|
if (h.aor == this.aor) {
|
||||||
|
count++
|
||||||
|
if (count > CALL_HISTORY_SIZE) {
|
||||||
|
remove = h
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (remove != null) {
|
||||||
|
if (remove.recording[0] != "")
|
||||||
|
deleteRecording(remove.recording)
|
||||||
|
BaresipService.callHistory.remove(remove)
|
||||||
|
}
|
||||||
|
save()
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val serialVersionUID: Long = 3
|
private const val serialVersionUID: Long = 3
|
||||||
private const val CALL_HISTORY_SIZE = 256
|
private const val CALL_HISTORY_SIZE = 256
|
||||||
|
|
||||||
fun add(history: CallHistoryNew) {
|
fun aorLatestPeerUri(aor: String): String? {
|
||||||
BaresipService.callHistory.add(history)
|
for (h in BaresipService.callHistory.reversed())
|
||||||
if (aorHistorySize(history.aor) > CALL_HISTORY_SIZE) {
|
if (h.aor == aor) return h.peerUri
|
||||||
for (h in BaresipService.callHistory)
|
return null
|
||||||
if (h.aor == history.aor) {
|
|
||||||
if (h.recording[0] != "")
|
|
||||||
deleteRecording(h.recording)
|
|
||||||
BaresipService.callHistory.remove(h)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clear(aor: String) {
|
fun clear(aor: String) {
|
||||||
@@ -43,15 +56,7 @@ class CallHistoryNew(val aor: String, val peerUri: String, val direction: String
|
|||||||
BaresipService.callHistory.removeAt(i)
|
BaresipService.callHistory.removeAt(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
save()
|
||||||
|
|
||||||
private fun aorHistorySize(aor: String): Int {
|
|
||||||
return BaresipService.callHistory.count { it.aor == aor }
|
|
||||||
}
|
|
||||||
fun aorLatestPeerUri(aor: String): String? {
|
|
||||||
for (h in BaresipService.callHistory.reversed())
|
|
||||||
if (h.aor == aor) return h.peerUri
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun save() {
|
fun save() {
|
||||||
|
|||||||
@@ -2759,7 +2759,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
val callp = ua.callAlloc(0L, Api.VIDMODE_OFF)
|
val callp = ua.callAlloc(0L, Api.VIDMODE_OFF)
|
||||||
return if (callp != 0L) {
|
return if (callp != 0L) {
|
||||||
Log.d(TAG, "Adding outgoing call ${ua.uap}/$callp/$uri")
|
Log.d(TAG, "Adding outgoing call ${ua.uap}/$callp/$uri")
|
||||||
val call = Call(callp, ua, uri, "out", "outgoing", null)
|
val call = Call(callp, ua, uri, "out", "outgoing")
|
||||||
call.onHoldCall = onHoldCall
|
call.onHoldCall = onHoldCall
|
||||||
call.add()
|
call.add()
|
||||||
if (onHoldCall != null)
|
if (onHoldCall != null)
|
||||||
@@ -2786,7 +2786,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
val newCallp = ua.callAlloc(call.callp, Api.VIDMODE_OFF)
|
val newCallp = ua.callAlloc(call.callp, Api.VIDMODE_OFF)
|
||||||
if (newCallp != 0L) {
|
if (newCallp != 0L) {
|
||||||
Log.d(TAG, "Adding outgoing call ${ua.uap}/$newCallp/$uri")
|
Log.d(TAG, "Adding outgoing call ${ua.uap}/$newCallp/$uri")
|
||||||
val newCall = Call(newCallp, ua, uri, "out", "transferring", null)
|
val newCall = Call(newCallp, ua, uri, "out", "transferring")
|
||||||
newCall.add()
|
newCall.add()
|
||||||
if (newCall.connect(uri)) {
|
if (newCall.connect(uri)) {
|
||||||
if (ua.account.aor != viewModel.selectedAor.value)
|
if (ua.account.aor != viewModel.selectedAor.value)
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class Message(val aor: String, val peerUri: String, val message: String, val tim
|
|||||||
val it = updatedMessages.iterator()
|
val it = updatedMessages.iterator()
|
||||||
while (it.hasNext()) if (it.next().aor == aor) it.remove()
|
while (it.hasNext()) if (it.next().aor == aor) it.remove()
|
||||||
BaresipService.messages = updatedMessages.toList()
|
BaresipService.messages = updatedMessages.toList()
|
||||||
|
save()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteAorMessage(aor: String, time: Long) {
|
fun deleteAorMessage(aor: String, time: Long) {
|
||||||
|
|||||||
Reference in New Issue
Block a user