Commit f151d70d authored by Christophe Deschamps's avatar Christophe Deschamps
Browse files

retired LinphoneContentPrivate in JNI & fixed Android compilation (friendlist)

parent 5269c01b
......@@ -53,6 +53,7 @@ LOCAL_SRC_FILES := \
enum.c \
event.c \
friend.c \
friendlist.c \
info.c \
linphonecall.c \
linphonecore.c \
......
......@@ -3182,17 +3182,10 @@ extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_markAsRead(JNIEnv*
extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createFileTransferMessage(JNIEnv* env, jobject thiz, jlong ptr, jstring jname, jstring jtype, jstring jsubtype, jint data_size) {
LinphoneContentPrivate content = {0};
LinphoneContent content = {0};
LinphoneChatMessage *message = NULL;
content.type = (char*)env->GetStringUTFChars(jtype, NULL);
content.subtype = (char*)env->GetStringUTFChars(jsubtype, NULL);
content.name = (char*)env->GetStringUTFChars(jname, NULL);
content.size = data_size;
message = linphone_chat_room_create_file_transfer_message((LinphoneChatRoom *)ptr, LINPHONE_CONTENT(&content));
env->ReleaseStringUTFChars(jtype, content.type);
env->ReleaseStringUTFChars(jsubtype, content.subtype);
env->ReleaseStringUTFChars(jname, content.name);
message = linphone_chat_room_create_file_transfer_message((LinphoneChatRoom *)ptr, &content);
return (jlong) message;
}
......@@ -4576,24 +4569,14 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_subscribe(JNIE
jstring jevname, jint expires, jstring jtype, jstring jsubtype, jbyteArray jdata, jstring jencoding){
LinphoneCore *lc=(LinphoneCore*)coreptr;
LinphoneAddress *addr=(LinphoneAddress*)addrptr;
LinphoneContentPrivate content={0};
LinphoneContent content={0};
LinphoneEvent *ev;
jobject jev=NULL;
const char *evname=env->GetStringUTFChars(jevname,NULL);
ev=linphone_core_subscribe(lc,addr,evname,expires,linphone_content_get_type(&content) ? &content : NULL);
if (jtype){
content.type=(char*)env->GetStringUTFChars(jtype,NULL);
content.subtype=(char*)env->GetStringUTFChars(jsubtype,NULL);
content.encoding=jencoding ? (char*)env->GetStringUTFChars(jencoding,NULL) : NULL;
content.data=(void*)env->GetByteArrayElements(jdata,NULL);
content.size=env->GetArrayLength(jdata);
}
ev=linphone_core_subscribe(lc,addr,evname,expires,content.type ? LINPHONE_CONTENT(&content) : NULL);
if (jtype){
env->ReleaseStringUTFChars(jtype,content.type);
env->ReleaseStringUTFChars(jsubtype,content.subtype);
if (jencoding) env->ReleaseStringUTFChars(jencoding,content.encoding);
env->ReleaseByteArrayElements(jdata,(jbyte*)content.data,JNI_ABORT);
env->ReleaseByteArrayElements(jdata,(jbyte*)linphone_content_get_user_data(&content),JNI_ABORT);
}
env->ReleaseStringUTFChars(jevname,evname);
if (ev){
......@@ -4611,24 +4594,16 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_publish(JNIEnv
jstring jtype, jstring jsubtype, jbyteArray jdata, jstring jencoding){
LinphoneCore *lc=(LinphoneCore*)coreptr;
LinphoneAddress *addr=(LinphoneAddress*)addrptr;
LinphoneContentPrivate content={0};
LinphoneContent content={0};
LinphoneEvent *ev;
jobject jev=NULL;
const char *evname=env->GetStringUTFChars(jevname,NULL);
ev=linphone_core_subscribe(lc,addr,evname,expires,linphone_content_get_type(&content) ? &content : NULL);
if (jtype){
content.type=(char*)env->GetStringUTFChars(jtype,NULL);
content.subtype=(char*)env->GetStringUTFChars(jsubtype,NULL);
content.encoding=jencoding ? (char*)env->GetStringUTFChars(jencoding,NULL) : NULL;
content.data=(void*)env->GetByteArrayElements(jdata,NULL);
content.size=env->GetArrayLength(jdata);
}
ev=linphone_core_publish(lc,addr,evname,expires,content.type ? LINPHONE_CONTENT(&content) : NULL);
if (jtype){
env->ReleaseStringUTFChars(jtype,content.type);
env->ReleaseStringUTFChars(jsubtype,content.subtype);
if (jencoding) env->ReleaseStringUTFChars(jencoding,content.encoding);
env->ReleaseByteArrayElements(jdata,(jbyte*)content.data,JNI_ABORT);
env->ReleaseByteArrayElements(jdata,(jbyte*)linphone_content_get_user_data(&content),JNI_ABORT);
}
env->ReleaseStringUTFChars(jevname,evname);
if (ev){
......@@ -4771,33 +4746,24 @@ static jobject create_java_linphone_content(JNIEnv *env, const LinphoneContent *
jstring jtype, jsubtype, jencoding, jname;
jbyteArray jdata = NULL;
jint jsize = 0;
const LinphoneContentPrivate *content = LINPHONE_CONTENT_PRIVATE(icontent);
contentClass = (jclass)env->FindClass("org/linphone/core/LinphoneContentImpl");
ctor = env->GetMethodID(contentClass,"<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[BLjava/lang/String;I)V");
jtype = env->NewStringUTF(content->type);
jsubtype = env->NewStringUTF(content->subtype);
jencoding = content->encoding ? env->NewStringUTF(content->encoding) : NULL;
jname = content->name ? env->NewStringUTF(content->name) : NULL;
jsize = (jint) content->size;
jtype = env->NewStringUTF(linphone_content_get_type(icontent));
jsubtype = env->NewStringUTF(linphone_content_get_subtype(icontent));
jencoding = linphone_content_get_encoding(icontent) ? env->NewStringUTF(linphone_content_get_encoding(icontent)) : NULL;
jname = linphone_content_get_name(icontent) ? env->NewStringUTF(linphone_content_get_name(icontent)) : NULL;
jsize = (jint) linphone_content_get_size(icontent);
if (content->data){
jdata = env->NewByteArray(content->size);
env->SetByteArrayRegion(jdata, 0, content->size, (jbyte*)content->data);
if (linphone_content_get_user_data(icontent)){
jdata = env->NewByteArray(linphone_content_get_size(icontent));
env->SetByteArrayRegion(jdata, 0, linphone_content_get_size(icontent), (jbyte*)linphone_content_get_user_data(icontent));
}
jobject jobj = env->NewObject(contentClass, ctor, jname, jtype, jsubtype, jdata, jencoding, jsize);
env->DeleteLocalRef(contentClass);
env->DeleteLocalRef(jtype);
env->DeleteLocalRef(jsubtype);
if (jencoding) {
env->DeleteLocalRef(jencoding);
}
if (jname) {
env->DeleteLocalRef(jname);
}
return jobj;
}
......@@ -4867,16 +4833,9 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_getCont
* Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_setContent(JNIEnv *env, jobject jobj, jlong infoptr, jstring jtype, jstring jsubtype, jstring jdata){
LinphoneContentPrivate content={0};
LinphoneContent content={0};
content.type=(char*)env->GetStringUTFChars(jtype,NULL);
content.subtype=(char*)env->GetStringUTFChars(jsubtype,NULL);
content.data=(void*)env->GetStringUTFChars(jdata,NULL);
content.size=strlen((char*)content.data);
linphone_info_message_set_content((LinphoneInfoMessage*)infoptr,LINPHONE_CONTENT(&content));
env->ReleaseStringUTFChars(jtype,content.type);
env->ReleaseStringUTFChars(jsubtype,content.subtype);
env->ReleaseStringUTFChars(jdata,(char*)content.data);
linphone_info_message_set_content((LinphoneInfoMessage*)infoptr,&content);
}
/*
......@@ -4975,26 +4934,13 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_denySubscription
* Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_notify(JNIEnv *env, jobject jobj, jlong evptr, jstring jtype, jstring jsubtype, jbyteArray jdata, jstring jencoding){
LinphoneContentPrivate content={0};
LinphoneContent content={0};
LinphoneEvent *ev=(LinphoneEvent*)evptr;
jint err;
if (jtype){
content.type=(char*)env->GetStringUTFChars(jtype,NULL);
content.subtype=(char*)env->GetStringUTFChars(jsubtype,NULL);
content.encoding=jencoding ? (char*)env->GetStringUTFChars(jsubtype,NULL) : NULL;
content.data=(void*)env->GetByteArrayElements(jdata,NULL);
content.size=env->GetArrayLength(jdata);
}
err=linphone_event_notify(ev,content.type ? LINPHONE_CONTENT(&content) : NULL);
err=linphone_event_notify(ev,linphone_content_get_type(&content) ? &content : NULL);
if (jtype){
env->ReleaseStringUTFChars(jtype,content.type);
env->ReleaseStringUTFChars(jsubtype,content.subtype);
if (jencoding) env->ReleaseStringUTFChars(jencoding,content.encoding);
env->ReleaseByteArrayElements(jdata,(jbyte*)content.data,JNI_ABORT);
}
return err;
}
......@@ -5004,26 +4950,12 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_notify(JNIEnv *e
* Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_updateSubscribe(JNIEnv *env, jobject jobj, jlong evptr, jstring jtype, jstring jsubtype, jbyteArray jdata, jstring jencoding){
LinphoneContentPrivate content={0};
LinphoneContent content={0};
LinphoneEvent *ev=(LinphoneEvent*)evptr;
jint err;
if (jtype){
content.type=(char*)env->GetStringUTFChars(jtype,NULL);
content.subtype=(char*)env->GetStringUTFChars(jsubtype,NULL);
content.encoding=jencoding ? (char*)env->GetStringUTFChars(jsubtype,NULL) : NULL;
content.data=(void*)env->GetByteArrayElements(jdata,NULL);
content.size=env->GetArrayLength(jdata);
}
err=linphone_event_update_subscribe(ev,linphone_content_get_type(&content) ? &content : NULL);
err=linphone_event_update_subscribe(ev,content.type ? LINPHONE_CONTENT(&content) : NULL);
if (jtype){
env->ReleaseStringUTFChars(jtype,content.type);
env->ReleaseStringUTFChars(jsubtype,content.subtype);
if (jencoding) env->ReleaseStringUTFChars(jencoding,content.encoding);
env->ReleaseByteArrayElements(jdata,(jbyte*)content.data,JNI_ABORT);
}
return err;
}
......@@ -5033,26 +4965,12 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_updateSubscribe(
* Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneEventImpl_updatePublish(JNIEnv *env, jobject jobj, jlong evptr, jstring jtype, jstring jsubtype, jbyteArray jdata, jstring jencoding){
LinphoneContentPrivate content={0};
LinphoneContent content={0};
LinphoneEvent *ev=(LinphoneEvent*)evptr;
jint err;
if (jtype){
content.type=(char*)env->GetStringUTFChars(jtype,NULL);
content.subtype=(char*)env->GetStringUTFChars(jsubtype,NULL);
content.encoding=jencoding ? (char*)env->GetStringUTFChars(jsubtype,NULL) : NULL;
content.data=(void*)env->GetByteArrayElements(jdata,NULL);
content.size=env->GetArrayLength(jdata);
}
err=linphone_event_update_publish(ev,content.type ? LINPHONE_CONTENT(&content) : NULL);
err=linphone_event_update_publish(ev,linphone_content_get_type(&content) ? &content : NULL);
if (jtype){
env->ReleaseStringUTFChars(jtype,content.type);
env->ReleaseStringUTFChars(jsubtype,content.subtype);
if (jencoding) env->ReleaseStringUTFChars(jencoding,content.encoding);
env->ReleaseByteArrayElements(jdata,(jbyte*)content.data,JNI_ABORT);
}
return err;
}
......@@ -5118,21 +5036,8 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_createSubscrib
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneEventImpl_sendSubscribe(JNIEnv *env, jobject thiz, jlong jevent, jstring jtype, jstring jsubtype, jbyteArray jdata, jstring jencoding) {
LinphoneContentPrivate content = {0};
if (jtype) {
content.type = (char*) env->GetStringUTFChars(jtype, NULL);
content.subtype = (char*) env->GetStringUTFChars(jsubtype, NULL);
content.encoding = jencoding ? (char*) env->GetStringUTFChars(jencoding, NULL) : NULL;
content.data = (void*) env->GetByteArrayElements(jdata, NULL);
content.size = env->GetArrayLength(jdata);
}
linphone_event_send_subscribe((LinphoneEvent*) jevent, content.type ? LINPHONE_CONTENT(&content) : NULL);
if (jtype) {
env->ReleaseStringUTFChars(jtype, content.type);
env->ReleaseStringUTFChars(jsubtype, content.subtype);
if (jencoding) env->ReleaseStringUTFChars(jencoding, content.encoding);
env->ReleaseByteArrayElements(jdata, (jbyte*) content.data, JNI_ABORT);
}
LinphoneContent content = {0};
linphone_event_send_subscribe((LinphoneEvent*) jevent, linphone_content_get_type(&content)? &content : NULL);
}
JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_createPublish(JNIEnv *env, jobject thiz, jlong jcore, jlong jaddr, jstring jeventname, jint expires) {
......@@ -5151,21 +5056,10 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_createPublish(
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneEventImpl_sendPublish(JNIEnv *env, jobject thiz, jlong jevent, jstring jtype, jstring jsubtype, jbyteArray jdata, jstring jencoding) {
LinphoneContentPrivate content = {0};
if (jtype) {
content.type = (char*) env->GetStringUTFChars(jtype, NULL);
content.subtype = (char*) env->GetStringUTFChars(jsubtype, NULL);
content.encoding = jencoding ? (char*) env->GetStringUTFChars(jencoding, NULL) : NULL;
content.data = (void*) env->GetByteArrayElements(jdata, NULL);
content.size = env->GetArrayLength(jdata);
}
linphone_event_send_publish((LinphoneEvent*) jevent, content.type ? LINPHONE_CONTENT(&content) : NULL);
if (jtype) {
env->ReleaseStringUTFChars(jtype, content.type);
env->ReleaseStringUTFChars(jsubtype, content.subtype);
if (jencoding) env->ReleaseStringUTFChars(jencoding, content.encoding);
env->ReleaseByteArrayElements(jdata, (jbyte*) content.data, JNI_ABORT);
}
LinphoneContent content = {0};
linphone_event_send_publish((LinphoneEvent*) jevent, linphone_content_get_type(&content)? &content : NULL);
}
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneEventImpl_addCustomHeader(JNIEnv *env, jobject thiz, jlong jevent, jstring jname, jstring jvalue) {
......
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