From b3c08e5d7ebbc30b1448f7a288f667c86904e6e2 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 14 Aug 2013 11:17:18 +0200 Subject: [PATCH] Added method to update message's url field in database in case of changes --- coreapi/linphonecore.h | 1 + coreapi/linphonecore_jni.cc | 7 +++++++ coreapi/message_storage.c | 13 +++++++++++++ java/common/org/linphone/core/LinphoneChatRoom.java | 6 ++++++ .../org/linphone/core/LinphoneChatRoomImpl.java | 6 ++++++ 5 files changed, 33 insertions(+) diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 0e5963bf5..6fe0fc7c4 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -860,6 +860,7 @@ LINPHONE_PUBLIC LinphoneChatMessage* linphone_chat_room_create_message(LinphoneC LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_room_get_peer_address(LinphoneChatRoom *cr); LINPHONE_PUBLIC void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg); LINPHONE_PUBLIC void linphone_chat_room_send_message2(LinphoneChatRoom *cr, LinphoneChatMessage* msg,LinphoneChatMessageStateChangeCb status_cb,void* ud); +LINPHONE_PUBLIC void linphone_chat_room_update_url(LinphoneChatRoom *cr, LinphoneChatMessage *msg); LINPHONE_PUBLIC MSList *linphone_chat_room_get_history(LinphoneChatRoom *cr,int nb_message); LINPHONE_PUBLIC void linphone_chat_room_mark_as_read(LinphoneChatRoom *cr); LINPHONE_PUBLIC void linphone_chat_room_delete_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg); diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 19be90590..677b45b8a 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -2100,6 +2100,13 @@ extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_markAsRead(JNIEnv* linphone_chat_room_mark_as_read((LinphoneChatRoom*)ptr); } +extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_updateUrl(JNIEnv* env + ,jobject thiz + ,jlong room + ,jlong msg) { + linphone_chat_room_update_url((LinphoneChatRoom*)room, (LinphoneChatMessage*)msg); +} + extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_destroy(JNIEnv* env ,jobject thiz ,jlong ptr) { diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 73d781a88..62d0c3a54 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -165,6 +165,16 @@ void linphone_chat_room_mark_as_read(LinphoneChatRoom *cr){ ms_free(peer); } +void linphone_chat_room_update_url(LinphoneChatRoom *cr, LinphoneChatMessage *msg) { + LinphoneCore *lc=linphone_chat_room_get_lc(cr); + + if (lc->db==NULL) return ; + + char *buf=sqlite3_mprintf("update history set url=%Q where id=%i;",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){ LinphoneCore *lc=linphone_chat_room_get_lc(cr); int numrows=0; @@ -320,6 +330,9 @@ 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; } diff --git a/java/common/org/linphone/core/LinphoneChatRoom.java b/java/common/org/linphone/core/LinphoneChatRoom.java index c55d495a8..f6708d0f4 100644 --- a/java/common/org/linphone/core/LinphoneChatRoom.java +++ b/java/common/org/linphone/core/LinphoneChatRoom.java @@ -81,4 +81,10 @@ public interface LinphoneChatRoom { * @param message the message to delete */ void deleteMessage(LinphoneChatMessage message); + + /** + * Update the value stored in the database for the external_body_url field + * @param message to update + */ + void updateUrl(LinphoneChatMessage message); } diff --git a/java/impl/org/linphone/core/LinphoneChatRoomImpl.java b/java/impl/org/linphone/core/LinphoneChatRoomImpl.java index e576fad0b..f93c428c3 100644 --- a/java/impl/org/linphone/core/LinphoneChatRoomImpl.java +++ b/java/impl/org/linphone/core/LinphoneChatRoomImpl.java @@ -32,6 +32,7 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom { private native void deleteHistory(long ptr); private native void markAsRead(long ptr); private native void deleteMessage(long room, long message); + private native void updateUrl(long room, long message); protected LinphoneChatRoomImpl(long aNativePtr) { nativePtr = aNativePtr; @@ -88,4 +89,9 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom { if (message != null) deleteMessage(nativePtr, message.getNativePtr()); } + + public void updateUrl(LinphoneChatMessage message) { + if (message != null) + updateUrl(nativePtr, message.getNativePtr()); + } }