Пример #1
0
static int
delayed_check (void *userdata)
{
    int freq = hexchat_pluginpref_get_int (ph, "freq");

    /* only start the timer if there's no update available during startup */
    if (print_version_quiet (NULL))
    {
        /* check for updates, every 6 hours by default */
        hexchat_hook_timer (ph, freq * 1000 * 60, print_version_quiet, NULL);
    }

    return 0;	/* run delayed_check() only once */
}
int hexchat_plugin_init(hexchat_plugin *plugin_handle, char **plugin_name,
	char **plugin_desc, char **plugin_version, char *arg)
{
	ph = plugin_handle;

	*plugin_name = "HexChat_FooWinampSpam_NowPlaying";
	*plugin_desc = "Prints the track title when the track changes";
	*plugin_version = "1.0.3";

	timer_hook = hexchat_hook_timer(ph, 1000, np_timer, NULL);

	hexchat_printf(ph, "%s %s plugin loaded successfully!\n", *plugin_name, *plugin_version);

	return 1;
}
Пример #3
0
static int api_hexchat_hook_timer(lua_State *L)
{
	int ref, timeout = luaL_checkinteger (L, 1);
	hook_info *info, **u;

	lua_pushvalue(L, 2);
	ref = luaL_ref(L, LUA_REGISTRYINDEX);
	info = g_new(hook_info, 1);
	info->state = L;
	info->ref = ref;
	info->hook = hexchat_hook_timer(ph, timeout, api_timer_closure, info);
	u = lua_newuserdata(L, sizeof(hook_info *));
	*u = info;
	luaL_newmetatable(L, "hook");
	lua_setmetatable(L, -2);
	register_hook(info);
	return 1;
}
Пример #4
0
static int
identd_command_cb (char *word[], char *word_eol[], void *userdata)
{
	g_return_val_if_fail (responses != NULL, HEXCHAT_EAT_ALL);

	if (!g_strcmp0 (word[2], "reload"))
	{
		if (service)
		{
			g_socket_service_stop (service);
			g_clear_object (&service);
		}

		identd_start_server ();

		if (service)
			return HEXCHAT_EAT_ALL;
	}

	if (service == NULL) /* If we are not running plugins can handle it */
		return HEXCHAT_EAT_HEXCHAT;

	if (word[2] && *word[2] && word[3] && *word[3])
	{
		guint64 port = g_ascii_strtoull (word[2], NULL, 0);

		if (port && port <= G_MAXUINT16)
		{
			g_hash_table_insert (responses, GINT_TO_POINTER (port), g_strdup (word[3]));
			/* Automatically remove entry after 30 seconds */
			hexchat_hook_timer (ph, 30000, identd_cleanup_response_cb, GINT_TO_POINTER (port));
		}
	}
	else
	{
		hexchat_command (ph, "HELP IDENTD");
	}

	return HEXCHAT_EAT_ALL;
}
Пример #5
0
int
hexchat_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
{
	int delay;
	OSVERSIONINFOEX osvi;
	ph = plugin_handle;

	*plugin_name = name;
	*plugin_desc = desc;
	*plugin_version = version;

	osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
	GetVersionEx ((OSVERSIONINFO*) &osvi);

	if (osvi.dwMajorVersion == 5)
	{
		legacy_os = 1;
	}

	/* these are required for the very first run */
	delay = hexchat_pluginpref_get_int (ph, "delay");
	if (delay == -1)
	{
		delay = DEFAULT_DELAY;
		hexchat_pluginpref_set_int (ph, "delay", DEFAULT_DELAY);
	}

	if (hexchat_pluginpref_get_int (ph, "freq") == -1)
	{
		hexchat_pluginpref_set_int (ph, "freq", DEFAULT_FREQ);
	}

	hexchat_hook_command (ph, "UPDCHK", HEXCHAT_PRI_NORM, print_version, upd_help, NULL);
	hexchat_hook_timer (ph, delay * 1000, delayed_check, NULL);
	hexchat_command (ph, "MENU -ietc\\download.png ADD \"Help/Check for Updates\" \"UPDCHK\"");
	hexchat_printf (ph, "%s plugin loaded\n", name);

	return 1;       /* return 1 for success */
}
Пример #6
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));
	}
}