|
@@ -42,6 +42,7 @@
|
|
|
#include "../../modules_k/dispatcher/api.h"
|
|
|
#include "../../modules/xhttp/api.h"
|
|
|
#include "../../modules/sdpops/api.h"
|
|
|
+#include "../../modules_k/presence/bind_presence.h"
|
|
|
|
|
|
#include "app_lua_api.h"
|
|
|
|
|
@@ -56,6 +57,7 @@
|
|
|
#define SR_LUA_EXP_MOD_DISPATCHER (1<<8)
|
|
|
#define SR_LUA_EXP_MOD_XHTTP (1<<9)
|
|
|
#define SR_LUA_EXP_MOD_SDPOPS (1<<10)
|
|
|
+#define SR_LUA_EXP_MOD_PRESENCE (1<<11)
|
|
|
|
|
|
/**
|
|
|
*
|
|
@@ -118,6 +120,11 @@ static xhttp_api_t _lua_xhttpb;
|
|
|
*/
|
|
|
static sdpops_api_t _lua_sdpopsb;
|
|
|
|
|
|
+/**
|
|
|
+ * presence
|
|
|
+ */
|
|
|
+static presence_api_t _lua_presenceb;
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
@@ -1339,6 +1346,51 @@ static const luaL_reg _sr_sdpops_Map [] = {
|
|
|
{NULL, NULL}
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ *
|
|
|
+ */
|
|
|
+static int lua_sr_pres_auth_status(lua_State *L)
|
|
|
+{
|
|
|
+ str param[2];
|
|
|
+ int ret;
|
|
|
+ sr_lua_env_t *env_L;
|
|
|
+
|
|
|
+ env_L = sr_lua_env_get();
|
|
|
+
|
|
|
+ if(!(_sr_lua_exp_reg_mods&SR_LUA_EXP_MOD_PRESENCE))
|
|
|
+ {
|
|
|
+ LM_WARN("weird: presence function executed but module not registered\n");
|
|
|
+ return app_lua_return_error(L);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(env_L->msg==NULL)
|
|
|
+ {
|
|
|
+ LM_WARN("invalid parameters from Lua env\n");
|
|
|
+ return app_lua_return_error(L);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(lua_gettop(L)!=2)
|
|
|
+ {
|
|
|
+ LM_ERR("incorrect number of arguments\n");
|
|
|
+ return app_lua_return_error(L);
|
|
|
+ }
|
|
|
+
|
|
|
+ param[0].s = (char *) lua_tostring(L, -2);
|
|
|
+ param[0].len = strlen(param[0].s);
|
|
|
+ param[1].s = (char *) lua_tostring(L, -1);
|
|
|
+ param[1].len = strlen(param[1].s);
|
|
|
+
|
|
|
+ ret = _lua_presenceb.pres_auth_status(env_L->msg, param[0], param[1]);
|
|
|
+ return app_lua_return_int(L, ret);
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ */
|
|
|
+static const luaL_reg _sr_presence_Map [] = {
|
|
|
+ {"pres_auth_status", lua_sr_pres_auth_status},
|
|
|
+ {NULL, NULL}
|
|
|
+};
|
|
|
|
|
|
/**
|
|
|
*
|
|
@@ -1461,6 +1513,16 @@ int lua_sr_exp_init_mod(void)
|
|
|
}
|
|
|
LM_DBG("loaded sdpops api\n");
|
|
|
}
|
|
|
+ if(_sr_lua_exp_reg_mods&SR_LUA_EXP_MOD_PRESENCE)
|
|
|
+ {
|
|
|
+ /* bind the PRESENCE API */
|
|
|
+ if (presence_load_api(&_lua_presenceb) < 0)
|
|
|
+ {
|
|
|
+ LM_ERR("cannot bind to PRESENCE API\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ LM_DBG("loaded presence api\n");
|
|
|
+ }
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -1507,6 +1569,9 @@ int lua_sr_exp_register_mod(char *mname)
|
|
|
} else if(len==6 && strcmp(mname, "sdpops")==0) {
|
|
|
_sr_lua_exp_reg_mods |= SR_LUA_EXP_MOD_SDPOPS;
|
|
|
return 0;
|
|
|
+ } else if(len==8 && strcmp(mname, "presence")==0) {
|
|
|
+ _sr_lua_exp_reg_mods |= SR_LUA_EXP_MOD_PRESENCE;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
return -1;
|
|
@@ -1539,5 +1604,7 @@ void lua_sr_exp_openlibs(lua_State *L)
|
|
|
luaL_openlib(L, "sr.xhttp", _sr_xhttp_Map, 0);
|
|
|
if(_sr_lua_exp_reg_mods&SR_LUA_EXP_MOD_SDPOPS)
|
|
|
luaL_openlib(L, "sr.sdpops", _sr_sdpops_Map, 0);
|
|
|
+ if(_sr_lua_exp_reg_mods&SR_LUA_EXP_MOD_PRESENCE)
|
|
|
+ luaL_openlib(L, "sr.presence", _sr_presence_Map, 0);
|
|
|
}
|
|
|
|