- Renamed "history" file to more intuitive "calls" file.
This commit is contained in:
@ -174,6 +174,9 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (File(filesDir, "history").exists())
|
||||||
|
File(filesDir, "history").renameTo(File(filesDir, "calls"))
|
||||||
|
|
||||||
Contact.restore()
|
Contact.restore()
|
||||||
CallHistory.restore()
|
CallHistory.restore()
|
||||||
Message.restore()
|
Message.restore()
|
||||||
@ -887,7 +890,7 @@ class BaresipService: Service() {
|
|||||||
private fun cleanService() {
|
private fun cleanService() {
|
||||||
uas.clear()
|
uas.clear()
|
||||||
status.clear()
|
status.clear()
|
||||||
history.clear()
|
callHistory.clear()
|
||||||
messages.clear()
|
messages.clear()
|
||||||
if (this::nm.isInitialized)
|
if (this::nm.isInitialized)
|
||||||
nm.cancelAll()
|
nm.cancelAll()
|
||||||
@ -937,7 +940,7 @@ class BaresipService: Service() {
|
|||||||
var uas = ArrayList<UserAgent>()
|
var uas = ArrayList<UserAgent>()
|
||||||
var status = ArrayList<Int>()
|
var status = ArrayList<Int>()
|
||||||
var calls = ArrayList<Call>()
|
var calls = ArrayList<Call>()
|
||||||
var history = ArrayList<CallHistory>()
|
var callHistory = ArrayList<CallHistory>()
|
||||||
var messages = ArrayList<Message>()
|
var messages = ArrayList<Message>()
|
||||||
var contacts = ArrayList<Contact>()
|
var contacts = ArrayList<Contact>()
|
||||||
var chatTexts: MutableMap<String, String> = mutableMapOf<String, String>()
|
var chatTexts: MutableMap<String, String> = mutableMapOf<String, String>()
|
||||||
|
|||||||
@ -13,45 +13,41 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
|
|||||||
|
|
||||||
const val CALL_HISTORY_SIZE = 100
|
const val CALL_HISTORY_SIZE = 100
|
||||||
|
|
||||||
fun history(): ArrayList<CallHistory> {
|
|
||||||
return BaresipService.history
|
|
||||||
}
|
|
||||||
|
|
||||||
fun add(history: CallHistory) {
|
fun add(history: CallHistory) {
|
||||||
BaresipService.history.add(history)
|
BaresipService.callHistory.add(history)
|
||||||
if (aorHistorySize(history.aor) > CALL_HISTORY_SIZE) {
|
if (aorHistorySize(history.aor) > CALL_HISTORY_SIZE) {
|
||||||
var i = 0
|
var i = 0
|
||||||
for (h in BaresipService.history)
|
for (h in BaresipService.callHistory)
|
||||||
if (h.aor == history.aor)
|
if (h.aor == history.aor)
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
i++
|
i++
|
||||||
BaresipService.history.removeAt(i)
|
BaresipService.callHistory.removeAt(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clear(aor: String) {
|
fun clear(aor: String) {
|
||||||
val it = BaresipService.history.iterator()
|
val it = BaresipService.callHistory.iterator()
|
||||||
while (it.hasNext()) if (it.next().aor == aor) it.remove()
|
while (it.hasNext()) if (it.next().aor == aor) it.remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun aorHistorySize(aor: String): Int {
|
fun aorHistorySize(aor: String): Int {
|
||||||
return BaresipService.history.filter { it.aor == aor }.count()
|
return BaresipService.callHistory.filter { it.aor == aor }.count()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun aorLatestHistory(aor: String): CallHistory? {
|
fun aorLatestHistory(aor: String): CallHistory? {
|
||||||
for (h in BaresipService.history.reversed())
|
for (h in BaresipService.callHistory.reversed())
|
||||||
if (h.aor == aor) return h
|
if (h.aor == aor) return h
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun save() {
|
fun save() {
|
||||||
Log.d("Baresip", "Saving call history of size ${BaresipService.history.size}")
|
Log.d("Baresip", "Saving history of ${BaresipService.callHistory.size} calls")
|
||||||
val file = File(BaresipService.filesPath, "history")
|
val file = File(BaresipService.filesPath, "calls")
|
||||||
try {
|
try {
|
||||||
val fos = FileOutputStream(file)
|
val fos = FileOutputStream(file)
|
||||||
val oos = ObjectOutputStream(fos)
|
val oos = ObjectOutputStream(fos)
|
||||||
oos.writeObject(BaresipService.history)
|
oos.writeObject(BaresipService.callHistory)
|
||||||
oos.close()
|
oos.close()
|
||||||
fos.close()
|
fos.close()
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
@ -61,22 +57,22 @@ class CallHistory(val aor: String, val peerURI: String, val direction: String,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun restore() {
|
fun restore() {
|
||||||
val file = File(BaresipService.filesPath, "history")
|
val file = File(BaresipService.filesPath, "calls")
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
try {
|
try {
|
||||||
val fis = FileInputStream(file)
|
val fis = FileInputStream(file)
|
||||||
val ois = ObjectInputStream(fis)
|
val ois = ObjectInputStream(fis)
|
||||||
BaresipService.history = ois.readObject() as ArrayList<CallHistory>
|
BaresipService.callHistory = ois.readObject() as ArrayList<CallHistory>
|
||||||
ois.close()
|
ois.close()
|
||||||
fis.close()
|
fis.close()
|
||||||
Log.d("Baresip", "Restored call history of size ${BaresipService.history.size}")
|
Log.d("Baresip", "Restored history of ${BaresipService.callHistory.size} calls")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("Baresip", "InputStream exception: - " + e.toString())
|
Log.e("Baresip", "InputStream exception: - " + e.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun print() {
|
fun print() {
|
||||||
for (h in BaresipService.history)
|
for (h in BaresipService.callHistory)
|
||||||
Log.d("Baresip", "[${h.aor}, ${h.peerURI}, ${h.direction}, ${h.connected}]")
|
Log.d("Baresip", "[${h.aor}, ${h.peerURI}, ${h.direction}, ${h.connected}]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -197,8 +197,8 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private fun aorGenerateHistory(aor: String) {
|
private fun aorGenerateHistory(aor: String) {
|
||||||
uaHistory.clear()
|
uaHistory.clear()
|
||||||
for (i in CallHistory.history().indices.reversed()) {
|
for (i in BaresipService.callHistory.indices.reversed()) {
|
||||||
val h = CallHistory.history()[i]
|
val h = BaresipService.callHistory[i]
|
||||||
if (h.aor == aor) {
|
if (h.aor == aor) {
|
||||||
var direction: Int
|
var direction: Int
|
||||||
if (h.direction == "in")
|
if (h.direction == "in")
|
||||||
@ -231,7 +231,7 @@ class CallsActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private fun removeUaHistoryAt(i: Int) {
|
private fun removeUaHistoryAt(i: Int) {
|
||||||
for (index in uaHistory[i].indexes)
|
for (index in uaHistory[i].indexes)
|
||||||
CallHistory.history().removeAt(index)
|
BaresipService.callHistory.removeAt(index)
|
||||||
uaHistory.removeAt(i)
|
uaHistory.removeAt(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -959,7 +959,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun backup(password: String) {
|
private fun backup(password: String) {
|
||||||
val files = arrayOf("accounts", "config", "contacts", "history", "messages", "uuid",
|
val files = arrayOf("accounts", "calls", "config", "contacts", "messages", "uuid",
|
||||||
"zrtp_cache.dat", "zrtp_zid", "cert.pem", "ca_cert", "ca_certs.crt")
|
"zrtp_cache.dat", "zrtp_zid", "cert.pem", "ca_cert", "ca_certs.crt")
|
||||||
val backupFilePath = BaresipService.downloadsPath + "/baresip.bs"
|
val backupFilePath = BaresipService.downloadsPath + "/baresip.bs"
|
||||||
val zipFilePath = BaresipService.filesPath + "/baresip.zip"
|
val zipFilePath = BaresipService.filesPath + "/baresip.zip"
|
||||||
|
|||||||
@ -414,7 +414,7 @@ object Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun unZip(zipFilePath: String): Boolean {
|
fun unZip(zipFilePath: String): Boolean {
|
||||||
val allFiles = listOf("accounts", "config", "contacts", "history", "messages", "uuid",
|
val allFiles = listOf("accounts", "calls", "config", "contacts", "messages", "uuid",
|
||||||
"zrtp_cache.dat", "zrtp_zid", "cert.pem", "ca_cert", "ca_certs.crt")
|
"zrtp_cache.dat", "zrtp_zid", "cert.pem", "ca_cert", "ca_certs.crt")
|
||||||
val zipFiles = mutableListOf<String>()
|
val zipFiles = mutableListOf<String>()
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user