Commit ae235690 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Store LinphoneContent key (when using lime) in db

parent c4cfbdf9
......@@ -187,6 +187,7 @@ void linphone_content_set_key(LinphoneContent *content, const char *key, const s
if (key != NULL) {
content->key = belle_sip_malloc(keyLength);
memcpy(content->key, key, keyLength);
content->keyLength = keyLength;
}
}
......
......@@ -129,7 +129,9 @@ static ORTP_INLINE LinphoneChatMessage* get_transient_message(LinphoneChatRoom*
* | 3 | name
* | 4 | encoding
* | 5 | size
* | 6 | data
* | 6 | data (currently not stored)
* | 7 | size
* | 8 | size
*/
// Callback for sql request when getting linphone content
static int callback_content(void *data, int argc, char **argv, char **colName) {
......@@ -145,6 +147,7 @@ static int callback_content(void *data, int argc, char **argv, char **colName) {
if (argv[3]) linphone_content_set_name(message->file_transfer_information, argv[3]);
if (argv[4]) linphone_content_set_encoding(message->file_transfer_information, argv[4]);
linphone_content_set_size(message->file_transfer_information, (size_t)atoi(argv[5]));
if (argv[8]) linphone_content_set_key(message->file_transfer_information, argv[8], (size_t)atol(argv[7]));
return 0;
}
......@@ -267,13 +270,15 @@ static int linphone_chat_message_store_content(LinphoneChatMessage *msg) {
int id = -1;
if (lc->db) {
LinphoneContent *content = msg->file_transfer_information;
char *buf = sqlite3_mprintf("INSERT INTO content VALUES(NULL,%Q,%Q,%Q,%Q,%i,%Q);",
char *buf = sqlite3_mprintf("INSERT INTO content VALUES(NULL,%Q,%Q,%Q,%Q,%i,%Q,%lld,%Q);",
linphone_content_get_type(content),
linphone_content_get_subtype(content),
linphone_content_get_name(content),
linphone_content_get_encoding(content),
linphone_content_get_size(content),
NULL
NULL,
(int64_t)linphone_content_get_key_size(content),
linphone_content_get_key(content)
);
linphone_sql_request(lc->db, buf);
sqlite3_free(buf);
......@@ -637,6 +642,21 @@ void linphone_update_table(sqlite3* db) {
ms_debug("Table content successfully created.");
}
}
// new fields for content key storage when using lime
ret=sqlite3_exec(db,"ALTER TABLE content ADD COLUMN key_size INTEGER;",NULL,NULL,&errmsg);
if(ret != SQLITE_OK) {
ms_message("Table already up to date: %s.", errmsg);
sqlite3_free(errmsg);
} else {
ret=sqlite3_exec(db,"ALTER TABLE content ADD COLUMN key TEXT;",NULL,NULL,&errmsg);
if(ret != SQLITE_OK) {
ms_message("Table already up to date: %s.", errmsg);
sqlite3_free(errmsg);
} else {
ms_debug("Table history content successfully for lime key storage data.");
}
}
}
void linphone_message_storage_init_chat_rooms(LinphoneCore *lc) {
......
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