提交 8f5a873d authored 作者: Anthony Minessale's avatar Anthony Minessale

break all the api in the swig stuff

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8225 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 6e8cd639
...@@ -61,6 +61,19 @@ Note that the first parameter to the new operator is implicitly handled by c++.. ...@@ -61,6 +61,19 @@ Note that the first parameter to the new operator is implicitly handled by c++..
*/ */
SWITCH_DECLARE(void) consoleLog(char *level_str, char *msg);
SWITCH_DECLARE(void) consoleCleanLog(char *msg);
class API {
protected:
char *last_data;
public:
SWITCH_DECLARE_CONSTRUCTOR API(void);
virtual SWITCH_DECLARE_CONSTRUCTOR ~API();
SWITCH_DECLARE(char *) execute(const char *command, const char *data);
SWITCH_DECLARE(char *) executeString(const char *command);
};
typedef struct input_callback_state { typedef struct input_callback_state {
void *function; // pointer to the language specific callback function void *function; // pointer to the language specific callback function
...@@ -291,8 +304,6 @@ class CoreSession { ...@@ -291,8 +304,6 @@ class CoreSession {
SWITCH_DECLARE(void) console_log(char *level_str, char *msg); SWITCH_DECLARE(void) console_log(char *level_str, char *msg);
SWITCH_DECLARE(void) console_clean_log(char *msg); SWITCH_DECLARE(void) console_clean_log(char *msg);
SWITCH_DECLARE(char *)api_execute(char *cmd, char *arg);
SWITCH_DECLARE(void) api_reply_delete(char *reply);
/** \brief bridge the audio of session_b into session_a /** \brief bridge the audio of session_b into session_a
* *
......
...@@ -9,20 +9,20 @@ ...@@ -9,20 +9,20 @@
package org.freeswitch.swig; package org.freeswitch.swig;
public class freeswitch { public class freeswitch {
public static void console_log(String level_str, String msg) { public static void consoleLog(String level_str, String msg) {
freeswitchJNI.console_log(level_str, msg); freeswitchJNI.consoleLog(level_str, msg);
} }
public static void console_clean_log(String msg) { public static void consoleCleanLog(String msg) {
freeswitchJNI.console_clean_log(msg); freeswitchJNI.consoleCleanLog(msg);
} }
public static String api_execute(String cmd, String arg) { public static void console_log(String level_str, String msg) {
return freeswitchJNI.api_execute(cmd, arg); freeswitchJNI.console_log(level_str, msg);
} }
public static void api_reply_delete(String reply) { public static void console_clean_log(String msg) {
freeswitchJNI.api_reply_delete(reply); freeswitchJNI.console_clean_log(msg);
} }
public static void bridge(CoreSession session_a, CoreSession session_b) { public static void bridge(CoreSession session_a, CoreSession session_b) {
......
...@@ -9,6 +9,12 @@ ...@@ -9,6 +9,12 @@
package org.freeswitch.swig; package org.freeswitch.swig;
class freeswitchJNI { class freeswitchJNI {
public final static native void consoleLog(String jarg1, String jarg2);
public final static native void consoleCleanLog(String jarg1);
public final static native long new_API();
public final static native void delete_API(long jarg1);
public final static native String API_execute(long jarg1, API jarg1_, String jarg2, String jarg3);
public final static native String API_executeString(long jarg1, API jarg1_, String jarg2);
public final static native void input_callback_state_t_function_set(long jarg1, input_callback_state_t jarg1_, long jarg2); public final static native void input_callback_state_t_function_set(long jarg1, input_callback_state_t jarg1_, long jarg2);
public final static native long input_callback_state_t_function_get(long jarg1, input_callback_state_t jarg1_); public final static native long input_callback_state_t_function_get(long jarg1, input_callback_state_t jarg1_);
public final static native void input_callback_state_t_threadState_set(long jarg1, input_callback_state_t jarg1_, long jarg2); public final static native void input_callback_state_t_threadState_set(long jarg1, input_callback_state_t jarg1_, long jarg2);
...@@ -101,8 +107,6 @@ class freeswitchJNI { ...@@ -101,8 +107,6 @@ class freeswitchJNI {
public final static native long CoreSession_run_dtmf_callback(long jarg1, CoreSession jarg1_, long jarg2, long jarg3); public final static native long CoreSession_run_dtmf_callback(long jarg1, CoreSession jarg1_, long jarg2, long jarg3);
public final static native void console_log(String jarg1, String jarg2); public final static native void console_log(String jarg1, String jarg2);
public final static native void console_clean_log(String jarg1); public final static native void console_clean_log(String jarg1);
public final static native String api_execute(String jarg1, String jarg2);
public final static native void api_reply_delete(String jarg1);
public final static native void bridge(long jarg1, CoreSession jarg1_, long jarg2, CoreSession jarg2_); public final static native void bridge(long jarg1, CoreSession jarg1_, long jarg2, CoreSession jarg2_);
public final static native long hanguphook(long jarg1); public final static native long hanguphook(long jarg1);
public final static native long dtmf_callback(long jarg1, long jarg2, long jarg3, long jarg4, long jarg5); public final static native long dtmf_callback(long jarg1, long jarg2, long jarg3, long jarg4, long jarg5);
......
...@@ -207,6 +207,117 @@ static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionC ...@@ -207,6 +207,117 @@ static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionC
extern "C" { extern "C" {
#endif #endif
SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_consoleLog(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2) {
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
(void)jenv;
(void)jcls;
arg1 = 0;
if (jarg1) {
arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0);
if (!arg1) return ;
}
arg2 = 0;
if (jarg2) {
arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
if (!arg2) return ;
}
consoleLog(arg1,arg2);
if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1);
if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
}
SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_consoleCleanLog(JNIEnv *jenv, jclass jcls, jstring jarg1) {
char *arg1 = (char *) 0 ;
(void)jenv;
(void)jcls;
arg1 = 0;
if (jarg1) {
arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0);
if (!arg1) return ;
}
consoleCleanLog(arg1);
if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1);
}
SWIGEXPORT jlong JNICALL Java_org_freeswitch_swig_freeswitchJNI_new_1API(JNIEnv *jenv, jclass jcls) {
jlong jresult = 0 ;
API *result = 0 ;
(void)jenv;
(void)jcls;
result = (API *)new API();
*(API **)&jresult = result;
return jresult;
}
SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_delete_1API(JNIEnv *jenv, jclass jcls, jlong jarg1) {
API *arg1 = (API *) 0 ;
(void)jenv;
(void)jcls;
arg1 = *(API **)&jarg1;
delete arg1;
}
SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_API_1execute(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3) {
jstring jresult = 0 ;
API *arg1 = (API *) 0 ;
char *arg2 = (char *) 0 ;
char *arg3 = (char *) 0 ;
char *result = 0 ;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(API **)&jarg1;
arg2 = 0;
if (jarg2) {
arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
if (!arg2) return 0;
}
arg3 = 0;
if (jarg3) {
arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0);
if (!arg3) return 0;
}
result = (char *)(arg1)->execute((char const *)arg2,(char const *)arg3);
if(result) jresult = jenv->NewStringUTF((const char *)result);
if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3);
return jresult;
}
SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_API_1executeString(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
jstring jresult = 0 ;
API *arg1 = (API *) 0 ;
char *arg2 = (char *) 0 ;
char *result = 0 ;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(API **)&jarg1;
arg2 = 0;
if (jarg2) {
arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
if (!arg2) return 0;
}
result = (char *)(arg1)->executeString((char const *)arg2);
if(result) jresult = jenv->NewStringUTF((const char *)result);
if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
return jresult;
}
SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_input_1callback_1state_1t_1function_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) { SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_input_1callback_1state_1t_1function_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2) {
input_callback_state_t *arg1 = (input_callback_state_t *) 0 ; input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
void *arg2 = (void *) 0 ; void *arg2 = (void *) 0 ;
...@@ -1915,47 +2026,6 @@ SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_console_1clean_1l ...@@ -1915,47 +2026,6 @@ SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_console_1clean_1l
} }
SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_api_1execute(JNIEnv *jenv, jclass jcls, jstring jarg1, jstring jarg2) {
jstring jresult = 0 ;
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
char *result = 0 ;
(void)jenv;
(void)jcls;
arg1 = 0;
if (jarg1) {
arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0);
if (!arg1) return 0;
}
arg2 = 0;
if (jarg2) {
arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
if (!arg2) return 0;
}
result = (char *)api_execute(arg1,arg2);
if(result) jresult = jenv->NewStringUTF((const char *)result);
if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1);
if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
return jresult;
}
SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_api_1reply_1delete(JNIEnv *jenv, jclass jcls, jstring jarg1) {
char *arg1 = (char *) 0 ;
(void)jenv;
(void)jcls;
arg1 = 0;
if (jarg1) {
arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0);
if (!arg1) return ;
}
api_reply_delete(arg1);
if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1);
}
SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_bridge(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) { SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_bridge(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject jarg2_) {
CoreSession *arg1 = 0 ; CoreSession *arg1 = 0 ;
CoreSession *arg2 = 0 ; CoreSession *arg2 = 0 ;
......
...@@ -140,7 +140,15 @@ static void lua_parse_and_execute(lua_State *L, char *input_code) ...@@ -140,7 +140,15 @@ static void lua_parse_and_execute(lua_State *L, char *input_code)
} }
} }
if (!error) { if (!error) {
error = luaL_loadfile(L, input_code) || docall(L, 0, 1); char *file = input_code, *fdup = NULL;
if (!switch_is_file_path(file)) {
fdup = switch_mprintf("%s/%s", SWITCH_GLOBAL_dirs.script_dir, file);
switch_assert(fdup);
file = fdup;
}
error = luaL_loadfile(L, file) || docall(L, 0, 1);
switch_safe_free(fdup);
} }
} }
......
...@@ -1484,26 +1484,27 @@ SWIG_Lua_dostring(lua_State *L, const char* str) { ...@@ -1484,26 +1484,27 @@ SWIG_Lua_dostring(lua_State *L, const char* str) {
/* -------- TYPES TABLE (BEGIN) -------- */ /* -------- TYPES TABLE (BEGIN) -------- */
#define SWIGTYPE_p_CoreSession swig_types[0] #define SWIGTYPE_p_API swig_types[0]
#define SWIGTYPE_p_Event swig_types[1] #define SWIGTYPE_p_CoreSession swig_types[1]
#define SWIGTYPE_p_Session swig_types[2] #define SWIGTYPE_p_Event swig_types[2]
#define SWIGTYPE_p_Stream swig_types[3] #define SWIGTYPE_p_Session swig_types[3]
#define SWIGTYPE_p_input_callback_state swig_types[4] #define SWIGTYPE_p_Stream swig_types[4]
#define SWIGTYPE_p_lua_State swig_types[5] #define SWIGTYPE_p_input_callback_state swig_types[5]
#define SWIGTYPE_p_session_flag_t swig_types[6] #define SWIGTYPE_p_lua_State swig_types[6]
#define SWIGTYPE_p_switch_channel_state_t swig_types[7] #define SWIGTYPE_p_session_flag_t swig_types[7]
#define SWIGTYPE_p_switch_channel_t swig_types[8] #define SWIGTYPE_p_switch_channel_state_t swig_types[8]
#define SWIGTYPE_p_switch_core_session_t swig_types[9] #define SWIGTYPE_p_switch_channel_t swig_types[9]
#define SWIGTYPE_p_switch_event_t swig_types[10] #define SWIGTYPE_p_switch_core_session_t swig_types[10]
#define SWIGTYPE_p_switch_input_args_t swig_types[11] #define SWIGTYPE_p_switch_event_t swig_types[11]
#define SWIGTYPE_p_switch_input_type_t swig_types[12] #define SWIGTYPE_p_switch_input_args_t swig_types[12]
#define SWIGTYPE_p_switch_priority_t swig_types[13] #define SWIGTYPE_p_switch_input_type_t swig_types[13]
#define SWIGTYPE_p_switch_size_t swig_types[14] #define SWIGTYPE_p_switch_priority_t swig_types[14]
#define SWIGTYPE_p_switch_status_t swig_types[15] #define SWIGTYPE_p_switch_size_t swig_types[15]
#define SWIGTYPE_p_switch_stream_handle_t swig_types[16] #define SWIGTYPE_p_switch_status_t swig_types[16]
#define SWIGTYPE_p_void swig_types[17] #define SWIGTYPE_p_switch_stream_handle_t swig_types[17]
static swig_type_info *swig_types[19]; #define SWIGTYPE_p_void swig_types[18]
static swig_module_info swig_module = {swig_types, 18, 0, 0, 0, 0}; static swig_type_info *swig_types[20];
static swig_module_info swig_module = {swig_types, 19, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
...@@ -1528,6 +1529,167 @@ typedef struct{} LANGUAGE_OBJ; ...@@ -1528,6 +1529,167 @@ typedef struct{} LANGUAGE_OBJ;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
static int _wrap_consoleLog(lua_State* L) {
int SWIG_arg = -1;
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
SWIG_check_num_args("consoleLog",2,2)
if(!lua_isstring(L,1)) SWIG_fail_arg("consoleLog",1,"char *");
if(!lua_isstring(L,2)) SWIG_fail_arg("consoleLog",2,"char *");
arg1 = (char *)lua_tostring(L, 1);
arg2 = (char *)lua_tostring(L, 2);
consoleLog(arg1,arg2);
SWIG_arg=0;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_consoleCleanLog(lua_State* L) {
int SWIG_arg = -1;
char *arg1 = (char *) 0 ;
SWIG_check_num_args("consoleCleanLog",1,1)
if(!lua_isstring(L,1)) SWIG_fail_arg("consoleCleanLog",1,"char *");
arg1 = (char *)lua_tostring(L, 1);
consoleCleanLog(arg1);
SWIG_arg=0;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_new_API(lua_State* L) {
int SWIG_arg = -1;
API *result = 0 ;
SWIG_check_num_args("API",0,0)
result = (API *)new API();
SWIG_arg=0;
SWIG_NewPointerObj(L,result,SWIGTYPE_p_API,1); SWIG_arg++;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_delete_API(lua_State* L) {
int SWIG_arg = -1;
API *arg1 = (API *) 0 ;
SWIG_check_num_args("API",1,1)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("API",1,"API *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_API,SWIG_POINTER_DISOWN))){
SWIG_fail_ptr("delete_API",1,SWIGTYPE_p_API);
}
delete arg1;
SWIG_arg=0;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_API_execute(lua_State* L) {
int SWIG_arg = -1;
API *arg1 = (API *) 0 ;
char *arg2 = (char *) 0 ;
char *arg3 = (char *) 0 ;
char *result = 0 ;
SWIG_check_num_args("execute",3,3)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("execute",1,"API *");
if(!lua_isstring(L,2)) SWIG_fail_arg("execute",2,"char const *");
if(!lua_isstring(L,3)) SWIG_fail_arg("execute",3,"char const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_API,0))){
SWIG_fail_ptr("API_execute",1,SWIGTYPE_p_API);
}
arg2 = (char *)lua_tostring(L, 2);
arg3 = (char *)lua_tostring(L, 3);
result = (char *)(arg1)->execute((char const *)arg2,(char const *)arg3);
SWIG_arg=0;
lua_pushstring(L,(const char*)result); SWIG_arg++;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_API_executeString(lua_State* L) {
int SWIG_arg = -1;
API *arg1 = (API *) 0 ;
char *arg2 = (char *) 0 ;
char *result = 0 ;
SWIG_check_num_args("executeString",2,2)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("executeString",1,"API *");
if(!lua_isstring(L,2)) SWIG_fail_arg("executeString",2,"char const *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_API,0))){
SWIG_fail_ptr("API_executeString",1,SWIGTYPE_p_API);
}
arg2 = (char *)lua_tostring(L, 2);
result = (char *)(arg1)->executeString((char const *)arg2);
SWIG_arg=0;
lua_pushstring(L,(const char*)result); SWIG_arg++;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static void swig_delete_API(void *obj) {
API *arg1 = (API *) obj;
delete arg1;
}
static swig_lua_method swig_API_methods[] = {
{"execute", _wrap_API_execute},
{"executeString", _wrap_API_executeString},
{0,0}
};
static swig_lua_attribute swig_API_attributes[] = {
{0,0,0}
};
static swig_lua_class *swig_API_bases[] = {0};
static const char *swig_API_base_names[] = {0};
static swig_lua_class _wrap_class_API = { "API", &SWIGTYPE_p_API,_wrap_new_API, swig_delete_API, swig_API_methods, swig_API_attributes, swig_API_bases, swig_API_base_names };
static int _wrap_input_callback_state_t_function_set(lua_State* L) { static int _wrap_input_callback_state_t_function_set(lua_State* L) {
int SWIG_arg = -1; int SWIG_arg = -1;
input_callback_state_t *arg1 = (input_callback_state_t *) 0 ; input_callback_state_t *arg1 = (input_callback_state_t *) 0 ;
...@@ -4640,50 +4802,6 @@ fail: ...@@ -4640,50 +4802,6 @@ fail:
} }
static int _wrap_api_execute(lua_State* L) {
int SWIG_arg = -1;
char *arg1 = (char *) 0 ;
char *arg2 = (char *) 0 ;
char *result = 0 ;
SWIG_check_num_args("api_execute",2,2)
if(!lua_isstring(L,1)) SWIG_fail_arg("api_execute",1,"char *");
if(!lua_isstring(L,2)) SWIG_fail_arg("api_execute",2,"char *");
arg1 = (char *)lua_tostring(L, 1);
arg2 = (char *)lua_tostring(L, 2);
result = (char *)api_execute(arg1,arg2);
SWIG_arg=0;
lua_pushstring(L,(const char*)result); SWIG_arg++;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_api_reply_delete(lua_State* L) {
int SWIG_arg = -1;
char *arg1 = (char *) 0 ;
SWIG_check_num_args("api_reply_delete",1,1)
if(!lua_isstring(L,1)) SWIG_fail_arg("api_reply_delete",1,"char *");
arg1 = (char *)lua_tostring(L, 1);
api_reply_delete(arg1);
SWIG_arg=0;
return SWIG_arg;
if(0) SWIG_fail;
fail:
lua_error(L);
return SWIG_arg;
}
static int _wrap_bridge(lua_State* L) { static int _wrap_bridge(lua_State* L) {
int SWIG_arg = -1; int SWIG_arg = -1;
CoreSession *arg1 = 0 ; CoreSession *arg1 = 0 ;
...@@ -5349,10 +5467,10 @@ static swig_lua_class _wrap_class_Session = { "Session", &SWIGTYPE_p_Session,_wr ...@@ -5349,10 +5467,10 @@ static swig_lua_class _wrap_class_Session = { "Session", &SWIGTYPE_p_Session,_wr
#endif #endif
static const struct luaL_reg swig_commands[] = { static const struct luaL_reg swig_commands[] = {
{ "consoleLog", _wrap_consoleLog},
{ "consoleCleanLog", _wrap_consoleCleanLog},
{ "console_log", _wrap_console_log}, { "console_log", _wrap_console_log},
{ "console_clean_log", _wrap_console_clean_log}, { "console_clean_log", _wrap_console_clean_log},
{ "api_execute", _wrap_api_execute},
{ "api_reply_delete", _wrap_api_reply_delete},
{ "bridge", _wrap_bridge}, { "bridge", _wrap_bridge},
{ "hanguphook", _wrap_hanguphook}, { "hanguphook", _wrap_hanguphook},
{ "dtmf_callback", _wrap_dtmf_callback}, { "dtmf_callback", _wrap_dtmf_callback},
...@@ -5375,6 +5493,7 @@ static swig_lua_const_info swig_constants[] = { ...@@ -5375,6 +5493,7 @@ static swig_lua_const_info swig_constants[] = {
static void *_p_SessionTo_p_CoreSession(void *x, int *newmemory) { static void *_p_SessionTo_p_CoreSession(void *x, int *newmemory) {
return (void *)((CoreSession *) ((Session *) x)); return (void *)((CoreSession *) ((Session *) x));
} }
static swig_type_info _swigt__p_API = {"_p_API", "API *", 0, 0, (void*)&_wrap_class_API, 0};
static swig_type_info _swigt__p_CoreSession = {"_p_CoreSession", "CoreSession *", 0, 0, (void*)&_wrap_class_CoreSession, 0}; static swig_type_info _swigt__p_CoreSession = {"_p_CoreSession", "CoreSession *", 0, 0, (void*)&_wrap_class_CoreSession, 0};
static swig_type_info _swigt__p_Event = {"_p_Event", "Event *", 0, 0, (void*)&_wrap_class_Event, 0}; static swig_type_info _swigt__p_Event = {"_p_Event", "Event *", 0, 0, (void*)&_wrap_class_Event, 0};
static swig_type_info _swigt__p_Session = {"_p_Session", "Session *", 0, 0, (void*)&_wrap_class_Session, 0}; static swig_type_info _swigt__p_Session = {"_p_Session", "Session *", 0, 0, (void*)&_wrap_class_Session, 0};
...@@ -5395,6 +5514,7 @@ static swig_type_info _swigt__p_switch_stream_handle_t = {"_p_switch_stream_hand ...@@ -5395,6 +5514,7 @@ static swig_type_info _swigt__p_switch_stream_handle_t = {"_p_switch_stream_hand
static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0};
static swig_type_info *swig_type_initial[] = { static swig_type_info *swig_type_initial[] = {
&_swigt__p_API,
&_swigt__p_CoreSession, &_swigt__p_CoreSession,
&_swigt__p_Event, &_swigt__p_Event,
&_swigt__p_Session, &_swigt__p_Session,
...@@ -5415,6 +5535,7 @@ static swig_type_info *swig_type_initial[] = { ...@@ -5415,6 +5535,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_void, &_swigt__p_void,
}; };
static swig_cast_info _swigc__p_API[] = { {&_swigt__p_API, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_CoreSession[] = { {&_swigt__p_CoreSession, 0, 0, 0}, {&_swigt__p_Session, _p_SessionTo_p_CoreSession, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_CoreSession[] = { {&_swigt__p_CoreSession, 0, 0, 0}, {&_swigt__p_Session, _p_SessionTo_p_CoreSession, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_Event[] = { {&_swigt__p_Event, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_Event[] = { {&_swigt__p_Event, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_Session[] = { {&_swigt__p_Session, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_Session[] = { {&_swigt__p_Session, 0, 0, 0},{0, 0, 0, 0}};
...@@ -5435,6 +5556,7 @@ static swig_cast_info _swigc__p_switch_stream_handle_t[] = { {&_swigt__p_switch ...@@ -5435,6 +5556,7 @@ static swig_cast_info _swigc__p_switch_stream_handle_t[] = { {&_swigt__p_switch
static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info *swig_cast_initial[] = { static swig_cast_info *swig_cast_initial[] = {
_swigc__p_API,
_swigc__p_CoreSession, _swigc__p_CoreSession,
_swigc__p_Event, _swigc__p_Event,
_swigc__p_Session, _swigc__p_Session,
......
...@@ -48,13 +48,54 @@ sub this { ...@@ -48,13 +48,54 @@ sub this {
package freeswitch; package freeswitch;
*consoleLog = *freeswitchc::consoleLog;
*consoleCleanLog = *freeswitchc::consoleCleanLog;
*console_log = *freeswitchc::console_log; *console_log = *freeswitchc::console_log;
*console_clean_log = *freeswitchc::console_clean_log; *console_clean_log = *freeswitchc::console_clean_log;
*api_execute = *freeswitchc::api_execute;
*api_reply_delete = *freeswitchc::api_reply_delete;
*bridge = *freeswitchc::bridge; *bridge = *freeswitchc::bridge;
*hanguphook = *freeswitchc::hanguphook; *hanguphook = *freeswitchc::hanguphook;
*dtmf_callback = *freeswitchc::dtmf_callback; *dtmf_callback = *freeswitchc::dtmf_callback;
*api_execute = *freeswitchc::api_execute;
*api_reply_delete = *freeswitchc::api_reply_delete;
############# Class : freeswitch::API ##############
package freeswitch::API;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( freeswitch );
%OWNER = ();
%ITERATORS = ();
sub new {
my $pkg = shift;
my $self = freeswitchc::new_API(@_);
bless $self, $pkg if defined($self);
}
sub DESTROY {
return unless $_[0]->isa('HASH');
my $self = tied(%{$_[0]});
return unless defined $self;
delete $ITERATORS{$self};
if (exists $OWNER{$self}) {
freeswitchc::delete_API($self);
delete $OWNER{$self};
}
}
*execute = *freeswitchc::API_execute;
*executeString = *freeswitchc::API_executeString;
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
}
############# Class : freeswitch::input_callback_state_t ############## ############# Class : freeswitch::input_callback_state_t ##############
......
...@@ -48,6 +48,25 @@ except AttributeError: ...@@ -48,6 +48,25 @@ except AttributeError:
del types del types
consoleLog = _freeswitch.consoleLog
consoleCleanLog = _freeswitch.consoleCleanLog
class API(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, API, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, API, name)
__repr__ = _swig_repr
def __init__(self, *args):
this = _freeswitch.new_API(*args)
try: self.this.append(this)
except: self.this = this
__swig_destroy__ = _freeswitch.delete_API
__del__ = lambda self : None;
def execute(*args): return _freeswitch.API_execute(*args)
def executeString(*args): return _freeswitch.API_executeString(*args)
API_swigregister = _freeswitch.API_swigregister
API_swigregister(API)
class input_callback_state_t(_object): class input_callback_state_t(_object):
__swig_setmethods__ = {} __swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, input_callback_state_t, name, value) __setattr__ = lambda self, name, value: _swig_setattr(self, input_callback_state_t, name, value)
...@@ -191,13 +210,13 @@ CoreSession_swigregister(CoreSession) ...@@ -191,13 +210,13 @@ CoreSession_swigregister(CoreSession)
console_log = _freeswitch.console_log console_log = _freeswitch.console_log
console_clean_log = _freeswitch.console_clean_log console_clean_log = _freeswitch.console_clean_log
api_execute = _freeswitch.api_execute
api_reply_delete = _freeswitch.api_reply_delete
bridge = _freeswitch.bridge bridge = _freeswitch.bridge
hanguphook = _freeswitch.hanguphook hanguphook = _freeswitch.hanguphook
dtmf_callback = _freeswitch.dtmf_callback dtmf_callback = _freeswitch.dtmf_callback
S_SWAPPED_IN = _freeswitch.S_SWAPPED_IN S_SWAPPED_IN = _freeswitch.S_SWAPPED_IN
S_SWAPPED_OUT = _freeswitch.S_SWAPPED_OUT S_SWAPPED_OUT = _freeswitch.S_SWAPPED_OUT
api_execute = _freeswitch.api_execute
api_reply_delete = _freeswitch.api_reply_delete
class PySession(CoreSession): class PySession(CoreSession):
__swig_setmethods__ = {} __swig_setmethods__ = {}
for _s in [CoreSession]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{})) for _s in [CoreSession]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
......
...@@ -37,6 +37,46 @@ ...@@ -37,6 +37,46 @@
#pragma warning(disable:4127 4003) #pragma warning(disable:4127 4003)
#endif #endif
SWITCH_DECLARE_CONSTRUCTOR API::API()
{
last_data = NULL;
}
SWITCH_DECLARE_CONSTRUCTOR API::~API()
{
switch_safe_free(last_data);
}
SWITCH_DECLARE(char *) API::execute(const char *cmd, const char *arg)
{
switch_stream_handle_t stream = { 0 };
SWITCH_STANDARD_STREAM(stream);
switch_api_execute(cmd, arg, NULL, &stream);
last_data = (char *) stream.data;
return last_data;
}
SWITCH_DECLARE(char *) API::executeString(const char *cmd)
{
char *arg;
switch_stream_handle_t stream = { 0 };
char *mycmd = strdup(cmd);
switch_assert(mycmd);
if ((arg = strchr(mycmd, ' '))) {
*arg++ = '\0';
}
switch_safe_free(last_data);
SWITCH_STANDARD_STREAM(stream);
switch_api_execute(mycmd, arg, NULL, &stream);
last_data = (char *) stream.data;
switch_safe_free(mycmd);
return last_data;
}
SWITCH_DECLARE_CONSTRUCTOR Event::Event(const char *type, const char *subclass_name) SWITCH_DECLARE_CONSTRUCTOR Event::Event(const char *type, const char *subclass_name)
{ {
...@@ -697,6 +737,15 @@ void CoreSession::store_file_handle(switch_file_handle_t *fh) { ...@@ -697,6 +737,15 @@ void CoreSession::store_file_handle(switch_file_handle_t *fh) {
/* ---- methods not bound to CoreSession instance ---- */ /* ---- methods not bound to CoreSession instance ---- */
SWITCH_DECLARE(void) consoleLog(char *level_str, char *msg)
{
return console_log(level_str, msg);
}
SWITCH_DECLARE(void) consoleCleanLog(char *msg)
{
return console_clean_log(msg);
}
SWITCH_DECLARE(void) console_log(char *level_str, char *msg) SWITCH_DECLARE(void) console_log(char *level_str, char *msg)
{ {
...@@ -716,22 +765,6 @@ SWITCH_DECLARE(void) console_clean_log(char *msg) ...@@ -716,22 +765,6 @@ SWITCH_DECLARE(void) console_clean_log(char *msg)
} }
SWITCH_DECLARE(char *)api_execute(char *cmd, char *arg)
{
switch_stream_handle_t stream = { 0 };
SWITCH_STANDARD_STREAM(stream);
switch_api_execute(cmd, arg, NULL, &stream);
return (char *) stream.data;
}
SWITCH_DECLARE(void) api_reply_delete(char *reply)
{
if (!switch_strlen_zero(reply)) {
free(reply);
}
}
SWITCH_DECLARE(void) bridge(CoreSession &session_a, CoreSession &session_b) SWITCH_DECLARE(void) bridge(CoreSession &session_a, CoreSession &session_b)
{ {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "bridge called, session_a uuid: %s\n", session_a.get_uuid()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "bridge called, session_a uuid: %s\n", session_a.get_uuid());
...@@ -746,7 +779,6 @@ SWITCH_DECLARE(void) bridge(CoreSession &session_a, CoreSession &session_b) ...@@ -746,7 +779,6 @@ SWITCH_DECLARE(void) bridge(CoreSession &session_a, CoreSession &session_b)
} }
SWITCH_DECLARE_NONSTD(switch_status_t) hanguphook(switch_core_session_t *session_hungup) SWITCH_DECLARE_NONSTD(switch_status_t) hanguphook(switch_core_session_t *session_hungup)
{ {
switch_channel_t *channel = switch_core_session_get_channel(session_hungup); switch_channel_t *channel = switch_core_session_get_channel(session_hungup);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论