Commit cdf240ec authored by Christophe Deschamps's avatar Christophe Deschamps
Browse files

Improve disconnection process

parent 94102c00
......@@ -43,8 +43,8 @@ class LinhomeApplication : Application() {
var someActivityRunning: Boolean = false
fun ensureCoreExists(context: Context) {
if (::coreContext.isInitialized && !coreContext.stopped) {
fun ensureCoreExists(context: Context, force:Boolean = false) {
if (!force && ::coreContext.isInitialized && !coreContext.stopped) {
return
}
......
......@@ -26,6 +26,7 @@ import org.linhome.LinhomeApplication
import org.linhome.LinhomeApplication.Companion.coreContext
import org.linhome.LinhomeApplication.Companion.corePreferences
import org.linhome.linphonecore.CorePreferences
import org.linhome.linphonecore.extensions.cleanHistory
import org.linphone.core.*
object Account {
......@@ -138,6 +139,11 @@ object Account {
it.done()
coreContext.core.removeProxyConfig(it)
}
coreContext.core.cleanHistory()
coreContext.core.provisioningUri = null
coreContext.core.config.setString("misc","config-uri",null)
coreContext.core.stop()
LinhomeApplication.ensureCoreExists(coreContext.context, true)
}
}
......@@ -21,6 +21,7 @@
package org.linhome.linphonecore.extensions
import org.linhome.LinhomeApplication.Companion.coreContext
import org.linhome.store.HistoryEventStore
import org.linphone.core.AudioDevice
import org.linphone.core.CallLog
import org.linphone.core.Core
......@@ -83,3 +84,12 @@ fun Core.missedCount(): Int {
return count
}
fun Core.cleanHistory() {
coreContext.core.callLogs.forEach {
if (it.callId != null)
HistoryEventStore.removeHistoryEventByCallId(it.callId)
coreContext.core.removeCallLog(it)
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment