Commit d28f0fc2 authored by jehan's avatar jehan
Browse files

add c interface

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@38 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 222273f3
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>p2pproxy-launcher</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${workspace_loc:/p2pproxy-launcher/Debug}</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
<value>clean</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
</natures>
</projectDescription>
#include <stdio.h>
#include <jni.h>
#include "p2pproxy.c"
#ifndef P2PPROXY_CLASSPATH
#define P2PPROXY_INSTALL_PREFIX "/usr/"
#endif
#ifndef P2PPROXY_JMX_PORT
#define P2PPROXY_JMX_PORT "5678"
#endif
JNIEnv* p2pproxy_application_jnienv = 0;
int p2pproxy_application_start(int argc, char **argv) {
JavaVM* jvm;
JNIEnv* env;
JavaVMInitArgs args;
JavaVMOption options[5];
if (p2pproxy_application_jnienv != 0) {
fprintf(stderr,"p2pproxy already started");
return P2PPROXY_ERROR_APPLICATION_ALREADY_STARTED;
}
args.version = JNI_VERSION_1_6;
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";
args.options = options;
args.ignoreUnrecognized = JNI_FALSE;
JNI_CreateJavaVM(&jvm, (void **)&env, &args);
return env;
return P2PPROXY_ERROR;
}
const char* p2pproxy_status_string(int status_code) {
return P2PPROXY_ERROR;
}
int p2pproxy_accountmgt_createAccount(const char* user_name) {
return P2PPROXY_ERROR;
}
int p2pproxy_accountmgt_isValidAccount(const char* user_name) {
return P2PPROXY_ERROR;
}
int p2pproxy_accountmgt_deleteAccount(const char* user_name) {
return P2PPROXY_ERROR;
}
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);
}
int main(int argc, char **argv) {
JNIEnv* env = create_vm();
invoke_class( env );
}
\ No newline at end of file
/*
p2pproxy Copyright (C) 2007 Jehan Monnier ()
p2pproxy.h - sip proxy.
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.
*/
#ifndef P2PPROXY_LAUNCHER_H_
#define P2PPROXY_LAUNCHER_H_
#define P2PPROXY_ACCOUNTMGT_USER_EXIST 1
#define P2PPROXY_ACCOUNTMGT_USER_NOT_EXIST 0
/* status code*/
#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
/**
* start p2pproxy application
* blocking call
* @param argc number of argument
* @param argv arguments
* @return status code
*
*/
int p2pproxy_application_start(int argc, char **argv);
/**
* return the status string corresponding to the status code
*/
const char* p2pproxy_status_string(int status_code);
/************************/
/***account management***/
/************************/
/**
* create an account with the given name (must be unique)
* @param user_name user sip uri (sip:joe@p2p.linphone.org)
*
* @return P2PPROXY_NO_ERROR, P2PPROXY_ERROR_APPLICATIONNOTSTARTED, P2PPROXY_ERROR_ACCOUNTMGT_USERALREADYEXIST, P2PPROXY_ERROR_ACCOUNTMGT_BADSIPURI
*/
int p2pproxy_accountmgt_createAccount(const char* user_name);
/**
* check if a user name has been already created
* @param user_name user sip uri (sip:joe@p2p.linphone.org)
* @return P2PPROXY_ACCOUNTMGT_USEREXIST, P2PPROXY_ACCOUNTMGT_USERNOTEXIST , P2PPROXY_ERROR_APPLICATIONNOTSTARTED
*/
int p2pproxy_accountmgt_isValidAccount(const char* user_name);
/**
* delete an account with the given name
* @param user_name user sip uri (sip:joe@p2p.linphone.org)
* @return P2PPROXY_NO_ERROR, P2PPROXY_ERROR_APPLICATIONNOTSTARTED
*/
int p2pproxy_accountmgt_deleteAccount(const char* user_name);
#endif /*P2PPROXY_LAUNCHER_H_*/
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment