Commit 31d5d90c authored by Benjamin REIS's avatar Benjamin REIS
Browse files

add is_secured API to LinphoneChatMessage

parent 9551c911
......@@ -416,6 +416,9 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage
LinphoneImEncryptionEngineCbsOutgoingMessageCb cb_process_outgoing_message = linphone_im_encryption_engine_cbs_get_process_outgoing_message(imee_cbs);
if (cb_process_outgoing_message) {
retval = cb_process_outgoing_message(imee, cr, msg);
if(retval == 0) {
msg->is_secured = TRUE;
}
}
}
......@@ -644,6 +647,9 @@ LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const
LinphoneImEncryptionEngineCbsIncomingMessageCb cb_process_incoming_message = linphone_im_encryption_engine_cbs_get_process_incoming_message(imee_cbs);
if (cb_process_incoming_message) {
retval = cb_process_incoming_message(imee, cr, msg);
if(retval == 0) {
msg->is_secured = TRUE;
}
}
}
......@@ -868,6 +874,7 @@ LinphoneChatMessage *linphone_chat_room_create_message(LinphoneChatRoom *cr, con
msg->file_transfer_information = NULL; /* this property is used only when transfering file */
msg->http_request = NULL;
msg->time = ms_time(0);
msg->is_secured = FALSE;
return msg;
}
......@@ -878,6 +885,7 @@ LinphoneChatMessage *linphone_chat_room_create_message_2(LinphoneChatRoom *cr, c
LinphoneCore *lc = linphone_chat_room_get_core(cr);
msg->external_body_url = external_body_url ? ms_strdup(external_body_url) : NULL;
msg->time = time;
msg->is_secured = FALSE;
linphone_chat_message_set_state(msg, state);
if (is_incoming) {
msg->dir = LinphoneChatMessageIncoming;
......@@ -1458,6 +1466,17 @@ const LinphoneAddress *linphone_chat_message_get_to_address(const LinphoneChatMe
return NULL;
}
void linphone_chat_message_set_is_secured(LinphoneChatMessage *msg, bool_t secured) {
msg->is_secured = secured;
}
bool_t linphone_chat_message_is_secured(LinphoneChatMessage *msg) {
if(msg) {
return msg->is_secured;
}
return NULL;
}
LinphoneAddress *linphone_chat_message_get_local_address(const LinphoneChatMessage *msg) {
return msg->dir == LinphoneChatMessageOutgoing ? msg->from : msg->to;
}
......
......@@ -214,6 +214,7 @@ static int callback_all(void *data, int argc, char **argv, char **colName){
* | 11 | linphone content id (LinphoneContent describing a file transfer)
* | 12 | message id (used for IMDN)
* | 13 | content type (of the message field [must be text representable])
* | 14 | secured flag
*/
static int create_chat_message(void *data, int argc, char **argv, char **colName){
LinphoneChatRoom *cr = (LinphoneChatRoom *)data;
......@@ -247,6 +248,7 @@ static int create_chat_message(void *data, int argc, char **argv, char **colName
new_message->appdata = ms_strdup(argv[10]);
new_message->message_id = ms_strdup(argv[12]);
new_message->content_type = ms_strdup(argv[13]);
new_message->is_secured = (bool_t)atoi(argv[14]);
if (argv[11] != NULL) {
int id = atoi(argv[11]);
......@@ -343,7 +345,7 @@ unsigned int linphone_chat_message_store(LinphoneChatMessage *msg){
peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(msg->chat_room));
local_contact=linphone_address_as_string_uri_only(linphone_chat_message_get_local_address(msg));
buf = sqlite3_mprintf("INSERT INTO history VALUES(NULL,%Q,%Q,%i,%Q,%Q,%i,%i,%Q,%lld,%Q,%i,%Q,%Q);",
buf = sqlite3_mprintf("INSERT INTO history VALUES(NULL,%Q,%Q,%i,%Q,%Q,%i,%i,%Q,%lld,%Q,%i,%Q,%Q,%i);",
local_contact,
peer,
msg->dir,
......@@ -356,7 +358,8 @@ unsigned int linphone_chat_message_store(LinphoneChatMessage *msg){
msg->appdata,
content_id,
msg->message_id,
msg->content_type
msg->content_type,
(int)msg->is_secured
);
linphone_sql_request(lc->db,buf);
sqlite3_free(buf);
......@@ -777,6 +780,14 @@ void linphone_update_table(sqlite3* db) {
} else {
ms_message("Table history updated successfully for content_type data.");
}
// new field for secured flag
ret = sqlite3_exec(db, "ALTER TABLE history ADD COLUMN is_secured INTEGER DEFAULT 0;", NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
ms_message("Table already up to date: %s", errmsg);
} else {
ms_message("Table history updated successfully for is_secured data.");
}
}
void linphone_message_storage_init_chat_rooms(LinphoneCore *lc) {
......
......@@ -258,6 +258,7 @@ struct _LinphoneChatMessage {
belle_http_request_listener_t *http_listener; /* our listener, only owned by us*/
char *file_transfer_filepath;
unsigned long bg_task_id;
bool_t is_secured;
#if defined(__clang__) || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
#pragma GCC diagnostic push
......@@ -613,6 +614,7 @@ void linphone_chat_room_add_weak_message(LinphoneChatRoom *cr, LinphoneChatMessa
void linphone_chat_message_destroy(LinphoneChatMessage* msg);
void linphone_chat_message_update_state(LinphoneChatMessage *msg, LinphoneChatMessageState new_state);
void linphone_chat_message_set_state(LinphoneChatMessage *msg, LinphoneChatMessageState state);
void linphone_chat_message_set_is_secured(LinphoneChatMessage *msg, bool_t secured);
void linphone_chat_message_send_delivery_notification(LinphoneChatMessage *cm, LinphoneReason reason);
void linphone_chat_message_send_display_notification(LinphoneChatMessage *cm);
int linphone_chat_room_upload_file(LinphoneChatMessage *msg);
......
......@@ -421,6 +421,13 @@ LINPHONE_PUBLIC void linphone_chat_message_set_to_address(LinphoneChatMessage* m
*/
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_to_address(const LinphoneChatMessage* message);
/**
* Get if the message was encrypted when transfered
* @param[in] message #LinphoneChatMessage obj
* @return whether the message was encrypted when transfered or not
*/
LINPHONE_PUBLIC bool_t linphone_chat_message_is_secured(LinphoneChatMessage *msg);
/**
* Linphone message can carry external body as defined by rfc2017
* @param message #LinphoneChatMessage
......
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