struct ast_channel *chan;
int res;
+ lua_getfield(L, LUA_REGISTRYINDEX, "autoservice");
+ if (lua_toboolean(L, -1)) {
+ /* autoservice already running */
+ return 1;
+ }
+ lua_pop(L, 1);
+
lua_getfield(L, LUA_REGISTRYINDEX, "channel");
chan = lua_touserdata(L, -1);
lua_pop(L, 1);
struct ast_channel *chan;
int res;
+ lua_getfield(L, LUA_REGISTRYINDEX, "autoservice");
+ if (!lua_toboolean(L, -1)) {
+ /* no autoservice running */
+ return 1;
+ }
+ lua_pop(L, 1);
+
lua_getfield(L, LUA_REGISTRYINDEX, "channel");
chan = lua_touserdata(L, -1);
lua_pop(L, 1);
ast_module_user_remove(u);
return -1;
}
-
+
+ lua_getfield(L, LUA_REGISTRYINDEX, "autoservice");
+ if (lua_toboolean(L, -1)) {
+ ast_autoservice_start(chan);
+ }
+ lua_pop(L, 1);
+
lua_update_registry(L, context, exten, priority);
lua_pushstring(L, context);
lua_pop(L, 1);
}
lua_remove(L, error_func);
+
+ lua_getfield(L, LUA_REGISTRYINDEX, "autoservice");
+ if (lua_toboolean(L, -1)) {
+ ast_autoservice_stop(chan);
+ }
+ lua_pop(L, 1);
+
if (!chan) lua_close(L);
ast_module_user_remove(u);
return res;