Commit 313b60c0 authored by johan's avatar johan

zid cache migration moved to bzrtp lib

- cache migration is now performed in place not to another file
- tester of the migration needs to be fixed
parent d1c3da96
This diff is collapsed.
......@@ -1056,7 +1056,6 @@ struct _LinphoneCore
struct _EchoTester *ect;
LinphoneTaskList hooks; /*tasks periodically executed in linphone_core_iterate()*/
LinphoneConference *conf_ctx;
char* zrtp_secrets_cache; /**< zrtp xml filename cache : obsolete, use zrtp_cache_db now, kept to allow cache migration */
char* user_certificates_path;
LinphoneVideoPolicy video_policy;
time_t network_last_check;
......@@ -1091,7 +1090,6 @@ struct _LinphoneCore
char *chat_db_file;
char *logs_db_file;
char *friends_db_file;
char *zrtp_cache_db_file;
#ifdef SQLITE_STORAGE_ENABLED
sqlite3 *zrtp_cache_db; /**< zrtp sqlite cache, used by both zrtp and lime */
sqlite3 *db;
......
......@@ -253,8 +253,7 @@ gboolean linphone_gtk_get_audio_assistant_option(void){
static void linphone_gtk_init_liblinphone(const char *config_file,
const char *factory_config_file, const char *chat_messages_db_file,
const char *call_logs_db_file, const char *friends_db_file,
const char *zrtp_cache_db_file) {
const char *call_logs_db_file, const char *friends_db_file) {
LinphoneCoreVTable vtable={0};
gchar *secrets_file=linphone_gtk_get_config_file(SECRETS_FILE);
gchar *user_certificates_dir=linphone_gtk_get_config_file(CERTIFICATES_PATH);
......@@ -291,7 +290,6 @@ static void linphone_gtk_init_liblinphone(const char *config_file,
linphone_core_set_user_agent(the_core,"Linphone", LINPHONE_VERSION);
linphone_core_set_waiting_callback(the_core,linphone_gtk_wait,NULL);
linphone_core_set_zrtp_secrets_file(the_core,secrets_file); /* XML cache is superseeded by the sqlite one, keep it for migration purpose but it shall be removed in future version */
if (zrtp_cache_db_file) linphone_core_set_zrtp_cache_database_path(the_core, zrtp_cache_db_file);
g_free(secrets_file);
linphone_core_set_user_certificates_path(the_core,user_certificates_dir);
g_free(user_certificates_dir);
......@@ -2191,7 +2189,7 @@ int main(int argc, char *argv[]){
const char *icon_name=LINPHONE_ICON_NAME;
const char *app_name="Linphone";
LpConfig *factory_config;
char *chat_messages_db_file, *call_logs_db_file, *friends_db_file, *zrtp_cache_db_file;
char *chat_messages_db_file, *call_logs_db_file, *friends_db_file;
GError *error=NULL;
const char *tmp;
const char *resources_dir;
......@@ -2339,8 +2337,7 @@ core_start:
chat_messages_db_file=linphone_gtk_message_storage_get_db_file(NULL);
call_logs_db_file = linphone_gtk_call_logs_storage_get_db_file(NULL);
friends_db_file = linphone_gtk_friends_storage_get_db_file(NULL);
zrtp_cache_db_file = linphone_gtk_zrtp_cache_get_db_file(NULL);
linphone_gtk_init_liblinphone(config_file, factory_config_file, chat_messages_db_file, call_logs_db_file, friends_db_file, zrtp_cache_db_file);
linphone_gtk_init_liblinphone(config_file, factory_config_file, chat_messages_db_file, call_logs_db_file, friends_db_file);
g_free(chat_messages_db_file);
g_free(call_logs_db_file);
g_free(friends_db_file);
......
......@@ -3655,18 +3655,8 @@ LINPHONE_PUBLIC void linphone_core_refresh_registers(LinphoneCore* lc);
* @param[in] lc #LinphoneCore object
* @param[in] file The path to the file to use to store the zrtp secrets cache.
* @ingroup initializing
* @deprecated cache is now hold as sqlite db, use linphone_core_set_zrtp_cache_database_path to set path to the db and open it
*/
LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_zrtp_secrets_file(LinphoneCore *lc, const char* file);
/**
* Get the path to the file storing the zrtp secrets cache.
* @param[in] lc #LinphoneCore object.
* @return The path to the file storing the zrtp secrets cache.
* @ingroup initializing
* @deprecated cache is now hold as sqlite db, use linphone_core_get_zrtp_cache_db to get a pointer to it
*/
LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_zrtp_secrets_file(LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_set_zrtp_secrets_file(LinphoneCore *lc, const char* file);
/**
* Get a pointer to the sqlite db holding zrtp/lime cache
......@@ -3676,15 +3666,6 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_zrtp_secrets_f
*/
LINPHONE_PUBLIC void *linphone_core_get_zrtp_cache_db(LinphoneCore *lc);
/**
* Sets the database filename where zrtp cache will be stored.
* If the file does not exist, it will be created.
* @ingroup initializing
* @param lc the linphone core
* @param path filesystem path
**/
LINPHONE_PUBLIC void linphone_core_set_zrtp_cache_database_path(LinphoneCore *lc, const char *path);
/**
* Set the path to the directory storing the user's x509 certificates (used by dtls)
* @param[in] lc #LinphoneCore object
......
......@@ -883,14 +883,18 @@ static int enable_lime_for_message_test(LinphoneCoreManager *marie, LinphoneCore
linphone_core_enable_lime(marie->lc, LinphoneLimeMandatory);
linphone_core_enable_lime(pauline->lc, LinphoneLimeMandatory);
/* make sure to not trigger the cache migration function */
lp_config_set_int(marie->lc->config, "sip", "zrtp_cache_migration_done", TRUE);
lp_config_set_int(pauline->lc->config, "sip", "zrtp_cache_migration_done", TRUE);
/* create temporary cache files: setting the database_path will create and initialise the files */
remove(bc_tester_file("tmpZIDCacheMarie.sqlite"));
remove(bc_tester_file("tmpZIDCachePauline.sqlite"));
filepath = bc_tester_file("tmpZIDCacheMarie.sqlite");
linphone_core_set_zrtp_cache_database_path(marie->lc, filepath);
linphone_core_set_zrtp_secrets_file(marie->lc, filepath);
bc_free(filepath);
filepath = bc_tester_file("tmpZIDCachePauline.sqlite");
linphone_core_set_zrtp_cache_database_path(pauline->lc, filepath);
linphone_core_set_zrtp_secrets_file(pauline->lc, filepath);
bc_free(filepath);
/* caches are empty, populate them */
......@@ -1397,6 +1401,35 @@ static void lime_transfer_message_without_encryption_2(void) {
lime_transfer_message_base(FALSE, FALSE, TRUE, FALSE);
}
static void lime_cache_migration(void) {
if (lime_is_available()) {
char *xmlCache_filepath = bc_tester_res("zidCacheMigration.xml");
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
if (!linphone_core_lime_available(marie->lc)) {
ms_warning("Lime not available, skiping");
return;
}
/* make sure lime is enabled */
linphone_core_enable_lime(marie->lc, LinphoneLimeMandatory);
/* make sure to trigger the cache migration function */
lp_config_set_int(marie->lc->config, "sip", "zrtp_cache_migration_done", FALSE);
/* set the cache path, it will trigger the migration function */
/* TODO: copy the resource folder xml file to a writable temporary file as it will be erased by sqlite version */
linphone_core_set_zrtp_secrets_file(marie->lc, xmlCache_filepath);
/* perform checks on the new cache */
/* TODO */
/* free memory */
linphone_core_manager_destroy(marie);
}
}
static void lime_unit(void) {
if (lime_is_available()) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
......@@ -2367,6 +2400,7 @@ test_t message_tests[] = {
TEST_ONE_TAG("Lime transfer message from history", lime_transfer_message_from_history, "LIME"),
TEST_ONE_TAG("Lime transfer message without encryption", lime_transfer_message_without_encryption, "LIME"),
TEST_ONE_TAG("Lime transfer message without encryption 2", lime_transfer_message_without_encryption_2, "LIME"),
TEST_ONE_TAG("Lime cache migration", lime_cache_migration, "LIME"),
TEST_ONE_TAG("Lime unitary", lime_unit, "LIME"),
TEST_NO_TAG("Database migration", database_migration),
TEST_NO_TAG("History range", history_range),
......
<?xml version="1.0" encoding="UTF-8"?>
<cache><selfZID>00112233445566778899aabb</selfZID><peer><ZID>99887766554433221100ffee</ZID><rs1>c4274f13a2b6fa05c15ec93158f930e7264b0a893393376dbc80c6eb1cccdc5a</rs1><uri>sip:bob@sip.linphone.org</uri><sndKey>219d9e445d10d4ed64083c7ccbb83a23bc17a97df0af5de4261f3fe026b05b0b</sndKey><rcvKey>747e72a5cc996413cb9fa6e3d18d8b370436e274cd6ba4efc1a4580340af57ca</rcvKey><sndSId>df2bf38e719fa89e17332cf8d5e774ee70d347baa74d16dee01f306c54789869</sndSId><rcvSId>928ce78b0bfc30427a02b1b668b2b3b0496d5664d7e89b75ed292ee97e3fc850</rcvSId><sndIndex>496bcc89</sndIndex><rcvIndex>59337abe</rcvIndex><rs2>5dda11f388384b349d210612f30824268a3753a7afa52ef6df5866dca76315c4</rs2><uri>sip:bob2@sip.linphone.org</uri></peer><peer><ZID>ffeeddccbbaa987654321012</ZID><rs1>858b495dfad483af3c088f26d68c4beebc638bd44feae45aea726a771727235e</rs1><uri>sip:bob@sip.linphone.org</uri><sndKey>b6aac945057bc4466bfe9a23771c6a1b3b8d72ec3e7d8f30ed63cbc5a9479a25</sndKey><rcvKey>bea5ac3225edd0545b816f061a8190370e3ee5160e75404846a34d1580e0c263</rcvKey><sndSId>17ce70fdf12e500294bcb5f2ffef53096761bb1c912b21e972ae03a5a9f05c47</sndSId><rcvSId>7e13a20e15a517700f0be0921f74b96d4b4a0c539d5e14d5cdd8706441874ac0</rcvSId><sndIndex>75e18caa</sndIndex><rcvIndex>2cfbbf06</rcvIndex><rs2>1533dee20c8116dc2c282cae9adfea689b87bc4c6a4e18a846f12e3e7fea3959</rs2></peer><peer><ZID>0987654321fedcba5a5a5a5a</ZID><rs1>cb6ecc87d1dd87b23f225eec53a26fc541384917623e0c46abab8c0350c6929e</rs1><sndKey>92bb03988e8f0ccfefa37a55fd7c5893bea3bfbb27312f49dd9b10d0e3c15fc7</sndKey><rcvKey>2315705a5830b98f68458fcd49623144cb34a667512c4d44686aee125bb8b622</rcvKey><sndSId>94c56eea0dd829379263b6da3f6ac0a95388090f168a3568736ca0bd9f8d595f</sndSId><rcvSId>c319ae0d41183fec90afc412d42253c5b456580f7a463c111c7293623b8631f4</rcvSId><uri>sip:bob@sip.linphone.org</uri><sndIndex>2c46ddcc</sndIndex><rcvIndex>15f5779e</rcvIndex><valid>0000000058f095bf</valid><pvs>01</pvs></peer></cache>
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