mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-18 03:28:07 +00:00
add function to chatroom to find a message with a given direction.
It re-enable to send messages to itself on the same device
This commit is contained in:
parent
88fe8d0044
commit
5e89a0416c
3 changed files with 44 additions and 11 deletions
|
|
@ -668,8 +668,9 @@ LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const
|
|||
cr = linphone_core_get_chat_room(lc, addr);
|
||||
|
||||
/* Check if this is a duplicate message */
|
||||
if (linphone_chat_room_find_message(cr, sal_op_get_call_id(op)) != NULL) {
|
||||
if ((msg = linphone_chat_room_find_message_with_dir(cr, sal_op_get_call_id(op), LinphoneChatMessageIncoming))) {
|
||||
reason = lc->chat_deny_code;
|
||||
linphone_chat_message_unref(msg);
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
|
@ -882,7 +883,7 @@ static void process_imdn(LinphoneChatRoom *cr, xmlparsing_context_t *xml_ctx) {
|
|||
}
|
||||
|
||||
if ((message_id_str != NULL) && (datetime_str != NULL)) {
|
||||
LinphoneChatMessage *cm = linphone_chat_room_find_message(cr, message_id_str);
|
||||
LinphoneChatMessage *cm = linphone_chat_room_find_message_with_dir(cr, message_id_str, LinphoneChatMessageOutgoing);
|
||||
if (cm == NULL) {
|
||||
ms_warning("Received IMDN for unknown message %s", message_id_str);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -627,25 +627,52 @@ 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) {
|
||||
|
||||
bctbx_list_t* linphone_chat_room_find_messages(LinphoneChatRoom *cr, const char *message_id) {
|
||||
LinphoneCore *lc = linphone_chat_room_get_core(cr);
|
||||
LinphoneChatMessage *cm = NULL;
|
||||
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);
|
||||
|
||||
if (cr->messages_hist) {
|
||||
cm = (LinphoneChatMessage *)bctbx_list_nth_data(cr->messages_hist, 0);
|
||||
}
|
||||
|
||||
cr->messages_hist = NULL;
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -278,6 +278,11 @@ 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{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue