static int
get_current_context_type (void)
{
    int type = 0;
    hexchat_list *list;
    hexchat_context *cur_ctx;

    list = hexchat_list_get (ph, "channels");
    if (!list)
        return 0;

    cur_ctx = hexchat_get_context (ph);

    while (hexchat_list_next (ph, list))
    {
        if ((hexchat_context*)hexchat_list_str (ph, list, "context") == cur_ctx)
        {
            type = hexchat_list_int (ph, list, "type");
            break;
        }
    }

    hexchat_list_free (ph, list);
    return type;
}
Beispiel #2
0
static int api_hexchat_get_context(lua_State *L)
{
	hexchat_context *context = hexchat_get_context(ph);
	hexchat_context **u = lua_newuserdata(L, sizeof(hexchat_context *));
	*u = context;
	luaL_newmetatable(L, "context");
	lua_setmetatable(L, -2);
	return 1;
}
Beispiel #3
0
static
XS (XS_Xchat_get_context)
{
	dXSARGS;
	if (items != 0) {
		hexchat_print (ph, "Usage: Xchat::get_context()");
	} else {
		XSRETURN_IV (PTR2IV (hexchat_get_context (ph)));
	}
}
Beispiel #4
0
static int wrap_context_closure(lua_State *L)
{
	hexchat_context *old, *context = *(hexchat_context **)luaL_checkudata(L, 1, "context");
	lua_pushvalue(L, lua_upvalueindex(1));
	lua_replace(L, 1);
	old = hexchat_get_context(ph);
	if(!hexchat_set_context(ph, context))
		return luaL_error(L, "could not switch into context");
	lua_call(L, lua_gettop(L) - 1, LUA_MULTRET);
	hexchat_set_context(ph, old);
	return lua_gettop(L);
}
Beispiel #5
0
/* Xchat::Internal::hook_timer(timeout, callback, userdata) */
static
XS (XS_Xchat_hook_timer)
{
	int timeout;
	SV *callback;
	SV *userdata;
	hexchat_hook *hook;
	SV *package;
	HookData *data;

	dXSARGS;

	if (items != 4) {
		hexchat_print (ph,
						 "Usage: Xchat::Internal::hook_timer(timeout, callback, userdata, package)");
	} else {
		timeout = (int) SvIV (ST (0));
		callback = ST (1);
		data = NULL;
		userdata = ST (2);
		package = ST (3);

		data = malloc (sizeof (HookData));
		if (data == NULL) {
			XSRETURN_UNDEF;
		}

		data->callback = newSVsv (callback);
		data->userdata = newSVsv (userdata);
		data->ctx = hexchat_get_context (ph);
		data->package = newSVsv (package);
		hook = hexchat_hook_timer (ph, timeout, timer_cb, data);
		data->hook = hook;

		XSRETURN_IV (PTR2IV (hook));
	}
}