Use default db path for call history & zrtp secrets + added migration from existing database files
This commit is contained in:
parent
98e81bb5c0
commit
1483e4d803
2 changed files with 49 additions and 13 deletions
|
@ -253,8 +253,6 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
||||||
private fun configureCore() {
|
private fun configureCore() {
|
||||||
Log.i("[Context] Configuring Core")
|
Log.i("[Context] Configuring Core")
|
||||||
|
|
||||||
core.zrtpSecretsFile = corePreferences.zrtpSecretsPath
|
|
||||||
core.callLogsDatabasePath = corePreferences.callHistoryDatabasePath
|
|
||||||
core.staticPicture = corePreferences.staticPicturePath
|
core.staticPicture = corePreferences.staticPicturePath
|
||||||
|
|
||||||
initUserCertificates()
|
initUserCertificates()
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.linphone.core
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.FileInputStream
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||||
import org.linphone.compatibility.Compatibility
|
import org.linphone.compatibility.Compatibility
|
||||||
|
@ -277,10 +278,18 @@ class CorePreferences constructor(private val context: Context) {
|
||||||
get() = config.getString("app", "rls_uri", "sip:rls@sip.linphone.org")!!
|
get() = config.getString("app", "rls_uri", "sip:rls@sip.linphone.org")!!
|
||||||
|
|
||||||
val conferenceServerUri: String
|
val conferenceServerUri: String
|
||||||
get() = config.getString("app", "default_conference_factory_uri", "sip:conference-factory@sip.linphone.org")!!
|
get() = config.getString(
|
||||||
|
"app",
|
||||||
|
"default_conference_factory_uri",
|
||||||
|
"sip:conference-factory@sip.linphone.org"
|
||||||
|
)!!
|
||||||
|
|
||||||
val limeX3dhServerUrl: String
|
val limeX3dhServerUrl: String
|
||||||
get() = config.getString("app", "default_lime_x3dh_server_url", "https://lime.linphone.org/lime-server/lime-server.php")!!
|
get() = config.getString(
|
||||||
|
"app",
|
||||||
|
"default_lime_x3dh_server_url",
|
||||||
|
"https://lime.linphone.org/lime-server/lime-server.php"
|
||||||
|
)!!
|
||||||
|
|
||||||
val allowMultipleFilesAndTextInSameMessage: Boolean
|
val allowMultipleFilesAndTextInSameMessage: Boolean
|
||||||
get() = config.getBool("app", "allow_multiple_files_and_text_in_same_message", true)
|
get() = config.getBool("app", "allow_multiple_files_and_text_in_same_message", true)
|
||||||
|
@ -295,7 +304,11 @@ class CorePreferences constructor(private val context: Context) {
|
||||||
get() = config.getBool("app", "show_border_on_big_contact_avatar", true)
|
get() = config.getBool("app", "show_border_on_big_contact_avatar", true)
|
||||||
|
|
||||||
val checkIfUpdateAvailableUrl: String?
|
val checkIfUpdateAvailableUrl: String?
|
||||||
get() = config.getString("misc", "version_check_url_root", "https://linphone.org/releases/android/RELEASE")
|
get() = config.getString(
|
||||||
|
"misc",
|
||||||
|
"version_check_url_root",
|
||||||
|
"https://linphone.org/releases/android/RELEASE"
|
||||||
|
)
|
||||||
|
|
||||||
val checkUpdateAvailableInterval: Int
|
val checkUpdateAvailableInterval: Int
|
||||||
get() = config.getInt("app", "version_check_interval", 86400000)
|
get() = config.getInt("app", "version_check_interval", 86400000)
|
||||||
|
@ -398,12 +411,6 @@ class CorePreferences constructor(private val context: Context) {
|
||||||
val userCertificatesPath: String
|
val userCertificatesPath: String
|
||||||
get() = context.filesDir.absolutePath + "/user-certs"
|
get() = context.filesDir.absolutePath + "/user-certs"
|
||||||
|
|
||||||
val zrtpSecretsPath: String
|
|
||||||
get() = context.filesDir.absolutePath + "/zrtp_secrets"
|
|
||||||
|
|
||||||
val callHistoryDatabasePath: String
|
|
||||||
get() = context.filesDir.absolutePath + "/linphone-log-history.db"
|
|
||||||
|
|
||||||
val staticPicturePath: String
|
val staticPicturePath: String
|
||||||
get() = context.filesDir.absolutePath + "/share/images/nowebcamcif.jpg"
|
get() = context.filesDir.absolutePath + "/share/images/nowebcamcif.jpg"
|
||||||
|
|
||||||
|
@ -417,6 +424,9 @@ class CorePreferences constructor(private val context: Context) {
|
||||||
copy("linphonerc_factory", factoryConfigPath, true)
|
copy("linphonerc_factory", factoryConfigPath, true)
|
||||||
copy("assistant_linphone_default_values", linphoneDefaultValuesPath, true)
|
copy("assistant_linphone_default_values", linphoneDefaultValuesPath, true)
|
||||||
copy("assistant_default_values", defaultValuesPath, true)
|
copy("assistant_default_values", defaultValuesPath, true)
|
||||||
|
|
||||||
|
move(context.filesDir.absolutePath + "/linphone-log-history.db", context.filesDir.absolutePath + "/call-history.db")
|
||||||
|
move(context.filesDir.absolutePath + "/zrtp_secrets", context.filesDir.absolutePath + "/zrtp-secrets.db")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getString(resource: Int): String {
|
fun getString(resource: Int): String {
|
||||||
|
@ -427,11 +437,11 @@ class CorePreferences constructor(private val context: Context) {
|
||||||
val outFile = File(to)
|
val outFile = File(to)
|
||||||
if (outFile.exists()) {
|
if (outFile.exists()) {
|
||||||
if (!overrideIfExists) {
|
if (!overrideIfExists) {
|
||||||
Log.i("[Preferences] File $to already exists")
|
android.util.Log.i(context.getString(org.linphone.R.string.app_name), "[Preferences] File $to already exists")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.i("[Preferences] Overriding $to by $from asset")
|
android.util.Log.i(context.getString(org.linphone.R.string.app_name), "[Preferences] Overriding $to by $from asset")
|
||||||
|
|
||||||
val outStream = FileOutputStream(outFile)
|
val outStream = FileOutputStream(outFile)
|
||||||
val inFile = context.assets.open(from)
|
val inFile = context.assets.open(from)
|
||||||
|
@ -447,4 +457,32 @@ class CorePreferences constructor(private val context: Context) {
|
||||||
outStream.flush()
|
outStream.flush()
|
||||||
outStream.close()
|
outStream.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun move(from: String, to: String, overrideIfExists: Boolean = false) {
|
||||||
|
val inFile = File(from)
|
||||||
|
val outFile = File(to)
|
||||||
|
if (inFile.exists()) {
|
||||||
|
if (outFile.exists() && !overrideIfExists) {
|
||||||
|
android.util.Log.w(context.getString(org.linphone.R.string.app_name), "[Preferences] Can't move [$from] to [$to], destination file already exists")
|
||||||
|
} else {
|
||||||
|
val inStream = FileInputStream(inFile)
|
||||||
|
val outStream = FileOutputStream(outFile)
|
||||||
|
|
||||||
|
val buffer = ByteArray(1024)
|
||||||
|
var read: Int
|
||||||
|
while (inStream.read(buffer).also { read = it } != -1) {
|
||||||
|
outStream.write(buffer, 0, read)
|
||||||
|
}
|
||||||
|
|
||||||
|
inStream.close()
|
||||||
|
outStream.flush()
|
||||||
|
outStream.close()
|
||||||
|
|
||||||
|
inFile.delete()
|
||||||
|
android.util.Log.i(context.getString(org.linphone.R.string.app_name), "[Preferences] Successfully moved [$from] to [$to]")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
android.util.Log.w(context.getString(org.linphone.R.string.app_name), "[Preferences] Can't move [$from] to [$to], source file doesn't exists")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue