first succesfull register

This commit is contained in:
Jehan Monnier 2010-01-21 17:31:28 +01:00
parent cb42456140
commit 135fac65cf
8 changed files with 66 additions and 34 deletions

View file

@ -21,3 +21,5 @@ package org.linphone.core;
public interface LinphoneAuthInfo {
}

13
LinphoneAuthInfoImpl.java Normal file
View file

@ -0,0 +1,13 @@
package org.linphone.core;
class LinphoneAuthInfoImpl implements LinphoneAuthInfo {
protected final long nativePtr;
private native long newLinphoneAuthInfo(String username, String userid, String passwd, String ha1,String realm);
private native void delete(long ptr);
protected LinphoneAuthInfoImpl(String username,String password) {
nativePtr = newLinphoneAuthInfo(username,null,password,null,null);
}
protected void finalize() throws Throwable {
delete(nativePtr);
}
}

View file

@ -18,8 +18,7 @@ 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 {
/*
@ -51,8 +50,16 @@ public interface LinphoneCore {
}
public LinphoneProxyConfig createProxyConfig(URI identity,URI proxy,URI route);
/**
* @param identity sip uri sip:jehan@linphone.org
* @param proxy sip uri (sip:linphone.org)
* @param route optionnal sip usi (sip:linphone.org)
* @return
*/
public LinphoneProxyConfig createProxyConfig(String identity,String proxy,String route) throws LinphoneCoreException;
public void addtProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException;
public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg);
/**

View file

@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
@SuppressWarnings("serial")
public class LinphoneCoreException extends Exception {
public LinphoneCoreException() {

View file

@ -19,10 +19,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package org.linphone.core;
import java.io.File;
import java.io.IOException;
public class LinphoneCoreFactory {
static {
System.loadLibrary("liblinphone");
System.loadLibrary("linphone");
}
static LinphoneCoreFactory theLinphoneCoreFactory = new LinphoneCoreFactory();
@ -31,11 +32,11 @@ public class LinphoneCoreFactory {
return theLinphoneCoreFactory;
}
public LinphoneAuthInfo createAuthInfo(String username,String password) {
throw new RuntimeException("Not Implemented yet");
return new LinphoneAuthInfoImpl(username,password) ;
}
public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) {
throw new RuntimeException("Not Implemented yet");
public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
return new LinphoneCoreImpl(listener,userConfig,factoryConfig,userdata);
}

View file

@ -20,35 +20,36 @@ package org.linphone.core;
import java.io.File;
import java.io.IOException;
import java.net.URI;
public class LinphoneCoreImpl implements LinphoneCore {
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);
private native void setDefaultProxyConfig(long nativePtr,long proxyCfgNativePtr);
private native int addProxyConfig(long nativePtr,long proxyCfgNativePtr);
private native void addAuthInfo(long nativePtr,long authInfoNativePtr);
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
addAuthInfo(nativePtr,((LinphoneAuthInfoImpl)info).nativePtr);
}
public LinphoneProxyConfig createProxyConfig(URI identity, URI proxy,URI route) {
public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route) throws LinphoneCoreException {
return new LinphoneProxyConfigImpl(identity, proxy, route);
}
public LinphoneProxyConfig getDefaultProxyConfig() {
// TODO Auto-generated method stub
return null;
throw new RuntimeException("not implemenetd yet");
}
public void invite(String url) {
// TODO Auto-generated method stub
throw new RuntimeException("not implemenetd yet");
}
public void iterate() {
@ -56,8 +57,13 @@ public class LinphoneCoreImpl implements LinphoneCore {
}
public void setDefaultProxyConfig(LinphoneProxyConfig proxyCfg) {
// TODO Auto-generated method stub
setDefaultProxyConfig(nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr);
}
public void addtProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException{
if (addProxyConfig(nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr) !=0) {
throw new LinphoneCoreException("bad proxy config");
}
}
}

View file

@ -22,4 +22,5 @@ public interface LinphoneProxyConfig {
void enableRegister(boolean value);
}

View file

@ -18,37 +18,38 @@ 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);
class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
protected final long nativePtr;
protected LinphoneProxyConfigImpl(String identity,String proxy,String route) throws LinphoneCoreException {
nativePtr = newLinphoneProxyConfig();
setIdentity(nativePtr,identity);
if (setProxy(nativePtr,proxy)!=0) {
throw new LinphoneCoreException("Bad proxy address ["+proxy+"]");
}
}
protected void finalize() throws Throwable {
deleteNative(nativePtr);
delete(nativePtr);
}
private native long createAndAdd();
private native long deleteNative(long ptr);
private native long newLinphoneProxyConfig();
private native void delete(long ptr);
private native void edit(long ptr);
private native void done(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 int setProxy(long ptr,String proxy);
private native void enableRegister(long ptr,boolean value);
public void enableRegister(boolean value) {
edit(nativePtr);
//edit(nativePtr);
enableRegister(nativePtr,value);
done(nativePtr);
//done(nativePtr);
}
}