diff --git a/p2pproxy/launcher/.cproject b/p2pproxy/launcher/.cproject
index f7d0a27f5..8863ad35f 100644
--- a/p2pproxy/launcher/.cproject
+++ b/p2pproxy/launcher/.cproject
@@ -49,7 +49,7 @@
-
+
@@ -107,7 +107,7 @@
-
+
@@ -120,6 +120,7 @@
+
@@ -504,6 +505,7 @@
+
diff --git a/p2pproxy/launcher/.settings/org.eclipse.cdt.core.prefs b/p2pproxy/launcher/.settings/org.eclipse.cdt.core.prefs
new file mode 100644
index 000000000..488bd5f75
--- /dev/null
+++ b/p2pproxy/launcher/.settings/org.eclipse.cdt.core.prefs
@@ -0,0 +1,3 @@
+#Wed Sep 24 10:53:31 CEST 2008
+eclipse.preferences.version=1
+environment/project/cdt.managedbuild.config.gnu.exe.debug.312796505=\n\n
diff --git a/p2pproxy/launcher/Debug/makefile b/p2pproxy/launcher/Debug/makefile
new file mode 100644
index 000000000..9559e2f52
--- /dev/null
+++ b/p2pproxy/launcher/Debug/makefile
@@ -0,0 +1,44 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+-include ../makefile.init
+
+RM := rm -rf
+
+# All of the sources participating in the build are defined here
+-include sources.mk
+-include subdir.mk
+-include src/subdir.mk
+-include objects.mk
+
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(strip $(C_DEPS)),)
+-include $(C_DEPS)
+endif
+endif
+
+-include ../makefile.defs
+
+# Add inputs and outputs from these tool invocations to the build variables
+
+# All Target
+all: p2pproxy-launcher
+
+# Tool invocations
+p2pproxy-launcher: $(OBJS) $(USER_OBJS)
+ @echo 'Building target: $@'
+ @echo 'Invoking: GCC C Linker'
+ gcc -L/usr/lib/jvm/java-6-openjdk/jre/lib/amd64 -L/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server -o"p2pproxy-launcher" $(OBJS) $(USER_OBJS) $(LIBS)
+ @echo 'Finished building target: $@'
+ @echo ' '
+
+# Other Targets
+clean:
+ -$(RM) $(OBJS)$(EXECUTABLES)$(C_DEPS) p2pproxy-launcher
+ -@echo ' '
+
+.PHONY: all clean dependents
+.SECONDARY:
+
+-include ../makefile.targets
diff --git a/p2pproxy/launcher/Debug/objects.mk b/p2pproxy/launcher/Debug/objects.mk
new file mode 100644
index 000000000..bb7a3d533
--- /dev/null
+++ b/p2pproxy/launcher/Debug/objects.mk
@@ -0,0 +1,7 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+LIBS := -ljvm
+
+USER_OBJS :=
diff --git a/p2pproxy/launcher/Debug/sources.mk b/p2pproxy/launcher/Debug/sources.mk
new file mode 100644
index 000000000..1b13571ac
--- /dev/null
+++ b/p2pproxy/launcher/Debug/sources.mk
@@ -0,0 +1,17 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+C_SRCS :=
+O_SRCS :=
+ASM_SRCS :=
+S_SRCS :=
+OBJ_SRCS :=
+OBJS :=
+EXECUTABLES :=
+C_DEPS :=
+
+# Every subdirectory with source files must be described here
+SUBDIRS := \
+src \
+
diff --git a/p2pproxy/launcher/Debug/src/launcher-tester.d b/p2pproxy/launcher/Debug/src/launcher-tester.d
new file mode 100644
index 000000000..f3d7000d3
--- /dev/null
+++ b/p2pproxy/launcher/Debug/src/launcher-tester.d
@@ -0,0 +1,4 @@
+src/launcher-tester.d src/launcher-tester.o: ../src/launcher-tester.c \
+ ../src/p2pproxy.h
+
+../src/p2pproxy.h:
diff --git a/p2pproxy/launcher/Debug/src/p2pproxy.d b/p2pproxy/launcher/Debug/src/p2pproxy.d
new file mode 100644
index 000000000..a6f15d484
--- /dev/null
+++ b/p2pproxy/launcher/Debug/src/p2pproxy.d
@@ -0,0 +1,9 @@
+src/p2pproxy.d src/p2pproxy.o: ../src/p2pproxy.c \
+ /usr/lib/jvm/java-6-openjdk/include/jni.h \
+ /usr/lib/jvm/java-6-openjdk/include/jni_md.h ../src/p2pproxy.h
+
+/usr/lib/jvm/java-6-openjdk/include/jni.h:
+
+/usr/lib/jvm/java-6-openjdk/include/jni_md.h:
+
+../src/p2pproxy.h:
diff --git a/p2pproxy/launcher/Debug/src/subdir.mk b/p2pproxy/launcher/Debug/src/subdir.mk
new file mode 100644
index 000000000..839cd1d90
--- /dev/null
+++ b/p2pproxy/launcher/Debug/src/subdir.mk
@@ -0,0 +1,34 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables
+C_SRCS += \
+../src/launcher-tester.c \
+../src/p2pproxy.c
+
+OBJS += \
+./src/launcher-tester.o \
+./src/p2pproxy.o
+
+C_DEPS += \
+./src/launcher-tester.d \
+./src/p2pproxy.d
+
+
+# Each subdirectory must supply rules for building sources it contributes
+src/%.o: ../src/%.c
+ @echo 'Building file: $<'
+ @echo 'Invoking: GCC C Compiler'
+ gcc -I/usr/lib/jvm/java-6-openjdk/include -O0 -g3 -Wall -c -fmessage-length=0 -ansi -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
+ @echo 'Finished building: $<'
+ @echo ' '
+
+src/p2pproxy.o: ../src/p2pproxy.c
+ @echo 'Building file: $<'
+ @echo 'Invoking: GCC C Compiler'
+ gcc -I/usr/lib/jvm/java-6-openjdk/include -O2 -g -Wall -c -fmessage-length=0 -ansi -MMD -MP -MF"$(@:%.o=%.d)" -MT"src/p2pproxy.d" -o"$@" "$<"
+ @echo 'Finished building: $<'
+ @echo ' '
+
+
diff --git a/p2pproxy/launcher/src/p2pproxy.c b/p2pproxy/launcher/src/p2pproxy.c
index df9d84f11..1d0c3b4fa 100644
--- a/p2pproxy/launcher/src/p2pproxy.c
+++ b/p2pproxy/launcher/src/p2pproxy.c
@@ -9,37 +9,44 @@
#define P2PPROXY_INSTALLDIR "/usr/local/share/java"
#endif
#ifndef P2PPROXY_BUILDDIR
- #define P2PPROXY_BUILDDIR "./antbuild/dist/p2pproxy_0.1"
+ #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) {
-
+
JavaVMInitArgs args;
- JavaVMOption options[0];
+ JavaVMOption options[8];
jint res=-1;
-
+ jclass lP2pProxyMainClass;
+ jmethodID mainMethod;
+ jobjectArray applicationArgsList;
+ jstring applicationArg;
+ int i=0;
+
if (p2pproxy_application_jnienv != 0) {
fprintf(stderr,"p2pproxy already started");
return P2PPROXY_ERROR_APPLICATION_ALREADY_STARTED;
}
args.version = JNI_VERSION_1_4;
- args.nOptions = sizeof (options);
- /*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";
-
+ args.nOptions = 8;
+ 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[2].optionString = "-Dcom.sun.management.jmxremote";
+ options[3].optionString = "-Dcom.sun.management.jmxremote.port="P2PPROXY_JMX_PORT;
+ options[4].optionString = "-Dcom.sun.management.jmxremote.authenticate=false";
+ options[5].optionString = "-Dcom.sun.management.jmxremote.ssl=false";
+ options[6].optionString = "-Dorg.linphone.p2pproxy.install.dir="P2PPROXY_INSTALLDIR;
+ options[7].optionString = "-Dorg.linphone.p2pproxy.build.dir="P2PPROXY_BUILDDIR;
+
-/*
- 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;
@@ -48,6 +55,26 @@ int p2pproxy_application_start(int argc, char **argv) {
fprintf(stderr,"cannot start p2pproxy vm [%i]",res);
return P2PPROXY_ERROR;
}
+
+ lP2pProxyMainClass = (*p2pproxy_application_jnienv)->FindClass(p2pproxy_application_jnienv, "org/linphone/p2pproxy/core/P2pProxyMain");
+
+ if (lP2pProxyMainClass == 0) {
+ fprintf(stderr,"cannot find class org/linphone/p2pproxy/core/P2pProxyMain");
+ return P2PPROXY_ERROR;
+ }
+ mainMethod = (*p2pproxy_application_jnienv)->GetStaticMethodID(p2pproxy_application_jnienv, lP2pProxyMainClass, "main", "([Ljava/lang/String;)V");
+
+ applicationArgsList = (*p2pproxy_application_jnienv)->NewObjectArray(p2pproxy_application_jnienv, argc, (*p2pproxy_application_jnienv)->FindClass(p2pproxy_application_jnienv, "java/lang/String"), NULL);
+
+ for (i=0;iNewStringUTF(p2pproxy_application_jnienv, *argv++);
+ (*p2pproxy_application_jnienv)->SetObjectArrayElement(p2pproxy_application_jnienv, applicationArgsList, 0, applicationArg);
+
+ }
+
+
+ (*p2pproxy_application_jnienv)->CallStaticVoidMethod(p2pproxy_application_jnienv, lP2pProxyMainClass, mainMethod, applicationArgsList);
+
return P2PPROXY_NO_ERROR;
}
@@ -76,20 +103,7 @@ JNIEnv* create_vm() {
}
void invoke_class(JNIEnv* env) {
- jclass helloWorldClass;
- jmethodID mainMethod;
- jobjectArray applicationArgs;
- jstring applicationArg0;
-
- helloWorldClass = (*env)->FindClass(env, "example/jni/InvocationHelloWorld");
-
- mainMethod = (*env)->GetStaticMethodID(env, helloWorldClass, "main", "([Ljava/lang/String;)V");
-
- applicationArgs = (*env)->NewObjectArray(env, 1, (*env)->FindClass(env, "java/lang/String"), NULL);
- applicationArg0 = (*env)->NewStringUTF(env, "From-C-program");
- (*env)->SetObjectArrayElement(env, applicationArgs, 0, applicationArg0);
-
- (*env)->CallStaticVoidMethod(env, helloWorldClass, mainMethod, applicationArgs);
+
}
diff --git a/p2pproxy/src/org/linphone/p2pproxy/core/P2pProxyMain.java b/p2pproxy/src/org/linphone/p2pproxy/core/P2pProxyMain.java
index 633b91d3f..c9199adeb 100644
--- a/p2pproxy/src/org/linphone/p2pproxy/core/P2pProxyMain.java
+++ b/p2pproxy/src/org/linphone/p2pproxy/core/P2pProxyMain.java
@@ -54,6 +54,8 @@ public class P2pProxyMain implements P2pProxyMainMBean {
public final static String MAIN_MBEAN_NAME="org.linphone.p2proxy:type=main";
private static P2pProxyMain mP2pProxyMain = new P2pProxyMain();
private static Configurator mConfigurator;
+ private static String mConfigHomeDir;
+
static {
// System.setProperty("com.sun.management.jmxremote", "true");
// System.setProperty("com.sun.management.jmxremote.port", "6789");
@@ -72,7 +74,7 @@ public class P2pProxyMain implements P2pProxyMainMBean {
*/
public static void main(String[] args) {
try {
- String lconfigHomeDir=System.getProperty("user.home")+"/.p2pproxy";
+ mConfigHomeDir=System.getProperty("user.home")+"/.p2pproxy";
int lsipPort=5040;
JxtaNetworkManager.Mode lMode = JxtaNetworkManager.Mode.auto;
boolean lEnableHttp = false;
@@ -82,14 +84,14 @@ public class P2pProxyMain implements P2pProxyMainMBean {
for (int i=0; i < args.length; i=i+2) {
String argument = args[i];
if (argument.equals("-jxta")) {
- lconfigHomeDir = args[i + 1];
- File lFile = new File(lconfigHomeDir);
+ mConfigHomeDir = args[i + 1];
+ File lFile = new File(mConfigHomeDir);
if (lFile.exists() == false) lFile.mkdir();
- System.out.println("lconfigHomeDir detected[" + lconfigHomeDir + "]");
+ System.out.println("mConfigHomeDir detected[" + mConfigHomeDir + "]");
}
}
- System.setProperty("org.linphone.p2pproxy.home", lconfigHomeDir);
+ System.setProperty("org.linphone.p2pproxy.home", mConfigHomeDir);
System.setProperty("net.jxta.logging.Logging", "FINEST");
@@ -101,7 +103,7 @@ public class P2pProxyMain implements P2pProxyMainMBean {
mLog.info("p2pproxy initilizing...");
- File lPropertyFile = new File(lconfigHomeDir+"/p2pproxy.properties.xml");
+ File lPropertyFile = new File(mConfigHomeDir+"/p2pproxy.properties.xml");
mConfigurator = new Configurator(lPropertyFile);
try {
ObjectName lObjectName = new ObjectName(MAIN_MBEAN_NAME);
@@ -121,7 +123,7 @@ public class P2pProxyMain implements P2pProxyMainMBean {
for (int i=0; i < args.length; i=i+2) {
String argument = args[i];
if (argument.equals("-jxta")) {
- lconfigHomeDir = args[i + 1];
+ mConfigHomeDir = args[i + 1];
//nop
} else if (argument.equals("-sip")) {
lsipPort = Integer.parseInt(args[i + 1]);
@@ -219,7 +221,7 @@ public class P2pProxyMain implements P2pProxyMainMBean {
//check from env
- File lJxtaDirectory = new File (lconfigHomeDir);
+ File lJxtaDirectory = new File (mConfigHomeDir);
if (lJxtaDirectory.exists() == false) lJxtaDirectory.mkdir();
@@ -256,7 +258,7 @@ public class P2pProxyMain implements P2pProxyMainMBean {
//setup account manager
mP2pProxyAccountManagement = new P2pProxyAccountManagement(mJxtaNetworkManager);
// setup sip provider
- SipStack.log_path = lconfigHomeDir+"/logs";
+ SipStack.log_path = mConfigHomeDir+"/logs";
mSipAndPipeListener = new SipProxyRegistrar(mConfigurator,mJxtaNetworkManager,mP2pProxyAccountManagement,mP2pProxyManagement);
//set management
try {
@@ -339,13 +341,25 @@ public void loadTraceConfigFile() throws P2pProxyException {
}
public static void staticLoadTraceConfigFile() throws P2pProxyException {
try {
- PropertyConfigurator.configureAndWatch("log4j.properties");
+ String lSearchDir;
+ //search build dir
+ lSearchDir = System.getProperty("org.linphone.p2pproxy.build.dir");
+ File lFile = new File(lSearchDir+"/log4j.properties");
+ if (lFile.exists() == false) {
+ lSearchDir = mConfigHomeDir;
+ lFile = new File(lSearchDir+"/log4j.properties");
+ if (lFile.exists() == false) {
+ lSearchDir=".";
+ }
+ }
+ String lLog4jFile= lSearchDir+"/log4j.properties";
+ PropertyConfigurator.configureAndWatch(lLog4jFile);
// read java.util.logging properties
Properties lLogginProperties = new Properties();
- lLogginProperties.load(new FileInputStream("log4j.properties"));
+ lLogginProperties.load(new FileInputStream(lLog4jFile));
lLogginProperties.setProperty("java.util.logging.FileHandler.pattern",System.getProperty("org.linphone.p2pproxy.home")+"/logs/p2pproxy.log");
- lLogginProperties.store(new FileOutputStream("log4j.properties.tmp"), "tmp");
- System.setProperty("java.util.logging.config.file","log4j.properties.tmp");
+ lLogginProperties.store(new FileOutputStream(lLog4jFile+".tmp"), "tmp");
+ System.setProperty("java.util.logging.config.file",lLog4jFile+".tmp");
java.util.logging.LogManager.getLogManager().readConfiguration();
} catch (Exception e) {
throw new P2pProxyException("enable to load traces",e);