2008-04-29 23:34:26 +00:00
|
|
|
#ifndef FREESWITCH_LUA_H
|
|
|
|
#define FREESWITCH_LUA_H
|
2008-04-25 22:16:16 +00:00
|
|
|
|
2008-04-30 19:42:26 +00:00
|
|
|
extern "C" {
|
|
|
|
#include "lua.h"
|
|
|
|
#include <lauxlib.h>
|
|
|
|
#include <lualib.h>
|
|
|
|
#include "mod_lua_extra.h"
|
|
|
|
}
|
2008-04-25 22:16:16 +00:00
|
|
|
#include <switch_cpp.h>
|
2010-09-07 11:21:25 -05:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct{
|
|
|
|
lua_State* L;
|
|
|
|
int idx;
|
|
|
|
}SWIGLUA_FN;
|
|
|
|
|
|
|
|
#define SWIGLUA_FN_GET(fn) {lua_pushvalue(fn.L,fn.idx);}
|
|
|
|
|
|
|
|
|
2008-05-12 00:24:38 +00:00
|
|
|
namespace LUA {
|
2010-02-06 03:38:24 +00:00
|
|
|
class Session:public CoreSession {
|
|
|
|
private:
|
|
|
|
virtual void do_hangup_hook();
|
|
|
|
lua_State *getLUA();
|
|
|
|
lua_State *L;
|
|
|
|
int hh;
|
|
|
|
int mark;
|
|
|
|
public:
|
|
|
|
Session();
|
|
|
|
Session(char *uuid, CoreSession * a_leg = NULL);
|
|
|
|
Session(switch_core_session_t *session);
|
|
|
|
~Session();
|
2012-01-27 19:03:04 -06:00
|
|
|
SWITCH_MOD_DECLARE(virtual void) destroy(const char *err = NULL);
|
2010-02-06 03:38:24 +00:00
|
|
|
|
|
|
|
virtual bool begin_allow_threads();
|
|
|
|
virtual bool end_allow_threads();
|
|
|
|
virtual void check_hangup_hook();
|
|
|
|
|
|
|
|
virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
|
|
|
|
void unsetInputCallback(void);
|
|
|
|
void setInputCallback(char *cbfunc, char *funcargs = NULL);
|
|
|
|
void setHangupHook(char *func, char *arg = NULL);
|
|
|
|
bool ready();
|
|
|
|
int originate(CoreSession * a_leg_session, char *dest, int timeout);
|
2008-04-30 19:42:26 +00:00
|
|
|
|
2010-02-06 03:38:24 +00:00
|
|
|
char *cb_function;
|
|
|
|
char *cb_arg;
|
|
|
|
char *hangup_func_str;
|
|
|
|
char *hangup_func_arg;
|
|
|
|
void setLUA(lua_State * state);
|
2009-03-24 15:30:08 +00:00
|
|
|
|
2010-02-06 03:38:24 +00:00
|
|
|
};
|
2010-09-07 11:21:25 -05:00
|
|
|
|
|
|
|
class Dbh {
|
|
|
|
protected:
|
|
|
|
switch_cache_db_handle_t *dbh;
|
2011-01-03 12:20:06 +01:00
|
|
|
bool m_connected;
|
2010-09-07 11:21:25 -05:00
|
|
|
static int query_callback(void *pArg, int argc, char **argv, char **cargv);
|
|
|
|
public:
|
|
|
|
Dbh(char *dsn, char *user = NULL, char *pass = NULL);
|
|
|
|
~Dbh();
|
|
|
|
bool release();
|
2011-01-03 12:20:06 +01:00
|
|
|
bool connected();
|
2011-01-27 14:17:49 +01:00
|
|
|
bool test_reactive(char *test_sql, char *drop_sql = NULL, char *reactive_sql = NULL);
|
2010-09-07 11:21:25 -05:00
|
|
|
bool query(char *sql, SWIGLUA_FN lua_fun);
|
2011-01-05 11:45:48 -06:00
|
|
|
int affected_rows();
|
2010-09-07 11:21:25 -05:00
|
|
|
};
|
2008-05-12 00:24:38 +00:00
|
|
|
}
|
2008-04-25 22:16:16 +00:00
|
|
|
#endif
|