Merge remote-tracking branch 'origin/master' into dev_conference_info

This commit is contained in:
Benjamin Reis 2017-08-31 11:19:34 +02:00
commit 4d1e1c8dfa
41 changed files with 2641 additions and 1380 deletions

View file

@ -238,6 +238,12 @@ char * linphone_call_log_to_str(LinphoneCallLog *cl){
case LinphoneCallMissed:
status=_("missed");
break;
case LinphoneCallAcceptedElsewhere:
status=_("answered elsewhere");
break;
case LinphoneCallDeclinedElsewhere:
status=_("declined elsewhere");
break;
default:
status=_("unknown");
}

File diff suppressed because it is too large Load diff

View file

@ -26,8 +26,12 @@
#include "private.h"
#include "ortp/b64.h"
#include "chat/chat-room.h"
extern LinphonePrivate::ChatRoom& linphone_chat_room_get_cpp_obj(LinphoneChatRoom *cr);
static bool_t file_transfer_in_progress_and_valid(LinphoneChatMessage* msg) {
return (msg->chat_room && msg->chat_room->lc && msg->http_request && !belle_http_request_is_cancelled(msg->http_request));
return (msg->chat_room && linphone_chat_room_get_core(msg->chat_room) && msg->http_request && !belle_http_request_is_cancelled(msg->http_request));
}
static void _release_http_request(LinphoneChatMessage* msg) {
@ -88,7 +92,7 @@ static void linphone_chat_message_file_transfer_on_progress(belle_sip_body_handl
msg, msg->file_transfer_information, offset, total);
} else {
/* Legacy: call back given by application level */
linphone_core_notify_file_transfer_progress_indication(msg->chat_room->lc, msg, msg->file_transfer_information,
linphone_core_notify_file_transfer_progress_indication(linphone_chat_room_get_core(msg->chat_room), msg, msg->file_transfer_information,
offset, total);
}
}
@ -108,7 +112,7 @@ static int on_send_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t *
return BELLE_SIP_STOP;
}
lc = msg->chat_room->lc;
lc = linphone_chat_room_get_core(msg->chat_room);
/* if we've not reach the end of file yet, ask for more data */
/* in case of file body handler, won't be called */
if (msg->file_transfer_filepath == NULL && offset < linphone_content_get_size(msg->file_transfer_information)) {
@ -153,7 +157,7 @@ static int on_send_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t *
static void on_send_end(belle_sip_user_body_handler_t *bh, void *data) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)data;
LinphoneCore *lc = msg->chat_room->lc;
LinphoneCore *lc = linphone_chat_room_get_core(msg->chat_room);
LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(lc);
if (imee) {
@ -185,8 +189,7 @@ static void file_upload_begin_background_task(LinphoneChatMessage *obj){
}
}
static void linphone_chat_message_process_response_from_post_file(void *data,
const belle_http_response_event_t *event) {
static void linphone_chat_message_process_response_from_post_file(void *data, const belle_http_response_event_t *event) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)data;
if (msg->http_request && !file_transfer_in_progress_and_valid(msg)) {
@ -205,7 +208,7 @@ static void linphone_chat_message_process_response_from_post_file(void *data,
belle_sip_body_handler_t *first_part_bh;
bool_t is_file_encryption_enabled = FALSE;
LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(msg->chat_room->lc);
LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(linphone_chat_room_get_core(msg->chat_room));
if (imee) {
LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee);
LinphoneImEncryptionEngineCbsIsEncryptionEnabledForFileTransferCb is_encryption_enabled_for_file_transfer_cb =
@ -339,7 +342,7 @@ static void linphone_chat_message_process_response_from_post_file(void *data,
linphone_chat_message_ref(msg);
linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone);
_release_http_request(msg);
_linphone_chat_room_send_message(msg->chat_room, msg);
linphone_chat_room_get_cpp_obj(msg->chat_room).sendMessage(msg);
file_upload_end_background_task(msg);
linphone_chat_message_unref(msg);
} else {
@ -374,7 +377,7 @@ static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t
linphone_chat_message_cancel_file_transfer(msg);
return;
}
lc = msg->chat_room->lc;
lc = linphone_chat_room_get_core(msg->chat_room);
if (lc == NULL){
return; /*might happen during linphone_core_destroy()*/
@ -425,7 +428,7 @@ static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t
static void on_recv_end(belle_sip_user_body_handler_t *bh, void *data) {
LinphoneChatMessage *msg = (LinphoneChatMessage *)data;
LinphoneCore *lc = msg->chat_room->lc;
LinphoneCore *lc = linphone_chat_room_get_core(msg->chat_room);
LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(lc);
int retval = -1;
@ -536,7 +539,7 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle
int _linphone_chat_room_start_http_transfer(LinphoneChatMessage *msg, const char* url, const char* action, const belle_http_request_listener_callbacks_t *cbs) {
belle_generic_uri_t *uri = NULL;
const char* ua = linphone_core_get_user_agent(msg->chat_room->lc);
const char* ua = linphone_core_get_user_agent(linphone_chat_room_get_core(msg->chat_room));
if (url == NULL) {
ms_warning("Cannot process file transfer msg: no file remote URI configured.");
@ -559,7 +562,7 @@ int _linphone_chat_room_start_http_transfer(LinphoneChatMessage *msg, const char
/* give msg to listener to be able to start the actual file upload when server answer a 204 No content */
msg->http_listener = belle_http_request_listener_create_from_callbacks(cbs, linphone_chat_message_ref(msg));
belle_http_provider_send_request(msg->chat_room->lc->http_provider, msg->http_request, msg->http_listener);
belle_http_provider_send_request(linphone_chat_room_get_core(msg->chat_room)->http_provider, msg->http_request, msg->http_listener);
return 0;
error:
if (uri) {
@ -580,7 +583,7 @@ int linphone_chat_room_upload_file(LinphoneChatMessage *msg) {
cbs.process_response = linphone_chat_message_process_response_from_post_file;
cbs.process_io_error = linphone_chat_message_process_io_error_upload;
cbs.process_auth_requested = linphone_chat_message_process_auth_requested_upload;
err = _linphone_chat_room_start_http_transfer(msg, linphone_core_get_file_transfer_server(msg->chat_room->lc), "POST", &cbs);
err = _linphone_chat_room_start_http_transfer(msg, linphone_core_get_file_transfer_server(linphone_chat_room_get_core(msg->chat_room)), "POST", &cbs);
if (err == -1){
linphone_chat_message_set_state(msg, LinphoneChatMessageStateNotDelivered);
}
@ -621,10 +624,10 @@ void _linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg, bool_
if (!belle_http_request_is_cancelled(msg->http_request)) {
if (msg->chat_room) {
ms_message("Canceling file transfer %s - msg [%p] chat room[%p]"
, (msg->external_body_url == NULL) ? linphone_core_get_file_transfer_server(msg->chat_room->lc) : msg->external_body_url
, (msg->external_body_url == NULL) ? linphone_core_get_file_transfer_server(linphone_chat_room_get_core(msg->chat_room)) : msg->external_body_url
, msg
, msg->chat_room);
belle_http_provider_cancel_request(msg->chat_room->lc->http_provider, msg->http_request);
belle_http_provider_cancel_request(linphone_chat_room_get_core(msg->chat_room)->http_provider, msg->http_request);
if ((msg->dir == LinphoneChatMessageOutgoing) && unref) {
// must release it
linphone_chat_message_unref(msg);
@ -654,20 +657,6 @@ const char *linphone_chat_message_get_file_transfer_filepath(LinphoneChatMessage
return msg->file_transfer_filepath;
}
LinphoneChatMessage *linphone_chat_room_create_file_transfer_message(LinphoneChatRoom *cr,
const LinphoneContent *initial_content) {
LinphoneChatMessage *msg = belle_sip_object_new(LinphoneChatMessage);
msg->callbacks = linphone_chat_message_cbs_new();
msg->chat_room = (LinphoneChatRoom *)cr;
msg->message = NULL;
msg->file_transfer_information = linphone_content_copy(initial_content);
msg->dir = LinphoneChatMessageOutgoing;
linphone_chat_message_set_to(msg, linphone_chat_room_get_peer_address(cr));
msg->from = linphone_address_new(linphone_core_get_identity(cr->lc)); /*direct assignment*/
/* this will be set to application/vnd.gsma.rcs-ft-http+xml when we will transfer the xml reply from server to the peers */
msg->content_type = NULL;
/* this will store the http request during file upload to the server */
msg->http_request = NULL;
msg->time = ms_time(0);
return msg;
LinphoneChatMessage *linphone_chat_room_create_file_transfer_message(LinphoneChatRoom *cr, const LinphoneContent *initial_content) {
return linphone_chat_room_get_cpp_obj(cr).createFileTransferMessage(initial_content);
}

View file

@ -749,11 +749,11 @@ error:
bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr) {
if (cr) {
switch (linphone_core_lime_enabled(cr->lc)) {
switch (linphone_core_lime_enabled(linphone_chat_room_get_core(cr))) {
case LinphoneLimeDisabled: return FALSE;
case LinphoneLimeMandatory:
case LinphoneLimePreferred: {
void *zrtp_cache_db = linphone_core_get_zrtp_cache_db(cr->lc);
void *zrtp_cache_db = linphone_core_get_zrtp_cache_db(linphone_chat_room_get_core(cr));
if (zrtp_cache_db != NULL) {
bool_t res;
limeURIKeys_t associatedKeys;
@ -832,7 +832,7 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryptionEn
LinphoneCore *lc = linphone_im_encryption_engine_get_core(engine);
int errcode = -1;
const char *new_content_type = "xml/cipher";
if(linphone_core_lime_enabled(room->lc)) {
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) {
@ -862,7 +862,7 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryptionEn
retval = lime_createMultipartMessage(zrtp_cache_db, msg->content_type, (uint8_t *)msg->message, selfUri, peerUri, &crypted_body);
if (retval != 0) { /* fail to encrypt */
ms_warning("Unable to encrypt message for %s : %s", room->peer, lime_error_code_to_string(retval));
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 */

View file

@ -1719,7 +1719,7 @@ static void linphone_call_set_terminated(LinphoneCall *call){
call->ringing_beep=FALSE;
}
if (call->chat_room){
call->chat_room->call = NULL;
linphone_chat_room_set_call(call->chat_room, NULL);
}
if (lc->calls == NULL){
ms_bandwidth_controller_reset_state(lc->bw_controller);
@ -1864,6 +1864,32 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
call->log->status=LinphoneCallMissed;
}
break;
case LinphoneReasonNone:
if (call->log->dir == LinphoneCallIncoming){
const LinphoneErrorInfo *ei = linphone_call_get_error_info(call);
if (ei) {
int code = linphone_error_info_get_protocol_code(ei);
if((code >= 200 && code < 300)) {
// error between 200-299 means accepted elsewhere
call->log->status=LinphoneCallAcceptedElsewhere;
break;
}
}
}
break;
case LinphoneReasonDoNotDisturb:
if (call->log->dir == LinphoneCallIncoming){
const LinphoneErrorInfo *ei = linphone_call_get_error_info(call);
if (ei) {
int code = linphone_error_info_get_protocol_code(ei);
if(code >= 600 && code < 700) {
// error between 600-699 means declined elsewhere
call->log->status=LinphoneCallDeclinedElsewhere;
break;
}
}
}
break;
default:
break;
}

View file

@ -463,8 +463,10 @@ void linphone_core_set_log_handler(OrtpLogFunc logfunc) {
if (ortp_get_log_handler() == linphone_core_log_collection_handler) {
ms_message("There is already a log collection handler, keep it");
liblinphone_log_func = logfunc;
} else
} else {
ortp_set_log_handler(logfunc);
sal_set_log_handler(logfunc);
}
}
void linphone_core_set_log_file(FILE *file) {
@ -696,8 +698,10 @@ void linphone_core_enable_log_collection(LinphoneLogCollectionState state) {
liblinphone_log_func = ortp_get_log_handler();
}
ortp_set_log_handler(linphone_core_log_collection_handler);
sal_set_log_handler(linphone_core_log_collection_handler);
} else {
ortp_set_log_handler(liblinphone_log_func);
sal_set_log_handler(liblinphone_log_func);
}
}

View file

@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef SQLITE_STORAGE_ENABLED
#include "chat/chat-room.h"
#ifndef _WIN32
#if !defined(__QNXNTO__) && !defined(__ANDROID__)
@ -42,6 +43,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <assert.h>
extern LinphonePrivate::ChatRoom& linphone_chat_room_get_cpp_obj(LinphoneChatRoom *cr);
static char *utf8_convert(const char *filename){
char db_file_utf8[MAX_PATH_SIZE] = "";
#if defined(_WIN32)
@ -117,31 +121,6 @@ int _linphone_sqlite3_open(const char *db_file, sqlite3 **db) {
#ifdef SQLITE_STORAGE_ENABLED
static LinphoneChatMessage * get_weak_message(LinphoneChatRoom *cr, unsigned int storage_id) {
LinphoneChatMessage *cm;
bctbx_list_t *item;
for (item = cr->weak_messages; item != NULL; item = bctbx_list_next(item)) {
cm = (LinphoneChatMessage *)bctbx_list_get_data(item);
if (linphone_chat_message_get_storage_id(cm) == storage_id)
return linphone_chat_message_ref(cm);
}
return NULL;
}
static ORTP_INLINE LinphoneChatMessage* get_transient_message(LinphoneChatRoom* cr, unsigned int storage_id){
bctbx_list_t* transients = cr->transient_messages;
LinphoneChatMessage* chat;
while( transients ){
chat = (LinphoneChatMessage*)transients->data;
if(chat->storage_id == storage_id){
return linphone_chat_message_ref(chat);
}
transients = transients->next;
}
return NULL;
}
/* DB layout:
* | 0 | storage_id
* | 1 | type
@ -172,7 +151,7 @@ static int callback_content(void *data, int argc, char **argv, char **colName) {
return 0;
}
static void fetch_content_from_database(sqlite3 *db, LinphoneChatMessage *message, int content_id) {
void linphone_chat_message_fetch_content_from_database(sqlite3 *db, LinphoneChatMessage *message, int content_id) {
char* errmsg = NULL;
int ret;
char * buf;
@ -186,8 +165,6 @@ static void fetch_content_from_database(sqlite3 *db, LinphoneChatMessage *messag
sqlite3_free(buf);
}
// Called when fetching all conversations from database
static int callback_all(void *data, int argc, char **argv, char **colName){
LinphoneCore* lc = (LinphoneCore*) data;
@ -200,93 +177,6 @@ static int callback_all(void *data, int argc, char **argv, char **colName){
return 0;
}
/* DB layout:
* | 0 | storage_id
* | 1 | localContact
* | 2 | remoteContact
* | 3 | direction flag (LinphoneChatMessageDir)
* | 4 | message (text content of the message)
* | 5 | time (unused now, used to be string-based timestamp, replaced by the utc timestamp)
* | 6 | read flag (no longer used, replaced by the LinphoneChatMessageStateDisplayed state)
* | 7 | status (LinphoneChatMessageState)
* | 8 | external body url (deprecated file transfer system)
* | 9 | utc timestamp
* | 10 | app data text
* | 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;
unsigned int storage_id = (unsigned int)atoi(argv[0]);
LinphoneChatMessage* new_message;
/* Check if the message exists in the weak messages list, in which case we should return that one. */
new_message = get_weak_message(cr, storage_id);
if (new_message == NULL) {
/* Check if the message exists in the transient list, in which case we should return that one. */
new_message = get_transient_message(cr, storage_id);
}
if (new_message == NULL) {
new_message = linphone_chat_room_create_message(cr, argv[4]);
if(atoi(argv[3])==LinphoneChatMessageIncoming){
new_message->dir=LinphoneChatMessageIncoming;
linphone_chat_message_set_from(new_message,linphone_chat_room_get_peer_address(cr));
new_message->to = NULL; /*will be filled at the end */
} else {
new_message->dir=LinphoneChatMessageOutgoing;
new_message->from = NULL; /*will be filled at the end */
linphone_chat_message_set_to(new_message,linphone_chat_room_get_peer_address(cr));
}
new_message->time = (time_t)atol(argv[9]);
new_message->is_read=atoi(argv[6]);
new_message->state=static_cast<LinphoneChatMessageState>(atoi(argv[7]));
new_message->storage_id=storage_id;
new_message->external_body_url= ms_strdup(argv[8]);
new_message->appdata = ms_strdup(argv[10]);
new_message->message_id = ms_strdup(argv[12]);
linphone_chat_message_set_content_type(new_message, argv[13]);
new_message->is_secured = (bool_t)atoi(argv[14]);
if (argv[11] != NULL) {
int id = atoi(argv[11]);
if (id >= 0) {
fetch_content_from_database(cr->lc->db, new_message, id);
}
}
/* Fix content type for old messages that were stored without it */
if (new_message->content_type == NULL) {
if (new_message->file_transfer_information != NULL) {
new_message->content_type = ms_strdup("application/vnd.gsma.rcs-ft-http+xml");
} else if (new_message->external_body_url != NULL) {
new_message->content_type = ms_strdup("message/external-body");
} else {
new_message->content_type = ms_strdup("text/plain");
}
}
/* Add the new message to the weak messages list. */
linphone_chat_room_add_weak_message(cr, new_message);
}
cr->messages_hist=bctbx_list_prepend(cr->messages_hist,new_message);
return 0;
}
void linphone_sql_request_message(sqlite3 *db,const char *stmt,LinphoneChatRoom *cr){
char* errmsg=NULL;
int ret;
ret=sqlite3_exec(db,stmt,create_chat_message,cr,&errmsg);
if(ret != SQLITE_OK) {
ms_error("Error in creation: %s.", errmsg);
sqlite3_free(errmsg);
}
}
int linphone_sql_request(sqlite3* db,const char *stmt){
char* errmsg=NULL;
int ret;
@ -407,7 +297,7 @@ void linphone_chat_message_store_update(LinphoneChatMessage *msg) {
}
void linphone_chat_message_store_state(LinphoneChatMessage *msg){
LinphoneCore *lc=msg->chat_room->lc;
LinphoneCore *lc=linphone_chat_room_get_core(msg->chat_room);
if (lc->db){
char *buf=sqlite3_mprintf("UPDATE history SET status=%i WHERE (id = %u);",
msg->state,msg->storage_id);
@ -417,7 +307,7 @@ void linphone_chat_message_store_state(LinphoneChatMessage *msg){
}
void linphone_chat_message_store_appdata(LinphoneChatMessage* msg){
LinphoneCore *lc=msg->chat_room->lc;
LinphoneCore *lc=linphone_chat_room_get_core(msg->chat_room);
if (lc->db){
char *buf=sqlite3_mprintf("UPDATE history SET appdata=%Q WHERE id=%u;",
msg->appdata,msg->storage_id);
@ -426,251 +316,44 @@ void linphone_chat_message_store_appdata(LinphoneChatMessage* msg){
}
}
void linphone_chat_room_mark_as_read(LinphoneChatRoom *cr){
LinphoneCore *lc=linphone_chat_room_get_core(cr);
bctbx_list_t *item;
char *peer;
char *buf;
if (lc->db==NULL) return ;
// optimization: do not modify the database if no message is marked as unread
if(linphone_chat_room_get_unread_messages_count(cr) == 0) return;
peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));
buf = sqlite3_mprintf("SELECT * FROM history WHERE remoteContact = %Q AND direction = %i AND status != %i", peer, LinphoneChatMessageIncoming, LinphoneChatMessageStateDisplayed);
linphone_sql_request_message(lc->db, buf, cr);
sqlite3_free(buf);
for (item = cr->messages_hist; item != NULL; item = bctbx_list_next(item)) {
LinphoneChatMessage *cm = (LinphoneChatMessage *)bctbx_list_get_data(item);
linphone_chat_message_send_display_notification(cm);
}
bctbx_list_free_with_data(cr->messages_hist, (bctbx_list_free_func)linphone_chat_message_unref);
cr->messages_hist = NULL;
buf=sqlite3_mprintf("UPDATE history SET status=%i WHERE remoteContact=%Q AND direction=%i;",
LinphoneChatMessageStateDisplayed, peer, LinphoneChatMessageIncoming);
linphone_sql_request(lc->db,buf);
sqlite3_free(buf);
ms_free(peer);
if (cr->pending_message) {
linphone_chat_message_set_state(cr->pending_message, LinphoneChatMessageStateDisplayed);
linphone_chat_message_send_display_notification(cr->pending_message);
}
cr->unread_count = 0;
void linphone_chat_room_mark_as_read(LinphoneChatRoom *cr) {
linphone_chat_room_get_cpp_obj(cr).markAsRead();
}
void linphone_chat_room_update_url(LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
LinphoneCore *lc=linphone_chat_room_get_core(cr);
char *buf;
if (lc->db==NULL) return ;
buf=sqlite3_mprintf("UPDATE history SET url=%Q WHERE id=%u;",msg->external_body_url,msg->storage_id);
linphone_sql_request(lc->db,buf);
sqlite3_free(buf);
int linphone_chat_room_get_unread_messages_count(LinphoneChatRoom *cr) {
return linphone_chat_room_get_cpp_obj(cr).getUnreadMessagesCount();
}
static int linphone_chat_room_get_messages_count(LinphoneChatRoom *cr, bool_t unread_only){
LinphoneCore *lc=linphone_chat_room_get_core(cr);
int numrows=0;
char *peer;
char *buf;
char *option = NULL;
sqlite3_stmt *selectStatement;
int returnValue;
if (lc->db==NULL) return 0;
// optimization: do not read database if the count is already available in memory
if(unread_only && cr->unread_count >= 0) return cr->unread_count;
peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));
if (unread_only) {
option = bctbx_strdup_printf("AND status!=%i AND direction=%i", LinphoneChatMessageStateDisplayed, LinphoneChatMessageIncoming);
}
buf=sqlite3_mprintf("SELECT count(*) FROM history WHERE remoteContact = %Q %s;",peer,unread_only?option:"");
returnValue = sqlite3_prepare_v2(lc->db,buf,-1,&selectStatement,NULL);
if (returnValue == SQLITE_OK){
if(sqlite3_step(selectStatement) == SQLITE_ROW){
numrows= sqlite3_column_int(selectStatement, 0);
}
}
sqlite3_finalize(selectStatement);
sqlite3_free(buf);
ms_free(peer);
/* no need to test the sign of cr->unread_count here
* because it has been tested above */
if(unread_only) {
cr->unread_count = numrows;
if (option) bctbx_free(option);
}
return numrows;
}
int linphone_chat_room_get_unread_messages_count(LinphoneChatRoom *cr){
return linphone_chat_room_get_messages_count(cr, TRUE);
}
int linphone_chat_room_get_history_size(LinphoneChatRoom *cr){
return linphone_chat_room_get_messages_count(cr, FALSE);
int linphone_chat_room_get_history_size(LinphoneChatRoom *cr) {
return linphone_chat_room_get_cpp_obj(cr).getHistorySize();
}
void linphone_chat_room_delete_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
LinphoneCore *lc=cr->lc;
char *buf;
if (lc->db==NULL) return ;
buf=sqlite3_mprintf("DELETE FROM history WHERE id = %u;", msg->storage_id);
linphone_sql_request(lc->db,buf);
sqlite3_free(buf);
/* Invalidate unread_count when we modify the database, so that next
time we need it it will be recomputed from latest database state */
cr->unread_count = -1;
linphone_chat_room_get_cpp_obj(cr).deleteMessage(msg);
}
void linphone_chat_room_delete_history(LinphoneChatRoom *cr){
LinphoneCore *lc=cr->lc;
char *peer;
char *buf;
if (lc->db==NULL) return ;
peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));
buf=sqlite3_mprintf("DELETE FROM history WHERE remoteContact = %Q;",peer);
linphone_sql_request(lc->db,buf);
sqlite3_free(buf);
ms_free(peer);
if(cr->unread_count > 0) cr->unread_count = 0;
void linphone_chat_room_delete_history(LinphoneChatRoom *cr) {
linphone_chat_room_get_cpp_obj(cr).deleteHistory();
}
bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int startm, int endm){
LinphoneCore *lc=linphone_chat_room_get_core(cr);
bctbx_list_t *ret;
char *buf,*buf2;
char *peer;
uint64_t begin,end;
int buf_max_size = 512;
if (lc->db==NULL) return NULL;
peer = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));
cr->messages_hist = NULL;
/*since we want to append query parameters depending on arguments given, we use malloc instead of sqlite3_mprintf*/
buf=reinterpret_cast<char *>(ms_malloc(buf_max_size));
buf=sqlite3_snprintf(buf_max_size-1,buf,"SELECT * FROM history WHERE remoteContact = %Q ORDER BY id DESC",peer);
if (startm<0) startm=0;
if ((endm>0&&endm>=startm) || (startm == 0 && endm == 0) ){
buf2=ms_strdup_printf("%s LIMIT %i ",buf,endm+1-startm);
ms_free(buf);
buf = buf2;
}else if(startm>0){
ms_message("%s(): end is lower than start (%d < %d). Assuming no end limit.",__FUNCTION__,endm,startm);
buf2=ms_strdup_printf("%s LIMIT -1",buf);
ms_free(buf);
buf = buf2;
}
if (startm>0){
buf2=ms_strdup_printf("%s OFFSET %i ",buf,startm);
ms_free(buf);
buf = buf2;
}
begin=ortp_get_cur_time_ms();
linphone_sql_request_message(lc->db,buf,cr);
end=ortp_get_cur_time_ms();
if (endm+1-startm > 1) {
//display message only if at least 2 messages are loaded
ms_message("%s(): completed in %i ms",__FUNCTION__, (int)(end-begin));
}
ms_free(buf);
if (cr->messages_hist) {
//fill local addr with core identity instead of per message
LinphoneAddress* local_addr = linphone_address_new(linphone_core_get_identity(cr->lc));
bctbx_list_t* it = cr->messages_hist;
while (it) {
LinphoneChatMessage* msg = reinterpret_cast<LinphoneChatMessage *>(it->data);
if (msg->dir == LinphoneChatMessageOutgoing) {
if (msg->from != NULL) linphone_address_unref(msg->from);
msg->from = linphone_address_ref(local_addr);
} else {
msg->to = linphone_address_ref(local_addr);
}
it = it->next;
}
linphone_address_unref(local_addr);
}
ret=cr->messages_hist;
cr->messages_hist=NULL;
ms_free(peer);
return ret;
bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int startm, int endm) {
std::list<LinphoneChatMessage *> l = linphone_chat_room_get_cpp_obj(cr).getHistoryRange(startm, endm);
bctbx_list_t *result = nullptr;
for (auto it = l.begin(); it != l.end(); it++)
result = bctbx_list_append(result, *it);
return result;
}
bctbx_list_t *linphone_chat_room_get_history(LinphoneChatRoom *cr,int nb_message){
return linphone_chat_room_get_history_range(cr, 0, nb_message-1);
}
bctbx_list_t* linphone_chat_room_find_messages(LinphoneChatRoom *cr, const char *message_id) {
LinphoneCore *lc = linphone_chat_room_get_core(cr);
char *buf;
char *peer;
bctbx_list_t* messages;
if (lc->db == NULL) return NULL;
peer = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));
cr->messages_hist = NULL;
buf = sqlite3_mprintf("SELECT * FROM history WHERE remoteContact = %Q AND messageId = %Q", peer, message_id);
linphone_sql_request_message(lc->db, buf, cr);
sqlite3_free(buf);
ms_free(peer);
messages = cr->messages_hist;
cr->messages_hist = NULL;
return messages;
}
LinphoneChatMessage * linphone_chat_room_find_message_with_dir(LinphoneChatRoom *cr, const char *message_id, LinphoneChatMessageDir dir) {
bctbx_list_t* messages = linphone_chat_room_find_messages(cr, message_id);
bctbx_list_t* it;
LinphoneChatMessage *ret = NULL;
for (it = messages; it != NULL; it = it->next) {
LinphoneChatMessage * cm = (LinphoneChatMessage*)it->data;
if (cm->dir == dir) {
linphone_chat_message_ref(cm);
ret = cm;
break;
}
}
if (messages)
bctbx_list_free_with_data(messages, (bctbx_list_free_func)linphone_chat_message_unref);
return ret;
bctbx_list_t *linphone_chat_room_get_history(LinphoneChatRoom *cr, int nb_message) {
std::list<LinphoneChatMessage *> l = linphone_chat_room_get_cpp_obj(cr).getHistory(nb_message);
bctbx_list_t *result = nullptr;
for (auto it = l.begin(); it != l.end(); it++)
result = bctbx_list_append(result, *it);
return result;
}
LinphoneChatMessage * linphone_chat_room_find_message(LinphoneChatRoom *cr, const char *message_id) {
bctbx_list_t* messages = linphone_chat_room_find_messages(cr, message_id);
LinphoneChatMessage *cm = NULL;
if (messages) {
cm = (LinphoneChatMessage *)bctbx_list_nth_data(messages, 0);
linphone_chat_message_ref(cm);
bctbx_list_free_with_data(messages, (bctbx_list_free_func)linphone_chat_message_unref);
}
return cm;
return linphone_chat_room_get_cpp_obj(cr).findMessage(message_id);
}
static void linphone_create_history_table(sqlite3* db){
@ -975,9 +658,6 @@ void linphone_core_message_storage_init(LinphoneCore *lc){
void linphone_core_message_storage_close(LinphoneCore *lc){
}
void linphone_chat_room_update_url(LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
}
int linphone_chat_room_get_unread_messages_count(LinphoneChatRoom *cr){
return 0;
}

View file

@ -180,6 +180,12 @@ struct _LinphoneCallParams{
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneCallParams);
typedef enum _ImdnType {
ImdnTypeDelivery,
ImdnTypeDisplay
} ImdnType;
struct _LinphoneQualityReporting{
reporting_session_report_t * reports[3]; /**Store information on audio and video media streams (RFC 6035) */
bool_t was_video_running; /*Keep video state since last check in order to detect its (de)activation*/
@ -279,11 +285,6 @@ struct _LinphoneChatMessage {
#endif
};
/*
*Gets a Message with a given message id and direction.
*/
LINPHONE_PUBLIC LinphoneChatMessage * linphone_chat_room_find_message_with_dir(LinphoneChatRoom *cr, const char *message_id,LinphoneChatMessageDir dir);
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatMessage);
typedef struct StunCandidate{
@ -594,7 +595,7 @@ LINPHONE_PUBLIC void linphone_core_get_local_ip(LinphoneCore *lc, int af, const
LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore *lc, int index);
void linphone_proxy_config_write_to_config_file(LinphoneConfig* config,LinphoneProxyConfig *obj, int index);
LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *msg);
int linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *msg);
void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *cr, uint32_t character, LinphoneCall *call);
void linphone_call_init_stats(LinphoneCallStats *stats, LinphoneStreamType type);
@ -650,7 +651,8 @@ void _linphone_proxy_config_release_ops(LinphoneProxyConfig *obj);
/*chat*/
void linphone_chat_room_release(LinphoneChatRoom *cr);
void linphone_chat_room_add_weak_message(LinphoneChatRoom *cr, LinphoneChatMessage *cm);
void linphone_chat_room_set_call(LinphoneChatRoom *cr, LinphoneCall *call);
bctbx_list_t * linphone_chat_room_get_transient_messages(const LinphoneChatRoom *cr);
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);
@ -659,11 +661,14 @@ void linphone_chat_message_send_delivery_notification(LinphoneChatMessage *cm, L
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);
void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
LinphoneChatMessageCbs *linphone_chat_message_cbs_new(void);
LinphoneChatRoom *_linphone_core_create_chat_room_from_call(LinphoneCall *call);
void linphone_chat_room_add_transient_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
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
@ -740,33 +745,11 @@ typedef enum _LinphoneIsComposingState {
LinphoneIsComposingActive
} LinphoneIsComposingState;
struct _LinphoneChatRoom{
belle_sip_object_t base;
void *user_data;
struct _LinphoneCore *lc;
char *peer;
LinphoneAddress *peer_url;
MSList *messages_hist;
MSList *transient_messages;
bctbx_list_t *weak_messages;
int unread_count;
LinphoneIsComposingState remote_is_composing;
LinphoneIsComposingState is_composing;
belle_sip_source_t *remote_composing_refresh_timer;
belle_sip_source_t *composing_idle_timer;
belle_sip_source_t *composing_refresh_timer;
LinphoneCall *call;
LinphoneChatMessage *pending_message;
MSList *received_rtt_characters;
};
typedef struct _LinphoneChatMessageCharacter {
uint32_t value;
bool_t has_been_read;
} LinphoneChatMessageCharacter;
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatRoom);
typedef struct _LinphoneFriendPresence {
char *uri_or_tel;

View file

@ -342,6 +342,12 @@ void linphone_gtk_call_log_update(GtkWidget *w){
case LinphoneCallDeclined:
status=_("Declined");
break;
case LinphoneCallAnsweredElsewhere:
status=_("Answered elsewhere");
break;
case LinphoneCallDeclinedElsewhere:
status=_("Declined elsewhere");
break;
default:
break;
}

View file

@ -343,7 +343,9 @@ typedef enum _LinphoneCallStatus {
LinphoneCallAborted, /**< The call was aborted */
LinphoneCallMissed, /**< The call was missed (unanswered) */
LinphoneCallDeclined, /**< The call was declined, either locally or by remote end */
LinphoneCallEarlyAborted /**<The call was aborted before being advertised to the application - for protocol reasons*/
LinphoneCallEarlyAborted, /**<The call was aborted before being advertised to the application - for protocol reasons*/
LinphoneCallAcceptedElsewhere, /**<The call was answered on another device*/
LinphoneCallDeclinedElsewhere /**<The call was declined on another device*/
} LinphoneCallStatus;
/**

View file

@ -61,6 +61,16 @@ public interface LinphoneCallLog {
*/
public final static CallStatus EarlyAborted = new CallStatus(4,"Early Aborted");
/**
* The call was answered on another device
*/
public final static CallStatus AcceptedElsewhere = new CallStatus(5,"Accepted Elsewhere");
/**
* The call was declined on another device
*/
public final static CallStatus DeclinedElsewhere = new CallStatus(6,"Declined Elsewhere");
private CallStatus(int value,String stringValue) {
mValue = value;

View file

@ -21,12 +21,16 @@
############################################################################
set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
address/address.h
conference/conference-listener.h
conference/local-conference-event-handler.h
conference/remote-conference-event-handler.h
c-wrapper/api/c-event-log.h
c-wrapper/c-tools.h
c-wrapper/c-types.h
c-wrapper/wrapper.h
chat/chat-room-p.h
chat/chat-room.h
content/content.h
core/core.h
cpim/cpim.h
@ -59,16 +63,21 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
object/object-p.h
object/object.h
object/singleton.h
utils/content-type.h
utils/enum-generator.h
utils/general.h
utils/magic-macros.h
utils/utils.h
xml/conference-info.h
xml/xml.h
)
set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
address/address.cpp
conference/local-conference-event-handler.cpp
conference/remote-conference-event-handler.cpp
c-wrapper/api/c-event-log.cpp
chat/chat-room.cpp
content/content.cpp
core/core.cpp
cpim/header/cpim-core-headers.cpp
@ -90,6 +99,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
message/message.cpp
object/clonable-object.cpp
object/object.cpp
utils/content-type.cpp
utils/general.cpp
utils/utils.cpp
xml/conference-info.cpp

269
src/address/address.cpp Normal file
View file

@ -0,0 +1,269 @@
/*
* address.cpp
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY {} without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// From coreapi.
#include "private.h"
#include "logger/logger.h"
#include "object/clonable-object-p.h"
#include "address.h"
// =============================================================================
using namespace std;
LINPHONE_BEGIN_NAMESPACE
class AddressPrivate : public ClonableObjectPrivate {
public:
SalAddress *internalAddress = nullptr;
};
// -----------------------------------------------------------------------------
Address::Address (const string &address) : ClonableObject(*new AddressPrivate) {
L_D(Address);
if (!address.empty() && !(d->internalAddress = sal_address_new(address.c_str())))
lWarning() << "Cannot create address, bad uri [" << address << "].";
}
Address::Address (const Address &src) : ClonableObject(*new AddressPrivate) {
L_D(Address);
SalAddress *salAddress = src.getPrivate()->internalAddress;
if (salAddress)
d->internalAddress = sal_address_clone(salAddress);
}
Address::~Address () {
L_D(Address);
if (d->internalAddress)
sal_address_destroy(d->internalAddress);
}
Address &Address::operator= (const Address &src) {
L_D(Address);
if (this != &src) {
if (d->internalAddress)
sal_address_destroy(d->internalAddress);
SalAddress *salAddress = src.getPrivate()->internalAddress;
d->internalAddress = salAddress ? sal_address_clone(salAddress) : nullptr;
}
return *this;
}
Address::operator bool () const {
L_D(const Address);
return static_cast<bool>(d->internalAddress);
}
bool Address::operator== (const Address &address) const {
return equal(address);
}
string Address::getScheme () const {
L_D(const Address);
return d->internalAddress ? sal_address_get_scheme(d->internalAddress) : "";
}
string Address::getDisplayName () const {
L_D(const Address);
return d->internalAddress ? sal_address_get_display_name(d->internalAddress) : "";
}
bool Address::setDisplayName (const string &displayName) {
L_D(const Address);
if (!d->internalAddress)
return false;
sal_address_set_display_name(d->internalAddress, displayName.c_str());
return true;
}
string Address::getUsername () const {
L_D(const Address);
return d->internalAddress ? sal_address_get_username(d->internalAddress) : "";
}
bool Address::setUsername (const string &username) {
L_D(const Address);
if (!d->internalAddress)
return false;
sal_address_set_username(d->internalAddress, username.c_str());
return true;
}
string Address::getDomain () const {
L_D(const Address);
return d->internalAddress ? sal_address_get_domain(d->internalAddress) : "";
}
bool Address::setDomain (const string &domain) {
L_D(const Address);
if (!d->internalAddress)
return false;
sal_address_set_domain(d->internalAddress, domain.c_str());
return true;
}
int Address::getPort () const {
L_D(const Address);
return d->internalAddress ? sal_address_get_port(d->internalAddress) : 0;
}
bool Address::setPort (int port) {
L_D(const Address);
if (!d->internalAddress)
return false;
sal_address_set_port(d->internalAddress, port);
return true;
}
Transport Address::getTransport () const {
L_D(const Address);
return d->internalAddress ? static_cast<Transport>(sal_address_get_transport(d->internalAddress)) : Transport::Udp;
}
bool Address::setTransport (Transport transport) {
L_D(const Address);
if (!d->internalAddress)
return false;
sal_address_set_transport(d->internalAddress, static_cast<SalTransport>(transport));
return true;
}
bool Address::getSecure () const {
L_D(const Address);
return d->internalAddress ? sal_address_is_secure(d->internalAddress) : false;
}
bool Address::setSecure (bool enabled) {
L_D(const Address);
if (!d->internalAddress)
return false;
sal_address_set_secure(d->internalAddress, enabled);
return true;
}
bool Address::isSip () const {
L_D(const Address);
return d->internalAddress ? sal_address_is_sip(d->internalAddress) : false;
}
string Address::getMethodParam () const {
L_D(const Address);
return d->internalAddress ? sal_address_get_method_param(d->internalAddress) : "";
}
bool Address::setMethodParam (const string &methodParam) {
L_D(const Address);
if (!d->internalAddress)
return false;
sal_address_set_method_param(d->internalAddress, methodParam.c_str());
return true;
}
string Address::getPassword () const {
L_D(const Address);
return sal_address_get_password(d->internalAddress);
}
bool Address::setPassword (const string &password) {
L_D(const Address);
if (!d->internalAddress)
return false;
sal_address_set_password(d->internalAddress, password.c_str());
return true;
}
bool Address::clean () {
L_D(const Address);
if (!d->internalAddress)
return false;
sal_address_clean(d->internalAddress);
return true;
}
string Address::asString () const {
L_D(const Address);
if (!d->internalAddress)
return "";
char *buf = sal_address_as_string(d->internalAddress);
string out = buf;
ms_free(buf);
return out;
}
string Address::asStringUriOnly () const {
L_D(const Address);
if (!d->internalAddress)
return "";
char *buf = sal_address_as_string_uri_only(d->internalAddress);
string out = buf;
ms_free(buf);
return out;
}
bool Address::equal (const Address &address) const {
return asString() == address.asString();
}
bool Address::weakEqual (const Address &address) const {
return getUsername() == address.getUsername() &&
getDomain() == address.getDomain() &&
getPort() == address.getPort();
}
string Address::getHeaderValue (const string &headerName) const {
L_D(const Address);
return d->internalAddress ? sal_address_get_header(d->internalAddress, headerName.c_str()) : "";
}
bool Address::setHeader (const string &headerName, const string &headerValue) {
L_D(const Address);
if (!d->internalAddress)
return false;
sal_address_set_header(d->internalAddress, headerName.c_str(), headerValue.c_str());
return true;
}
LINPHONE_END_NAMESPACE

90
src/address/address.h Normal file
View file

@ -0,0 +1,90 @@
/*
* address.h
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _ADDRESS_H_
#define _ADDRESS_H_
#include <string>
#include "enums.h"
#include "object/clonable-object.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class AddressPrivate;
class LINPHONE_PUBLIC Address : public ClonableObject {
public:
Address (const std::string &address = "");
Address (const Address &src);
~Address ();
Address &operator= (const Address &src);
operator bool () const;
bool operator== (const Address &address) const;
std::string getScheme () const;
std::string getDisplayName () const;
bool setDisplayName (const std::string &displayName);
std::string getUsername () const;
bool setUsername (const std::string &username);
std::string getDomain () const;
bool setDomain (const std::string &domain);
int getPort () const;
bool setPort (int port);
Transport getTransport () const;
bool setTransport (Transport transport);
bool getSecure () const;
bool setSecure (bool enabled);
bool isSip () const;
std::string getMethodParam () const;
bool setMethodParam (const std::string &methodParam);
std::string getPassword () const;
bool setPassword (const std::string &password);
bool clean ();
std::string asString () const;
std::string asStringUriOnly () const;
bool equal (const Address &address) const;
bool weakEqual (const Address &address) const;
std::string getHeaderValue (const std::string &headerName) const;
bool setHeader (const std::string &headerName, const std::string &headerValue);
private:
L_DECLARE_PRIVATE(Address);
};
LINPHONE_END_NAMESPACE
#endif // ifndef _ADDRESS_H_

View file

@ -20,12 +20,18 @@
#include "c-event-log.h"
#include "event-log/call-event.h"
#include "event-log/conference-participant-event.h"
#include "event-log/message-event.h"
// =============================================================================
using namespace std;
extern "C" {
// -----------------------------------------------------------------------------
// Event log.
// -----------------------------------------------------------------------------
L_DECLARE_C_STRUCT_IMPL(EventLog, event_log);
L_DECLARE_C_STRUCT_NEW_DEFAULT(EventLog, event_log);
@ -34,6 +40,10 @@ LinphoneEventLogType linphone_event_log_get_type (const LinphoneEventLog *eventL
return static_cast<LinphoneEventLogType>(eventLog->cppPtr->getType());
}
// -----------------------------------------------------------------------------
// Message event.
// -----------------------------------------------------------------------------
L_DECLARE_C_STRUCT_IMPL(MessageEvent, message_event);
LinphoneMessageEvent *linphone_message_event_new (LinphoneMessage *message) {
@ -47,3 +57,59 @@ LinphoneMessage *linphone_message_event_get_message (const LinphoneMessageEvent
// TODO.
return nullptr;
}
// -----------------------------------------------------------------------------
// Call event.
// -----------------------------------------------------------------------------
// L_DECLARE_C_STRUCT_IMPL(CallEvent, call_event);
LinphoneCallEvent *linphone_call_event_new (LinphoneEventLogType type, LinphoneCall *call) {
// TODO.
return nullptr;
}
LinphoneCall *linphone_call_event_get_call (const LinphoneCallEvent *call_event) {
// TODO.
return nullptr;
}
// -----------------------------------------------------------------------------
// Conference event.
// -----------------------------------------------------------------------------
// L_DECLARE_C_STRUCT_IMPL(ConferenceEvent, conference_event);
LinphoneConferenceEvent *linphone_conference_event_new (
LinphoneEventLogType type,
const LinphoneAddress *address
) {
// TODO.
return nullptr;
}
const LinphoneAddress *linphone_conference_event_get_address (const LinphoneConferenceEvent *conference_event) {
// TODO.
return nullptr;
}
// -----------------------------------------------------------------------------
// Conference participant event.
// -----------------------------------------------------------------------------
// L_DECLARE_C_STRUCT_IMPL(ConferenceParticipantEvent, conference_participant_event);
LinphoneConferenceParticipantEvent *linphone_conference_participant_event_new (
LinphoneEventLogType type,
const LinphoneAddress *conference_address,
const LinphoneAddress *participant_address
) {
// TODO.
return nullptr;
}
const LinphoneAddress *linphone_conference_participant_event_get_participant_address (const LinphoneConferenceParticipantEvent *conference_participant_event) {
// TODO.
return nullptr;
}
}

View file

@ -23,6 +23,10 @@
// =============================================================================
#ifdef __cplusplus
extern "C" {
#endif
LINPHONE_PUBLIC LinphoneEventLog *linphone_event_log_new ();
LINPHONE_PUBLIC LinphoneEventLogType linphone_event_log_get_type (const LinphoneEventLog *event_log);
@ -34,7 +38,7 @@ LINPHONE_PUBLIC LinphoneConferenceEvent *linphone_conference_event_new (
const LinphoneAddress *address
);
LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_event_get_address ();
LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_event_get_address (const LinphoneConferenceEvent *conference_event);
LINPHONE_PUBLIC LinphoneConferenceParticipantEvent *linphone_conference_participant_event_new (
LinphoneEventLogType type,
@ -42,9 +46,13 @@ LINPHONE_PUBLIC LinphoneConferenceParticipantEvent *linphone_conference_particip
const LinphoneAddress *participantAddress
);
LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_participant_event_get_participant_address ();
LINPHONE_PUBLIC const LinphoneAddress *linphone_conference_participant_event_get_participant_address (const LinphoneConferenceParticipantEvent *conference_participant_event);
LINPHONE_PUBLIC LinphoneMessageEvent *linphone_message_event_new (LinphoneMessage *message);
LINPHONE_PUBLIC LinphoneMessage *linphone_message_event_get_message (const LinphoneMessageEvent *message_event);
#ifdef __cplusplus
}
#endif
#endif // ifndef _C_EVENT_LOG_H_

View file

@ -52,7 +52,7 @@
);
#define L_DECLARE_C_STRUCT_NEW_DEFAULT(STRUCT, C_NAME) \
Linphone ## STRUCT * CNAME ## _new() { \
Linphone ## STRUCT * linphone_ ## C_NAME ## _new() { \
Linphone ## STRUCT * object = _linphone_ ## C_NAME ## _init(); \
object->cppPtr = make_shared<LINPHONE_NAMESPACE::STRUCT>(); \
return object; \

View file

@ -19,18 +19,25 @@
#ifndef _C_TYPES_H_
#define _C_TYPES_H_
// Do not move these defines.
#define L_DECLARE_ENUM(CLASS, ENUM) enum Linphone ## CLASS ## ENUM
#define L_DECLARE_C_STRUCT(STRUCT) typedef struct _Linphone ## STRUCT Linphone ## STRUCT;
// Do not move this define.
// Enable C enums.
#define L_USE_C_ENUM
#include "event-log/event-log-enums.h"
#define L_DECLARE_C_ENUM(CLASS, ENUM, VALUES) enum Linphone ## CLASS ## ENUM { VALUES }
#define L_DECLARE_C_STRUCT(STRUCT) typedef struct _Linphone ## STRUCT Linphone ## STRUCT;
// =============================================================================
#ifdef __cplusplus
extern "C" {
#endif
// =============================================================================
// C Structures.
// =============================================================================
L_DECLARE_C_STRUCT(Call);
L_DECLARE_C_STRUCT(CallEvent);
L_DECLARE_C_STRUCT(ConferenceEvent);
@ -42,6 +49,12 @@ L_DECLARE_C_STRUCT(MessageEvent);
// TODO: Remove me in the future.
typedef struct SalAddress LinphoneAddress;
// =============================================================================
// C Enums.
// =============================================================================
L_DECLARE_C_ENUM(EventLog, Type, L_ENUM_VALUES_EVENT_LOG_TYPE);
#ifdef __cplusplus
}
#endif

48
src/c-wrapper/wrapper.h Normal file
View file

@ -0,0 +1,48 @@
/*
* wrapper.h
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _WRAPPER_H_
#define _WRAPPER_H_
#include <utility>
#include "object/object.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class Wrapper {
public:
template<typename T>
static decltype(std::declval<T>().getPrivate()) getPrivate (T *object) {
return object->getPrivate();
}
private:
Wrapper ();
L_DISABLE_COPY(Wrapper);
};
LINPHONE_END_NAMESPACE
#define L_GET_PRIVATE(OBJECT) \
LINPHONE_NAMESPACE::Wrapper::getPrivate(OBJECT)
#endif // ifndef _WRAPPER_H_

127
src/chat/chat-room-p.h Normal file
View file

@ -0,0 +1,127 @@
/*
* chat-room-p.h
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CHAT_ROOM_P_H_
#define _CHAT_ROOM_P_H_
// From coreapi.
#include "private.h"
#include "chat-room.h"
#include "object/object-p.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class ChatRoomPrivate : public ObjectPrivate {
public:
virtual ~ChatRoomPrivate ();
private:
static int refreshComposing (void *data, unsigned int revents);
static int remoteRefreshComposing (void *data, unsigned int revents);
static int stopComposing (void *data, unsigned int revents);
static int createChatMessageFromDb (void *data, int argc, char **argv, char **colName);
static void onWeakMessageDestroyed (void *obj, belle_sip_object_t *messageBeingDestroyed);
public:
void addTransientMessage (LinphoneChatMessage *msg);
void addWeakMessage (LinphoneChatMessage *msg);
std::list<LinphoneChatMessage *> getTransientMessages () const {
return transientMessages;
}
void moveTransientMessageToWeakMessages (LinphoneChatMessage *msg);
void removeTransientMessage (LinphoneChatMessage *msg);
void release ();
void sendImdn (const std::string &content, LinphoneReason reason);
int getMessagesCount (bool unreadOnly);
void setCBackPointer (LinphoneChatRoom *cr) {
this->cBackPointer = cr;
}
void setCall (LinphoneCall *call) {
this->call = call;
}
private:
std::string createIsComposingXml () const;
void deleteComposingIdleTimer ();
void deleteComposingRefreshTimer ();
void deleteRemoteComposingRefreshTimer ();
int refreshComposing (unsigned int revents);
int remoteRefreshComposing (unsigned int revents);
void sendIsComposingNotification ();
int stopComposing (unsigned int revents);
void processImdn (xmlparsing_context_t *xmlCtx);
void processIsComposingNotification (xmlparsing_context_t *xmlCtx);
int createChatMessageFromDb (int argc, char **argv, char **colName);
void onWeakMessageDestroyed (LinphoneChatMessage *messageBeingDestroyed);
LinphoneChatMessage *getTransientMessage (unsigned int storageId) const;
LinphoneChatMessage *getWeakMessage (unsigned int storageId) const;
int sqlRequest (sqlite3 *db, const std::string &stmt);
void sqlRequestMessage (sqlite3 *db, const std::string &stmt);
std::list<LinphoneChatMessage *> findMessages (const std::string &messageId);
LinphoneChatMessage *findMessageWithDirection (const std::string &messageId, LinphoneChatMessageDir direction);
void storeOrUpdateMessage (LinphoneChatMessage *msg);
public:
LinphoneReason messageReceived (SalOp *op, const SalMessage *msg);
void realtimeTextReceived (uint32_t character, LinphoneCall *call);
private:
void chatMessageReceived (LinphoneChatMessage *msg);
void imdnReceived (const std::string &text);
void isComposingReceived (const std::string &text);
public:
static const int composingDefaultIdleTimeout = 15;
static const int composingDefaultRefreshTimeout = 60;
static const int composingDefaultRemoteRefreshTimeout = 120;
static const std::string imdnPrefix;
static const std::string isComposingPrefix;
LinphoneChatRoom *cBackPointer = nullptr;
LinphoneCore *core = nullptr;
LinphoneCall *call = nullptr;
LinphoneAddress *peerAddress = nullptr;
std::string peer;
int unreadCount = -1;
bool isComposing = false;
bool remoteIsComposing = false;
belle_sip_source_t *remoteComposingRefreshTimer = nullptr;
belle_sip_source_t *composingIdleTimer = nullptr;
belle_sip_source_t *composingRefreshTimer = nullptr;
std::list<LinphoneChatMessage *> messages;
std::list<LinphoneChatMessage *> transientMessages;
std::list<LinphoneChatMessage *> weakMessages;
std::list<LinphoneChatMessageCharacter *> receivedRttCharacters;
LinphoneChatMessage *pendingMessage = nullptr;
private:
L_DECLARE_PUBLIC(ChatRoom);
};
LINPHONE_END_NAMESPACE
#endif // ifndef _CHAT_ROOM_P_H_

1235
src/chat/chat-room.cpp Normal file

File diff suppressed because it is too large Load diff

66
src/chat/chat-room.h Normal file
View file

@ -0,0 +1,66 @@
/*
* chat-room.h
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CHAT_ROOM_H_
#define _CHAT_ROOM_H_
#include <list>
#include "object/object.h"
#include "linphone/types.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class ChatRoomPrivate;
class ChatRoom : public Object {
public:
ChatRoom (LinphoneCore *core, LinphoneAddress *peerAddress);
virtual ~ChatRoom () = default;
void compose ();
LinphoneChatMessage *createFileTransferMessage (const LinphoneContent *initialContent);
LinphoneChatMessage *createMessage (const std::string &msg);
void deleteHistory ();
void deleteMessage (LinphoneChatMessage *msg);
LinphoneChatMessage *findMessage (const std::string &messageId);
uint32_t getChar () const;
std::list<LinphoneChatMessage *> getHistory (int nbMessages);
int getHistorySize ();
std::list<LinphoneChatMessage *> getHistoryRange (int startm, int endm);
int getUnreadMessagesCount ();
bool isRemoteComposing () const;
void markAsRead ();
void sendMessage (LinphoneChatMessage *msg);
LinphoneCall *getCall () const;
LinphoneCore *getCore () const;
const LinphoneAddress *getPeerAddress () const;
private:
L_DECLARE_PRIVATE(ChatRoom);
L_DISABLE_COPY(ChatRoom);
};
LINPHONE_END_NAMESPACE
#endif // ifndef _CHAT_ROOM_H_

View file

@ -252,17 +252,17 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {}
bool EventsDb::addEvent (const EventLog &eventLog) {
// TODO.
switch (eventLog.getType()) {
case EventLog::NoneEvent:
case EventLog::TypeNone:
return false;
case EventLog::MessageEvent:
case EventLog::CallStartEvent:
case EventLog::CallEndEvent:
case EventLog::ConferenceCreatedEvent:
case EventLog::ConferenceDestroyedEvent:
case EventLog::ConferenceParticipantAddedEvent:
case EventLog::ConferenceParticipantRemovedEvent:
case EventLog::ConferenceParticipantSetAdminEvent:
case EventLog::ConferenceParticipantUnsetAdminEvent:
case EventLog::TypeMessage:
case EventLog::TypeCallStart:
case EventLog::TypeCallEnd:
case EventLog::TypeConferenceCreated:
case EventLog::TypeConferenceDestroyed:
case EventLog::TypeConferenceParticipantAdded:
case EventLog::TypeConferenceParticipantRemoved:
case EventLog::TypeConferenceParticipantSetAdmin:
case EventLog::TypeConferenceParticipantUnsetAdmin:
break;
}

View file

@ -25,7 +25,12 @@
LINPHONE_BEGIN_NAMESPACE
// Nothing. for the moment.
enum class Transport {
Udp,
Tcp,
Tls,
Dtls
};
LINPHONE_END_NAMESPACE

View file

@ -36,7 +36,7 @@ public:
CallEvent::CallEvent (Type type, const shared_ptr<Call> &call) : EventLog(*new CallEventPrivate, type) {
L_D(CallEvent);
L_ASSERT(call);
L_ASSERT(type == CallStartEvent || type == CallEndEvent);
L_ASSERT(type == TypeCallStart || type == TypeCallEnd);
d->call = call;
}

View file

@ -29,7 +29,7 @@ LINPHONE_BEGIN_NAMESPACE
ConferenceEvent::ConferenceEvent (Type type, const shared_ptr<const Address> &address) :
EventLog(*new ConferenceEventPrivate, type) {
L_D(ConferenceEvent);
L_ASSERT(type == ConferenceCreatedEvent || type == ConferenceDestroyedEvent);
L_ASSERT(type == TypeConferenceCreated || type == TypeConferenceDestroyed);
L_ASSERT(address);
// TODO: Duplicate address.
d->address = address;

View file

@ -40,10 +40,10 @@ ConferenceParticipantEvent::ConferenceParticipantEvent (
) : ConferenceEvent(*new ConferenceParticipantEventPrivate, type, conferenceAddress) {
L_D(ConferenceParticipantEvent);
L_ASSERT(
type == ConferenceParticipantAddedEvent ||
type == ConferenceParticipantRemovedEvent ||
type == ConferenceParticipantSetAdminEvent ||
type == ConferenceParticipantUnsetAdminEvent
type == TypeConferenceParticipantAdded ||
type == TypeConferenceParticipantRemoved ||
type == TypeConferenceParticipantSetAdmin ||
type == TypeConferenceParticipantUnsetAdmin
);
L_ASSERT(participantAddress);
// TODO: Duplicate address.

View file

@ -19,25 +19,22 @@
#ifndef _EVENT_LOG_ENUMS_H_
#define _EVENT_LOG_ENUMS_H_
#include "utils/general.h"
#include "utils/enum-generator.h"
// =============================================================================
L_DECLARE_ENUM(EventLog, Type) {
NoneEvent,
// MessageEvent.
MessageEvent,
// CallEvent.
CallStartEvent,
CallEndEvent,
// ConferenceEvent.
ConferenceCreatedEvent,
ConferenceDestroyedEvent,
// ConferenceParticipantEvent.
ConferenceParticipantAddedEvent,
ConferenceParticipantRemovedEvent,
ConferenceParticipantSetAdminEvent,
ConferenceParticipantUnsetAdminEvent
};
#define L_ENUM_VALUES_EVENT_LOG_TYPE \
L_DECLARE_ENUM_VALUES(EventLog, Type, \
None, \
Message, \
CallStart, \
CallEnd, \
ConferenceCreated, \
ConferenceDestroyed, \
ConferenceParticipantAdded, \
ConferenceParticipantRemoved, \
ConferenceParticipantSetAdmin, \
ConferenceParticipantUnsetAdmin \
)
#endif // ifndef _EVENT_LOG_ENUMS_H_

View file

@ -28,7 +28,7 @@ LINPHONE_BEGIN_NAMESPACE
class EventLogPrivate : public ClonableObjectPrivate {
private:
EventLog::Type type = EventLog::NoneEvent;
EventLog::Type type = EventLog::TypeNone;
L_DECLARE_PUBLIC(EventLog);
};

View file

@ -20,6 +20,7 @@
#define _EVENT_LOG_H_
#include "object/clonable-object.h"
#include "event-log-enums.h"
// =============================================================================
@ -29,7 +30,9 @@ class EventLogPrivate;
class LINPHONE_PUBLIC EventLog : public ClonableObject {
public:
enum Type : int;
enum Type {
L_ENUM_VALUES_EVENT_LOG_TYPE
};
EventLog ();
EventLog (const EventLog &src);
@ -46,8 +49,6 @@ private:
L_DECLARE_PRIVATE(EventLog);
};
#include "event-log-enums.h"
LINPHONE_END_NAMESPACE
#endif // ifndef _EVENT_LOG_H_

View file

@ -34,7 +34,7 @@ public:
// -----------------------------------------------------------------------------
MessageEvent::MessageEvent (const shared_ptr<Message> &message) :
EventLog(*new MessageEventPrivate, EventLog::MessageEvent) {
EventLog(*new MessageEventPrivate, EventLog::TypeMessage) {
L_D(MessageEvent);
L_ASSERT(message);
d->message = message;

View file

@ -23,7 +23,6 @@
#include <memory>
#include <string>
#include "enums.h"
#include "object/object.h"
// =============================================================================

View file

@ -0,0 +1,43 @@
/*
* content-type.cpp
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "content-type.h"
// =============================================================================
using namespace std;
LINPHONE_BEGIN_NAMESPACE
bool ContentType::isFileTransfer (const string &contentType) {
return "application/vnd.gsma.rcs-ft-http+xml" == contentType;
}
bool ContentType::isImIsComposing (const string &contentType) {
return "application/im-iscomposing+xml" == contentType;
}
bool ContentType::isImdn (const string &contentType) {
return "message/imdn+xml" == contentType;
}
bool ContentType::isText (const string &contentType) {
return "text/plain" == contentType;
}
LINPHONE_END_NAMESPACE

39
src/utils/content-type.h Normal file
View file

@ -0,0 +1,39 @@
/*
* content-type.h
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CONTENT_TYPE_H_
#define _CONTENT_TYPE_H_
#include <string>
#include "general.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
namespace ContentType {
bool isFileTransfer (const std::string &contentType);
bool isImIsComposing (const std::string &contentType);
bool isImdn (const std::string &contentType);
bool isText (const std::string &contentType);
}
LINPHONE_END_NAMESPACE
#endif // ifndef _CONTENT_TYPE_H_

View file

@ -0,0 +1,40 @@
/*
* enum-generator.h
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _ENUM_GENERATOR_H_
#define _ENUM_GENERATOR_H_
#include "magic-macros.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
#define L_ENUM_VALUE(C, VALUE) C ## VALUE
#ifndef L_USE_C_ENUM
#define L_DECLARE_ENUM_VALUES(CLASS_NAME, ENUM_NAME, ...) \
MM_APPLY_COMMA(L_ENUM_VALUE, ENUM_NAME, __VA_ARGS__)
#else
#define L_DECLARE_ENUM_VALUES(CLASS_NAME, ENUM_NAME, ...) \
MM_APPLY_COMMA(L_ENUM_VALUE, Linphone ## CLASS_NAME ## ENUM_NAME, __VA_ARGS__)
#endif // ifndef L_USE_C_ENUM
LINPHONE_END_NAMESPACE
#endif // ifndef _ENUM_GENERATOR_H_

View file

@ -55,10 +55,6 @@ LINPHONE_BEGIN_NAMESPACE
#ifdef __cplusplus
#ifndef L_DECLARE_ENUM
#define L_DECLARE_ENUM(CLASS, ENUM) enum CLASS::ENUM : int
#endif
void l_assert (const char *condition, const char *file, int line);
#ifdef DEBUG
@ -67,6 +63,8 @@ void l_assert (const char *condition, const char *file, int line);
#define L_ASSERT(CONDITION) ((CONDITION) ? static_cast<void>(0) : l_assert(#CONDITION, __FILE__, __LINE__))
#endif
// Allows access to private internal data.
// Gives a control to C Wrapper.
#define L_DECLARE_PRIVATE(CLASS) \
inline CLASS ## Private * getPrivate() { \
return reinterpret_cast<CLASS ## Private *>(mPrivate); \
@ -74,7 +72,8 @@ void l_assert (const char *condition, const char *file, int line);
inline const CLASS ## Private *getPrivate() const { \
return reinterpret_cast<const CLASS ## Private *>(mPrivate); \
} \
friend class CLASS ## Private;
friend class CLASS ## Private; \
friend class Wrapper;
class ClonableObject;
class ClonableObjectPrivate;

240
src/utils/magic-macros.h Normal file
View file

@ -0,0 +1,240 @@
/*
* magic-macros.h
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _MAGIC_MACROS_H_
#define _MAGIC_MACROS_H_
#include "general.h"
// =============================================================================
// Original header.
// Source: https://github.com/facebookresearch/ELF/blob/master/elf/pybind_helper.h
// =============================================================================
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
// File: macros.h
// Author: Yuxin Wu <ppwwyyxxc@gmail.com>
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
#define MM_CONCAT__(A, B) A ## B
#define MM_CONCAT_(A, B) MM_CONCAT__(A, B)
#define MM_CONCAT(A, B) MM_CONCAT_(A, B)
#define MM_INVOKE(MACRO, ARGS) MACRO ARGS
#define MM_INVOKE_B(MACRO, ARGS) MACRO ARGS
#define MM_APPLY_1(MACRONAME, C, A1) \
MM_INVOKE_B(MACRONAME, (C, A1))
#define MM_APPLY_2(MACRONAME, C, A1, A2) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_1(MACRONAME, C, A2)
#define MM_APPLY_3(MACRONAME, C, A1, A2, A3) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_2(MACRONAME, C, A2, A3)
#define MM_APPLY_4(MACRONAME, C, A1, A2, A3, A4) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_3(MACRONAME, C, A2, A3, A4)
#define MM_APPLY_5(MACRONAME, C, A1, A2, A3, A4, A5) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_4(MACRONAME, C, A2, A3, A4, A5)
#define MM_APPLY_6(MACRONAME, C, A1, A2, A3, A4, A5, A6) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_5(MACRONAME, C, A2, A3, A4, A5, A6)
#define MM_APPLY_7(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_6(MACRONAME, C, A2, A3, A4, A5, A6, A7)
#define MM_APPLY_8(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_7(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8)
#define MM_APPLY_9(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_8(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9)
#define MM_APPLY_10(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_9(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10)
#define MM_APPLY_11(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_10(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)
#define MM_APPLY_12(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_11(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12)
#define MM_APPLY_13(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_12(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13)
#define MM_APPLY_14(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_13(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14)
#define MM_APPLY_15(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_14(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15)
#define MM_APPLY_16(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_15(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16)
#define MM_APPLY_17(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_16(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17)
#define MM_APPLY_18(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_17(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18)
#define MM_APPLY_19(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_18(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19)
#define MM_APPLY_20(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_19(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20)
#define MM_APPLY_21(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_20(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21)
#define MM_APPLY_22(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22) \
MM_INVOKE_B(MACRONAME, (C, A1)) \
MM_APPLY_21(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22)
#define MM_NARG(...) \
MM_NARG_(__VA_ARGS__, MM_RSEQ_N())
#define MM_NARG_(...) \
MM_ARG_N(__VA_ARGS__)
#define MM_ARG_N( \
_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \
_11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \
_21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \
_31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \
_41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \
_51, _52, _53, _54, _55, _56, _57, _58, _59, _60, \
_61, _62, _63, N, ...) N
#define MM_RSEQ_N() \
63, 62, 61, 60, \
59, 58, 57, 56, 55, 54, 53, 52, 51, 50, \
49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \
39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \
29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \
9, 8, 7, 6, 5, 4, 3, 2, 1, 0
#define MM_APPLY(MACRONAME, C, ...) \
MM_INVOKE( \
MM_CONCAT(MM_APPLY_, MM_NARG(__VA_ARGS__)), \
(MACRONAME, C, __VA_ARGS__) \
)
#define MM_APPLY_COMMA(MACRONAME, C, ...) \
MM_INVOKE( \
MM_CONCAT(MM_APPLY_COMMA_, MM_NARG(__VA_ARGS__)), \
(MACRONAME, C, __VA_ARGS__) \
)
#define MM_APPLY_COMMA_1(MACRONAME, C, A1) \
MM_INVOKE_B(MACRONAME, (C, A1))
#define MM_APPLY_COMMA_2(MACRONAME, C, A1, A2) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_1(MACRONAME, C, A2)
#define MM_APPLY_COMMA_3(MACRONAME, C, A1, A2, A3) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_2(MACRONAME, C, A2, A3)
#define MM_APPLY_COMMA_4(MACRONAME, C, A1, A2, A3, A4) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_3(MACRONAME, C, A2, A3, A4)
#define MM_APPLY_COMMA_5(MACRONAME, C, A1, A2, A3, A4, A5) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_4(MACRONAME, C, A2, A3, A4, A5)
#define MM_APPLY_COMMA_6(MACRONAME, C, A1, A2, A3, A4, A5, A6) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_5(MACRONAME, C, A2, A3, A4, A5, A6)
#define MM_APPLY_COMMA_7(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_6(MACRONAME, C, A2, A3, A4, A5, A6, A7)
#define MM_APPLY_COMMA_8(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_7(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8)
#define MM_APPLY_COMMA_9(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_8(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9)
#define MM_APPLY_COMMA_10(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_9(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10)
#define MM_APPLY_COMMA_11(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_10(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)
#define MM_APPLY_COMMA_12(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_11(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12)
#define MM_APPLY_COMMA_13(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_12(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13)
#define MM_APPLY_COMMA_14(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_13(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14)
#define MM_APPLY_COMMA_15(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_14(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15)
#define MM_APPLY_COMMA_16(MACRONAME, C, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16) \
MM_INVOKE_B(MACRONAME, (C, A1)), \
MM_APPLY_COMMA_15(MACRONAME, C, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16)
LINPHONE_END_NAMESPACE
#endif // ifndef _MAGIC_MACROS_H_

View file

@ -17,6 +17,9 @@
*/
#include <cstdlib>
#include <sstream>
#include <bctoolbox/port.h>
#include "utils.h"
@ -50,6 +53,30 @@ vector<string> Utils::split (const string &str, const string &delimiter) {
return out;
}
#ifndef __ANDROID__
#define TO_STRING_IMPL(TYPE) \
string Utils::toString(TYPE val) { \
return to_string(val); \
}
#else
#define TO_STRING_IMPL(TYPE) \
string Utils::toString(TYPE val) { \
ostringstream os; \
os << val; \
return os.str(); \
}
#endif // ifndef __ANDROID__
TO_STRING_IMPL(int)
TO_STRING_IMPL(long)
TO_STRING_IMPL(long long)
TO_STRING_IMPL(unsigned)
TO_STRING_IMPL(unsigned long)
TO_STRING_IMPL(unsigned long long)
TO_STRING_IMPL(float)
TO_STRING_IMPL(double)
TO_STRING_IMPL(long double)
int Utils::stoi (const string &str, size_t *idx, int base) {
char *p;
int v = strtol(str.c_str(), &p, base);
@ -60,4 +87,30 @@ int Utils::stoi (const string &str, size_t *idx, int base) {
return v;
}
char *Utils::utf8ToChar (uint32_t ic) {
char *result = new char[5];
int size = 0;
if (ic < 0x80) {
result[0] = ic;
size = 1;
} else if (ic < 0x800) {
result[1] = 0x80 + ((ic & 0x3F));
result[0] = 0xC0 + ((ic >> 6) & 0x1F);
size = 2;
} else if (ic < 0x100000) {
result[2] = 0x80 + (ic & 0x3F);
result[1] = 0x80 + ((ic >> 6) & 0x3F);
result[0] = 0xE0 + ((ic >> 12) & 0xF);
size = 3;
} else if (ic < 0x110000) {
result[3] = 0x80 + (ic & 0x3F);
result[2] = 0x80 + ((ic >> 6) & 0x3F);
result[1] = 0x80 + ((ic >> 12) & 0x3F);
result[0] = 0xF0 + ((ic >> 18) & 0x7);
size = 4;
}
result[size] = '\0';
return result;
}
LINPHONE_END_NAMESPACE

View file

@ -37,7 +37,20 @@ namespace Utils {
return split(str, std::string(1, delimiter));
}
LINPHONE_PUBLIC std::string toString (int val);
LINPHONE_PUBLIC std::string toString (long val);
LINPHONE_PUBLIC std::string toString (long long val);
LINPHONE_PUBLIC std::string toString (unsigned val);
LINPHONE_PUBLIC std::string toString (unsigned long val);
LINPHONE_PUBLIC std::string toString (unsigned long long val);
LINPHONE_PUBLIC std::string toString (float val);
LINPHONE_PUBLIC std::string toString (double val);
LINPHONE_PUBLIC std::string toString (long double val);
LINPHONE_PUBLIC int stoi (const std::string &str, size_t *idx = 0, int base = 10);
// Return a buffer allocated with new.
LINPHONE_PUBLIC char *utf8ToChar (uint32_t ic);
}
LINPHONE_END_NAMESPACE

View file

@ -1044,6 +1044,7 @@ static void terminate_call_with_error(void) {
BC_ASSERT_STRING_EQUAL(linphone_error_info_get_phrase(rei), "Call refused for security reason");
BC_ASSERT_STRING_EQUAL(linphone_error_info_get_protocol(ei), "SIP");
}
BC_ASSERT_EQUAL(linphone_call_log_get_status(linphone_call_get_call_log(call_callee)), LinphoneCallAcceptedElsewhere, int, "%d");
BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallReleased,1));
@ -1094,6 +1095,7 @@ static void cancel_call_with_error(void) {
BC_ASSERT_STRING_EQUAL(linphone_error_info_get_phrase(rei), "Call has been cancelled");
BC_ASSERT_STRING_EQUAL(linphone_error_info_get_protocol(rei), "SIP");
}
BC_ASSERT_EQUAL(linphone_call_log_get_status(linphone_call_get_call_log(call_callee)), LinphoneCallDeclinedElsewhere, int, "%d");
BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallReleased,1));
@ -1142,6 +1144,7 @@ static void cancel_other_device_after_accept(void) {
BC_ASSERT_STRING_EQUAL(linphone_error_info_get_phrase(rei), "Call completed elsewhere");
BC_ASSERT_STRING_EQUAL(linphone_error_info_get_protocol(rei), "SIP");
}
BC_ASSERT_EQUAL(linphone_call_log_get_status(linphone_call_get_call_log(call_callee_2)), LinphoneCallAcceptedElsewhere, int, "%d");
}
linphone_call_terminate(out_call);
BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallEnd,1));
@ -1179,10 +1182,12 @@ static void cancel_other_device_after_decline(void) {
BC_ASSERT_PTR_NOT_NULL(call_callee_2);
BC_ASSERT_EQUAL(linphone_call_decline(call_callee, LinphoneReasonDeclined), 0 , int, "%d");
BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallEnd,1));
BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallEnd,1));
BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallReleased, 1));
BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr_2->lc,&callee_mgr_2->stat.number_of_LinphoneCallEnd,1));
BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr_2->lc,&callee_mgr_2->stat.number_of_LinphoneCallReleased,1));
BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallEnd,1));
BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallReleased, 1));
BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr_2->lc, &callee_mgr_2->stat.number_of_LinphoneCallEnd,1));
BC_ASSERT_TRUE(wait_for(caller_mgr->lc,callee_mgr_2->lc, &callee_mgr_2->stat.number_of_LinphoneCallReleased,1));
rei = linphone_call_get_error_info(call_callee_2);
BC_ASSERT_PTR_NOT_NULL(rei);
@ -1192,6 +1197,7 @@ static void cancel_other_device_after_decline(void) {
BC_ASSERT_STRING_EQUAL(linphone_error_info_get_phrase(rei), "Busy Everywhere");
BC_ASSERT_STRING_EQUAL(linphone_error_info_get_protocol(rei), "SIP");
}
BC_ASSERT_EQUAL(linphone_call_log_get_status(linphone_call_get_call_log(call_callee_2)), LinphoneCallDeclinedElsewhere, int, "%d");
}
if (out_call) linphone_call_unref(out_call);
if (call_callee) linphone_call_unref(call_callee);

