Commit 67962422 authored by Sylvain Berfini's avatar Sylvain Berfini
Browse files

Added JNI glue for markAsRead LinphoneChatRoom method + get all the messages...

Added JNI glue for markAsRead LinphoneChatRoom method + get all the messages with getHistory method if limit <= 0
parent 55b640b0
......@@ -2049,7 +2049,7 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JNIE
extern "C" jlongArray Java_org_linphone_core_LinphoneChatRoomImpl_getHistory(JNIEnv* env
,jobject thiz
,jlong ptr) {
MSList* history = linphone_chat_room_get_history((LinphoneChatRoom*)ptr, 20);
MSList* history = linphone_chat_room_get_history((LinphoneChatRoom*)ptr, 0);
int historySize = ms_list_size(history);
jlongArray jHistory = env->NewLongArray(historySize);
jlong *jInternalArray = env->GetLongArrayElements(jHistory, NULL);
......@@ -2088,6 +2088,12 @@ extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_deleteHistory(JNIEnv
,jlong ptr) {
linphone_chat_room_delete_history((LinphoneChatRoom*)ptr);
}
extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_markAsRead(JNIEnv* env
,jobject thiz
,jlong ptr) {
linphone_chat_room_mark_as_read((LinphoneChatRoom*)ptr);
}
extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_destroy(JNIEnv* env
,jobject thiz
,jlong ptr) {
......
......@@ -196,11 +196,16 @@ void linphone_chat_room_delete_history(LinphoneChatRoom *cr){
MSList *linphone_chat_room_get_history(LinphoneChatRoom *cr,int nb_message){
LinphoneCore *lc=linphone_chat_room_get_lc(cr);
MSList *ret;
char *buf;
char *peer;
if (lc->db==NULL) return NULL;
char *peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));
peer=linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr));
cr->messages_hist = NULL;
char *buf=sqlite3_mprintf("select * from history where remoteContact = %Q order by id DESC limit %i ;",peer,nb_message);
if (nb_message > 0)
buf=sqlite3_mprintf("select * from history where remoteContact = %Q order by id DESC limit %i ;",peer,nb_message);
else
buf=sqlite3_mprintf("select * from history where remoteContact = %Q order by id DESC;",peer);
linphone_sql_request_message(lc->db,buf,cr);
sqlite3_free(buf);
ret=cr->messages_hist;
......@@ -225,7 +230,7 @@ void linphone_create_table(sqlite3* db){
}
void linphone_message_storage_init_chat_rooms(LinphoneCore *lc) {
if (lc->db==NULL) return NULL;
if (lc->db==NULL) return;
char *buf=sqlite3_mprintf("SELECT remoteContact FROM history Group By remoteContact;");
linphone_sql_request_all(lc->db,buf,lc);
sqlite3_free(buf);
......
......@@ -70,4 +70,9 @@ public interface LinphoneChatRoom {
* Deletes all the messages associated with the peer of this chat room
*/
void deleteHistory();
/**
* Marks all the messages in this conversation as read
*/
void markAsRead();
}
......@@ -30,6 +30,7 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom {
private native void destroy(long ptr);
private native int getUnreadMessagesCount(long ptr);
private native void deleteHistory(long ptr);
private native void markAsRead(long ptr);
protected LinphoneChatRoomImpl(long aNativePtr) {
nativePtr = aNativePtr;
......@@ -77,4 +78,8 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom {
public void deleteHistory() {
deleteHistory(nativePtr);
}
public void markAsRead() {
markAsRead(nativePtr);
}
}
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