Commit fd813601 authored by Simon Morlat's avatar Simon Morlat
Browse files

fix management of LinphoneChatMessage in android glue

add authInfoRequested implementation.
parent 5e3ff318
......@@ -97,7 +97,6 @@ public class TutorialBuddyStatus implements LinphoneCoreListener {
}
public void show(LinphoneCore lc) {}
public void byeReceived(LinphoneCore lc, String from) {}
public void authInfoRequested(LinphoneCore lc, String realm, String username) {}
public void displayStatus(LinphoneCore lc, String message) {}
public void displayMessage(LinphoneCore lc, String message) {}
public void displayWarning(LinphoneCore lc, String message) {}
......@@ -294,5 +293,12 @@ public class TutorialBuddyStatus implements LinphoneCoreListener {
}
@Override
public void authInfoRequested(LinphoneCore lc, String realm,
String username, String Domain) {
// TODO Auto-generated method stub
}
}
......@@ -73,7 +73,7 @@ public class TutorialChatRoom implements LinphoneCoreListener, LinphoneChatMessa
public void show(LinphoneCore lc) {}
public void byeReceived(LinphoneCore lc, String from) {}
public void authInfoRequested(LinphoneCore lc, String realm, String username) {}
public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain) {}
public void displayStatus(LinphoneCore lc, String message) {}
public void displayMessage(LinphoneCore lc, String message) {}
public void displayWarning(LinphoneCore lc, String message) {}
......
......@@ -67,7 +67,7 @@ public class TutorialHelloWorld implements LinphoneCoreListener {
public void show(LinphoneCore lc) {}
public void byeReceived(LinphoneCore lc, String from) {}
public void authInfoRequested(LinphoneCore lc, String realm, String username) {}
public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain) {}
public void displayStatus(LinphoneCore lc, String message) {}
public void displayMessage(LinphoneCore lc, String message) {}
public void displayWarning(LinphoneCore lc, String message) {}
......
......@@ -78,7 +78,7 @@ public class TutorialRegistration implements LinphoneCoreListener {
public void show(LinphoneCore lc) {}
public void byeReceived(LinphoneCore lc, String from) {}
public void authInfoRequested(LinphoneCore lc, String realm, String username) {}
public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain) {}
public void displayStatus(LinphoneCore lc, String message) {}
public void displayMessage(LinphoneCore lc, String message) {}
public void displayWarning(LinphoneCore lc, String message) {}
......
......@@ -2447,13 +2447,6 @@ extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_destroy(JNIEnv* env
linphone_chat_room_destroy((LinphoneChatRoom*)ptr);
}
extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env
,jobject thiz
,jlong ptr) {
jobject ud = env->NewGlobalRef(thiz);
linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud);
}
extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_store(JNIEnv* env
,jobject thiz
,jlong ptr) {
......@@ -2554,6 +2547,12 @@ extern "C" jint Java_org_linphone_core_LinphoneChatMessageImpl_getStorageId(JNIE
return (jint) linphone_chat_message_get_storage_id((LinphoneChatMessage*)ptr);
}
extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_unref(JNIEnv* env
,jobject thiz
,jlong ptr) {
linphone_chat_message_unref((LinphoneChatMessage*)ptr);
}
extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getChatRooms(JNIEnv* env
,jobject thiz
,jlong ptr) {
......@@ -2592,26 +2591,32 @@ static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessag
jobject listener = (jobject) ud;
jclass clazz = (jclass) env->GetObjectClass(listener);
jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
jobject jmessage=(jobject)linphone_chat_message_get_user_data(msg);
LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg));
LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
env->CallVoidMethod(
listener,
method,
(jobject)linphone_chat_message_get_user_data(msg),
jmessage,
env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state));
if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
env->DeleteGlobalRef(listener);
env->DeleteGlobalRef(jmessage);
linphone_chat_message_set_user_data(msg,NULL);
}
}
extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
,jobject thiz
,jlong ptr
,jlong jmessage
,jlong chatroom_ptr
,jobject message
,jlong messagePtr
,jobject jlistener) {
jobject listener = env->NewGlobalRef(jlistener);
linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
message = env->NewGlobalRef(message);
linphone_chat_message_ref((LinphoneChatMessage*)messagePtr);
linphone_chat_message_set_user_data((LinphoneChatMessage*)messagePtr, message);
linphone_chat_room_send_message2((LinphoneChatRoom*)chatroom_ptr, (LinphoneChatMessage*)messagePtr, chat_room_impl_callback, (void*)listener);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
......
......@@ -52,11 +52,6 @@ public interface LinphoneChatMessage {
}
}
long getNativePtr();
Object getUserData();
void setUserData();
/**
* get text associated to this LinphoneChatMessage
......
......@@ -2,7 +2,6 @@ package org.linphone.core;
public class LinphoneChatMessageImpl implements LinphoneChatMessage {
protected final long nativePtr;
private native void setUserData(long ptr);
private native String getText(long ptr);
private native long getPeerAddress(long ptr);
private native String getExternalBodyUrl(long ptr);
......@@ -14,27 +13,16 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage {
private native boolean isOutgoing(long ptr);
private native void store(long ptr);
private native int getStorageId(long ptr);
private native void unref(long ptr);
protected LinphoneChatMessageImpl(long aNativePtr) {
nativePtr = aNativePtr;
setUserData();
}
public long getNativePtr() {
return nativePtr;
}
@Override
public Object getUserData() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setUserData() {
setUserData(nativePtr);
}
@Override
public String getText() {
return getText(nativePtr);
......@@ -97,12 +85,15 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage {
private native int getReason(long ptr);
public Reason getReason() {
return Reason.fromInt(getReason(nativePtr));
}
private native long getErrorInfo(long nativePtr);
@Override
public ErrorInfo getErrorInfo() {
return new ErrorInfoImpl(getErrorInfo(nativePtr));
}
public Reason getReason() {
return Reason.fromInt(getReason(nativePtr));
}
private native long getErrorInfo(long nativePtr);
@Override
public ErrorInfo getErrorInfo() {
return new ErrorInfoImpl(getErrorInfo(nativePtr));
}
protected void finalize(){
unref(nativePtr);
}
}
......@@ -26,7 +26,7 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom {
private native long createLinphoneChatMessage(long ptr, String message);
private native long getPeerAddress(long ptr);
private native void sendMessage(long ptr, String message);
private native void sendMessage2(long ptr, long message, StateListener listener);
private native void sendMessage2(long ptr, Object msg, long messagePtr, StateListener listener);
private native long[] getHistory(long ptr, int limit);
private native void destroy(long ptr);
private native int getUnreadMessagesCount(long ptr);
......@@ -54,7 +54,7 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom {
@Override
public void sendMessage(LinphoneChatMessage message, StateListener listener) {
sendMessage2(nativePtr, message.getNativePtr(), listener);
sendMessage2(nativePtr, message, ((LinphoneChatMessageImpl)message).getNativePtr(), listener);
}
@Override
......@@ -104,12 +104,12 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom {
public void deleteMessage(LinphoneChatMessage message) {
if (message != null)
deleteMessage(nativePtr, message.getNativePtr());
deleteMessage(nativePtr, ((LinphoneChatMessageImpl)message).getNativePtr());
}
public void updateUrl(LinphoneChatMessage message) {
if (message != null)
updateUrl(nativePtr, message.getNativePtr());
updateUrl(nativePtr, ((LinphoneChatMessageImpl)message).getNativePtr());
}
@Override
......
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