Commit 9867c2fe authored by Ghislain MARY's avatar Ghislain MARY

Send and receive imdn.

parent 41b9cf9c
......@@ -595,6 +595,8 @@ void sal_set_callbacks(Sal *ctx, const SalCallbacks *cbs){
ctx->callbacks.text_received=(SalOnTextReceived)unimplemented_stub;
if (ctx->callbacks.is_composing_received==NULL)
ctx->callbacks.is_composing_received=(SalOnIsComposingReceived)unimplemented_stub;
if (ctx->callbacks.imdn_received == NULL)
ctx->callbacks.imdn_received = (SalOnImdnReceived)unimplemented_stub;
if (ctx->callbacks.ping_reply==NULL)
ctx->callbacks.ping_reply=(SalOnPingReply)unimplemented_stub;
if (ctx->callbacks.auth_requested==NULL)
......
......@@ -68,8 +68,13 @@ static bool_t is_im_iscomposing(belle_sip_header_content_type_t* content_type) {
&& strcmp("im-iscomposing+xml",belle_sip_header_content_type_get_subtype(content_type))==0;
}
static bool_t is_imdn_xml(belle_sip_header_content_type_t *content_type) {
return (strcmp("message", belle_sip_header_content_type_get_type(content_type)) == 0)
&& (strcmp("imdn+xml", belle_sip_header_content_type_get_subtype(content_type)) == 0);
}
static void add_message_accept(belle_sip_message_t *msg){
belle_sip_message_add_header(msg,belle_sip_header_create("Accept","text/plain, message/external-body, application/im-iscomposing+xml, xml/cipher, application/vnd.gsma.rcs-ft-http+xml, application/cipher.vnd.gsma.rcs-ft-http+xml"));
belle_sip_message_add_header(msg,belle_sip_header_create("Accept","text/plain, message/external-body, application/im-iscomposing+xml, xml/cipher, application/vnd.gsma.rcs-ft-http+xml, application/cipher.vnd.gsma.rcs-ft-http+xml, message/imdn+xml"));
}
void sal_process_incoming_message(SalOp *op,const belle_sip_request_event_t *event){
......@@ -105,6 +110,16 @@ void sal_process_incoming_message(SalOp *op,const belle_sip_request_event_t *eve
op->base.root->callbacks.is_composing_received(op,&saliscomposing);
belle_sip_object_unref(address);
belle_sip_free(from);
} else if (is_imdn_xml(content_type)) {
SalImdn salimdn;
address = belle_sip_header_address_create(belle_sip_header_address_get_displayname(BELLE_SIP_HEADER_ADDRESS(from_header)),
belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(from_header)));
from = belle_sip_object_to_string(BELLE_SIP_OBJECT(address));
salimdn.from = from;
salimdn.content = belle_sip_message_get_body(BELLE_SIP_MESSAGE(req));
op->base.root->callbacks.imdn_received(op, &salimdn);
belle_sip_object_unref(address);
belle_sip_free(from);
} else {
SalMessage salmsg;
char message_id[256]={0};
......
......@@ -1187,6 +1187,13 @@ static void is_composing_received(SalOp *op, const SalIsComposing *is_composing)
sal_op_release(op);
}
static void imdn_received(SalOp *op, const SalImdn *imdn) {
LinphoneCore *lc = (LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
LinphoneReason reason = linphone_core_imdn_received(lc, op, imdn);
sal_message_reply(op, linphone_reason_to_sal(reason));
sal_op_release(op);
}
static void parse_presence_requested(SalOp *op, const char *content_type, const char *content_subtype, const char *body, SalPresenceModel **result) {
linphone_notify_parse_presence(content_type, content_subtype, body, result);
}
......@@ -1503,6 +1510,7 @@ SalCallbacks linphone_sal_callbacks={
text_received,
text_delivery_update,
is_composing_received,
imdn_received,
notify_refer,
subscribe_received,
incoming_subscribe_closed,
......
This diff is collapsed.
......@@ -81,13 +81,17 @@ static void linphone_chat_message_file_transfer_on_progress(belle_sip_body_handl
_release_http_request(msg);
return;
}
if (linphone_chat_message_cbs_get_file_transfer_progress_indication(msg->callbacks)) {
linphone_chat_message_cbs_get_file_transfer_progress_indication(msg->callbacks)(
msg, msg->file_transfer_information, offset, total);
if (linphone_chat_room_cbs_get_file_transfer_progress_indication(msg->chat_room->callbacks)) {
linphone_chat_room_cbs_get_file_transfer_progress_indication(msg->chat_room->callbacks)(msg->chat_room, 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,
offset, total);
if (linphone_chat_message_cbs_get_file_transfer_progress_indication(msg->callbacks)) {
linphone_chat_message_cbs_get_file_transfer_progress_indication(msg->callbacks)(
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,
offset, total);
}
}
}
......@@ -111,9 +115,9 @@ static int on_send_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t *
/* in case of file body handler, won't be called */
if (offset < linphone_content_get_size(msg->file_transfer_information)) {
/* get data from call back */
LinphoneChatMessageCbsFileTransferSendCb file_transfer_send_cb = linphone_chat_message_cbs_get_file_transfer_send(msg->callbacks);
if (file_transfer_send_cb) {
LinphoneBuffer *lb = file_transfer_send_cb(msg, msg->file_transfer_information, offset, *size);
LinphoneChatRoomCbsFileTransferSendCb cr_file_transfer_send_cb = linphone_chat_room_cbs_get_file_transfer_send(msg->chat_room->callbacks);
if (cr_file_transfer_send_cb) {
LinphoneBuffer *lb = cr_file_transfer_send_cb(msg->chat_room, msg, msg->file_transfer_information, offset, *size);
if (lb == NULL) {
*size = 0;
} else {
......@@ -122,8 +126,20 @@ static int on_send_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t *
linphone_buffer_unref(lb);
}
} else {
/* Legacy */
linphone_core_notify_file_transfer_send(lc, msg, msg->file_transfer_information, (char *)buffer, size);
LinphoneChatMessageCbsFileTransferSendCb file_transfer_send_cb = linphone_chat_message_cbs_get_file_transfer_send(msg->callbacks);
if (file_transfer_send_cb) {
LinphoneBuffer *lb = file_transfer_send_cb(msg, msg->file_transfer_information, offset, *size);
if (lb == NULL) {
*size = 0;
} else {
*size = linphone_buffer_get_size(lb);
memcpy(buffer, linphone_buffer_get_content(lb), *size);
linphone_buffer_unref(lb);
}
} else {
/* Legacy */
linphone_core_notify_file_transfer_send(lc, msg, msg->file_transfer_information, (char *)buffer, size);
}
}
}
......@@ -397,13 +413,19 @@ static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t
ms_free(decrypted_buffer);
if (retval <= 0) {
if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) {
if (linphone_chat_room_cbs_get_file_transfer_recv(msg->chat_room->callbacks)) {
LinphoneBuffer *lb = linphone_buffer_new_from_data(buffer, size);
linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb);
linphone_chat_room_cbs_get_file_transfer_recv(msg->chat_room->callbacks)(msg->chat_room, msg, msg->file_transfer_information, lb);
linphone_buffer_unref(lb);
} else {
/* Legacy: call back given by application level */
linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, (const char *)buffer, size);
if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) {
LinphoneBuffer *lb = linphone_buffer_new_from_data(buffer, size);
linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb);
linphone_buffer_unref(lb);
} else {
/* Legacy: call back given by application level */
linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, (const char *)buffer, size);
}
}
} else {
ms_warning("File transfer decrypt failed with code %d", (int)retval);
......@@ -428,16 +450,22 @@ static void on_recv_end(belle_sip_user_body_handler_t *bh, void *data) {
}
if (retval <= 0) {
if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) {
if (linphone_chat_room_cbs_get_file_transfer_recv(msg->chat_room->callbacks)) {
LinphoneBuffer *lb = linphone_buffer_new();
linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb);
linphone_chat_room_cbs_get_file_transfer_recv(msg->chat_room->callbacks)(msg->chat_room, msg, msg->file_transfer_information, lb);
linphone_buffer_unref(lb);
} else {
/* Legacy: call back given by application level */
linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0);
if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) {
LinphoneBuffer *lb = linphone_buffer_new();
linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb);
linphone_buffer_unref(lb);
} else {
/* Legacy: call back given by application level */
linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0);
}
}
}
if (retval <= 0 && linphone_chat_message_get_state(msg) != LinphoneChatMessageStateFileTransferError) {
linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone);
}
......
......@@ -44,7 +44,7 @@ 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) {
static void file_transfer_progress_indication(LinphoneChatRoom *room,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);
char *address = linphone_chat_message_is_outgoing(message)?linphone_address_as_string(to_address):linphone_address_as_string(from_address);
......@@ -59,7 +59,7 @@ static void file_transfer_progress_indication(LinphoneChatMessage *message, cons
/**
* function invoked when a file transfer is received.
**/
static void file_transfer_received(LinphoneChatMessage *message, const LinphoneContent* content, const LinphoneBuffer *buffer){
static void file_transfer_received(LinphoneChatRoom *room, LinphoneChatMessage *message, const LinphoneContent* content, const LinphoneBuffer *buffer){
FILE* file=NULL;
if (!linphone_chat_message_get_user_data(message)) {
/*first chunk, creating file*/
......@@ -85,7 +85,7 @@ char big_file [128000];
/*
* function called when the file transfer is initiated. file content should be feed into object LinphoneContent
* */
static LinphoneBuffer * file_transfer_send(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t size){
static LinphoneBuffer * file_transfer_send(LinphoneChatRoom *room, LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t size){
size_t size_to_send = MIN(size, sizeof(big_file) - offset);
if (size == 0) return linphone_buffer_new(); /*end of file*/
return linphone_buffer_new_from_data((uint8_t *)big_file + offset, size_to_send);
......@@ -94,7 +94,7 @@ static LinphoneBuffer * file_transfer_send(LinphoneChatMessage *message, const
/*
* Call back to get delivery status of a message
* */
static void linphone_file_transfer_state_changed(LinphoneChatMessage* msg,LinphoneChatMessageState state) {
static void linphone_file_transfer_state_changed(LinphoneChatRoom *room,LinphoneChatMessage* msg,LinphoneChatMessageState state) {
const LinphoneAddress* to_address = linphone_chat_message_get_to(msg);
char *to = linphone_address_as_string(to_address);
printf("File transfer sent to [%s] delivery status is [%s] \n" , to
......@@ -123,7 +123,7 @@ int main(int argc, char *argv[]){
LinphoneChatRoom* chat_room;
LinphoneContent* content;
LinphoneChatMessage* chat_message;
LinphoneChatMessageCbs *cbs;
LinphoneChatRoomCbs *cbs;
/*seting dummy file content to something*/
for (i=0;i<sizeof(big_file);i+=strlen(big_file_content))
......@@ -157,6 +157,17 @@ int main(int argc, char *argv[]){
/*Next step is to create a chat room*/
chat_room = linphone_core_get_chat_room_from_uri(lc,dest_friend);
/**
* Fill the application callbacks. The file_transfer_received callback is used in order to get notifications
* about incoming file reception, file_transfer_send to feed file to be transfered and
* file_transfer_progress_indication to print progress.
*/
cbs = linphone_chat_room_get_callbacks(chat_room);
linphone_chat_room_cbs_set_file_transfer_recv(cbs, file_transfer_received);
linphone_chat_room_cbs_set_file_transfer_send(cbs, file_transfer_send);
linphone_chat_room_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication);
linphone_chat_room_cbs_set_msg_state_changed(cbs, linphone_file_transfer_state_changed);
content = linphone_core_create_content(lc);
linphone_content_set_type(content,"text");
linphone_content_set_subtype(content,"plain");
......@@ -169,17 +180,6 @@ int main(int argc, char *argv[]){
printf("returned message is null\n");
}
/**
* Fill the application callbacks. The file_transfer_received callback is used in order to get notifications
* about incoming file reception, file_transfer_send to feed file to be transfered and
* file_transfer_progress_indication to print progress.
*/
cbs = linphone_chat_message_get_callbacks(chat_message);
linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received);
linphone_chat_message_cbs_set_file_transfer_send(cbs, file_transfer_send);
linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication);
linphone_chat_message_cbs_set_msg_state_changed(cbs, linphone_file_transfer_state_changed);
/*initiating file transfer*/
linphone_chat_room_send_chat_message(chat_room, chat_message);
......
......@@ -201,6 +201,7 @@ static int callback_all(void *data, int argc, char **argv, char **colName){
* | 9 | utc timestamp
* | 10 | app data text
* | 11 | linphone content id
* | 12 | message id
*/
static int create_chat_message(void *data, int argc, char **argv, char **colName){
LinphoneChatRoom *cr = (LinphoneChatRoom *)data;
......@@ -227,6 +228,7 @@ static int create_chat_message(void *data, int argc, char **argv, char **colName
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]);
if (argv[11] != NULL) {
int id = atoi(argv[11]);
......@@ -309,7 +311,7 @@ unsigned int linphone_chat_message_store(LinphoneChatMessage *msg){
peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(msg->chat_room));
local_contact=linphone_address_as_string_uri_only(linphone_chat_message_get_local_address(msg));
buf = sqlite3_mprintf("INSERT INTO history VALUES(NULL,%Q,%Q,%i,%Q,%Q,%i,%i,%Q,%lld,%Q,%i);",
buf = sqlite3_mprintf("INSERT INTO history VALUES(NULL,%Q,%Q,%i,%Q,%Q,%i,%i,%Q,%lld,%Q,%i,%Q);",
local_contact,
peer,
msg->dir,
......@@ -320,7 +322,8 @@ unsigned int linphone_chat_message_store(LinphoneChatMessage *msg){
msg->external_body_url,
(int64_t)msg->time,
msg->appdata,
content_id
content_id,
msg->message_id
);
linphone_sql_request(lc->db,buf);
sqlite3_free(buf);
......@@ -527,6 +530,28 @@ 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);
}
LinphoneChatMessage * linphone_chat_room_find_message(LinphoneChatRoom *cr, const char *message_id) {
LinphoneCore *lc = linphone_chat_room_get_core(cr);
LinphoneChatMessage *cm = NULL;
char *buf;
char *peer;
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);
if (cr->messages_hist) {
cm = (LinphoneChatMessage *)bctbx_list_nth_data(cr->messages_hist, 0);
}
cr->messages_hist = NULL;
ms_free(peer);
return cm;
}
void linphone_create_table(sqlite3* db){
char* errmsg=NULL;
int ret;
......@@ -681,6 +706,14 @@ void linphone_update_table(sqlite3* db) {
ms_debug("Table history content successfully for lime key storage data.");
}
}
// new field for message_id
ret = sqlite3_exec(db, "ALTER TABLE history ADD COLUMN messageId TEXT;", NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
ms_message("Table already up to date: %s", errmsg);
} else {
ms_message("Table history updated successfully for message_id data.");
}
}
void linphone_message_storage_init_chat_rooms(LinphoneCore *lc) {
......@@ -764,7 +797,11 @@ bctbx_list_t *linphone_chat_room_get_history(LinphoneChatRoom *cr,int nb_message
return NULL;
}
LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int begin, int end){
bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int begin, int end){
return NULL;
}
LinphoneChatMessage * linphone_chat_room_find_message(LinphoneChatRoom *cr, const char *message_id) {
return NULL;
}
......
......@@ -249,6 +249,7 @@ struct _LinphoneChatMessage {
LinphoneChatMessageState state;
bool_t is_read;
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 */
......@@ -553,6 +554,7 @@ void linphone_proxy_config_write_to_config_file(struct _LpConfig* config,Linphon
LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *msg);
LinphoneReason linphone_core_is_composing_received(LinphoneCore *lc, SalOp *op, const SalIsComposing *is_composing);
LinphoneReason linphone_core_imdn_received(LinphoneCore *lc, SalOp *op, const SalImdn *imdn);
void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *cr, uint32_t character, LinphoneCall *call);
void linphone_call_init_stats(LinphoneCallStats *stats, int type);
......@@ -608,12 +610,15 @@ void _linphone_proxy_config_release_ops(LinphoneProxyConfig *obj);
/*chat*/
void linphone_chat_room_release(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_send_delivery_notification(LinphoneChatMessage *cm);
void linphone_chat_message_send_display_notification(LinphoneChatMessage *cm);
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);
LinphoneChatMessageCbs *linphone_chat_message_cbs_new(void); /* deprecated */
LinphoneChatRoom *_linphone_core_create_chat_room_from_call(LinphoneCall *call);
/**/
......@@ -689,10 +694,22 @@ typedef enum _LinphoneIsComposingState {
LinphoneIsComposingActive
} LinphoneIsComposingState;
struct _LinphoneChatRoomCbs {
belle_sip_object_t base;
void *user_data;
LinphoneChatRoomCbsMsgStateChangedCb msg_state_changed;
LinphoneChatRoomCbsFileTransferRecvCb file_transfer_recv; /**< Callback to store file received attached to a #LinphoneChatRoom */
LinphoneChatRoomCbsFileTransferSendCb file_transfer_send; /**< Callback to collect file chunk to be sent for a #LinphoneChatRoom */
LinphoneChatRoomCbsFileTransferProgressIndicationCb file_transfer_progress_indication; /**< Callback to indicate file transfer progress */
};
BELLE_SIP_DECLARE_VPTR(LinphoneChatRoomCbs);
struct _LinphoneChatRoom{
belle_sip_object_t base;
void *user_data;
struct _LinphoneCore *lc;
LinphoneChatRoomCbs *callbacks;
char *peer;
LinphoneAddress *peer_url;
MSList *messages_hist;
......@@ -1533,6 +1550,7 @@ BELLE_SIP_TYPE_ID(LinphoneCallParams),
BELLE_SIP_TYPE_ID(LinphoneChatMessage),
BELLE_SIP_TYPE_ID(LinphoneChatMessageCbs),
BELLE_SIP_TYPE_ID(LinphoneChatRoom),
BELLE_SIP_TYPE_ID(LinphoneChatRoomCbs),
BELLE_SIP_TYPE_ID(LinphoneContent),
BELLE_SIP_TYPE_ID(LinphoneImEncryptionEngine),
BELLE_SIP_TYPE_ID(LinphoneImEncryptionEngineCbs),
......
......@@ -29,6 +29,7 @@ set(HEADER_FILES
call_log.h
call_params.h
call_stats.h
chat.h
conference.h
contactprovider.h
content.h
......
......@@ -9,6 +9,7 @@ linphone_include_HEADERS=\
call_log.h \
call_params.h \
call_stats.h \
chat.h \
conference.h \
contactprovider.h \
content.h \
......
This diff is collapsed.
This diff is collapsed.
......@@ -312,6 +312,11 @@ typedef struct SalIsComposing {
const char *text;
} SalIsComposing;
typedef struct SalImdn {
const char *from;
const char *content;
} SalImdn;
#define SAL_MEDIA_DESCRIPTION_MAX_MESSAGE_ATTRIBUTES 5
SalMediaDescription *sal_media_description_new(void);
......@@ -503,6 +508,7 @@ typedef void (*SalOnRefer)(Sal *sal, SalOp *op, const char *referto);
typedef void (*SalOnTextReceived)(SalOp *op, const SalMessage *msg);
typedef void (*SalOnTextDeliveryUpdate)(SalOp *op, SalTextDeliveryStatus);
typedef void (*SalOnIsComposingReceived)(SalOp *op, const SalIsComposing *is_composing);
typedef void (*SalOnImdnReceived)(SalOp *op, const SalImdn *imdn);
typedef void (*SalOnNotifyRefer)(SalOp *op, SalReferStatus state);
typedef void (*SalOnSubscribeResponse)(SalOp *op, SalSubscribeStatus status, int will_retry);
typedef void (*SalOnNotify)(SalOp *op, SalSubscribeStatus status, const char *event, SalBodyHandler *body);
......@@ -541,6 +547,7 @@ typedef struct SalCallbacks{
SalOnTextReceived text_received;
SalOnTextDeliveryUpdate text_delivery_update;
SalOnIsComposingReceived is_composing_received;
SalOnImdnReceived imdn_received;
SalOnNotifyRefer notify_refer;
SalOnSubscribeReceived subscribe_received;
SalOnIncomingSubscribeClosed incoming_subscribe_closed;
......
......@@ -64,13 +64,13 @@ static void message_forking(void) {
LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc");
bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc);
LinphoneChatRoom* chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity);
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(chat_room);
LinphoneChatMessage* message = linphone_chat_room_create_message(chat_room,"Bli bli bli \n blu");
LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(message);
lcs=bctbx_list_append(lcs,pauline->lc);
lcs=bctbx_list_append(lcs,marie2->lc);
linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_room_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_room_send_chat_message(chat_room, message);
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneMessageReceived,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneMessageReceived,1,1000));
......@@ -94,8 +94,8 @@ static void message_forking_with_unreachable_recipients(void) {
LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc");
bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc);
LinphoneChatRoom* chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity);
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(chat_room);
LinphoneChatMessage* message = linphone_chat_room_create_message(chat_room,"Bli bli bli \n blu");
LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(message);
lcs=bctbx_list_append(lcs,pauline->lc);
lcs=bctbx_list_append(lcs,marie2->lc);
......@@ -112,7 +112,7 @@ static void message_forking_with_unreachable_recipients(void) {
linphone_core_set_network_reachable(marie2->lc,FALSE);
linphone_core_set_network_reachable(marie3->lc,FALSE);
linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_room_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_room_send_chat_message(chat_room, message);
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneMessageReceived,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneMessageDelivered,1,1000));
......@@ -144,8 +144,8 @@ static void message_forking_with_all_recipients_unreachable(void) {
LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc");
bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc);
LinphoneChatRoom* chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity);
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(chat_room);
LinphoneChatMessage* message = linphone_chat_room_create_message(chat_room,"Bli bli bli \n blu");
LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(message);
lcs=bctbx_list_append(lcs,pauline->lc);
lcs=bctbx_list_append(lcs,marie2->lc);
......@@ -164,7 +164,7 @@ static void message_forking_with_all_recipients_unreachable(void) {
linphone_core_set_network_reachable(marie2->lc,FALSE);
linphone_core_set_network_reachable(marie3->lc,FALSE);
linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_room_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_room_send_chat_message(chat_room, message);
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneMessageInProgress,1,5000));
......@@ -772,8 +772,8 @@ static void call_ipv6_to_ipv4(void){
static void file_transfer_message_rcs_to_external_body_client(void) {
if (transport_supported(LinphoneTransportTls)) {
LinphoneChatRoom* chat_room;
LinphoneChatRoomCbs *cbs;
LinphoneChatMessage* message;
LinphoneChatMessageCbs *cbs;
LinphoneContent* content;
FILE *file_to_send = NULL;
size_t file_size;
......@@ -806,8 +806,11 @@ static void file_transfer_message_rcs_to_external_body_client(void) {
linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php");
/* create a chatroom on pauline's side */
chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity);
cbs = linphone_chat_room_get_callbacks(chat_room);
linphone_chat_room_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_room_cbs_set_file_transfer_send(cbs, tester_file_transfer_send);
/* create a file transfer message */
content = linphone_core_create_content(pauline->lc);
linphone_content_set_type(content,"image");
......@@ -816,22 +819,19 @@ static void file_transfer_message_rcs_to_external_body_client(void) {
linphone_content_set_name(content,"nowebcamCIF.jpg");
message = linphone_chat_room_create_file_transfer_message(chat_room, content);
linphone_chat_message_set_user_data(message, file_to_send);
cbs = linphone_chat_message_get_callbacks(message);
{
int dummy=0;
wait_for_until(marie->lc,pauline->lc,&dummy,1,100); /*just to have time to purge message stored in the server*/
reset_counters(&marie->stat);
reset_counters(&pauline->stat);
}
linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_message_cbs_set_file_transfer_send(cbs, tester_file_transfer_send);
linphone_chat_room_send_chat_message(chat_room,message);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageExtBodyReceived,1));
if (marie->stat.last_received_chat_message ) {
cbs = linphone_chat_message_get_callbacks(marie->stat.last_received_chat_message);
linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received);
cbs = linphone_chat_room_get_callbacks(marie->stat.last_received_chat_message->chat_room);
linphone_chat_room_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_room_cbs_set_file_transfer_recv(cbs, file_transfer_received);
linphone_chat_message_download_file(marie->stat.last_received_chat_message);
}
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageFileTransferDone,1));
......@@ -850,18 +850,17 @@ static void file_transfer_message_rcs_to_external_body_client(void) {
}
void send_file_transfer_message_using_external_body_url(LinphoneCoreManager *marie, LinphoneCoreManager *pauline) {
LinphoneChatMessageCbs *cbs;
LinphoneChatRoom *chat_room;
LinphoneChatRoomCbs *cbs;
LinphoneChatMessage *message;
/* create a chatroom on pauline's side */
chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity);
cbs = linphone_chat_room_get_callbacks(chat_room);
linphone_chat_room_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
message = linphone_chat_room_create_message(chat_room, NULL);
cbs = linphone_chat_message_get_callbacks(message);
linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
linphone_chat_message_set_external_body_url(message, "https://www.linphone.org:444//tmp/54ec58280ace9_c30709218df8eaba61d1.jpg");
linphone_chat_room_send_chat_message(chat_room, message);
......
......@@ -162,6 +162,8 @@ typedef struct _stats {
int number_of_LinphoneMessageDelivered;
int number_of_LinphoneMessageNotDelivered;
int number_of_LinphoneMessageFileTransferDone;
int number_of_LinphoneMessageDeliveredToUser;
int number_of_LinphoneMessageDisplayed;
int number_of_LinphoneIsComposingActiveReceived;
int number_of_LinphoneIsComposingIdleReceived;
int progress_of_LinphoneFileTransfer;
......@@ -305,10 +307,10 @@ void notify_presence_received(LinphoneCore *lc, LinphoneFriend * lf);
void notify_presence_received_for_uri_or_tel(LinphoneCore *lc, LinphoneFriend *lf, const char *uri_or_tel, const LinphonePresenceModel *presence);
void text_message_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from_address, const char *message);
void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage* message);
void file_transfer_received(LinphoneChatMessage *message, const LinphoneContent* content, const LinphoneBuffer *buffer);
LinphoneBuffer * tester_file_transfer_send(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t size);
void file_transfer_received(LinphoneChatRoom *room, LinphoneChatMessage *message, const LinphoneContent* content, const LinphoneBuffer *buffer);
LinphoneBuffer * tester_file_transfer_send(LinphoneChatRoom *room, LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t size);
LinphoneBuffer * tester_memory_file_transfer_send(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t size);
void file_transfer_progress_indication(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t total);
void file_transfer_progress_indication(LinphoneChatRoom *room, LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t total);
void is_composing_received(LinphoneCore *lc, LinphoneChatRoom *room);
void info_message_received(LinphoneCore *lc, LinphoneCall *call, const LinphoneInfoMessage *msg);
void new_subscription_requested(LinphoneCore *lc, LinphoneFriend *lf, const char *url);
......@@ -351,7 +353,7 @@ LinphoneCoreManager *get_manager(LinphoneCore *lc);
const char *liblinphone_tester_get_subscribe_content(void);
const char *liblinphone_tester_get_notify_content(void);
void liblinphone_tester_chat_message_state_change(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud);
void liblinphone_tester_chat_message_msg_state_changed(LinphoneChatMessage *msg, LinphoneChatMessageState state);
void liblinphone_tester_chat_message_msg_state_changed(LinphoneChatRoom *room, LinphoneChatMessage *msg, LinphoneChatMessageState state);
void liblinphone_tester_check_rtcp(LinphoneCoreManager* caller, LinphoneCoreManager* callee);
void liblinphone_tester_clock_start(MSTimeSpec *start);
bool_t liblinphone_tester_clock_elapsed(const MSTimeSpec *start, int value_ms);
......
This diff is collapsed.
......@@ -44,7 +44,7 @@ static void helper(const char *progname) {
exit(0);
}
static void on_msg_state_changed(LinphoneChatMessage *msg, LinphoneChatMessageState state){
static void on_msg_state_changed(LinphoneChatRoom *room, LinphoneChatMessage *msg, LinphoneChatMessageState state){
switch(state){
case LinphoneChatMessageStateInProgress:
printf("Sending message...\n");
......@@ -57,6 +57,8 @@ static void on_msg_state_changed(LinphoneChatMessage *msg, LinphoneChatMessageSt
printf("Message transmitted succesfully.\n");
running = FALSE;
break;
case LinphoneChatMessageStateDeliveredToUser:
case LinphoneChatMessageStateDisplayed:
case LinphoneChatMessageStateFileTransferDone:
case LinphoneChatMessageStateFileTransferError:
case LinphoneChatMessageStateIdle:
......@@ -83,7 +85,7 @@ int main(int argc, char *argv[]){
LinphoneProxyConfig *cfg;
LinphoneChatMessage *msg;
LinphoneChatRoom *room;
LinphoneChatMessageCbs *cbs;
LinphoneChatRoomCbs *cbs;
char * text = NULL;
char *tmp;
......@@ -175,9 +177,9 @@ int main(int argc, char *argv[]){
linphone_proxy_config_unref(cfg);
room = linphone_core_get_chat_room(lc, to);
cbs = linphone_chat_room_get_callbacks(room);
linphone_chat_room_cbs_set_msg_state_changed(cbs, on_msg_state_changed);
msg = linphone_chat_room_create_message(room, text);
cbs = linphone_chat_message_get_callbacks(msg);
linphone_chat_message_cbs_set_msg_state_changed(cbs, on_msg_state_changed);
linphone_chat_room_send_chat_message(room, msg);
/* main loop for receiving notifications and doing background linphonecore work: */
while(running){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment