Commit 389922ac authored by Sylvain Berfini's avatar Sylvain Berfini
Browse files

Started the JNI binding of the message_storage functions

parent 1d144769
......@@ -535,7 +535,7 @@ public:
,lcData->messageReceivedId
,lcData->core
,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
,env->NewObject(lcData->chatMessageClass,lcData->chatMessageCtrId,(jlong)msg));
,env->NewObject(lcData->chatMessageClass,lcData->chatMessageCtrId,(jlong)msg));
}
static void ecCalibrationStatus(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data) {
JNIEnv *env = 0;
......@@ -718,6 +718,12 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneCallImpl_sendInfoMessage(J
return linphone_call_send_info_message((LinphoneCall*)callptr,(LinphoneInfoMessage*)infoptr);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setChatDatabasePath(JNIEnv* env, jobject thiz, jlong lc, jstring jpath) {
const char* path = env->GetStringUTFChars(jpath, NULL);
linphone_core_set_chat_database_path((LinphoneCore*)lc, path);
env->ReleaseStringUTFChars(jpath, path);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPrimaryContact(JNIEnv* env, jobject thiz, jlong lc, jstring jdisplayname, jstring jusername) {
const char* displayname = env->GetStringUTFChars(jdisplayname, NULL);
const char* username = env->GetStringUTFChars(jusername, NULL);
......@@ -753,7 +759,7 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig(
}
extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getProxyConfigList(JNIEnv* env, jobject thiz, jlong lc) {
const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
const MSList* proxies = linphone_core_get_proxy_config_list((LinphoneCore*)lc);
int proxyCount = ms_list_size(proxies);
jlongArray jProxies = env->NewLongArray(proxyCount);
jlong *jInternalArray = env->GetLongArrayElements(jProxies, NULL);
......@@ -1009,7 +1015,7 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_listVideoPayloadTy
codecs = codecs->next;
}
env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
env->ReleaseLongArrayElements(jCodecs, jInternalArray, 0);
return jCodecs;
}
......@@ -2038,6 +2044,23 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JNIE
return (jlong) lf;
}
//LinphoneChatRoom
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);
int historySize = ms_list_size(history);
jlongArray jHistory = env->NewLongArray(historySize);
jlong *jInternalArray = env->GetLongArrayElements(jHistory, NULL);
for (int i = 0; i < historySize; i++) {
jInternalArray[i] = (unsigned long) (history->data);
history = history->next;
}
env->ReleaseLongArrayElements(jHistory, jInternalArray, 0);
return jHistory;
}
extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv* env
,jobject thiz
,jlong ptr) {
......@@ -2158,6 +2181,7 @@ extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv*
jobject listener = env->NewGlobalRef(jlistener);
linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
,jobject thiz
,jlong lc
......
......@@ -48,4 +48,10 @@ public interface LinphoneChatRoom {
* @return LinphoneChatMessage object
*/
LinphoneChatMessage createLinphoneChatMessage(String message);
/**
* Returns the chat history associated with the peer address associated with this chat room
* @return an array of LinphoneChatMessage
*/
LinphoneChatMessage[] getHistory();
}
......@@ -20,9 +20,11 @@ package org.linphone.core;
import java.util.Vector;
import org.linphone.core.LinphoneCall.State;
import org.linphone.mediastream.video.AndroidVideoWindowImpl;
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import android.view.SurfaceView;
/**
* Linphone core main object created by method {@link LinphoneCoreFactory#createLinphoneCore(LinphoneCoreListener, String, String, Object)}.
*
......@@ -1313,4 +1315,9 @@ public interface LinphoneCore {
*/
public LinphoneEvent publish(LinphoneAddress resource, String event, int expires, LinphoneContent content);
/**
* Sets the path to the database where the chat messages will be stored (if enabled)
* @param path the database where the chat messages will be stored.
*/
public void setChatDatabasePath(String path);
}
......@@ -26,6 +26,7 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom {
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 long[] getHistory(long ptr);
protected LinphoneChatRoomImpl(long aNativePtr) {
nativePtr = aNativePtr;
......@@ -49,4 +50,16 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom {
public LinphoneChatMessage createLinphoneChatMessage(String message) {
return new LinphoneChatMessageImpl(createLinphoneChatMessage(nativePtr, message));
}
public LinphoneChatMessage[] getHistory() {
long[] typesPtr = getHistory(nativePtr);
if (typesPtr == null) return null;
LinphoneChatMessage[] messages = new LinphoneChatMessage[typesPtr.length];
for (int i=0; i < messages.length; i++) {
messages[i] = new LinphoneChatMessageImpl(typesPtr[i]);
}
return messages;
}
}
......@@ -19,7 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package org.linphone.core;
import static android.media.AudioManager.MODE_IN_CALL;
import static android.media.AudioManager.MODE_RINGTONE;
import java.io.File;
import java.io.IOException;
......@@ -133,6 +132,7 @@ class LinphoneCoreImpl implements LinphoneCore {
private native void setIncomingTimeout(long nativePtr, int timeout);
private native void setInCallTimeout(long nativePtr, int timeout);
private native void setPrimaryContact(long nativePtr, String displayName, String username);
private native void setChatDatabasePath(long nativePtr, String path);
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
mListener=listener;
......@@ -980,4 +980,8 @@ class LinphoneCoreImpl implements LinphoneCore {
return (LinphoneEvent)publish(nativePtr, ((LinphoneAddressImpl)resource).nativePtr, eventname, expires,
content!=null ? content.getType() : null, content!=null ? content.getSubtype() : null, content!=null ? content.getDataAsString() : null);
}
public void setChatDatabasePath(String path) {
setChatDatabasePath(nativePtr, path);
}
}
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