Exemple #1
0
int
hexchat_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
{
	int delay;
	ph = plugin_handle;

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

	/* 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 */
}
Exemple #2
0
static int api_hexchat_pluginprefs_meta_pairs_closure(lua_State *L)
{
	char *dest = lua_touserdata(L, lua_upvalueindex(1));
	hexchat_plugin *h = get_info(L)->handle;

	if(dest && *dest)
	{
		int r;
		char str[512];
		char *key = dest;

		dest = strchr(dest, ',');
		if(dest)
			*(dest++) = 0;
		lua_pushlightuserdata(L, dest);
		lua_replace(L, lua_upvalueindex(1));
		lua_pushstring(L, key);
		r = hexchat_pluginpref_get_int(h, key);
		if(r != -1)
		{
			lua_pushinteger(L, r);
			return 2;
		}
		if(hexchat_pluginpref_get_str(h, key, str))
		{
			lua_pushstring(L, str);
			return 2;
		}
		lua_pushnil(L);
		return 2;
	}
	else
		return 0;
}
Exemple #3
0
static int api_hexchat_pluginprefs_meta_index(lua_State *L)
{
	script_info *script = get_info(L);
	const char *key;
	hexchat_plugin *h;
	char str[512];
	int r;

	if(!script->name)
		return luaL_error(L, "cannot use hexchat.pluginprefs before registering with hexchat.register");

	key = luaL_checkstring(L, 2);
	h = script->handle;
	r = hexchat_pluginpref_get_int(h, key);
	if(r != -1)
	{
		lua_pushinteger(L, r);
		return 1;
	}
	if(hexchat_pluginpref_get_str(h, key, str))
	{
		/* Wasn't actually a failure */
		if (!strcmp(str, "-1"))
			lua_pushinteger(L, r);
		else
			lua_pushstring(L, str);
		return 1;
	}
	lua_pushnil(L);
	return 1;
}
Exemple #4
0
int
hexchat_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
{
	ph = plugin_handle;
	*plugin_name    = name;
	*plugin_desc    = desc;
	*plugin_version = version;
	char buffer[bsize];

	hexchat_hook_command (ph, "SYSINFO",	HEXCHAT_PRI_NORM,	sysinfo_cb,	sysinfo_help, NULL);
	hexchat_hook_command (ph, "NETDATA",	HEXCHAT_PRI_NORM,	netdata_cb,	NULL, NULL);
	hexchat_hook_command (ph, "NETSTREAM",	HEXCHAT_PRI_NORM,	netstream_cb,	NULL, NULL);

	/* this is required for the very first run */
	if (hexchat_pluginpref_get_str (ph, "pciids", buffer) == 0)
	{
		hexchat_pluginpref_set_str (ph, "pciids", DEFAULT_PCIIDS);
	}

	if (hexchat_pluginpref_get_str (ph, "format", buffer) == 0)
	{
		hexchat_pluginpref_set_str (ph, "format", DEFAULT_FORMAT);
	}

	if (hexchat_pluginpref_get_int (ph, "percent") == -1)
	{
		hexchat_pluginpref_set_int (ph, "percent", DEFAULT_PERCENT);
	}

	hexchat_command (ph, "MENU ADD \"Window/Display System Info\" \"SYSINFO\"");
	hexchat_printf (ph, "%s plugin loaded\n", name);
	return 1;
}
Exemple #5
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 */
}
Exemple #6
0
static int
get_limit ()
{
	int size = hexchat_pluginpref_get_int (ph, "limit");

	if (size <= -1 || size >= INT_MAX)
	{
		return DEFAULT_LIMIT;
	}
	else
	{
		return size;
	}
}
Exemple #7
0
void LoadPrefs()
{
	/**************************************************************************************************/
	/*********************** Our Settings Section *****************************************************/
	/**************************************************************************************************/

	/**************************************************************************************************/
	/*************************** Get the value for each of our preferances ****************************/
	/**************************************************************************************************/

	g_dwPrefs = hexchat_pluginpref_get_int (ph, "settings");
	g_iTime = hexchat_pluginpref_get_int (ph, "aot");
	g_hHotKey.key = hexchat_pluginpref_get_int (ph, "key");
	g_hHotKey.mod = hexchat_pluginpref_get_int (ph, "mod");
	hexchat_pluginpref_get_str (ph, "away", (char *) g_szAway);

	/**************************************************************************************************/
	/******************************** Register our hotkey with windows ********************************/
	/**************************************************************************************************/
	if(g_dwPrefs & (1<<PREF_UWIOB))
	{
		RegisterHotKey(g_hHotkeyWnd, 1, g_hHotKey.mod, g_hHotKey.key);
	}
}
Exemple #8
0
int
hexchat_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
{
	ph = plugin_handle;

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

	/* this is required for the very first run */
	if (hexchat_pluginpref_get_int (ph, "limit") == -1)
	{
		hexchat_pluginpref_set_int (ph, "limit", DEFAULT_LIMIT);
	}

	hexchat_hook_command (ph, "CHECKSUM", HEXCHAT_PRI_NORM, checksum, "Usage: /CHECKSUM GET|SET", 0);
	hexchat_hook_print (ph, "DCC RECV Complete", HEXCHAT_PRI_NORM, dccrecv_cb, NULL);
	hexchat_hook_print (ph, "DCC Offer", HEXCHAT_PRI_NORM, dccoffer_cb, NULL);

	hexchat_printf (ph, "%s plugin loaded\n", name);
	return 1;
}
Exemple #9
0
static int
print_version (char *word[], char *word_eol[], void *userdata)
{
	char *version;
	int prevbuf;
	int convbuf;

	if (!g_ascii_strcasecmp ("HELP", word[2]))
	{
		hexchat_printf (ph, upd_help);
		return HEXCHAT_EAT_HEXCHAT;
	}
	else if (!g_ascii_strcasecmp ("SET", word[2]))
	{
		if (!g_ascii_strcasecmp ("", word_eol[4]))
		{
			hexchat_printf (ph, "%s\tEnter a value!\n", name);
			return HEXCHAT_EAT_HEXCHAT;
		}
		if (!g_ascii_strcasecmp ("delay", word[3]))
		{
			convbuf = atoi (word[4]);	/* don't use word_eol, numbers must not contain spaces */

			if (convbuf > 0 && convbuf < INT_MAX)
			{
				prevbuf = hexchat_pluginpref_get_int (ph, "delay");
				hexchat_pluginpref_set_int (ph, "delay", convbuf);
				hexchat_printf (ph, "%s\tUpdate check startup delay is set to %d seconds (from %d).\n", name, convbuf, prevbuf);
			}
			else
			{
				hexchat_printf (ph, "%s\tInvalid input!\n", name);
			}
		}
		else if (!g_ascii_strcasecmp ("freq", word[3]))
		{
			convbuf = atoi (word[4]);	/* don't use word_eol, numbers must not contain spaces */

			if (convbuf > 0 && convbuf < INT_MAX)
			{
				prevbuf = hexchat_pluginpref_get_int (ph, "freq");
				hexchat_pluginpref_set_int (ph, "freq", convbuf);
				hexchat_printf (ph, "%s\tUpdate check frequency is set to %d minutes (from %d).\n", name, convbuf, prevbuf);
			}
			else
			{
				hexchat_printf (ph, "%s\tInvalid input!\n", name);
			}
		}
		else
		{
			hexchat_printf (ph, "%s\tInvalid variable name! Use 'delay' or 'freq'!\n", name);
			return HEXCHAT_EAT_HEXCHAT;
		}

		return HEXCHAT_EAT_HEXCHAT;
	}
	else if (!g_ascii_strcasecmp ("", word[2]))
	{
		version = check_version ();

		if (strcmp (version, hexchat_get_info (ph, "version")) == 0)
		{
			hexchat_printf (ph, "%s\tYou have the latest version of HexChat installed!\n", name);
		}
		else if (strcmp (version, "Unknown") == 0)
		{
			hexchat_printf (ph, "%s\tUnable to check for HexChat updates!\n", name);
		}
		else
		{
#ifdef _WIN64 /* use this approach, the wProcessorArchitecture method always returns 0 (=x86) for some reason */
			hexchat_printf (ph, "%s\tA HexChat update is available! You can download it from here:\nhttps://github.com/downloads/hexchat/hexchat/HexChat%%20%s%%20x64.exe\n", name, version);
#else
			hexchat_printf (ph, "%s\tA HexChat update is available! You can download it from here:\nhttps://github.com/downloads/hexchat/hexchat/HexChat%%20%s%%20x86.exe\n", name, version);
#endif
		}
		return HEXCHAT_EAT_HEXCHAT;
	}
	else
	{
		hexchat_printf (ph, upd_help);
		return HEXCHAT_EAT_HEXCHAT;
	}
}
Exemple #10
0
int
sysinfo_get_percent ()
{
	return hexchat_pluginpref_get_int (ph, "percent");
}
Exemple #11
0
int hexchat_plugin_init(hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg)
{
	ph = plugin_handle;

	*plugin_name	= "HexTray";
	*plugin_desc	= "Minimize HexChat to the Windows system tray";
	*plugin_version = "1.3.0";

	char buffer[256];

	/***************************************************************************************************************************/
	/************************* Initialize our preferences if they don't exist yet **********************************************/
	/***************************************************************************************************************************/

	if (hexchat_pluginpref_get_int (ph, "settings") == -1)
	{
		hexchat_pluginpref_set_int (ph, "settings", HT_DEF_SET);
	}
	if (hexchat_pluginpref_get_int (ph, "aot") == -1)
	{
		hexchat_pluginpref_set_int (ph, "aot", HT_DEF_AOT);
	}
	if (hexchat_pluginpref_get_int (ph, "key") == -1)
	{
		hexchat_pluginpref_set_int (ph, "key", HT_DEF_KEY);
	}
	if (hexchat_pluginpref_get_int (ph, "mod") == -1)
	{
		hexchat_pluginpref_set_int (ph, "mod", HT_DEF_MOD);
	}
	if (hexchat_pluginpref_get_str (ph, "away", buffer) == 0)
	{
		hexchat_pluginpref_set_str (ph, "away", "");
	}

	/***************************************************************************************************************************/
	/************************* Load our preferences ****************************************************************************/
	/***************************************************************************************************************************/
	LoadPrefs();

	/***************************************************************************************************************************/
	/************************* Finds the HexChat window and saves it for later use *********************************************/
	/***************************************************************************************************************************/
	g_hXchatWnd = (HWND)hexchat_get_info(ph, "win_ptr");

	if(g_hXchatWnd == NULL)
	{
		EnumThreadWindows(GetCurrentThreadId(), EnumWindowsProc, 0);
	}

	g_hOldProc	= (WNDPROC)GetWindowLongPtr(g_hXchatWnd, GWLP_WNDPROC);
	SetWindowLongPtr(g_hXchatWnd, GWLP_WNDPROC, (LONG_PTR)WindowProc);

	/***************************************************************************************************************************/	
	/************************* Grab the HexChat Icon, Load our menu, create the window to receive the hotkey messages  *********/
	/************************* and register the windows message so we know if explorer crashes                       ***********/
	/***************************************************************************************************************************/
	g_hTrayMenu		= GetSubMenu(LoadMenu((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDR_TRAY_MENU)), 0);
	g_hHotkeyWnd	= CreateDialog((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDD_ALERT), NULL,		(DLGPROC)HotKeyProc);
	g_hPrefDlg		= CreateDialog((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDD_PREF),  g_hXchatWnd, (DLGPROC)PrefProc);

	g_hIcons[0]	= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_XCHAT),			IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
	g_hIcons[2]	= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_HIGHLIGHT),		IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
	g_hIcons[5]	= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_BANNED),			IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
	g_hIcons[6]	= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_KICKED),			IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
	g_hIcons[8]	= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_PMSG),			IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
	g_hIcons[10]= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_SNOTICE),		IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
	g_hIcons[11]= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_DISCONNECTED),	IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
	g_hIcons[22]	= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_CHANMSG),		IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);

	/***************************************************************************************************************************/
	/************************* Add our icon to the tray ************************************************************************/
	/***************************************************************************************************************************/
	char szVersion[64];
	_snprintf(szVersion, 64, "HexChat %s", hexchat_get_info(ph, "version"));
	AddIcon(g_hXchatWnd, 1, g_hIcons[0], szVersion, (NIF_ICON | NIF_MESSAGE | NIF_TIP), WM_TRAYMSG);

	/***************************************************************************************************************************/
	/***************************************************************************************************************************/
	/***************************************************************************************************************************/
	if(g_dwPrefs & (1<<PREF_DNSIT))
	{
		DWORD dwStyle;
		dwStyle = GetWindowLong(g_hXchatWnd, GWL_STYLE);
		dwStyle |= (1<<WS_CHILD);
		SetWindowLongPtr(g_hXchatWnd, GWL_STYLE, (LONG_PTR)dwStyle);
		SetWindowLongPtr(g_hXchatWnd, GWL_HWNDPARENT, (LONG_PTR)g_hHotkeyWnd);
	}

	/***************************************************************************************************************************/
	/************************* Set our hooks and save them for later so we can unhook them *************************************/
	/***************************************************************************************************************************/
	g_vHooks.push_back(hexchat_hook_print(ph, "Channel Msg Hilight",			HEXCHAT_PRI_NORM, event_cb,	(void *)CHAN_HILIGHT));
	g_vHooks.push_back(hexchat_hook_print(ph, "Channel Message",				HEXCHAT_PRI_NORM, event_cb,	(void *)CHAN_MESSAGE));
	g_vHooks.push_back(hexchat_hook_print(ph, "Topic Change",					HEXCHAT_PRI_NORM, event_cb,	(void *)CHAN_TOPIC_CHANGE));
	g_vHooks.push_back(hexchat_hook_print(ph, "Channel Action Hilight",		HEXCHAT_PRI_NORM, event_cb,	(void *)CHAN_HILIGHT));
	g_vHooks.push_back(hexchat_hook_print(ph, "Channel INVITE",				HEXCHAT_PRI_NORM, event_cb,	(void *)CHAN_INVITE));
	g_vHooks.push_back(hexchat_hook_print(ph, "You Kicked",					HEXCHAT_PRI_NORM, event_cb,	(void *)CHAN_KICKED));
	g_vHooks.push_back(hexchat_hook_print(ph, "Banned",						HEXCHAT_PRI_NORM, event_cb,	(void *)CHAN_BANNED));
	g_vHooks.push_back(hexchat_hook_print(ph, "CTCP Generic",					HEXCHAT_PRI_NORM, event_cb,	(void *)CTCP_GENERIC));
	g_vHooks.push_back(hexchat_hook_print(ph, "Private Message",				HEXCHAT_PRI_NORM, event_cb,	(void *)PMSG_RECEIVE));
	g_vHooks.push_back(hexchat_hook_print(ph, "Private Message to Dialog",	HEXCHAT_PRI_NORM, event_cb,	(void *)PMSG_RECEIVE));
	g_vHooks.push_back(hexchat_hook_print(ph, "Disconnected",					HEXCHAT_PRI_NORM, event_cb,	(void *)SERV_DISCONNECT));
	g_vHooks.push_back(hexchat_hook_print(ph, "Killed",						HEXCHAT_PRI_NORM, event_cb,	(void *)SERV_KILLED));
	g_vHooks.push_back(hexchat_hook_print(ph, "Notice",						HEXCHAT_PRI_NORM, event_cb,	(void *)SERV_NOTICE));
	g_vHooks.push_back(hexchat_hook_command(ph, "tray_alert",					HEXCHAT_PRI_NORM, command_cb,	"Create an Alert", NULL));

	return 1;
}