- Fixed call, message, and call transfer actions when initiated from

notification.
- Moved save and restore messages functions to Message class.
- Coding style edits.
This commit is contained in:
Juha Heinanen
2019-04-20 13:17:50 +03:00
parent 622e0f5c0f
commit d3a8e2df41
7 changed files with 81 additions and 97 deletions
@@ -15,10 +15,6 @@ class Message(val aor: String, val peerUri: String, val message: String, val tim
return BaresipService.messages
}
fun messages(messages: ArrayList<Message>) {
BaresipService.messages = messages
}
fun add(message: Message) {
BaresipService.messages.add(message)
var count = 0
@@ -35,5 +31,37 @@ class Message(val aor: String, val peerUri: String, val message: String, val tim
BaresipService.messages.removeAt(firstIndex)
}
fun saveMessages(path: String) {
val file = File(path, "messages")
try {
val fos = FileOutputStream(file)
val oos = ObjectOutputStream(fos)
oos.writeObject(BaresipService.messages)
oos.close()
fos.close()
Log.d("Baresip", "Saved ${BaresipService.messages.size} messages")
} catch (e: IOException) {
Log.e("Baresip", "OutputStream exception: " + e.toString())
e.printStackTrace()
}
}
fun restoreMessages(path: String) {
val file = File(path, "messages")
if (file.exists()) {
try {
val fis = FileInputStream(file)
val ois = ObjectInputStream(fis)
BaresipService.messages = ois.readObject() as ArrayList<Message>
ois.close()
fis.close()
Log.d("Baresip", "Restored ${BaresipService.messages.size} messages")
} catch (e: Exception) {
Log.e("Baresip", "InputStream exception: - " + e.toString())
}
}
}
}
}