Commit d9d06fa3 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Fixed compil broken due to chat message changes

parent eccde9b8
......@@ -605,11 +605,11 @@ static void message_delivery_update(SalOp *op, SalMessageDeliveryStatus status){
return;
}
// check that the message does not belong to an already destroyed chat room - if so, do not invoke callbacks
if (chat_msg->chat_room != NULL) {
if (linphone_chat_message_get_chat_room(chat_msg) != NULL) {
linphone_chat_message_update_state(chat_msg, chatStatusSal2Linphone(status));
}
if (status != SalMessageDeliveryInProgress) { /*only release op if not in progress*/
linphone_chat_message_destroy(chat_msg);
linphone_chat_message_unref(chat_msg);
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -45,8 +45,8 @@ static void stop(int signum){
* function invoked to report file transfer progress.
* */
static void file_transfer_progress_indication(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t total) {
const LinphoneAddress* from_address = linphone_chat_message_get_from(message);
const LinphoneAddress* to_address = linphone_chat_message_get_to(message);
const LinphoneAddress* from_address = linphone_chat_message_get_from_address(message);
const LinphoneAddress* to_address = linphone_chat_message_get_to_address(message);
char *address = linphone_chat_message_is_outgoing(message)?linphone_address_as_string(to_address):linphone_address_as_string(from_address);
printf(" File transfer [%d%%] %s of type [%s/%s] %s [%s] \n", (int)((offset *100)/total)
,(linphone_chat_message_is_outgoing(message)?"sent":"received")
......@@ -70,7 +70,7 @@ static void file_transfer_received(LinphoneChatMessage *message, const LinphoneC
file = (FILE*)linphone_chat_message_get_user_data(message);
if (linphone_buffer_is_empty(buffer)) {
printf("File transfert completed\n");
linphone_chat_message_destroy(message);
linphone_chat_message_unref(message);
fclose(file);
running=FALSE;
} else { /* store content on a file*/
......@@ -95,7 +95,7 @@ static LinphoneBuffer * file_transfer_send(LinphoneChatMessage *message, const L
* Call back to get delivery status of a message
* */
static void linphone_file_transfer_state_changed(LinphoneChatMessage* msg,LinphoneChatMessageState state) {
const LinphoneAddress* to_address = linphone_chat_message_get_to(msg);
const LinphoneAddress* to_address = linphone_chat_message_get_to_address(msg);
char *to = linphone_address_as_string(to_address);
printf("File transfer sent to [%s] delivery status is [%s] \n" , to
, linphone_chat_message_state_to_string(state));
......
......@@ -785,7 +785,9 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn
LinphoneCore *lc = linphone_im_encryption_engine_get_core(engine);
int errcode = -1;
/* check if we have a xml/cipher message to be decrypted */
if (msg->content_type && (strcmp("xml/cipher", msg->content_type) == 0 || strcmp("application/cipher.vnd.gsma.rcs-ft-http+xml", msg->content_type) == 0)) {
if (linphone_chat_message_get_content_type(msg) &&
(strcmp("xml/cipher", linphone_chat_message_get_content_type(msg)) == 0 ||
strcmp("application/cipher.vnd.gsma.rcs-ft-http+xml", linphone_chat_message_get_content_type(msg)) == 0)) {
errcode = 0;
int retval;
void *zrtp_cache_db = NULL; /* use a void * instead of sqlite3 * to avoid problems and ifdef when SQLITE is not available(the get function shall return NULL in that case) */
......@@ -800,9 +802,9 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn
errcode = 500;
return errcode;
}
peerUri = linphone_address_as_string_uri_only(msg->from);
selfUri = linphone_address_as_string_uri_only(msg->to);
retval = lime_decryptMultipartMessage(zrtp_cache_db, (uint8_t *)msg->message, selfUri, peerUri, &decrypted_body, &decrypted_content_type,
peerUri = linphone_address_as_string_uri_only(linphone_chat_message_get_from_address(msg));
selfUri = linphone_address_as_string_uri_only(linphone_chat_message_get_to_address(msg));
retval = lime_decryptMultipartMessage(zrtp_cache_db, (uint8_t *)linphone_chat_message_get_text(msg), selfUri, peerUri, &decrypted_body, &decrypted_content_type,
bctbx_time_string_to_sec(lp_config_get_string(lc->config, "sip", "lime_key_validity", "0")));
ms_free(peerUri);
ms_free(selfUri);
......@@ -813,15 +815,12 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn
return errcode;
} else {
/* swap encrypted message with plain text message */
if (msg->message) {
ms_free(msg->message);
}
msg->message = (char *)decrypted_body;
linphone_chat_message_set_text(msg, (char *)decrypted_body);
if (decrypted_content_type != NULL) {
linphone_chat_message_set_content_type(msg, decrypted_content_type);
ms_free(decrypted_content_type);
} else {
if (strcmp("application/cipher.vnd.gsma.rcs-ft-http+xml", msg->content_type) == 0) {
if (strcmp("application/cipher.vnd.gsma.rcs-ft-http+xml", linphone_chat_message_get_content_type(msg)) == 0) {
linphone_chat_message_set_content_type(msg, "application/vnd.gsma.rcs-ft-http+xml");
} else {
linphone_chat_message_set_content_type(msg, "text/plain");
......@@ -839,14 +838,14 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryptionEn
if(linphone_core_lime_enabled(linphone_chat_room_get_core(room))) {
if (linphone_chat_room_lime_available(room)) {
void *zrtp_cache_db = NULL; /* use a void * instead of sqlite3 * to avoid problems and ifdef when SQLITE is not available(the get function shall return NULL in that case) */
if (msg->content_type) {
if (strcmp(msg->content_type, "application/vnd.gsma.rcs-ft-http+xml") == 0) {
if (linphone_chat_message_get_content_type(msg)) {
if (strcmp(linphone_chat_message_get_content_type(msg), "application/vnd.gsma.rcs-ft-http+xml") == 0) {
/* It's a file transfer, content type shall be set to application/cipher.vnd.gsma.rcs-ft-http+xml
TODO: As of january 2017, the content type is now included in the encrypted body, this
application/cipher.vnd.gsma.rcs-ft-http+xml is kept for compatibility with previous versions,
but may be dropped in the future to use xml/cipher instead. */
new_content_type = "application/cipher.vnd.gsma.rcs-ft-http+xml";
} else if (strcmp(msg->content_type, "application/im-iscomposing+xml") == 0) {
} else if (strcmp(linphone_chat_message_get_content_type(msg), "application/im-iscomposing+xml") == 0) {
/* We don't encrypt composing messages */
return errcode;
}
......@@ -861,19 +860,16 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryptionEn
} else {
int retval;
uint8_t *crypted_body = NULL;
char *selfUri = linphone_address_as_string_uri_only(msg->from);
char *selfUri = linphone_address_as_string_uri_only(linphone_chat_message_get_from_address(msg));
char *peerUri = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(room));
retval = lime_createMultipartMessage(zrtp_cache_db, msg->content_type, (uint8_t *)msg->message, selfUri, peerUri, &crypted_body);
retval = lime_createMultipartMessage(zrtp_cache_db, linphone_chat_message_get_content_type(msg), (uint8_t *)linphone_chat_message_get_text(msg), selfUri, peerUri, &crypted_body);
if (retval != 0) { /* fail to encrypt */
ms_warning("Unable to encrypt message for %s : %s", peerUri, lime_error_code_to_string(retval));
if (crypted_body) ms_free(crypted_body);
errcode = 488;
} else { /* encryption ok, swap plain text message body by encrypted one */
if (msg->message) {
ms_free(msg->message);
}
msg->message = (char *)crypted_body;
linphone_chat_message_set_text(msg, (char *)crypted_body);
linphone_chat_message_set_content_type(msg, new_content_type);
}
ms_free(peerUri);
......@@ -890,23 +886,23 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryptionEn
}
int lime_im_encryption_engine_process_downloading_file_cb(LinphoneImEncryptionEngine *engine, LinphoneChatMessage *msg, size_t offset, const uint8_t *buffer, size_t size, uint8_t *decrypted_buffer) {
if (linphone_content_get_key(msg->file_transfer_information) == NULL) return -1;
if (linphone_content_get_key(linphone_chat_message_get_file_transfer_information(msg)) == NULL) return -1;
if (buffer == NULL || size == 0) {
return lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL);
return lime_decryptFile(linphone_content_get_cryptoContext_address(linphone_chat_message_get_file_transfer_information(msg)), NULL, 0, NULL, NULL);
}
return lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information),
(unsigned char *)linphone_content_get_key(msg->file_transfer_information), size, (char *)decrypted_buffer,
return lime_decryptFile(linphone_content_get_cryptoContext_address(linphone_chat_message_get_file_transfer_information(msg)),
(unsigned char *)linphone_content_get_key(linphone_chat_message_get_file_transfer_information(msg)), size, (char *)decrypted_buffer,
(char *)buffer);
}
int lime_im_encryption_engine_process_uploading_file_cb(LinphoneImEncryptionEngine *engine, LinphoneChatMessage *msg, size_t offset, const uint8_t *buffer, size_t *size, uint8_t *encrypted_buffer) {
size_t file_size = linphone_content_get_size(msg->file_transfer_information);
if (linphone_content_get_key(msg->file_transfer_information) == NULL) return -1;
size_t file_size = linphone_content_get_size(linphone_chat_message_get_file_transfer_information(msg));
if (linphone_content_get_key(linphone_chat_message_get_file_transfer_information(msg)) == NULL) return -1;
if (buffer == NULL || *size == 0) {
return lime_encryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL);
return lime_encryptFile(linphone_content_get_cryptoContext_address(linphone_chat_message_get_file_transfer_information(msg)), NULL, 0, NULL, NULL);
}
if (file_size == 0) {
......@@ -915,8 +911,8 @@ int lime_im_encryption_engine_process_uploading_file_cb(LinphoneImEncryptionEngi
*size -= (*size % 16);
}
return lime_encryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information),
(unsigned char *)linphone_content_get_key(msg->file_transfer_information), *size,
return lime_encryptFile(linphone_content_get_cryptoContext_address(linphone_chat_message_get_file_transfer_information(msg)),
(unsigned char *)linphone_content_get_key(linphone_chat_message_get_file_transfer_information(msg)), *size,
(char *)buffer, (char *)encrypted_buffer);
}
......@@ -930,7 +926,7 @@ void lime_im_encryption_engine_generate_file_transfer_key_cb(LinphoneImEncryptio
/* generate a random 192 bits key + 64 bits of initial vector and store it into the
* file_transfer_information->key field of the msg */
sal_get_random_bytes((unsigned char *)keyBuffer, FILE_TRANSFER_KEY_SIZE);
linphone_content_set_key(msg->file_transfer_information, keyBuffer, FILE_TRANSFER_KEY_SIZE); /* key is duplicated in the content private structure */
linphone_content_set_key(linphone_chat_message_get_file_transfer_information(msg), keyBuffer, FILE_TRANSFER_KEY_SIZE); /* key is duplicated in the content private structure */
}
#else /* HAVE_LIME */
......
......@@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "private.h"
#include "linphone/core.h"
#ifdef SQLITE_STORAGE_ENABLED
#include "chat/chat-room.h"
......@@ -133,17 +132,14 @@ int _linphone_sqlite3_open(const char *db_file, sqlite3 **db) {
static int callback_content(void *data, int argc, char **argv, char **colName) {
LinphoneChatMessage *message = (LinphoneChatMessage *)data;
if (message->file_transfer_information) {
linphone_content_unref(message->file_transfer_information);
message->file_transfer_information = NULL;
}
message->file_transfer_information = linphone_content_new();
if (argv[1]) linphone_content_set_type(message->file_transfer_information, argv[1]);
if (argv[2]) linphone_content_set_subtype(message->file_transfer_information, argv[2]);
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]));
LinphoneContent *content = linphone_content_new();
if (argv[1]) linphone_content_set_type(content, argv[1]);
if (argv[2]) linphone_content_set_subtype(content, argv[2]);
if (argv[3]) linphone_content_set_name(content, argv[3]);
if (argv[4]) linphone_content_set_encoding(content, argv[4]);
linphone_content_set_size(content, (size_t)atoi(argv[5]));
if (argv[8]) linphone_content_set_key(content, argv[8], (size_t)atol(argv[7]));
linphone_chat_message_set_file_transfer_information(message, content);
return 0;
}
......@@ -197,10 +193,10 @@ void linphone_sql_request_all(sqlite3* db,const char *stmt, LinphoneCore* lc){
}
static int linphone_chat_message_store_content(LinphoneChatMessage *msg) {
LinphoneCore *lc = linphone_chat_room_get_core(msg->chat_room);
LinphoneCore *lc = linphone_chat_room_get_core(linphone_chat_message_get_chat_room(msg));
int id = -1;
if (lc->db) {
LinphoneContent *content = msg->file_transfer_information;
LinphoneContent *content = linphone_chat_message_get_file_transfer_information(msg);
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),
......@@ -219,7 +215,7 @@ static int linphone_chat_message_store_content(LinphoneChatMessage *msg) {
}
unsigned int linphone_chat_message_store(LinphoneChatMessage *msg){
LinphoneCore *lc=linphone_chat_room_get_core(msg->chat_room);
LinphoneCore *lc=linphone_chat_room_get_core(linphone_chat_message_get_chat_room(msg));
int id = 0;
if (lc->db){
......@@ -227,27 +223,27 @@ unsigned int linphone_chat_message_store(LinphoneChatMessage *msg){
char *peer;
char *local_contact;
char *buf;
if (msg->file_transfer_information) {
if (linphone_chat_message_get_file_transfer_information(msg)) {
content_id = linphone_chat_message_store_content(msg);
}
peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(msg->chat_room));
peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(linphone_chat_message_get_chat_room(msg)));
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,%i);",
local_contact,
peer,
msg->dir,
msg->message,
linphone_chat_message_get_direction(msg),
linphone_chat_message_get_text(msg),
"-1", /* use UTC field now */
FALSE, /* use state == LinphoneChatMessageStateDisplayed now */
msg->state,
msg->external_body_url,
(int64_t)msg->time,
msg->appdata,
linphone_chat_message_get_state(msg),
linphone_chat_message_get_external_body_url(msg),
(int64_t)linphone_chat_message_get_time(msg),
linphone_chat_message_get_appdata(msg),
content_id,
msg->message_id,
msg->content_type,
(int)msg->is_secured
linphone_chat_message_get_message_id(msg),
linphone_chat_message_get_content_type(msg),
(int)linphone_chat_message_is_secured(msg)
);
linphone_sql_request(lc->db,buf);
sqlite3_free(buf);
......@@ -255,18 +251,19 @@ unsigned int linphone_chat_message_store(LinphoneChatMessage *msg){
ms_free(peer);
id = (unsigned int) sqlite3_last_insert_rowid (lc->db);
}
linphone_chat_message_set_storage_id(msg, id);
return id;
}
void linphone_chat_message_store_update(LinphoneChatMessage *msg) {
LinphoneCore *lc = linphone_chat_room_get_core(msg->chat_room);
LinphoneCore *lc = linphone_chat_room_get_core(linphone_chat_message_get_chat_room(msg));
if (lc->db) {
char *peer;
char *local_contact;
char *buf;
peer = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(msg->chat_room));
peer = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(linphone_chat_message_get_chat_room(msg)));
local_contact = linphone_address_as_string_uri_only(linphone_chat_message_get_local_address(msg));
buf = sqlite3_mprintf("UPDATE history SET"
" localContact = %Q,"
......@@ -279,12 +276,12 @@ void linphone_chat_message_store_update(LinphoneChatMessage *msg) {
" WHERE (id = %u);",
local_contact,
peer,
msg->message,
msg->state,
msg->appdata,
msg->message_id,
msg->content_type,
msg->storage_id
linphone_chat_message_get_text(msg),
linphone_chat_message_get_state(msg),
linphone_chat_message_get_appdata(msg),
linphone_chat_message_get_message_id(msg),
linphone_chat_message_get_content_type(msg),
linphone_chat_message_get_storage_id(msg)
);
linphone_sql_request(lc->db, buf);
sqlite3_free(buf);
......@@ -294,20 +291,20 @@ void linphone_chat_message_store_update(LinphoneChatMessage *msg) {
}
void linphone_chat_message_store_state(LinphoneChatMessage *msg){
LinphoneCore *lc=linphone_chat_room_get_core(msg->chat_room);
LinphoneCore *lc=linphone_chat_room_get_core(linphone_chat_message_get_chat_room(msg));
if (lc->db){
char *buf=sqlite3_mprintf("UPDATE history SET status=%i WHERE (id = %u);",
msg->state,msg->storage_id);
linphone_chat_message_get_state(msg), linphone_chat_message_get_storage_id(msg));
linphone_sql_request(lc->db,buf);
sqlite3_free(buf);
}
}
void linphone_chat_message_store_appdata(LinphoneChatMessage* msg){
LinphoneCore *lc=linphone_chat_room_get_core(msg->chat_room);
LinphoneCore *lc=linphone_chat_room_get_core(linphone_chat_message_get_chat_room(msg));
if (lc->db){
char *buf=sqlite3_mprintf("UPDATE history SET appdata=%Q WHERE id=%u;",
msg->appdata,msg->storage_id);
linphone_chat_message_get_appdata(msg), linphone_chat_message_get_storage_id(msg));
linphone_sql_request(lc->db,buf);
sqlite3_free(buf);
}
......
......@@ -129,11 +129,6 @@ extern "C" {
#define STRING_TRANSFER(field, newvalue) do{ if (field){bctbx_free(field);field=NULL;}; field=newvalue; }while(0)
typedef enum _ImdnType {
ImdnTypeDelivery,
ImdnTypeDisplay
} ImdnType;
struct _LinphoneQualityReporting{
reporting_session_report_t * reports[3]; /**Store information on audio and video media streams (RFC 6035) */
......@@ -174,14 +169,9 @@ typedef struct _CallCallbackObj
void * _user_data;
}CallCallbackObj;
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatMessageCbs);
typedef enum _LinphoneChatMessageDir{
LinphoneChatMessageIncoming,
LinphoneChatMessageOutgoing
} LinphoneChatMessageDir;
//BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatMessageCbs);
struct _LinphoneChatMessage {
/*struct _LinphoneChatMessage {
belle_sip_object_t base;
LinphoneChatRoom* chat_room;
LinphoneChatMessageCbs *callbacks;
......@@ -201,11 +191,11 @@ struct _LinphoneChatMessage {
unsigned int storage_id;
char *message_id;
SalOp *op;
LinphoneContent *file_transfer_information; /**< used to store file transfer information when the message is of file transfer type */
char *content_type; /**< is used to specified the type of message to be sent, used only for file transfer message */
LinphoneContent *file_transfer_information; //< used to store file transfer information when the message is of file transfer type
char *content_type; //< is used to specified the type of message to be sent, used only for file transfer message
bool_t to_be_stored;
belle_http_request_t *http_request; /**< keep a reference to the http_request in case of file transfer in order to be able to cancel the transfer */
belle_http_request_listener_t *http_listener; /* our listener, only owned by us*/
belle_http_request_t *http_request; //< keep a reference to the http_request in case of file transfer in order to be able to cancel the transfer
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;
......@@ -223,9 +213,7 @@ struct _LinphoneChatMessage {
#if defined(__clang__) || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
#pragma GCC diagnostic pop
#endif
};
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatMessage);
};*/
typedef struct StunCandidate{
char addr[64];
......@@ -500,22 +488,6 @@ void linphone_chat_room_release(LinphoneChatRoom *cr);
void linphone_chat_room_set_call(LinphoneChatRoom *cr, LinphoneCall *call);
bctbx_list_t * linphone_chat_room_get_transient_messages(const LinphoneChatRoom *cr);
LinphoneChatRoomCbs * linphone_chat_room_cbs_new (void);
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);
void _linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg, bool_t unref);
int linphone_chat_room_upload_file(LinphoneChatMessage *msg);
LinphoneChatMessageCbs *linphone_chat_message_cbs_new(void);
LinphoneChatRoom *_linphone_core_create_chat_room_from_call(LinphoneCall *call);
void linphone_chat_room_remove_transient_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
void linphone_chat_message_deactivate(LinphoneChatMessage *msg);
void linphone_chat_message_release(LinphoneChatMessage *msg);
void create_file_transfer_information_from_vnd_gsma_rcs_ft_http_xml(LinphoneChatMessage *msg);
void linphone_chat_message_fetch_content_from_database(sqlite3 *db, LinphoneChatMessage *message, int content_id);
void linphone_chat_message_send_imdn(LinphoneChatMessage *cm, ImdnType imdn_type, LinphoneReason reason);
/**/
struct _LinphoneProxyConfig
......
......@@ -33,6 +33,50 @@
* @addtogroup chatroom
* @{
*/
/**
* Call back used to notify message delivery status
* @param msg #LinphoneChatMessage object
* @param status LinphoneChatMessageState
* @param ud application user data
* @deprecated Use LinphoneChatMessageCbsMsgStateChangedCb instead.
* @donotwrap
*/
typedef void (*LinphoneChatMessageStateChangedCb)(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud);
/**
* Call back used to notify message delivery status
* @param msg #LinphoneChatMessage object
* @param status LinphoneChatMessageState
*/
typedef void (*LinphoneChatMessageCbsMsgStateChangedCb)(LinphoneChatMessage* msg, LinphoneChatMessageState state);
/**
* File transfer receive callback prototype. This function is called by the core upon an incoming File transfer is started. This function may be call several time for the same file in case of large file.
* @param message #LinphoneChatMessage message from which the body is received.
* @param content #LinphoneContent incoming content information
* @param buffer #LinphoneBuffer holding the received data. Empty buffer means end of file.
*/
typedef void (*LinphoneChatMessageCbsFileTransferRecvCb)(LinphoneChatMessage *message, const LinphoneContent* content, const LinphoneBuffer *buffer);
/**
* File transfer send callback prototype. This function is called by the core when an outgoing file transfer is started. This function is called until size is set to 0.
* @param message #LinphoneChatMessage message from which the body is received.
* @param content #LinphoneContent outgoing content
* @param offset the offset in the file from where to get the data to be sent
* @param size the number of bytes expected by the framework
* @return A LinphoneBuffer object holding the data written by the application. An empty buffer means end of file.
*/
typedef LinphoneBuffer * (*LinphoneChatMessageCbsFileTransferSendCb)(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t size);
/**
* File transfer progress indication callback prototype.
* @param message #LinphoneChatMessage message from which the body is received.
* @param content #LinphoneContent incoming content information
* @param offset The number of bytes sent/received since the beginning of the transfer.
* @param total The total number of bytes to be sent/received.
*/
typedef void (*LinphoneChatMessageCbsFileTransferProgressIndicationCb)(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t total);
/**
* Is composing notification callback prototype.
......
......@@ -32,6 +32,8 @@
* @addtogroup chatroom
* @{
*/
LinphoneChatMessageCbs *linphone_chat_message_cbs_new(void);
/**
* Acquire a reference to the chat room callbacks object.
......
......@@ -19,7 +19,25 @@
#ifndef _C_CHAT_MESSAGE_H_
#define _C_CHAT_MESSAGE_H_
#include "sal/sal.h"
#include "linphone/api/c-types.h"
#include "linphone/api/c-chat-message-cbs.h"
#ifdef SQLITE_STORAGE_ENABLED
#include <sqlite3.h>
#endif
// =============================================================================
typedef enum _ImdnType {
ImdnTypeDelivery,
ImdnTypeDisplay
} ImdnType;
typedef enum _LinphoneChatMessageDir{
LinphoneChatMessageIncoming,
LinphoneChatMessageOutgoing
} LinphoneChatMessageDir;
// =============================================================================
......@@ -59,6 +77,352 @@ LINPHONE_PUBLIC void *linphone_chat_message_get_user_data(const LinphoneChatMess
**/
LINPHONE_PUBLIC void linphone_chat_message_set_user_data(LinphoneChatMessage *msg, void *ud);
// =============================================================================
LINPHONE_PUBLIC const char * linphone_chat_message_get_external_body_url(const LinphoneChatMessage *msg);
LINPHONE_PUBLIC void linphone_chat_message_set_external_body_url(LinphoneChatMessage *msg, const char *external_body_url);
/**
* Get the time the message was sent.
*/
LINPHONE_PUBLIC time_t linphone_chat_message_get_time(const LinphoneChatMessage* msg);
/**
* Returns TRUE if the message has been sent, returns FALSE if the message has been received.
* @param message the message
**/
LINPHONE_PUBLIC bool_t linphone_chat_message_is_outgoing(LinphoneChatMessage* msg);
/**
* Set origin of the message
* @param[in] message #LinphoneChatMessage obj
* @param[in] from #LinphoneAddress origin of this message (copied)
*/
LINPHONE_PUBLIC void linphone_chat_message_set_from_address(LinphoneChatMessage* msg, const LinphoneAddress* from);
/**
* Get origin of the message
* @param[in] message #LinphoneChatMessage obj
* @return #LinphoneAddress
*/
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_from_address(const LinphoneChatMessage* msg);
/**
* Set destination of the message
* @param[in] message #LinphoneChatMessage obj
* @param[in] addr #LinphoneAddress destination of this message (copied)
*/
LINPHONE_PUBLIC void linphone_chat_message_set_to_address(LinphoneChatMessage* msg, const LinphoneAddress* addr);
/**
* Get destination of the message
* @param[in] message #LinphoneChatMessage obj
* @return #LinphoneAddress
*/
LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_to_address(const LinphoneChatMessage* msg);
/**
* Get the content type of a chat message.
* @param[in] message LinphoneChatMessage object
* @return The content type of the chat message
*/
LINPHONE_PUBLIC const char * linphone_chat_message_get_content_type(const LinphoneChatMessage *msg);
/**
* Set the content type of a chat message.
* This content type must match a content that is text representable, such as text/plain, text/html or image/svg+xml.
* @param[in] message LinphoneChatMessage object
* @param[in] content_type The new content type of the chat message
*/
LINPHONE_PUBLIC void linphone_chat_message_set_content_type(LinphoneChatMessage *msg, const char *content_type);
/**
* Get text part of this message
* @return text or NULL if no text.
*/
LINPHONE_PUBLIC const char* linphone_chat_message_get_text(const LinphoneChatMessage* msg);
/**
* Returns the id used to identify this message in the storage database
* @param message the message
* @return the id
*/
LINPHONE_PUBLIC unsigned int linphone_chat_message_get_storage_id(LinphoneChatMessage* msg);
/**
* Get the message identifier.
* It is used to identify a message so that it can be notified as delivered and/or displayed.
* @param[in] cm LinphoneChatMessage object
* @return The message identifier.
*/
LINPHONE_PUBLIC const char* linphone_chat_message_get_message_id(const LinphoneChatMessage *msg);
/**
* Linphone message has an app-specific field that can store a text. The application might want
* to use it for keeping data over restarts, like thumbnail image path.
* @param message #LinphoneChatMessage
* @return the application-specific data or NULL if none has been stored.
*/
LINPHONE_PUBLIC const char* linphone_chat_message_get_appdata(const LinphoneChatMessage* message);
/**
* Linphone message has an app-specific field that can store a text. The application might want
* to use it for keeping data over restarts, like thumbnail image path.
*
* Invoking this function will attempt to update the message storage to reflect the changeif it is
* enabled.
*