View file

@ -161,7 +161,7 @@ void file_transfer_progress_indication(LinphoneChatMessage *msg, const LinphoneC
void is_composing_received(LinphoneCore *lc, LinphoneChatRoom *room) {
stats *counters = get_stats(lc);
if (room->remote_is_composing == LinphoneIsComposingActive) {
if (linphone_chat_room_is_remote_composing(room)) {
counters->number_of_LinphoneIsComposingActiveReceived++;
} else {
counters->number_of_LinphoneIsComposingIdleReceived++;
@ -236,7 +236,7 @@ LinphoneChatMessage* create_message_from_sintel_trailer(LinphoneChatRoom *chat_r
file_size = ftell(file_to_send);
fseek(file_to_send, 0, SEEK_SET);
content = linphone_core_create_content(chat_room->lc);
content = linphone_core_create_content(linphone_chat_room_get_core(chat_room));
belle_sip_object_set_name(&content->base, "sintel trailer content");
linphone_content_set_type(content,"video");
linphone_content_set_subtype(content,"mkv");
@ -262,7 +262,7 @@ LinphoneChatMessage* create_file_transfer_message_from_sintel_trailer(LinphoneCh
LinphoneChatMessage* msg;
char *send_filepath = bc_tester_res("sounds/sintel_trailer_opus_h264.mkv");
content = linphone_core_create_content(chat_room->lc);
content = linphone_core_create_content(linphone_chat_room_get_core(chat_room));
belle_sip_object_set_name(&content->base, "sintel trailer content");
linphone_content_set_type(content,"video");
linphone_content_set_subtype(content,"mkv");
@ -413,15 +413,15 @@ static void text_message_with_send_error(void) {
linphone_chat_room_send_chat_message(chat_room,msg);
/* check transient msg list: the msg should be in it, and should be the only one */
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(chat_room->transient_messages), 1, unsigned int, "%u");
BC_ASSERT_PTR_EQUAL(bctbx_list_nth_data(chat_room->transient_messages,0), msg);
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_chat_room_get_transient_messages(chat_room)), 1, unsigned int, "%u");
BC_ASSERT_PTR_EQUAL(bctbx_list_nth_data(linphone_chat_room_get_transient_messages(chat_room),0), msg);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageNotDelivered,1));
/*BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageInProgress,1, int, "%d");*/
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageReceived,0, int, "%d");
/* the msg should have been discarded from transient list after an error */
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(chat_room->transient_messages), 0, unsigned int, "%u");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_chat_room_get_transient_messages(chat_room)), 0, unsigned int, "%u");
sal_set_send_error(marie->lc->sal, 0);
@ -446,8 +446,8 @@ static void text_message_with_external_body(void) {
linphone_chat_room_send_chat_message(chat_room,msg);
/* check transient msg list: the msg should be in it, and should be the only one */
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(chat_room->transient_messages), 1, unsigned int, "%u");
BC_ASSERT_PTR_EQUAL(bctbx_list_nth_data(chat_room->transient_messages,0), msg);
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_chat_room_get_transient_messages(chat_room)), 1, unsigned int, "%u");
BC_ASSERT_PTR_EQUAL(bctbx_list_nth_data(linphone_chat_room_get_transient_messages(chat_room),0), msg);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageDelivered,1));
@ -455,7 +455,7 @@ static void text_message_with_external_body(void) {
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,1, int, "%d");
BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageExtBodyReceived,1, int, "%d");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(chat_room->transient_messages), 0, unsigned int, "%u");
BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_chat_room_get_transient_messages(chat_room)), 0, unsigned int, "%u");
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);