From cb424561404f671fb4642fac21189859d516d5f8 Mon Sep 17 00:00:00 2001 From: jehan Date: Mon, 18 Jan 2010 18:04:25 +0100 Subject: [PATCH] initial commit --- LinphoneAuthInfo.java | 23 ++++++++++++ LinphoneCore.java | 68 ++++++++++++++++++++++++++++++++++++ LinphoneCoreException.java | 42 ++++++++++++++++++++++ LinphoneCoreFactory.java | 43 +++++++++++++++++++++++ LinphoneCoreImpl.java | 63 +++++++++++++++++++++++++++++++++ LinphoneCoreListener.java | 49 ++++++++++++++++++++++++++ LinphoneProxyConfig.java | 25 +++++++++++++ LinphoneProxyConfigImpl.java | 54 ++++++++++++++++++++++++++++ 8 files changed, 367 insertions(+) create mode 100644 LinphoneAuthInfo.java create mode 100644 LinphoneCore.java create mode 100644 LinphoneCoreException.java create mode 100644 LinphoneCoreFactory.java create mode 100644 LinphoneCoreImpl.java create mode 100644 LinphoneCoreListener.java create mode 100644 LinphoneProxyConfig.java create mode 100644 LinphoneProxyConfigImpl.java diff --git a/LinphoneAuthInfo.java b/LinphoneAuthInfo.java new file mode 100644 index 000000000..0b8865f42 --- /dev/null +++ b/LinphoneAuthInfo.java @@ -0,0 +1,23 @@ +/* +LinphoneAuthInfo.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; + +public interface LinphoneAuthInfo { + +} diff --git a/LinphoneCore.java b/LinphoneCore.java new file mode 100644 index 000000000..f10cf0df3 --- /dev/null +++ b/LinphoneCore.java @@ -0,0 +1,68 @@ +/* +LinphoneCore.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; + +import java.io.File; +import java.net.URI; + +public interface LinphoneCore { + /* + * linphone core states + */ + interface GeneralState { + /* states for GSTATE_GROUP_POWER */ + static int GSTATE_POWER_OFF =0; /* initial state */ + static int GSTATE_POWER_STARTUP=1; + static int GSTATE_POWER_ON=2; + static int GSTATE_POWER_SHUTDOWN=3; + /* states for GSTATE_GROUP_REG */ + static int GSTATE_REG_NONE=10; /* initial state */ + static int GSTATE_REG_OK=11; + static int GSTATE_REG_FAILED=12; + /* states for GSTATE_GROUP_CALL */ + static int GSTATE_CALL_IDLE=20; /* initial state */ + static int GSTATE_CALL_OUT_INVITE=21; + static int GSTATE_CALL_OUT_CONNECTED=22; + static int GSTATE_CALL_IN_INVITE=23; + static int GSTATE_CALL_IN_CONNECTED=24; + static int GSTATE_CALL_END=25; + static int GSTATE_CALL_ERROR=26; + static int GSTATE_INVALID=27; + /** + * get new state {@link: } + */ + public int getNewState(); +} + + + public LinphoneProxyConfig createProxyConfig(URI identity,URI proxy,URI route); + + public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg); + + /** + * @return null if no default proxyconfig + */ + public LinphoneProxyConfig getDefaultProxyConfig(); + + void addAuthInfo(LinphoneAuthInfo info); + + public void invite(String url); + + public void iterate(); +} diff --git a/LinphoneCoreException.java b/LinphoneCoreException.java new file mode 100644 index 000000000..069e114a0 --- /dev/null +++ b/LinphoneCoreException.java @@ -0,0 +1,42 @@ +/* +LinphoneCoreException.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; + +public class LinphoneCoreException extends Exception { + + public LinphoneCoreException() { + // TODO Auto-generated constructor stub + } + + public LinphoneCoreException(String detailMessage) { + super(detailMessage); + // TODO Auto-generated constructor stub + } + + public LinphoneCoreException(Throwable throwable) { + super(throwable); + // TODO Auto-generated constructor stub + } + + public LinphoneCoreException(String detailMessage, Throwable throwable) { + super(detailMessage, throwable); + // TODO Auto-generated constructor stub + } + +} diff --git a/LinphoneCoreFactory.java b/LinphoneCoreFactory.java new file mode 100644 index 000000000..6a8c69493 --- /dev/null +++ b/LinphoneCoreFactory.java @@ -0,0 +1,43 @@ +/* +LinphoneCoreFactory.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; + +import java.io.File; + +public class LinphoneCoreFactory { + static { + System.loadLibrary("liblinphone"); + } + static LinphoneCoreFactory theLinphoneCoreFactory = new LinphoneCoreFactory(); + + public static LinphoneCoreFactory instance() { + + return theLinphoneCoreFactory; + } + public LinphoneAuthInfo createAuthInfo(String username,String password) { + throw new RuntimeException("Not Implemented yet"); + } + + public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) { + throw new RuntimeException("Not Implemented yet"); + } + + + +} diff --git a/LinphoneCoreImpl.java b/LinphoneCoreImpl.java new file mode 100644 index 000000000..958a66b9a --- /dev/null +++ b/LinphoneCoreImpl.java @@ -0,0 +1,63 @@ +/* +LinphoneCoreImpl.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; + +import java.io.File; +import java.io.IOException; +import java.net.URI; + +public class LinphoneCoreImpl implements LinphoneCore { + + private final LinphoneCoreListener mListener; + private final long nativePtr; + private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata); + private native void iterate(long nativePtr); + LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { + mListener=listener; + nativePtr = newLinphoneCore(listener,userConfig.getCanonicalPath(),factoryConfig.getCanonicalPath(),userdata); + } + + public void addAuthInfo(LinphoneAuthInfo info) { + // TODO Auto-generated method stub + + } + + public LinphoneProxyConfig createProxyConfig(URI identity, URI proxy,URI route) { + return new LinphoneProxyConfigImpl(identity, proxy, route); + } + + public LinphoneProxyConfig getDefaultProxyConfig() { + // TODO Auto-generated method stub + return null; + } + + public void invite(String url) { + // TODO Auto-generated method stub + } + + public void iterate() { + iterate(nativePtr); + } + + public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg) { + // TODO Auto-generated method stub + + } + +} diff --git a/LinphoneCoreListener.java b/LinphoneCoreListener.java new file mode 100644 index 000000000..e8a0279f3 --- /dev/null +++ b/LinphoneCoreListener.java @@ -0,0 +1,49 @@ +/* +LinphoneCoreListener.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; + + + +public interface LinphoneCoreListener { + + /**< Notifies the application that it should show up + * @return */ + public void show(LinphoneCore lc); + /**< Notifies incoming calls + * @return */ + public void inviteReceived(LinphoneCore lc,String from); + /**< Notify calls terminated by far end + * @return */ + public void byeReceived(LinphoneCore lc,String from); + /**< Ask the application some authentication information + * @return */ + public void authInfoRequested(LinphoneCore lc,String realm,String username); + /**< Callback that notifies various events with human readable text. + * @return */ + public void displayStatus(LinphoneCore lc,String message);; + /**< Callback to display a message to the user + * @return */ + public void displayMessage(LinphoneCore lc,String message); + /** Callback to display a warning to the user + * @return */ + public void displayWarning(LinphoneCore lc,String message); + /**< State notification callback + * @return */ + public void generalState(LinphoneCore lc,LinphoneCore.GeneralState state); +} diff --git a/LinphoneProxyConfig.java b/LinphoneProxyConfig.java new file mode 100644 index 000000000..fb8b68eb3 --- /dev/null +++ b/LinphoneProxyConfig.java @@ -0,0 +1,25 @@ +/* +LinphoneProxyConfig.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; + +public interface LinphoneProxyConfig { + + void enableRegister(boolean value); + +} diff --git a/LinphoneProxyConfigImpl.java b/LinphoneProxyConfigImpl.java new file mode 100644 index 000000000..84e470045 --- /dev/null +++ b/LinphoneProxyConfigImpl.java @@ -0,0 +1,54 @@ +/* +LinphoneProxyConfigImpl.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; + +import java.net.URI; + + +public class LinphoneProxyConfigImpl implements LinphoneProxyConfig { + + final long nativePtr; + protected LinphoneProxyConfigImpl(URI identity,URI proxy,URI route) { + nativePtr = createAndAdd(); + edit(nativePtr); + setIdentity(nativePtr,identity.getScheme()+":"+identity.getHost()); + done(nativePtr); + } + + protected void finalize() throws Throwable { + deleteNative(nativePtr); + } + private native long createAndAdd(); + private native long deleteNative(long ptr); + + private native void edit(long ptr); + private native void done(long ptr); + + private native void setIdentity(long ptr,String identity); + /*private native void setProxy(long ptr,String identity);*/ + + private native void enableRegister(long ptr,boolean value); + + public void enableRegister(boolean value) { + edit(nativePtr); + enableRegister(nativePtr,value); + done(nativePtr); + } + +}