]> sjero.net Git - linphone/blob - coreapi/linphonecore_jni.cc
add enablePubish java binding
[linphone] / coreapi / linphonecore_jni.cc
1 /*
2 linphonecore_jni.cc
3 Copyright (C) 2010  Belledonne Communications, Grenoble, France
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  */
19 #include <jni.h>
20 #include "linphonecore.h"
21 #ifdef ANDROID
22 #include <android/log.h>
23 extern "C" void libmsilbc_init();
24 extern "C" void libmsx264_init();
25 #endif /*ANDROID*/
26
27 extern "C" void ms_andsnd_set_jvm(JavaVM *jvm) ;
28 extern "C" void ms_andvid_set_jvm(JavaVM *jvm) ;
29
30 static JavaVM *jvm=0;
31
32 #ifdef ANDROID
33 static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
34         int prio;
35         switch(lev){
36         case ORTP_DEBUG:        prio = ANDROID_LOG_DEBUG;       break;
37         case ORTP_MESSAGE:      prio = ANDROID_LOG_INFO;        break;
38         case ORTP_WARNING:      prio = ANDROID_LOG_WARN;        break;
39         case ORTP_ERROR:        prio = ANDROID_LOG_ERROR;       break;
40         case ORTP_FATAL:        prio = ANDROID_LOG_FATAL;       break;
41         default:                prio = ANDROID_LOG_DEFAULT;     break;
42         }
43         __android_log_vprint(prio, LOG_DOMAIN, fmt, args);
44 }
45 #endif /*ANDROID*/
46
47 JNIEXPORT jint JNICALL  JNI_OnLoad(JavaVM *ajvm, void *reserved)
48 {
49 #ifdef ANDROID
50         ms_andsnd_set_jvm(ajvm);
51         #ifdef VIDEO_ENABLED
52         ms_andvid_set_jvm(ajvm);
53         #endif /*VIDEO_ENABLED*/
54 #endif /*ANDROID*/
55         jvm=ajvm;
56         return JNI_VERSION_1_2;
57 }
58
59
60 //LinphoneFactory
61 extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv*  env
62                 ,jobject  thiz
63                 ,jboolean isDebug) {
64         if (isDebug) {
65                 linphone_core_enable_logs_with_cb(linphone_android_log_handler);
66         } else {
67                 linphone_core_disable_logs();
68         }
69 }
70 // LinphoneCore
71
72 class LinphoneCoreData {
73 public:
74         LinphoneCoreData(JNIEnv*  env, jobject lc,jobject alistener, jobject auserdata) {
75
76                 core = env->NewGlobalRef(lc);
77                 listener = env->NewGlobalRef(alistener);
78                 userdata = auserdata?env->NewGlobalRef(auserdata):0;
79                 memset(&vTable,0,sizeof(vTable));
80                 vTable.show = showInterfaceCb;
81                 vTable.auth_info_requested = authInfoRequested;
82                 vTable.display_status = displayStatusCb;
83                 vTable.display_message = displayMessageCb;
84                 vTable.display_warning = displayMessageCb;
85                 vTable.global_state_changed = globalStateChange;
86                 vTable.registration_state_changed = registrationStateChange;
87                 vTable.call_state_changed = callStateChange;
88                 vTable.text_received = text_received;
89                 vTable.new_subscription_request = new_subscription_request;
90                 vTable.notify_presence_recv = notify_presence_recv;
91
92                 listernerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
93                 /*displayStatus(LinphoneCore lc,String message);*/
94                 displayStatusId = env->GetMethodID(listernerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
95                 /*void generalState(LinphoneCore lc,int state); */
96                 globalStateId = env->GetMethodID(listernerClass,"globalState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCore$GlobalState;Ljava/lang/String;)V");
97                 globalStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$GlobalState"));
98                 globalStateFromIntId = env->GetStaticMethodID(globalStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$GlobalState;");
99                 /*registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);*/
100                 registrationStateId = env->GetMethodID(listernerClass,"registrationState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneProxyConfig;Lorg/linphone/core/LinphoneCore$RegistrationState;Ljava/lang/String;)V");
101                 registrationStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$RegistrationState"));
102                 registrationStateFromIntId = env->GetStaticMethodID(registrationStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$RegistrationState;");
103                 /*callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State cstate,String message);*/
104                 callStateId = env->GetMethodID(listernerClass,"callState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;Ljava/lang/String;)V");
105                 callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
106                 callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
107
108                 /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
109                 newSubscriptionRequestId = env->GetMethodID(listernerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
110
111                 /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
112                 notifyPresenceReceivedId = env->GetMethodID(listernerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
113
114                 /*void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);*/
115                 textReceivedId = env->GetMethodID(listernerClass,"textReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneChatRoom;Lorg/linphone/core/LinphoneAddress;Ljava/lang/String;)V");
116
117                 proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
118                 proxyCtrId = env->GetMethodID(proxyClass,"<init>", "(J)V");
119
120                 callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl"));
121                 callCtrId = env->GetMethodID(callClass,"<init>", "(J)V");
122
123                 chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
124                 chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
125
126                 friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
127                 friendCtrId =env->GetMethodID(friendClass,"<init>", "(J)V");
128
129                 addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
130                 addressCtrId =env->GetMethodID(addressClass,"<init>", "(J)V");
131
132         }
133
134         ~LinphoneCoreData() {
135                 JNIEnv *env = 0;
136                 jvm->AttachCurrentThread(&env,NULL);
137                 env->DeleteGlobalRef(core);
138                 env->DeleteGlobalRef(listener);
139                 if (userdata) env->DeleteGlobalRef(userdata);
140                 env->DeleteGlobalRef(listernerClass);
141                 env->DeleteGlobalRef(globalStateClass);
142                 env->DeleteGlobalRef(registrationStateClass);
143                 env->DeleteGlobalRef(callStateClass);
144                 env->DeleteGlobalRef(proxyClass);
145                 env->DeleteGlobalRef(callClass);
146                 env->DeleteGlobalRef(chatRoomClass);
147                 env->DeleteGlobalRef(friendClass);
148
149         }
150         jobject core;
151         jobject listener;
152         jobject userdata;
153
154         jclass listernerClass;
155         jmethodID displayStatusId;
156         jmethodID newSubscriptionRequestId;
157         jmethodID notifyPresenceReceivedId;
158         jmethodID textReceivedId;
159
160         jclass globalStateClass;
161         jmethodID globalStateId;
162         jmethodID globalStateFromIntId;
163
164         jclass registrationStateClass;
165         jmethodID registrationStateId;
166         jmethodID registrationStateFromIntId;
167
168         jclass callStateClass;
169         jmethodID callStateId;
170         jmethodID callStateFromIntId;
171
172         jclass proxyClass;
173         jmethodID proxyCtrId;
174
175         jclass callClass;
176         jmethodID callCtrId;
177
178         jclass chatRoomClass;
179         jmethodID chatRoomCtrId;
180
181         jclass friendClass;
182         jmethodID friendCtrId;
183
184         jclass addressClass;
185         jmethodID addressCtrId;
186
187         LinphoneCoreVTable vTable;
188
189         static void showInterfaceCb(LinphoneCore *lc) {
190
191         }
192         static void byeReceivedCb(LinphoneCore *lc, const char *from) {
193
194         }
195         static void displayStatusCb(LinphoneCore *lc, const char *message) {
196                 JNIEnv *env = 0;
197                 jint result = jvm->AttachCurrentThread(&env,NULL);
198                 if (result != 0) {
199                         ms_error("cannot attach VM\n");
200                         return;
201                 }
202                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
203                 env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,env->NewStringUTF(message));
204         }
205         static void displayMessageCb(LinphoneCore *lc, const char *message) {
206
207         }
208         static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username) {
209
210         }
211         static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) {
212                 JNIEnv *env = 0;
213                 jint result = jvm->AttachCurrentThread(&env,NULL);
214                 if (result != 0) {
215                         ms_error("cannot attach VM\n");
216                         return;
217                 }
218                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
219                 env->CallVoidMethod(lcData->listener
220                                                         ,lcData->globalStateId
221                                                         ,lcData->core
222                                                         ,env->CallStaticObjectMethod(lcData->globalStateClass,lcData->globalStateFromIntId,(jint)gstate),
223                                                         message ? env->NewStringUTF(message) : NULL);
224         }
225         static void registrationStateChange(LinphoneCore *lc, LinphoneProxyConfig* proxy,LinphoneRegistrationState state,const char* message) {
226                 JNIEnv *env = 0;
227                 jint result = jvm->AttachCurrentThread(&env,NULL);
228                 if (result != 0) {
229                         ms_error("cannot attach VM\n");
230                         return;
231                 }
232                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
233                 env->CallVoidMethod(lcData->listener
234                                                         ,lcData->registrationStateId
235                                                         ,lcData->core
236                                                         ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy)
237                                                         ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state),
238                                                         message ? env->NewStringUTF(message) : NULL);
239         }
240         static void callStateChange(LinphoneCore *lc, LinphoneCall* call,LinphoneCallState state,const char* message) {
241                 JNIEnv *env = 0;
242                 jint result = jvm->AttachCurrentThread(&env,NULL);
243                 if (result != 0) {
244                         ms_error("cannot attach VM\n");
245                         return;
246                 }
247                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
248                 env->CallVoidMethod(lcData->listener
249                                                         ,lcData->callStateId
250                                                         ,lcData->core
251                                                         ,env->NewObject(lcData->callClass,lcData->callCtrId,(jlong)call)
252                                                         ,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)state),
253                                                         message ? env->NewStringUTF(message) : NULL);
254         }
255         static void notify_presence_recv (LinphoneCore *lc,  LinphoneFriend *my_friend) {
256                 JNIEnv *env = 0;
257                 jint result = jvm->AttachCurrentThread(&env,NULL);
258                 if (result != 0) {
259                         ms_error("cannot attach VM\n");
260                         return;
261                 }
262                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
263                 env->CallVoidMethod(lcData->listener
264                                                         ,lcData->notifyPresenceReceivedId
265                                                         ,lcData->core
266                                                         ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend));
267         }
268         static void new_subscription_request (LinphoneCore *lc,  LinphoneFriend *my_friend, const char* url) {
269                 JNIEnv *env = 0;
270                 jint result = jvm->AttachCurrentThread(&env,NULL);
271                 if (result != 0) {
272                         ms_error("cannot attach VM\n");
273                         return;
274                 }
275                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
276                 env->CallVoidMethod(lcData->listener
277                                                         ,lcData->newSubscriptionRequestId
278                                                         ,lcData->core
279                                                         ,env->NewObject(lcData->friendClass,lcData->friendCtrId,(jlong)my_friend)
280                                                         ,url ? env->NewStringUTF(url) : NULL);
281         }
282         static void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
283                 JNIEnv *env = 0;
284                 jint result = jvm->AttachCurrentThread(&env,NULL);
285                 if (result != 0) {
286                         ms_error("cannot attach VM\n");
287                         return;
288                 }
289                 LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
290                 env->CallVoidMethod(lcData->listener
291                                                         ,lcData->textReceivedId
292                                                         ,lcData->core
293                                                         ,env->NewObject(lcData->chatRoomClass,lcData->chatRoomCtrId,(jlong)room)
294                                                         ,env->NewObject(lcData->addressClass,lcData->addressCtrId,(jlong)from)
295                                                         ,message ? env->NewStringUTF(message) : NULL);
296         }
297
298
299 };
300 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv*  env
301                 ,jobject  thiz
302                 ,jobject jlistener
303                 ,jstring juserConfig
304                 ,jstring jfactoryConfig
305                 ,jobject  juserdata){
306
307         const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL;
308         const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL;
309         LinphoneCoreData* ldata = new LinphoneCoreData(env,thiz,jlistener,juserdata);
310 #ifdef ANDROID
311         ms_andsnd_set_jvm(jvm);
312 #endif /*ANDROID*/
313
314 #ifdef HAVE_ILBC
315         libmsilbc_init(); // requires an fpu
316 #endif
317 #ifdef VIDEO_ENABLED
318         libmsx264_init();
319 #endif
320         jlong nativePtr = (jlong)linphone_core_new(     &ldata->vTable
321                         ,userConfig
322                         ,factoryConfig
323                         ,ldata);
324         //clear auth info list
325         linphone_core_clear_all_auth_info((LinphoneCore*) nativePtr);
326         //clear existing proxy config
327         linphone_core_clear_proxy_config((LinphoneCore*) nativePtr);
328
329         if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig);
330         if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig);
331         return nativePtr;
332 }
333 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv*  env
334                 ,jobject  thiz
335                 ,jlong lc) {
336         LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data((LinphoneCore*)lc);
337         linphone_core_destroy((LinphoneCore*)lc);
338         delete lcData;
339 }
340
341 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearProxyConfigs(JNIEnv* env, jobject thiz,jlong lc) {
342         linphone_core_clear_proxy_config((LinphoneCore*)lc);
343 }
344
345 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDefaultProxyConfig(  JNIEnv*  env
346                 ,jobject  thiz
347                 ,jlong lc
348                 ,jlong pc) {
349         linphone_core_set_default_proxy((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
350 }
351 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getDefaultProxyConfig( JNIEnv*  env
352                 ,jobject  thiz
353                 ,jlong lc) {
354         LinphoneProxyConfig *config=0;
355         linphone_core_get_default_proxy((LinphoneCore*)lc,&config);
356         return (jlong)config;
357 }
358
359 extern "C" int Java_org_linphone_core_LinphoneCoreImpl_addProxyConfig(  JNIEnv*  env
360                 ,jobject  thiz
361                 ,jobject jproxyCfg
362                 ,jlong lc
363                 ,jlong pc) {
364         LinphoneProxyConfig* proxy = (LinphoneProxyConfig*)pc;
365         linphone_proxy_config_set_user_data(proxy, env->NewGlobalRef(jproxyCfg));
366
367         return linphone_core_add_proxy_config((LinphoneCore*)lc,(LinphoneProxyConfig*)pc);
368 }
369
370 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* env, jobject thiz,jlong lc) {
371         linphone_core_clear_all_auth_info((LinphoneCore*)lc);
372 }
373
374 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo(    JNIEnv*  env
375                 ,jobject  thiz
376                 ,jlong lc
377                 ,jlong pc) {
378         linphone_core_add_auth_info((LinphoneCore*)lc,(LinphoneAuthInfo*)pc);
379 }
380 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_iterate(        JNIEnv*  env
381                 ,jobject  thiz
382                 ,jlong lc) {
383         linphone_core_iterate((LinphoneCore*)lc);
384 }
385 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_invite(        JNIEnv*  env
386                 ,jobject  thiz
387                 ,jlong lc
388                 ,jstring juri) {
389         const char* uri = env->GetStringUTFChars(juri, NULL);
390         LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri);
391         env->ReleaseStringUTFChars(juri, uri);
392         return (jlong)lCall;
393 }
394 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_inviteAddress( JNIEnv*  env
395                 ,jobject  thiz
396                 ,jlong lc
397                 ,jlong to) {
398         return (jlong) linphone_core_invite_address((LinphoneCore*)lc,(LinphoneAddress*)to);
399 }
400
401 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_terminateCall(  JNIEnv*  env
402                 ,jobject  thiz
403                 ,jlong lc
404                 ,jlong call) {
405         linphone_core_terminate_call((LinphoneCore*)lc,(LinphoneCall*)call);
406 }
407
408 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getRemoteAddress(      JNIEnv*  env
409                 ,jobject  thiz
410                 ,jlong lc) {
411         return (jlong)linphone_core_get_current_call_remote_address((LinphoneCore*)lc);
412 }
413 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInCall(   JNIEnv*  env
414                 ,jobject  thiz
415                 ,jlong lc) {
416
417         return linphone_core_in_call((LinphoneCore*)lc);
418 }
419 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isInComingInvitePending(    JNIEnv*  env
420                 ,jobject  thiz
421                 ,jlong lc) {
422
423         return linphone_core_inc_invite_pending((LinphoneCore*)lc);
424 }
425 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_acceptCall(     JNIEnv*  env
426                 ,jobject  thiz
427                 ,jlong lc
428                 ,jlong call) {
429
430         linphone_core_accept_call((LinphoneCore*)lc,(LinphoneCall*)call);
431 }
432
433 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCallLog(    JNIEnv*  env
434                 ,jobject  thiz
435                 ,jlong lc
436                 ,jint position) {
437                 return (jlong)ms_list_nth_data(linphone_core_get_call_logs((LinphoneCore*)lc),position);
438 }
439 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getNumberOfCallLogs(    JNIEnv*  env
440                 ,jobject  thiz
441                 ,jlong lc) {
442                 return ms_list_size(linphone_core_get_call_logs((LinphoneCore*)lc));
443 }
444 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable(       JNIEnv*  env
445                 ,jobject  thiz
446                 ,jlong lc
447                 ,jboolean isReachable) {
448                 linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable);
449 }
450
451 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain(        JNIEnv*  env
452                 ,jobject  thiz
453                 ,jlong lc
454                 ,jfloat gain) {
455                 linphone_core_set_playback_gain_db((LinphoneCore*)lc,gain);
456 }
457
458 extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPlaybackGain(       JNIEnv*  env
459                 ,jobject  thiz
460                 ,jlong lc) {
461                 return linphone_core_get_playback_gain_db((LinphoneCore*)lc);
462 }
463
464 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_muteMic(        JNIEnv*  env
465                 ,jobject  thiz
466                 ,jlong lc
467                 ,jboolean isMuted) {
468                 linphone_core_mute_mic((LinphoneCore*)lc,isMuted);
469 }
470
471 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl(  JNIEnv*  env
472                 ,jobject  thiz
473                 ,jlong lc
474                 ,jstring jurl) {
475         const char* url = env->GetStringUTFChars(jurl, NULL);
476         jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url);
477         env->ReleaseStringUTFChars(jurl, url);
478         return result;
479 }
480 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf(       JNIEnv*  env
481                 ,jobject  thiz
482                 ,jlong lc
483                 ,jchar dtmf) {
484         linphone_core_send_dtmf((LinphoneCore*)lc,dtmf);
485 }
486 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_playDtmf(       JNIEnv*  env
487                 ,jobject  thiz
488                 ,jlong lc
489                 ,jchar dtmf
490                 ,jint duration) {
491         linphone_core_play_dtmf((LinphoneCore*)lc,dtmf,duration);
492 }
493 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopDtmf(       JNIEnv*  env
494                 ,jobject  thiz
495                 ,jlong lc) {
496         linphone_core_stop_dtmf((LinphoneCore*)lc);
497 }
498
499 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv*  env
500                                                                                                                                                 ,jobject  thiz
501                                                                                                                                                 ,jlong lc) {
502         linphone_core_clear_call_logs((LinphoneCore*)lc);
503 }
504 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isMicMuted( JNIEnv*  env
505                 ,jobject  thiz
506                 ,jlong lc) {
507         return linphone_core_is_mic_muted((LinphoneCore*)lc);
508 }
509 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv*  env
510                                                                                                                                                         ,jobject  thiz
511                                                                                                                                                         ,jlong lc
512                                                                                                                                                         ,jstring jmime
513                                                                                                                                                         ,jint rate) {
514         const char* mime = env->GetStringUTFChars(jmime, NULL);
515         jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate);
516         env->ReleaseStringUTFChars(jmime, mime);
517         return result;
518 }
519 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_enablePayloadType(JNIEnv*  env
520                                                                                                                                                         ,jobject  thiz
521                                                                                                                                                         ,jlong lc
522                                                                                                                                                         ,jlong pt
523                                                                                                                                                         ,jboolean enable) {
524         return linphone_core_enable_payload_type((LinphoneCore*)lc,(PayloadType*)pt,enable);
525 }
526 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableEchoCancellation(JNIEnv*  env
527                                                                                                                                                         ,jobject  thiz
528                                                                                                                                                         ,jlong lc
529                                                                                                                                                         ,jboolean enable) {
530         linphone_core_enable_echo_cancellation((LinphoneCore*)lc,enable);
531 }
532 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isEchoCancellationEnabled(JNIEnv*  env
533                                                                                                                                                         ,jobject  thiz
534                                                                                                                                                         ,jlong lc
535                                                                                                                                                         ) {
536         return linphone_core_echo_cancellation_enabled((LinphoneCore*)lc);
537 }
538
539 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv*  env
540                                                                                                                                                         ,jobject  thiz
541                                                                                                                                                         ,jlong lc
542                                                                                                                                                         ) {
543         return (jlong)linphone_core_get_current_call((LinphoneCore*)lc);
544 }
545 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv*  env
546                                                                                                                                                         ,jobject  thiz
547                                                                                                                                                         ,jlong lc
548                                                                                                                                                         ,jlong aFriend
549                                                                                                                                                         ) {
550         linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
551 }
552 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv*  env
553                                                                                                                                                         ,jobject  thiz
554                                                                                                                                                         ,jlong lc
555                                                                                                                                                         ,jint minute_away
556                                                                                                                                                         ,jstring jalternative_contact
557                                                                                                                                                         ,jint status) {
558         const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL;
559         linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,(LinphoneOnlineStatus)status);
560         if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
561 }
562
563 extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv*  env
564                                                                                                                                                         ,jobject  thiz
565                                                                                                                                                         ,jlong lc
566                                                                                                                                                         ,jstring jto) {
567
568         const char* to = env->GetStringUTFChars(jto, NULL);
569         LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
570         env->ReleaseStringUTFChars(jto, to);
571         return (long)lResult;
572 }
573
574 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_enableVideo(JNIEnv*  env
575                                                                                                                                                         ,jobject  thiz
576                                                                                                                                                         ,jlong lc
577                                                                                                                                                         ,jboolean vcap_enabled
578                                                                                                                                                         ,jboolean display_enabled) {
579         linphone_core_enable_video((LinphoneCore*)lc, vcap_enabled,display_enabled);
580
581 }
582 extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isVideoEnabled(JNIEnv*  env
583                                                                                                                                                         ,jobject  thiz
584                                                                                                                                                         ,jlong lc) {
585         return linphone_core_video_enabled((LinphoneCore*)lc);
586 }
587 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv*  env
588                                                                                                                                                         ,jobject  thiz
589                                                                                                                                                         ,jlong lc
590                                                                                                                                                         ,jstring jpath) {
591         const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL;
592         linphone_core_set_ring((LinphoneCore*)lc,path);
593         if (path) env->ReleaseStringUTFChars(jpath, path);
594 }
595 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv*  env
596                                                                                                                                                         ,jobject  thiz
597                                                                                                                                                         ,jlong lc
598                                                                                                                                                         ) {
599         const char* path = linphone_core_get_ring((LinphoneCore*)lc);
600         if (path) {
601                 return env->NewStringUTF(path);
602         } else {
603                 return NULL;
604         }
605 }
606
607
608 //ProxyConfig
609
610 extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_newLinphoneProxyConfig(JNIEnv*  env,jobject  thiz) {
611         LinphoneProxyConfig* proxy = linphone_proxy_config_new();
612         return  (jlong) proxy;
613 }
614
615 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_delete(JNIEnv*  env,jobject  thiz,jlong ptr) {
616         linphone_proxy_config_destroy((LinphoneProxyConfig*)ptr);
617 }
618 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) {
619         const char* identity = env->GetStringUTFChars(jidentity, NULL);
620         linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity);
621         env->ReleaseStringUTFChars(jidentity, identity);
622 }
623 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) {
624         const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg);
625         if (identity) {
626                 return env->NewStringUTF(identity);
627         } else {
628                 return NULL;
629         }
630 }
631 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) {
632         const char* proxy = env->GetStringUTFChars(jproxy, NULL);
633         int err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy);
634         env->ReleaseStringUTFChars(jproxy, proxy);
635         return err;
636 }
637 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) {
638         const char* proxy = linphone_proxy_config_get_addr((LinphoneProxyConfig*)proxyCfg);
639         if (proxy) {
640                 return env->NewStringUTF(proxy);
641         } else {
642                 return NULL;
643         }
644 }
645 extern "C" int Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) {
646         if (jroute != NULL) {
647                 const char* route = env->GetStringUTFChars(jroute, NULL);
648                 int err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route);
649                 env->ReleaseStringUTFChars(jroute, route);
650                 return err;
651         } else {
652                 return linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL);
653         }
654 }
655 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getRoute(JNIEnv* env,jobject thiz,jlong proxyCfg) {
656         const char* route = linphone_proxy_config_get_route((LinphoneProxyConfig*)proxyCfg);
657         if (route) {
658                 return env->NewStringUTF(route);
659         } else {
660                 return NULL;
661         }
662 }
663
664 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enableRegister(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean enableRegister) {
665         linphone_proxy_config_enable_register((LinphoneProxyConfig*)proxyCfg,enableRegister);
666 }
667 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegistered(JNIEnv* env,jobject thiz,jlong proxyCfg) {
668         return linphone_proxy_config_is_registered((LinphoneProxyConfig*)proxyCfg);
669 }
670 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_isRegisterEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
671         return linphone_proxy_config_register_enabled((LinphoneProxyConfig*)proxyCfg);
672 }
673 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_edit(JNIEnv* env,jobject thiz,jlong proxyCfg) {
674         linphone_proxy_config_edit((LinphoneProxyConfig*)proxyCfg);
675 }
676 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_done(JNIEnv* env,jobject thiz,jlong proxyCfg) {
677         linphone_proxy_config_done((LinphoneProxyConfig*)proxyCfg);
678 }
679 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhoneNumber(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jnumber) {
680         if (jnumber == 0) {
681                 ms_error("cannot normalized null number");
682         }
683         const char* number = env->GetStringUTFChars(jnumber, NULL);
684         int len = env->GetStringLength(jnumber);
685         if (len == 0) {
686                 ms_warning("cannot normalize empty number");
687                 return jnumber;
688         }
689         char targetBuff[2*len];// returned number can be greater than origin (specially in case of prefix insertion
690         linphone_proxy_config_normalize_number((LinphoneProxyConfig*)proxyCfg,number,targetBuff,sizeof(targetBuff));
691         jstring normalizedNumber = env->NewStringUTF(targetBuff);
692         env->ReleaseStringUTFChars(jnumber, number);
693         return normalizedNumber;
694 }
695 extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env
696                                                                                                                                                         ,jobject thiz
697                                                                                                                                                         ,jlong proxyCfg) {
698         const char* domain = linphone_proxy_config_get_domain((LinphoneProxyConfig*)proxyCfg);
699         if (domain) {
700                 return env->NewStringUTF(domain);
701         } else {
702                 return NULL;
703         }
704 }
705 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialEscapePlus(JNIEnv* env,jobject thiz,jlong proxyCfg,jboolean value) {
706         linphone_proxy_config_set_dial_escape_plus((LinphoneProxyConfig*)proxyCfg,value);
707 }
708
709 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNIEnv* env
710                                                                                                                                         ,jobject thiz
711                                                                                                                                         ,jlong proxyCfg
712                                                                                                                                         ,jstring jprefix) {
713         const char* prefix = env->GetStringUTFChars(jprefix, NULL);
714         linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix);
715         env->ReleaseStringUTFChars(jprefix, prefix);
716 }
717 extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_enablePublish(JNIEnv* env
718                                                                                                                                                                 ,jobject thiz
719                                                                                                                                                                 ,jlong proxyCfg
720                                                                                                                                                                 ,jboolean val) {
721         linphone_proxy_config_enable_publish((LinphoneProxyConfig*)proxyCfg,val);
722 }
723 extern "C" jboolean Java_org_linphone_core_LinphoneProxyConfigImpl_publishEnabled(JNIEnv* env,jobject thiz,jlong proxyCfg) {
724         return linphone_proxy_config_publish_enabled((LinphoneProxyConfig*)proxyCfg);
725 }
726
727 //Auth Info
728
729 extern "C" jlong Java_org_linphone_core_LinphoneAuthInfoImpl_newLinphoneAuthInfo(JNIEnv* env
730                 , jobject thiz
731                 , jstring jusername
732                 , jstring juserid
733                 , jstring jpassword
734                 , jstring jha1
735                 , jstring jrealm) {
736
737         const char* username = env->GetStringUTFChars(jusername, NULL);
738         const char* password = env->GetStringUTFChars(jpassword, NULL);
739         jlong auth = (jlong)linphone_auth_info_new(username,NULL,password,NULL,NULL);
740
741         env->ReleaseStringUTFChars(jusername, username);
742         env->ReleaseStringUTFChars(jpassword, password);
743         return auth;
744
745 }
746 extern "C" void Java_org_linphone_core_LinphoneAuthInfoImpl_delete(JNIEnv* env
747                 , jobject thiz
748                 , jlong ptr) {
749         linphone_auth_info_destroy((LinphoneAuthInfo*)ptr);
750 }
751
752 //LinphoneAddress
753
754 extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressImpl(JNIEnv*  env
755                                                                                                                                                                         ,jobject  thiz
756                                                                                                                                                                         ,jstring juri
757                                                                                                                                                                         ,jstring jdisplayName) {
758         const char* uri = env->GetStringUTFChars(juri, NULL);
759         LinphoneAddress* address = linphone_address_new(uri);
760         if (jdisplayName && address) {
761                 const char* displayName = env->GetStringUTFChars(jdisplayName, NULL);
762                 linphone_address_set_display_name(address,displayName);
763                 env->ReleaseStringUTFChars(jdisplayName, displayName);
764         }
765         env->ReleaseStringUTFChars(juri, uri);
766
767         return  (jlong) address;
768 }
769 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_delete(JNIEnv*  env
770                                                                                                                                                 ,jobject  thiz
771                                                                                                                                                 ,jlong ptr) {
772         linphone_address_destroy((LinphoneAddress*)ptr);
773 }
774
775 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDisplayName(JNIEnv*  env
776                                                                                                                                                 ,jobject  thiz
777                                                                                                                                                 ,jlong ptr) {
778         const char* displayName = linphone_address_get_display_name((LinphoneAddress*)ptr);
779         if (displayName) {
780                 return env->NewStringUTF(displayName);
781         } else {
782                 return 0;
783         }
784 }
785 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getUserName(JNIEnv*  env
786                                                                                                                                                 ,jobject  thiz
787                                                                                                                                                 ,jlong ptr) {
788         const char* userName = linphone_address_get_username((LinphoneAddress*)ptr);
789         if (userName) {
790                 return env->NewStringUTF(userName);
791         } else {
792                 return 0;
793         }
794 }
795 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_getDomain(JNIEnv*  env
796                                                                                                                                                 ,jobject  thiz
797                                                                                                                                                 ,jlong ptr) {
798         const char* domain = linphone_address_get_domain((LinphoneAddress*)ptr);
799         if (domain) {
800                 return env->NewStringUTF(domain);
801         } else {
802                 return 0;
803         }
804 }
805
806 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toString(JNIEnv*  env
807                                                                                                                                                 ,jobject  thiz
808                                                                                                                                                 ,jlong ptr) {
809         char* uri = linphone_address_as_string((LinphoneAddress*)ptr);
810         jstring juri =env->NewStringUTF(uri);
811         ms_free(uri);
812         return juri;
813 }
814 extern "C" jstring Java_org_linphone_core_LinphoneAddressImpl_toUri(JNIEnv*  env
815                                                                                                                                                 ,jobject  thiz
816                                                                                                                                                 ,jlong ptr) {
817         char* uri = linphone_address_as_string_uri_only((LinphoneAddress*)ptr);
818         jstring juri =env->NewStringUTF(uri);
819         ms_free(uri);
820         return juri;
821 }
822 extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv*  env
823                                                                                                                                                 ,jobject  thiz
824                                                                                                                                                 ,jlong address
825                                                                                                                                                 ,jstring jdisplayName) {
826         const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL;
827         linphone_address_set_display_name((LinphoneAddress*)address,displayName);
828         if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName);
829 }
830
831
832 //CallLog
833 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getFrom(JNIEnv*  env
834                                                                                                                                                 ,jobject  thiz
835                                                                                                                                                 ,jlong ptr) {
836         return (jlong)((LinphoneCallLog*)ptr)->from;
837 }
838 extern "C" jlong Java_org_linphone_core_LinphoneCallLogImpl_getTo(JNIEnv*  env
839                                                                                                                                                 ,jobject  thiz
840                                                                                                                                                 ,jlong ptr) {
841         return (jlong)((LinphoneCallLog*)ptr)->to;
842 }
843 extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_isIncoming(JNIEnv*  env
844                                                                                                                                                 ,jobject  thiz
845                                                                                                                                                 ,jlong ptr) {
846         return ((LinphoneCallLog*)ptr)->dir==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
847 }
848
849 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv*  env
850                                                                                                                                                 ,jobject  thiz
851                                                                                                                                                 ,jlong ptr) {
852
853         PayloadType* pt = (PayloadType*)ptr;
854         char* value = ms_strdup_printf("[%s] clock [%s], bitrate [%s]"
855                                                                         ,payload_type_get_mime(pt)
856                                                                         ,payload_type_get_rate(pt)
857                                                                         ,payload_type_get_bitrate(pt));
858         jstring jvalue =env->NewStringUTF(value);
859         ms_free(value);
860         return jvalue;
861 }
862 //LinphoneCall
863 extern "C" void Java_org_linphone_core_LinphoneCallImpl_ref(JNIEnv*  env
864                                                                                                                                                 ,jobject  thiz
865                                                                                                                                                 ,jlong ptr) {
866         linphone_call_ref((LinphoneCall*)ptr);
867 }
868
869 extern "C" void Java_org_linphone_core_LinphoneCallImpl_unref(JNIEnv*  env
870                                                                                                                                                 ,jobject  thiz
871                                                                                                                                                 ,jlong ptr) {
872         linphone_call_unref((LinphoneCall*)ptr);
873 }
874
875 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog(    JNIEnv*  env
876                                                                                                                                                 ,jobject  thiz
877                                                                                                                                                 ,jlong ptr) {
878         return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr);
879 }
880
881 extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv*  env
882                                                                                                                                                 ,jobject  thiz
883                                                                                                                                                 ,jlong ptr) {
884         return linphone_call_get_dir((LinphoneCall*)ptr)==LinphoneCallIncoming?JNI_TRUE:JNI_FALSE;
885 }
886
887 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getRemoteAddress(      JNIEnv*  env
888                                                                                                                                                 ,jobject  thiz
889                                                                                                                                                 ,jlong ptr) {
890         return (jlong)linphone_call_get_remote_address((LinphoneCall*)ptr);
891 }
892
893 extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState(       JNIEnv*  env
894                                                                                                                                                 ,jobject  thiz
895                                                                                                                                                 ,jlong ptr) {
896         return (jint)linphone_call_get_state((LinphoneCall*)ptr);
897 }
898
899 //LinphoneFriend
900 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv*  env
901                                                                                                                                                 ,jobject  thiz
902                                                                                                                                                 ,jstring jFriendUri) {
903         LinphoneFriend* lResult;
904
905         if (jFriendUri) {
906                 const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
907                 lResult= linphone_friend_new_with_addr(friendUri);
908                 env->ReleaseStringUTFChars(jFriendUri, friendUri);
909         } else {
910                 lResult = linphone_friend_new();
911         }
912         return (long)lResult;
913 }
914 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv*  env
915                                                                                                                                                 ,jobject  thiz
916                                                                                                                                                 ,jlong ptr
917                                                                                                                                                 ,jlong linphoneAddress) {
918         linphone_friend_set_addr((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
919 }
920 extern "C" long Java_org_linphone_core_LinphoneFriendImpl_getAddress(JNIEnv*  env
921                                                                                                                                                 ,jobject  thiz
922                                                                                                                                                 ,jlong ptr) {
923         return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
924 }
925 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv*  env
926                                                                                                                                                 ,jobject  thiz
927                                                                                                                                                 ,jlong ptr
928                                                                                                                                                 ,jint policy) {
929         linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,(LinphoneSubscribePolicy)policy);
930 }
931 extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv*  env
932                                                                                                                                                 ,jobject  thiz
933                                                                                                                                                 ,jlong ptr) {
934         return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
935 }
936 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv*  env
937                                                                                                                                                 ,jobject  thiz
938                                                                                                                                                 ,jlong ptr
939                                                                                                                                                 ,jboolean value) {
940         linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
941 }
942 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv*  env
943                                                                                                                                                 ,jobject  thiz
944                                                                                                                                                 ,jlong ptr) {
945         return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
946 }
947 extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv*  env
948                                                                                                                                                 ,jobject  thiz
949                                                                                                                                                 ,jlong ptr) {
950         return linphone_friend_get_status((LinphoneFriend*)ptr);
951 }
952 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv*  env
953                                                                                                                                                 ,jobject  thiz
954                                                                                                                                                 ,jlong ptr) {
955         return linphone_friend_edit((LinphoneFriend*)ptr);
956 }
957 extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv*  env
958                                                                                                                                                 ,jobject  thiz
959                                                                                                                                                 ,jlong ptr) {
960          linphone_friend_done((LinphoneFriend*)ptr);
961 }
962 //LinphoneChatRoom
963 extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv*  env
964                                                                                                                                                 ,jobject  thiz
965                                                                                                                                                 ,jlong ptr) {
966         return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
967 }
968 extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv*  env
969                                                                                                                                                 ,jobject  thiz
970                                                                                                                                                 ,jlong ptr
971                                                                                                                                                 ,jstring jmessage) {
972         const char* message = env->GetStringUTFChars(jmessage, NULL);
973         linphone_chat_room_send_message((LinphoneChatRoom*)ptr,message);
974         env->ReleaseStringUTFChars(jmessage, message);
975
976 }
977
978 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env
979                                                                                                                                                 ,jobject thiz
980                                                                                                                                                 ,jlong lc
981                                                                                                                                                 ,jobject obj) {
982         linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
983 }
984
985
986 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
987         linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
988 }
989
990 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
991         return linphone_core_get_firewall_policy((LinphoneCore*)lc);
992 }
993
994 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
995         const char* server = NULL;
996         if (jserver) server=env->GetStringUTFChars(jserver, NULL);
997         linphone_core_set_stun_server((LinphoneCore*)lc,server);
998         if (server) env->ReleaseStringUTFChars(jserver,server);
999 }
1000
1001 extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
1002         const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
1003         if (ret==NULL) return NULL;
1004         jstring jvalue =env->NewStringUTF(ret);
1005         return jvalue;
1006 }
1007
1008 extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong lcp, jboolean b){
1009         linphone_call_params_enable_video((LinphoneCallParams*)lcp, b);
1010 }
1011
1012 extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_getVideoEnabled(JNIEnv *env, jobject thiz, jlong lcp){
1013         return linphone_call_params_video_enabled((LinphoneCallParams*)lcp);
1014 }
1015 extern "C" jlong Java_org_linphone_core_LinphoneCallParamsImpl_copy(JNIEnv *env, jobject thiz, jlong lcp){
1016         return (jlong) linphone_call_params_copy((LinphoneCallParams*)lcp);
1017 }
1018 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createDefaultCallParams(JNIEnv *env, jobject thiz, jlong lc){
1019         return (jlong) linphone_core_create_default_call_parameters((LinphoneCore*)lc);
1020 }
1021
1022 extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCurrentParams(JNIEnv *env, jobject thiz, jlong lc){
1023         return (jlong) linphone_call_get_current_params((LinphoneCall*)lc);
1024 }
1025
1026 extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_inviteAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong addr, jlong params){
1027         return (jlong) linphone_core_invite_address_with_params((LinphoneCore *)lc, (const LinphoneAddress *)addr, (const LinphoneCallParams *)params);
1028 }
1029
1030 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateAddressWithParams(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1031         return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1032 }
1033
1034 extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_updateCall(JNIEnv *env, jobject thiz, jlong lc, jlong call, jlong params){
1035         return (jint) linphone_core_update_call((LinphoneCore *)lc, (LinphoneCall *)call, (LinphoneCallParams *)params);
1036 }
1037
1038
1039 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc, jint width, jint height){
1040         MSVideoSize vsize;
1041         vsize.width = (int)width;
1042         vsize.height = (int)height;
1043         linphone_core_set_preferred_video_size((LinphoneCore *)lc, vsize);
1044 }
1045
1046 extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){
1047         MSVideoSize vsize = linphone_core_get_preferred_video_size((LinphoneCore *)lc);
1048     jintArray arr = env->NewIntArray(2);
1049         int tVsize [2]= {vsize.width,vsize.height};
1050     env->SetIntArrayRegion(arr, 0, 2, tVsize);
1051     return arr;
1052 }
1053
1054 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1055         linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw);
1056 }
1057
1058 extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){
1059         linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw);
1060 }
1061