Ejemplo n.º 1
0
Archivo: upd.c Proyecto: fuzzmz/hexchat
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 */
}
Ejemplo n.º 2
0
void SavePrefs(int iDlg)
{
	hexchat_pluginpref_set_int (ph, "settings", g_dwPrefs);
	hexchat_pluginpref_set_int (ph, "aot", g_iTime);
	hexchat_pluginpref_set_int (ph, "key", g_hHotKey.key);
	hexchat_pluginpref_set_int (ph, "mod", g_hHotKey.mod);
	hexchat_pluginpref_set_str (ph, "away", (const char*) g_szAway);
}
Ejemplo n.º 3
0
Archivo: lua.c Proyecto: Cynede/hexchat
static int api_hexchat_pluginprefs_meta_newindex(lua_State *L)
{
	script_info *script = get_info(L);
	const char *key;
	hexchat_plugin *h;

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

	key = luaL_checkstring(L, 2);
	h = script->handle;
	switch(lua_type(L, 3))
	{
		case LUA_TSTRING:
			hexchat_pluginpref_set_str(h, key, lua_tostring(L, 3));
			return 0;
		case LUA_TNUMBER:
			hexchat_pluginpref_set_int(h, key, lua_tointeger(L, 3));
			return 0;
		case LUA_TNIL: case LUA_TNONE:
			hexchat_pluginpref_delete(h, key);
			return 0;
		default:
			return luaL_argerror(L, 3, "expected string, number, or nil");
	}
}
Ejemplo n.º 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;
}
Ejemplo n.º 5
0
static void
reset_settings ()
{
	hexchat_pluginpref_set_str (ph, "pciids", DEFAULT_PCIIDS);
	hexchat_pluginpref_set_str (ph, "format", DEFAULT_FORMAT);
	hexchat_pluginpref_set_int (ph, "percent", DEFAULT_PERCENT);
}
Ejemplo n.º 6
0
static void
set_limit (char* size)
{
	int buffer = atoi (size);

	if (buffer > 0 && buffer < INT_MAX)
	{
		if (hexchat_pluginpref_set_int (ph, "limit", buffer))
		{
			hexchat_printf (ph, "File size limit has successfully been set to: %d MiB\n", buffer);
		}
		else
		{
			hexchat_printf (ph, "File access error while saving!\n");
		}
	}
	else
	{
		hexchat_printf (ph, "Invalid input!\n");
	}
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
Archivo: upd.c Proyecto: fuzzmz/hexchat
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;
	}
}
Ejemplo n.º 9
0
static int
sysinfo_cb (char *word[], char *word_eol[], void *userdata)
{
	error_printed = 0;
	int announce = 0;
	int buffer;
	char format[bsize];

	if (!hexchat_pluginpref_get_str (ph, "format", format))
	{
		hexchat_printf (ph, "%s\tError reading config file!", name);
		return HEXCHAT_EAT_ALL;
	}

	if (hexchat_list_int (ph, NULL, "type") >= 2)
	{
		announce = 1;
	}

	if (!g_ascii_strcasecmp ("HELP", word[2]))
	{
		hexchat_printf (ph, sysinfo_help);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("LIST", word[2]))
	{
		list_settings ();
		return HEXCHAT_EAT_ALL;
	}
	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_ALL;
		}
		if (!g_ascii_strcasecmp ("format", word[3]))
		{
			hexchat_pluginpref_set_str (ph, "format", word_eol[4]);
			hexchat_printf (ph, "%s\tformat is set to: %s\n", name, word_eol[4]);
		}
		else if (!g_ascii_strcasecmp ("percent", word[3]))
		{
			buffer = atoi (word[4]);	/* don't use word_eol, numbers must not contain spaces */

			if (buffer > 0 && buffer < INT_MAX)
			{
				hexchat_pluginpref_set_int (ph, "percent", buffer);
				hexchat_printf (ph, "%s\tpercent is set to: %d\n", name, buffer);
			}
			else
			{
				hexchat_printf (ph, "%s\tInvalid input!\n", name);
			}
		}
		else if (!g_ascii_strcasecmp ("pciids", word[3]))
		{
			hexchat_pluginpref_set_str (ph, "pciids", word_eol[4]);
			hexchat_printf (ph, "%s\tpciids is set to: %s\n", name, word_eol[4]);
		}
		else
		{
			hexchat_printf (ph, "%s\tInvalid variable name! Use 'pciids', 'format' or 'percent'!\n", name);
			return HEXCHAT_EAT_ALL;
		}

		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("RESET", word[2]))
	{
		reset_settings ();
		hexchat_printf (ph, "%s\tSettings have been restored to defaults.\n", name);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("OS", word[2]))
	{
		print_os (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("DISTRO", word[2]))
	{
		print_distro (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("CPU", word[2]))
	{
		print_cpu (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("RAM", word[2]))
	{
		print_ram (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("DISK", word[2]))
	{
		print_disk (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("VGA", word[2]))
	{
		print_vga (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("SOUND", word[2]))
	{
		print_sound (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("ETHERNET", word[2]))
	{
		print_ethernet (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("UPTIME", word[2]))
	{
		print_uptime (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else if (!g_ascii_strcasecmp ("", word[2]))
	{
		print_summary (announce, format);
		return HEXCHAT_EAT_ALL;
	}
	else
	{
		hexchat_printf (ph, sysinfo_help);
		return HEXCHAT_EAT_ALL;
	}
}
Ejemplo n.º 10
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;
}