diff --git a/coreapi/help/Makefile.am b/coreapi/help/Makefile.am index 7fa592da2..74767bea3 100644 --- a/coreapi/help/Makefile.am +++ b/coreapi/help/Makefile.am @@ -32,23 +32,29 @@ endif clean-local: rm -rf doc +#tutorials + noinst_PROGRAMS=helloworld registration buddy_status chatroom helloworld_SOURCES=helloworld.c +LINPHONE_TUTOS=$(helloworld_SOURCES) helloworld_LDADD=$(top_builddir)/coreapi/liblinphone.la \ $(MEDIASTREAMER_LIBS) \ $(ORTP_LIBS) registration_SOURCES=registration.c +LINPHONE_TUTOS+=$(registration_SOURCES) registration_LDADD=$(helloworld_LDADD) buddy_status_SOURCES=buddy_status.c +LINPHONE_TUTOS+=$(buddy_status_SOURCES) buddy_status_LDADD=$(helloworld_LDADD) chatroom_SOURCES=chatroom.c +LINPHONE_TUTOS+=$(chatroom_SOURCES) chatroom_LDADD=$(helloworld_LDADD) @@ -68,3 +74,7 @@ AM_CFLAGS=$(STRICT_OPTIONS) -DIN_LINPHONE \ -DORTP_INET6 \ $(VIDEO_CFLAGS) + +tutodir=$(datadir)/tutorials/linphone + +tuto_DATA=$(LINPHONE_TUTOS) diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java index 25dae37d7..61855d9e5 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java @@ -81,7 +81,9 @@ public class TutorialBuddyStatus implements LinphoneCoreListener { } - public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg,RegistrationState cstate, String smessage) {} + public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg,RegistrationState cstate, String smessage) { + write(cfg.getIdentity() + " : "+smessage+"\n"); + } public void show(LinphoneCore lc) {} public void byeReceived(LinphoneCore lc, String from) {} public void authInfoRequested(LinphoneCore lc, String realm, String username) {} @@ -97,8 +99,8 @@ public class TutorialBuddyStatus implements LinphoneCoreListener { public static void main(String[] args) { // Check tutorial was called with the right number of arguments - if (args.length != 1) { - throw new IllegalArgumentException("Bad number of arguments"); + if (args.length < 1 || args.length > 3 ) { + throw new IllegalArgumentException("Bad number of arguments ["+args.length+"] should be 1, 2 or 3"); } // Create tutorial object @@ -106,7 +108,13 @@ public class TutorialBuddyStatus implements LinphoneCoreListener { try { // takes sip uri identity from the command line arguments String userSipAddress = args[1]; - tutorial.launchTutorial(userSipAddress); + + // takes sip uri identity from the command line arguments + String mySipAddress = args.length>1?args[1]:null; + // takes password from the command line arguments + String mySipPassword =args.length>2?args[2]:null; + + tutorial.launchTutorial(userSipAddress,mySipAddress,mySipPassword); } catch (Exception e) { e.printStackTrace(); } @@ -114,7 +122,7 @@ public class TutorialBuddyStatus implements LinphoneCoreListener { - public void launchTutorial(String sipAddress) throws LinphoneCoreException { + public void launchTutorial(String sipAddress,String mySipAddress, String mySipPassword) throws LinphoneCoreException { final LinphoneCoreFactory lcFactory = LinphoneCoreFactory.instance(); // First instantiate the core Linphone object given only a listener. @@ -131,6 +139,33 @@ public class TutorialBuddyStatus implements LinphoneCoreListener { return; } + if (mySipAddress != null) { + // Parse identity + LinphoneAddress address = lcFactory.createLinphoneAddress(mySipAddress); + String username = address.getUserName(); + String domain = address.getDomain(); + + + if (mySipPassword != null) { + // create authentication structure from identity and add to linphone + lc.addAuthInfo(lcFactory.createAuthInfo(username, mySipPassword, null)); + } + + // create proxy config + LinphoneProxyConfig proxyCfg = lcFactory.createProxyConfig(mySipAddress, domain, null, true); + lc.addProxyConfig(proxyCfg); // add it to linphone + lc.setDefaultProxyConfig(proxyCfg); + while (!proxyCfg.isRegistered()) { + lc.iterate(); //iterate until registration + try{ + Thread.sleep(1000); + } catch(InterruptedException ie) { + write("Interrupted!\nAborting"); + return; + } + } + } + // configure this friend to emit SUBSCRIBE message after being added to LinphoneCore lf.enableSubscribes(true); diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index f9a85b627..bf134ac6b 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include "linphonecore.h" +#include "mediastreamer2/msjava.h" + #ifdef ANDROID #include extern "C" void libmsilbc_init(); @@ -47,6 +49,7 @@ static void linphone_android_log_handler(OrtpLogLevel lev, const char *fmt, va_l JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) { #ifdef ANDROID + ms_set_jvm(ajvm); ms_andsnd_set_jvm(ajvm); #ifdef VIDEO_ENABLED ms_andvid_set_jvm(ajvm);