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