diff --git a/LinphoneAddressImpl.java b/LinphoneAddressImpl.java index bf4670ec3..b9d290971 100644 --- a/LinphoneAddressImpl.java +++ b/LinphoneAddressImpl.java @@ -32,6 +32,9 @@ public class LinphoneAddressImpl implements LinphoneAddress { private native void setDisplayName(long ptr,String name); private native String toString(long ptr); + protected LinphoneAddressImpl(String identity) { + nativePtr = newLinphoneAddressImpl(identity, null); + } protected LinphoneAddressImpl(String username,String domain,String displayName) { nativePtr = newLinphoneAddressImpl("sip:"+username+"@"+domain, displayName); diff --git a/LinphoneCoreFactoryImpl.java b/LinphoneCoreFactoryImpl.java index a6f899f31..1b4e9aaf0 100644 --- a/LinphoneCoreFactoryImpl.java +++ b/LinphoneCoreFactoryImpl.java @@ -39,8 +39,8 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { } @Override - public LinphoneAddress createLinphoneAddress(String address) { - throw new RuntimeException("Not implemeneted yet"); + public LinphoneAddress createLinphoneAddress(String identity) { + return new LinphoneAddressImpl(identity); } @Override @@ -54,6 +54,15 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { } } + @Override + public LinphoneCore createLinphoneCore(LinphoneCoreListener listener) throws LinphoneCoreException { + try { + return new LinphoneCoreImpl(listener); + } catch (IOException e) { + throw new LinphoneCoreException("Cannot create LinphoneCore",e); + } + } + @Override public LinphoneProxyConfig createProxyConfig(String identity, String proxy, String route, boolean enableRegister) throws LinphoneCoreException { @@ -70,12 +79,12 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { } @Override - LinphoneFriend createLinphoneFriend(String friendUri) { + public LinphoneFriend createLinphoneFriend(String friendUri) { return new LinphoneFriendImpl(friendUri); } @Override - LinphoneFriend createLinphoneFriend() { + public LinphoneFriend createLinphoneFriend() { return createLinphoneFriend(null); } } diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java index 0143dc7d5..83a78a00e 100644 --- a/LinphoneCoreImpl.java +++ b/LinphoneCoreImpl.java @@ -72,6 +72,11 @@ class LinphoneCoreImpl implements LinphoneCore { mListener=listener; nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); } + LinphoneCoreImpl(LinphoneCoreListener listener) throws IOException { + mListener=listener; + nativePtr = newLinphoneCore(listener,null,null,null); + } + protected void finalize() throws Throwable { } @@ -287,5 +292,14 @@ class LinphoneCoreImpl implements LinphoneCore { public LinphoneChatRoom createChatRoom(String to) { return new LinphoneChatRoomImpl(createChatRoom(nativePtr,to)); } + public void setPreviewWindow(VideoWindow w) { + throw new RuntimeException("not implemented yet"); + // TODO Auto-generated method stub + + } + public void setVideoWindow(VideoWindow w) { + throw new RuntimeException("not implemented yet"); + // TODO Auto-generated method stub + } } diff --git a/tutorials/AndroidTutorialNotifier.java b/tutorials/AndroidTutorialNotifier.java new file mode 100644 index 000000000..01e0555e2 --- /dev/null +++ b/tutorials/AndroidTutorialNotifier.java @@ -0,0 +1,49 @@ +/* +AndroidTutorialNotifier.java +Copyright (C) 2010 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +package org.linphone.core.tutorials; + +import android.os.Handler; +import android.widget.TextView; + +/** + * Write notifications to a TextView widget. + * + * @author Guillaume Beraudo + * + */ +public class AndroidTutorialNotifier extends TutorialNotifier { + + private Handler mHandler; + private TextView outputTextView; + + public AndroidTutorialNotifier(Handler mHandler, final TextView outputTextView) { + this.mHandler = mHandler; + this.outputTextView = outputTextView; + } + + + @Override + public void notify(final String s) { + mHandler.post(new Runnable() { + public void run() { + outputTextView.setText(s + "\n" + outputTextView.getText()); + } + }); + } +} diff --git a/tutorials/TutorialBuddyStatusActivity.java b/tutorials/TutorialBuddyStatusActivity.java new file mode 100644 index 000000000..376afadfb --- /dev/null +++ b/tutorials/TutorialBuddyStatusActivity.java @@ -0,0 +1,98 @@ +/* +TutorialBuddyStatusActivity.java +Copyright (C) 2010 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +package org.linphone.core.tutorials; + +import org.linphone.R; +import org.linphone.core.LinphoneCoreException; + +import android.app.Activity; +import android.os.Bundle; +import android.os.Handler; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +/** + * Activity for displaying and starting the BuddyStatus example on Android phone. + * + * @author Guillaume Beraudo + * + */ +public class TutorialBuddyStatusActivity extends Activity { + + private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059"; + private TextView sipAddressWidget; + private TutorialBuddyStatus tutorial; + private Handler mHandler = new Handler() ; + private Button buttonCall; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.hello_world); + sipAddressWidget = (TextView) findViewById(R.id.AddressId); + sipAddressWidget.setText(defaultSipAddress); + + // Output text to the outputText widget + final TextView outputText = (TextView) findViewById(R.id.OutputText); + final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); + + + // Create BuddyStatus object + tutorial = new TutorialBuddyStatus(notifier); + + + + // Assign call action to call button + buttonCall = (Button) findViewById(R.id.CallButton); + buttonCall.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + TutorialLaunchingThread thread = new TutorialLaunchingThread(); + buttonCall.setEnabled(false); + thread.start(); + } + }); + + // Assign stop action to stop button + Button buttonStop = (Button) findViewById(R.id.ButtonStop); + buttonStop.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + tutorial.stopMainLoop(); + } + }); + } + + + private class TutorialLaunchingThread extends Thread { + @Override + public void run() { + super.run(); + try { + tutorial.launchTutorial(sipAddressWidget.getText().toString()); + mHandler.post(new Runnable() { + public void run() { + buttonCall.setEnabled(true); + } + }); + } catch (LinphoneCoreException e) { + e.printStackTrace(); + } + } + } +} diff --git a/tutorials/TutorialChatRoomActivity.java b/tutorials/TutorialChatRoomActivity.java new file mode 100644 index 000000000..aa4623eeb --- /dev/null +++ b/tutorials/TutorialChatRoomActivity.java @@ -0,0 +1,98 @@ +/* +TutorialChatRoomActivity.java +Copyright (C) 2010 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +package org.linphone.core.tutorials; + +import org.linphone.R; +import org.linphone.core.LinphoneCoreException; + +import android.app.Activity; +import android.os.Bundle; +import android.os.Handler; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +/** + * Activity for displaying and starting the chatroom example on Android phone. + * + * @author Guillaume Beraudo + * + */ +public class TutorialChatRoomActivity extends Activity { + + private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059"; + private TextView sipAddressWidget; + private TutorialChatRoom tutorial; + private Handler mHandler = new Handler() ; + private Button buttonCall; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.hello_world); + sipAddressWidget = (TextView) findViewById(R.id.AddressId); + sipAddressWidget.setText(defaultSipAddress); + + // Output text to the outputText widget + final TextView outputText = (TextView) findViewById(R.id.OutputText); + final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); + + + // Create HelloWorld object + tutorial = new TutorialChatRoom(notifier); + + + + // Assign call action to call button + buttonCall = (Button) findViewById(R.id.CallButton); + buttonCall.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + TutorialLaunchingThread thread = new TutorialLaunchingThread(); + buttonCall.setEnabled(false); + thread.start(); + } + }); + + // Assign stop action to stop button + Button buttonStop = (Button) findViewById(R.id.ButtonStop); + buttonStop.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + tutorial.stopMainLoop(); + } + }); + } + + + private class TutorialLaunchingThread extends Thread { + @Override + public void run() { + super.run(); + try { + tutorial.launchTutorial(sipAddressWidget.getText().toString()); + mHandler.post(new Runnable() { + public void run() { + buttonCall.setEnabled(true); + } + }); + } catch (LinphoneCoreException e) { + e.printStackTrace(); + } + } + } +} diff --git a/tutorials/TutorialHelloWorldActivity.java b/tutorials/TutorialHelloWorldActivity.java new file mode 100644 index 000000000..3ef643a61 --- /dev/null +++ b/tutorials/TutorialHelloWorldActivity.java @@ -0,0 +1,98 @@ +/* +TutorialHelloWorldActivity.java +Copyright (C) 2010 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +package org.linphone.core.tutorials; + +import org.linphone.R; +import org.linphone.core.LinphoneCoreException; + +import android.app.Activity; +import android.os.Bundle; +import android.os.Handler; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +/** + * Activity for displaying and starting the HelloWorld example on Android phone. + * + * @author Guillaume Beraudo + * + */ +public class TutorialHelloWorldActivity extends Activity { + + private static final String defaultSipAddress = "sip:tested@10.0.2.6:5059"; + private TextView sipAddressWidget; + private TutorialHelloWorld tutorial; + private Handler mHandler = new Handler() ; + private Button buttonCall; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.hello_world); + sipAddressWidget = (TextView) findViewById(R.id.AddressId); + sipAddressWidget.setText(defaultSipAddress); + + // Output text to the outputText widget + final TextView outputText = (TextView) findViewById(R.id.OutputText); + final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); + + + // Create HelloWorld object + tutorial = new TutorialHelloWorld(notifier); + + + + // Assign call action to call button + buttonCall = (Button) findViewById(R.id.CallButton); + buttonCall.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + TutorialLaunchingThread thread = new TutorialLaunchingThread(); + buttonCall.setEnabled(false); + thread.start(); + } + }); + + // Assign stop action to stop button + Button buttonStop = (Button) findViewById(R.id.ButtonStop); + buttonStop.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + tutorial.stopMainLoop(); + } + }); + } + + + private class TutorialLaunchingThread extends Thread { + @Override + public void run() { + super.run(); + try { + tutorial.launchTutorial(sipAddressWidget.getText().toString()); + mHandler.post(new Runnable() { + public void run() { + buttonCall.setEnabled(true); + } + }); + } catch (LinphoneCoreException e) { + e.printStackTrace(); + } + } + } +} diff --git a/tutorials/TutorialRegistrationActivity.java b/tutorials/TutorialRegistrationActivity.java new file mode 100644 index 000000000..4da10f632 --- /dev/null +++ b/tutorials/TutorialRegistrationActivity.java @@ -0,0 +1,105 @@ +/* +TutorialRegistrationActivity.java +Copyright (C) 2010 Belledonne Communications, Grenoble, France + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +package org.linphone.core.tutorials; + +import org.linphone.R; +import org.linphone.core.LinphoneCoreException; + +import android.os.Bundle; +import android.os.Handler; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +/** + * Activity for displaying and starting the registration example on Android phone. + * + * @author Guillaume Beraudo + * + */ +public class TutorialRegistrationActivity extends TutorialHelloWorldActivity { + + private static final String defaultSipAddress = "sip:8182449901ip@mty11.axtel.net"; + private static final String defaultSipPassword = "49901"; + private TextView sipAddressWidget; + private TextView sipPasswordWidget; + private TutorialRegistration tutorial; + private Button buttonCall; + private Handler mHandler = new Handler(); + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.hello_world); + sipAddressWidget = (TextView) findViewById(R.id.AddressId); + sipAddressWidget.setText(defaultSipAddress); + sipPasswordWidget = (TextView) findViewById(R.id.Password); + sipPasswordWidget.setVisibility(TextView.VISIBLE); + sipPasswordWidget.setText(defaultSipPassword); + + // Output text to the outputText widget + final TextView outputText = (TextView) findViewById(R.id.OutputText); + final TutorialNotifier notifier = new AndroidTutorialNotifier(mHandler, outputText); + + + // Create Tutorial object + tutorial = new TutorialRegistration(notifier); + + + + // Assign call action to call button + buttonCall = (Button) findViewById(R.id.CallButton); + buttonCall.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + TutorialLaunchingThread thread = new TutorialLaunchingThread(); + buttonCall.setEnabled(false); + thread.start(); + } + }); + + // Assign stop action to stop button + Button buttonStop = (Button) findViewById(R.id.ButtonStop); + buttonStop.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + tutorial.stopMainLoop(); + } + }); + } + + + private class TutorialLaunchingThread extends Thread { + @Override + public void run() { + super.run(); + try { + tutorial.launchTutorial( + sipAddressWidget.getText().toString(), + sipPasswordWidget.getText().toString()); + mHandler.post(new Runnable() { + public void run() { + buttonCall.setEnabled(true); + } + }); + } catch (LinphoneCoreException e) { + e.printStackTrace(); + } + } + } +}