From 7724a1bf2457e911899e1b92ea4d3af16ceff760 Mon Sep 17 00:00:00 2001 From: jehan Date: Thu, 25 Sep 2008 16:16:21 +0000 Subject: [PATCH] add c interface git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@43 3f6dc0c8-ddfe-455d-9043-3cd528dc4637 --- p2pproxy/build.xml | 4 +- p2pproxy/launcher/src/launcher-tester.c | 5 +++ p2pproxy/launcher/src/p2pproxy.c | 53 +++++++++++++++---------- p2pproxy/launcher/src/p2pproxy.h | 8 ++-- 4 files changed, 44 insertions(+), 26 deletions(-) diff --git a/p2pproxy/build.xml b/p2pproxy/build.xml index 40e1a9cef..530f12192 100644 --- a/p2pproxy/build.xml +++ b/p2pproxy/build.xml @@ -14,7 +14,8 @@ - + + @@ -50,6 +51,7 @@ + diff --git a/p2pproxy/launcher/src/launcher-tester.c b/p2pproxy/launcher/src/launcher-tester.c index e69de29bb..f0507b21d 100644 --- a/p2pproxy/launcher/src/launcher-tester.c +++ b/p2pproxy/launcher/src/launcher-tester.c @@ -0,0 +1,5 @@ +#include "p2pproxy.h" +int main(int argc, char **argv) { + printf("starting p2pproxy tester"); + p2pproxy_application_start( 0, 0); +} \ No newline at end of file diff --git a/p2pproxy/launcher/src/p2pproxy.c b/p2pproxy/launcher/src/p2pproxy.c index fc9861ddb..df9d84f11 100644 --- a/p2pproxy/launcher/src/p2pproxy.c +++ b/p2pproxy/launcher/src/p2pproxy.c @@ -1,44 +1,59 @@ #include #include -#include "p2pproxy.c" +#include "p2pproxy.h" -#ifndef P2PPROXY_CLASSPATH - #define P2PPROXY_INSTALL_PREFIX "/usr/" -#endif #ifndef P2PPROXY_JMX_PORT #define P2PPROXY_JMX_PORT "5678" #endif +#ifndef P2PPROXY_INSTALLDIR + #define P2PPROXY_INSTALLDIR "/usr/local/share/java" +#endif +#ifndef P2PPROXY_BUILDDIR + #define P2PPROXY_BUILDDIR "./antbuild/dist/p2pproxy_0.1" +#endif JNIEnv* p2pproxy_application_jnienv = 0; +JavaVM* p2pproxy_application_jvm = 0; int p2pproxy_application_start(int argc, char **argv) { - JavaVM* jvm; - JNIEnv* env; + JavaVMInitArgs args; - JavaVMOption options[5]; + JavaVMOption options[0]; + jint res=-1; if (p2pproxy_application_jnienv != 0) { fprintf(stderr,"p2pproxy already started"); return P2PPROXY_ERROR_APPLICATION_ALREADY_STARTED; } - args.version = JNI_VERSION_1_6; + args.version = JNI_VERSION_1_4; args.nOptions = sizeof (options); - options[0].optionString = "-Dcom.sun.management.jmxremote"; - options[1].optionString = "-Dcom.sun.management.jmxremote.port="P2PPROXY_JMX_POR"; - options[2].optionString = "-Dcom.sun.management.jmxremote.authenticate=false"; - options[3].optionString = "-Dcom.sun.management.jmxremote.ssl=false"; - options[4].optionString = "-Djava.class.path="P2PPROXY_INSTALL_PREFIX"/share/java/p2pproxy.jar"; + /*options[0].optionString = "-verbose:jni";*/ + /*options[1].optionString = "-Djava.class.path="P2PPROXY_BUILDDIR"/p2pproxy.jar:"\ + P2PPROXY_INSTALLDIR"/p2pproxy.jar:"\ + P2PPROXY_BUILDDIR"/log4j.jar:"\ + P2PPROXY_INSTALLDIR"/log4j.jar"; + + +/* + options[1].optionString = "-Dcom.sun.management.jmxremote"; + options[2].optionString = "-Dcom.sun.management.jmxremote.port="P2PPROXY_JMX_PORT; + options[3].optionString = "-Dcom.sun.management.jmxremote.authenticate=false"; + options[4].optionString = "-Dcom.sun.management.jmxremote.ssl=false"; + */ args.options = options; args.ignoreUnrecognized = JNI_FALSE; - JNI_CreateJavaVM(&jvm, (void **)&env, &args); - return env; - return P2PPROXY_ERROR; + res = JNI_CreateJavaVM(&p2pproxy_application_jvm, (void **)&p2pproxy_application_jnienv, &args); + if (res < 0) { + fprintf(stderr,"cannot start p2pproxy vm [%i]",res); + return P2PPROXY_ERROR; + } + return P2PPROXY_NO_ERROR; } const char* p2pproxy_status_string(int status_code) { - return P2PPROXY_ERROR; + return 0; } @@ -78,7 +93,3 @@ void invoke_class(JNIEnv* env) { } -int main(int argc, char **argv) { - JNIEnv* env = create_vm(); - invoke_class( env ); -} \ No newline at end of file diff --git a/p2pproxy/launcher/src/p2pproxy.h b/p2pproxy/launcher/src/p2pproxy.h index db45cd999..2aeb8ea9a 100644 --- a/p2pproxy/launcher/src/p2pproxy.h +++ b/p2pproxy/launcher/src/p2pproxy.h @@ -28,10 +28,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define P2PPROXY_NO_ERROR 0 /*error codes*/ #define P2PPROXY_ERROR -1 -#define P2PPROXY_ERROR_APPLICATION_NOT_STARTED = -2 -#define P2PPROXY_ERROR_APPLICATION_ALREADY_STARTED = -3 -#define P2PPROXY_ERROR_ACCOUNTMGT_USER_ALREADY_EXIST = -4 -#define P2PPROXY_ERROR_ACCOUNTMGT_BAD_SIP_URI = -5 +#define P2PPROXY_ERROR_APPLICATION_NOT_STARTED -2 +#define P2PPROXY_ERROR_APPLICATION_ALREADY_STARTED -3 +#define P2PPROXY_ERROR_ACCOUNTMGT_USER_ALREADY_EXIST -4 +#define P2PPROXY_ERROR_ACCOUNTMGT_BAD_SIP_URI -5 /** * start p2pproxy application