summary refs log tree commit diff stats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/exec/exec.c48
-rw-r--r--plugins/perl/perl.c9
-rw-r--r--plugins/python/python.c145
-rw-r--r--plugins/sysinfo/match.c25
-rw-r--r--plugins/sysinfo/parse.c35
-rw-r--r--plugins/sysinfo/xsys.c94
-rw-r--r--plugins/upd/upd.c80
7 files changed, 287 insertions, 149 deletions
diff --git a/plugins/exec/exec.c b/plugins/exec/exec.c
index 790278a2..d83a4d74 100644
--- a/plugins/exec/exec.c
+++ b/plugins/exec/exec.c
@@ -28,7 +28,7 @@
 static hexchat_plugin *ph;   /* plugin handle */
 static char name[] = "Exec";
 static char desc[] = "Execute commands inside HexChat";
-static char version[] = "1.1";
+static char version[] = "1.2";
 
 static int
 run_command (char *word[], char *word_eol[], void *userdata)
@@ -41,6 +41,10 @@ run_command (char *word[], char *word_eol[], void *userdata)
 	time_t start;
 	double timeElapsed;
 
+	char *token;
+	char *context = NULL;
+	int announce = 0;
+
 	HANDLE readPipe;
 	HANDLE writePipe;
 	STARTUPINFO sInfo; 
@@ -59,9 +63,8 @@ run_command (char *word[], char *word_eol[], void *userdata)
 
 		if (!stricmp("-O", word[2]))
 		{
-			/*strcat (commandLine, word_eol[3]);*/
-			hexchat_printf (ph, "Printing Exec output to others is not supported yet.\n");
-			return HEXCHAT_EAT_HEXCHAT;
+			strcat (commandLine, word_eol[3]);
+			announce = 1;
 		}
 		else
 		{
@@ -90,7 +93,19 @@ run_command (char *word[], char *word_eol[], void *userdata)
 				{
 					/* avoid garbage */
 					buffer[dwRead] = '\0';
-					hexchat_printf (ph, "%s", buffer);
+
+					if (announce)
+					{
+						/* Say each line seperately, TODO: improve... */
+						token = strtok_s (buffer, "\n", &context);
+						while (token != NULL)
+						{
+							hexchat_commandf (ph, "SAY %s", token);
+							token = strtok_s (NULL, "\n", &context);
+						}
+					}
+					else
+						hexchat_printf (ph, "%s", buffer);
 				}
 			}
 			else
@@ -100,20 +115,25 @@ run_command (char *word[], char *word_eol[], void *userdata)
 			}
 			timeElapsed = difftime (time (0), start);
 		}
-	}
 
-	/* display a newline to separate things */
-	hexchat_printf (ph, "\n");
+		/* display a newline to separate things */
+		if (!announce)
+			hexchat_printf (ph, "\n");
+
+		if (timeElapsed >= 10)
+		{
+			hexchat_printf (ph, "Command took too much time to run, execution aborted.\n");
+		}
 
-	if (timeElapsed >= 10)
+		CloseHandle (readPipe);
+		CloseHandle (pInfo.hProcess);
+		CloseHandle (pInfo.hThread);
+	}
+	else
 	{
-		hexchat_printf (ph, "Command took too much time to run, execution aborted.\n");
+		hexchat_command (ph, "help exec");
 	}
 
-	CloseHandle (readPipe);
-	CloseHandle (pInfo.hProcess);
-	CloseHandle (pInfo.hThread);
-
 	return HEXCHAT_EAT_HEXCHAT;
 }
 
diff --git a/plugins/perl/perl.c b/plugins/perl/perl.c
index 732fd65c..abb66c5a 100644
--- a/plugins/perl/perl.c
+++ b/plugins/perl/perl.c
@@ -1520,7 +1520,7 @@ perl_command_unload (char *word[], char *word_eol[], void *userdata)
 }
 
 static int
-perl_command_reload (char *word[], char *word_eol[], void *userdata)
+perl_command_reload (char *word[], char *word_eol[], void *eat)
 {
 	char *file = get_filename (word, word_eol);
 	
@@ -1529,7 +1529,10 @@ perl_command_reload (char *word[], char *word_eol[], void *userdata)
 		return HEXCHAT_EAT_HEXCHAT;
 	}
 	
-	return HEXCHAT_EAT_HEXCHAT;
+	if (eat)
+		return HEXCHAT_EAT_HEXCHAT;
+	else
+		return HEXCHAT_EAT_NONE;
 }
 
 void
@@ -1570,7 +1573,7 @@ hexchat_plugin_init (hexchat_plugin * plugin_handle, char **plugin_name,
 	hexchat_hook_command (ph, "reload", HEXCHAT_PRI_NORM, perl_command_reload, 0,
 							  0);
 	hexchat_hook_command (ph, "pl_reload", HEXCHAT_PRI_NORM, perl_command_reload, 0,
-							  0);
+							  (int*)1);
 	hexchat_hook_command (ph, "unloadall", HEXCHAT_PRI_NORM,
 							  perl_command_unloadall, 0, 0);
 	hexchat_hook_command (ph, "reloadall", HEXCHAT_PRI_NORM,
diff --git a/plugins/python/python.c b/plugins/python/python.c
index 90dbb22d..7bedcad9 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -72,15 +72,32 @@
 #include <structmember.h>
 #include <pythread.h>
 
+/* Macros to convert version macros into string literals.
+ * The indirect macro is a well-known preprocessor trick to force X to be evaluated before the # operator acts to make it a string literal.
+ * If STRINGIZE were to be directly defined as #X instead, VERSION would be "VERSION_MAJOR" instead of "1".
+ */
+#define STRINGIZE2(X) #X
+#define STRINGIZE(X) STRINGIZE2(X)
+
+/* Version number macros */
 #define VERSION_MAJOR 1
 #define VERSION_MINOR 0
 
-#if PY_MAJOR_VERSION == 2
+/* Version string macro */
 #ifdef WIN32
-#undef WITH_THREAD
-#define VERSION "1.0/2.7"	/* Linked to python27.dll */
+#if PY_MAJOR_VERSION == 2
+#define VERSION STRINGIZE(VERSION_MAJOR) "." STRINGIZE(VERSION_MINOR) "/2.7"	/* Linked to python27.dll */
+#elif PY_MAJOR_VERSION == 3
+#define VERSION STRINGIZE(VERSION_MAJOR) "." STRINGIZE(VERSION_MINOR) "/3.3"	/* Linked to python33.dll */
+#endif
 #endif
 
+#ifndef VERSION
+#define VERSION STRINGIZE(VERSION_MAJOR) "." STRINGIZE(VERSION_MINOR)
+#endif
+
+/* #define's for Python 2 */
+#if PY_MAJOR_VERSION == 2
 #undef PyLong_Check
 #define PyLong_Check PyInt_Check
 #define PyLong_AsLong PyInt_AsLong
@@ -95,15 +112,14 @@
 #define PyUnicode_FromString PyString_FromString
 #define PyUnicode_AsUTF8 PyString_AsString
 
-#else
-#define IS_PY3K
 #ifdef WIN32
-#define VERSION "1.0/3.3"	/* Linked to python33.dll */
+#undef WITH_THREAD
 #endif
 #endif
 
-#ifndef VERSION
-#define VERSION "1.0"
+/* #define for Python 3 */
+#if PY_MAJOR_VERSION == 3
+#define IS_PY3K
 #endif
 
 #define NONE 0
@@ -269,7 +285,8 @@ static char *Util_Expand(char *filename);
 
 static int Callback_Server(char *word[], char *word_eol[], hexchat_event_attrs *attrs, void *userdata);
 static int Callback_Command(char *word[], char *word_eol[], void *userdata);
-static int Callback_Print(char *word[], hexchat_event_attrs *attrs, void *userdata);
+static int Callback_Print_Attrs(char *word[], hexchat_event_attrs *attrs, void *userdata);
+static int Callback_Print(char *word[], void *userdata);
 static int Callback_Timer(void *userdata);
 static int Callback_ThreadTimer(void *userdata);
 
@@ -365,9 +382,6 @@ Usage: /PY LOAD   <filename>\n\
            ABOUT\n\
 \n";
 
-/* Remove if/when HexChat supports this command for plugins */
-static const char reload[] = "Usage: RELOAD <name>, reloads a python script";
-
 static const char about[] = "HexChat Python " PY_VERSION " Interface Version " VERSION "\n";
 
 /* ===================================================================== */
@@ -593,10 +607,8 @@ Callback_Command(char *word[], char *word_eol[], void *userdata)
 	return ret;
 }
 
-/* No Callback_Server() here. We use Callback_Command() as well. */
-
 static int
-Callback_Print(char *word[], hexchat_event_attrs *attrs, void *userdata)
+Callback_Print_Attrs(char *word[], hexchat_event_attrs *attrs, void *userdata)
 {
 	Hook *hook = (Hook *) userdata;
 	PyObject *retobj;
@@ -662,12 +674,8 @@ Callback_Print(char *word[], hexchat_event_attrs *attrs, void *userdata)
 
 	attributes = Attribute_New(attrs);
 
-	if (hook->type == HOOK_XCHAT_ATTR)
-		retobj = PyObject_CallFunction(hook->callback, "(OOOO)", word_list,
-					       word_eol_list, hook->userdata, attributes);
-	else
-		retobj = PyObject_CallFunction(hook->callback, "(OOO)", word_list,
-					       word_eol_list, hook->userdata);
+	retobj = PyObject_CallFunction(hook->callback, "(OOOO)", word_list,
+					    word_eol_list, hook->userdata, attributes);
 
 	Py_DECREF(word_list);
 	Py_DECREF(word_eol_list);
@@ -691,6 +699,94 @@ Callback_Print(char *word[], hexchat_event_attrs *attrs, void *userdata)
 }
 
 static int
+Callback_Print(char *word[], void *userdata)
+{
+	Hook *hook = (Hook *) userdata;
+	PyObject *retobj;
+	PyObject *word_list;
+	PyObject *word_eol_list;
+	char **word_eol;
+	char *word_eol_raw;
+	int listsize = 0;
+	int next = 0;
+	int i;
+	int ret = 0;
+	PyObject *plugin;
+
+	/* Cut off the message identifier. */
+	word += 1;
+
+	/* HexChat doesn't provide a word_eol for print events, so we
+	 * build our own here. */
+	while (word[listsize] && word[listsize][0])
+		listsize++;
+	word_eol = (char **) g_malloc(sizeof(char*)*(listsize+1));
+	if (word_eol == NULL) {
+		hexchat_print(ph, "Not enough memory to alloc word_eol "
+				"for python plugin callback.");
+		return 0;
+	}
+	/* First build a word clone, but NULL terminated. */
+	memcpy(word_eol, word, listsize*sizeof(char*));
+	word_eol[listsize] = NULL;
+	/* Then join it. */
+	word_eol_raw = g_strjoinv(" ", word_eol);
+	if (word_eol_raw == NULL) {
+		hexchat_print(ph, "Not enough memory to alloc word_eol_raw "
+				"for python plugin callback.");
+		return 0;
+	}
+	/* And rebuild the real word_eol. */
+	for (i = 0; i != listsize; i++) {
+		word_eol[i] = word_eol_raw+next;
+		next += strlen(word[i])+1;
+	}
+	word_eol[i] = "";
+
+	plugin = hook->plugin;
+	BEGIN_PLUGIN(plugin);
+
+	word_list = Util_BuildList(word);
+	if (word_list == NULL) {
+		g_free(word_eol_raw);
+		g_free(word_eol);
+		END_PLUGIN(plugin);
+		return 0;
+	}
+	word_eol_list = Util_BuildList(word_eol);
+	if (word_eol_list == NULL) {
+		g_free(word_eol_raw);
+		g_free(word_eol);
+		Py_DECREF(word_list);
+		END_PLUGIN(plugin);
+		return 0;
+	}
+
+
+	retobj = PyObject_CallFunction(hook->callback, "(OOO)", word_list,
+					       word_eol_list, hook->userdata);
+
+	Py_DECREF(word_list);
+	Py_DECREF(word_eol_list);
+
+	g_free(word_eol_raw);
+	g_free(word_eol);
+	if (retobj == Py_None) {
+		ret = HEXCHAT_EAT_NONE;
+		Py_DECREF(retobj);
+	} else if (retobj) {
+		ret = PyLong_AsLong(retobj);
+		Py_DECREF(retobj);
+	} else {
+		PyErr_Print();
+	}
+
+	END_PLUGIN(plugin);
+
+	return ret;
+}
+
+static int
 Callback_Timer(void *userdata)
 {
 	Hook *hook = (Hook *) userdata;
@@ -896,6 +992,7 @@ static PyTypeObject XChatOut_Type = {
 /* ===================================================================== */
 /* Attribute object */
 
+#undef OFF
 #define OFF(x) offsetof(AttributeObject, x)
 
 static PyMemberDef Attribute_members[] = {
@@ -2028,7 +2125,7 @@ Module_hexchat_hook_print(PyObject *self, PyObject *args, PyObject *kwargs)
 		return NULL;
 
 	BEGIN_XCHAT_CALLS(NONE);
-	hook->data = (void*)hexchat_hook_print_attrs(ph, name, priority,
+	hook->data = (void*)hexchat_hook_print(ph, name, priority,
 					     Callback_Print, hook);
 	END_XCHAT_CALLS();
 
@@ -2065,7 +2162,7 @@ Module_hexchat_hook_print_attrs(PyObject *self, PyObject *args, PyObject *kwargs
 
 	BEGIN_XCHAT_CALLS(NONE);
 	hook->data = (void*)hexchat_hook_print_attrs(ph, name, priority,
-					     Callback_Print, hook);
+					     Callback_Print_Attrs, hook);
 	END_XCHAT_CALLS();
 
 	return PyLong_FromVoidPtr(hook);
@@ -2755,7 +2852,7 @@ hexchat_plugin_init(hexchat_plugin *plugin_handle,
 	hexchat_hook_command(ph, "PY", HEXCHAT_PRI_NORM, Command_Py, usage, 0);
 	hexchat_hook_command(ph, "LOAD", HEXCHAT_PRI_NORM, Command_Load, 0, 0);
 	hexchat_hook_command(ph, "UNLOAD", HEXCHAT_PRI_NORM, Command_Unload, 0, 0);
-	hexchat_hook_command(ph, "RELOAD", HEXCHAT_PRI_NORM, Command_Reload, reload, 0);
+	hexchat_hook_command(ph, "RELOAD", HEXCHAT_PRI_NORM, Command_Reload, 0, 0);
 #ifdef WITH_THREAD
 	thread_timer = hexchat_hook_timer(ph, 300, Callback_ThreadTimer, NULL);
 #endif
diff --git a/plugins/sysinfo/match.c b/plugins/sysinfo/match.c
index 7d719738..2853aab6 100644
--- a/plugins/sysinfo/match.c
+++ b/plugins/sysinfo/match.c
@@ -65,14 +65,31 @@ char *pretty_freespace(const char *desc, unsigned long long *free_k, unsigned lo
         return result;
 }
 
+
 void remove_leading_whitespace(char *buffer)
 {
-	char *pos;
-        while((pos = memchr(buffer, 0x20, 1)))
+	char *buffer2 = NULL;
+	int i = 0, j = 0, ews = 0;
+
+	buffer2 = (char*)malloc(strlen(buffer) * sizeof(char));
+	if (buffer2 == NULL)
+		return;
+
+	memset (buffer2, (char)0, strlen(buffer));
+	while (i < strlen(buffer))
 	{
-		pos += 1;
-		strcpy(buffer, pos);
+		/* count tabs, spaces as whitespace. */
+		if (!(buffer[i] == (char)32 || buffer[i] == (char)9) || ews == 1)
+		{
+			ews = 1;
+			buffer2[j] = buffer[i];
+			j++;
+		}
+		i++;
 	}
+	memset (buffer, (char)0, strlen(buffer));
+	strcpy (buffer, buffer2);
+	free (buffer2);
 }
 
 char *decruft_filename(char *buffer)
diff --git a/plugins/sysinfo/parse.c b/plugins/sysinfo/parse.c
index ed6ba146..44ad4f86 100644
--- a/plugins/sysinfo/parse.c
+++ b/plugins/sysinfo/parse.c
@@ -378,22 +378,9 @@ int xs_parse_distro(char *name)
 {
 	FILE *fp = NULL;
 	char buffer[bsize], *pos = NULL;
-	
-	if((fp = fopen("/etc/lsb-release", "r")) != NULL)
-	{
-		char id[bsize], codename[bsize], release[bsize];
-		strcpy(id, "?");
-		strcpy(codename, "?");
-		strcpy(release, "?");
-		while(fgets(buffer, bsize, fp) != NULL)
-		{
-			find_match_char(buffer, "DISTRIB_ID", id);
-			find_match_char(buffer, "DISTRIB_CODENAME", codename);
-			find_match_char(buffer, "DISTRIB_RELEASE", release);
-		}
-		snprintf(buffer, bsize, "%s \"%s\" %s", id, codename, release);
-	}
-	else if((fp = fopen("/etc/make.conf", "r")) != NULL)
+
+	if((fp = fopen("/etc/portage/make.conf", "r")) != NULL ||
+			(fp = fopen("/etc/make.conf", "r")) != NULL)
 	{
 		char keywords[bsize];
 		while(fgets(buffer, bsize, fp) != NULL)
@@ -403,7 +390,7 @@ int xs_parse_distro(char *name)
 			snprintf(buffer, bsize, "Gentoo Linux (stable)");
 		else
 			snprintf(buffer, bsize, "Gentoo Linux %s", keywords);
-	}		
+	}
 	else if((fp = fopen("/etc/redhat-release", "r")) != NULL)
 		fgets(buffer, bsize, fp);
 	else if((fp = fopen("/etc/mageia-release", "r")) != NULL)
@@ -424,6 +411,20 @@ int xs_parse_distro(char *name)
 		fgets(buffer, bsize, fp);
 	else if((fp = fopen("/etc/arch-release", "r")) != NULL)
 		snprintf(buffer, bsize, "ArchLinux");
+	else if((fp = fopen("/etc/lsb-release", "r")) != NULL)
+	{
+		char id[bsize], codename[bsize], release[bsize];
+		strcpy(id, "?");
+		strcpy(codename, "?");
+		strcpy(release, "?");
+		while(fgets(buffer, bsize, fp) != NULL)
+		{
+			find_match_char(buffer, "DISTRIB_ID", id);
+			find_match_char(buffer, "DISTRIB_CODENAME", codename);
+			find_match_char(buffer, "DISTRIB_RELEASE", release);
+		}
+		snprintf(buffer, bsize, "%s \"%s\" %s", id, codename, release);
+	}
 	else
 		snprintf(buffer, bsize, "Unknown Distro");
 	if(fp != NULL) fclose(fp);
diff --git a/plugins/sysinfo/xsys.c b/plugins/sysinfo/xsys.c
index eb71cb94..9e444df9 100644
--- a/plugins/sysinfo/xsys.c
+++ b/plugins/sysinfo/xsys.c
@@ -35,6 +35,7 @@
 
 #define DEFAULT_FORMAT "%B%1:%B %2 **"
 #define DEFAULT_PERCENT 1
+#define DEFAULT_ANNOUNCE 1
 #define DEFAULT_PCIIDS "/usr/share/hwdata/pci.ids"
 
 static hexchat_plugin *ph;	/* plugin handle */
@@ -43,7 +44,7 @@ static int error_printed = 0;	/* semaphore, make sure not to print the same erro
 static char name[] = "SysInfo";
 static char desc[] = "Display info about your hardware and OS";
 static char version[] = "3.0";
-static char sysinfo_help[] = "SysInfo Usage:\n  /SYSINFO [OS|DISTRO|CPU|RAM|DISK|VGA|SOUND|ETHERNET|UPTIME], print various details about your system or print a summary without arguments\n  /SYSINFO LIST, print current settings\n  /SYSINFO SET <variable>, update given setting\n  /SYSINFO RESET, reset settings to defaults\n  /NETDATA <iface>, show transmitted data on given interface\n  /NETSTREAM <iface>, show current bandwidth on given interface\n";
+static char sysinfo_help[] = "SysInfo Usage:\n  /SYSINFO [-e|-o] [OS|DISTRO|CPU|RAM|DISK|VGA|SOUND|ETHERNET|UPTIME], print various details about your system or print a summary without arguments\n  /SYSINFO LIST, print current settings\n  /SYSINFO SET <variable>, update given setting\n  /SYSINFO RESET, reset settings to defaults\n  /NETDATA <iface>, show transmitted data on given interface\n  /NETSTREAM <iface>, show current bandwidth on given interface\n";
 
 void
 sysinfo_get_pciids (char* dest)
@@ -57,6 +58,12 @@ sysinfo_get_percent ()
 	return hexchat_pluginpref_get_int (ph, "percent");
 }
 
+int
+sysinfo_get_announce ()
+{
+	return hexchat_pluginpref_get_int (ph, "announce");
+}
+
 void
 sysinfo_print_error (const char* msg)
 {
@@ -705,13 +712,15 @@ 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);
+	hexchat_pluginpref_set_int (ph, "announce", DEFAULT_ANNOUNCE);
 }
 
 static int
 sysinfo_cb (char *word[], char *word_eol[], void *userdata)
 {
 	error_printed = 0;
-	int announce = 0;
+	int announce = sysinfo_get_announce ();
+	int offset = 0;
 	int buffer;
 	char format[bsize];
 
@@ -721,36 +730,49 @@ sysinfo_cb (char *word[], char *word_eol[], void *userdata)
 		return HEXCHAT_EAT_ALL;
 	}
 
-	if (hexchat_list_int (ph, NULL, "type") >= 2)
+	/* Cannot send to server tab */
+	if (hexchat_list_int (ph, NULL, "type") == 1)
+	{
+		announce = 0;
+	}
+
+	/* Allow overriding global announce setting */
+	if (!strcmp ("-e", word[2]))
+	{
+		announce = 0;
+		offset++;
+	}
+	else if (!strcmp ("-o", word[2]))
 	{
 		announce = 1;
+		offset++;
 	}
 
-	if (!g_ascii_strcasecmp ("HELP", word[2]))
+	if (!g_ascii_strcasecmp ("HELP", word[2+offset]))
 	{
 		hexchat_printf (ph, sysinfo_help);
 		return HEXCHAT_EAT_ALL;
 	}
-	else if (!g_ascii_strcasecmp ("LIST", word[2]))
+	else if (!g_ascii_strcasecmp ("LIST", word[2+offset]))
 	{
 		list_settings ();
 		return HEXCHAT_EAT_ALL;
 	}
-	else if (!g_ascii_strcasecmp ("SET", word[2]))
+	else if (!g_ascii_strcasecmp ("SET", word[2+offset]))
 	{
-		if (!g_ascii_strcasecmp ("", word_eol[4]))
+		if (!g_ascii_strcasecmp ("", word_eol[4+offset]))
 		{
 			hexchat_printf (ph, "%s\tEnter a value!\n", name);
 			return HEXCHAT_EAT_ALL;
 		}
-		if (!g_ascii_strcasecmp ("format", word[3]))
+		if (!g_ascii_strcasecmp ("format", word[3+offset]))
 		{
-			hexchat_pluginpref_set_str (ph, "format", word_eol[4]);
-			hexchat_printf (ph, "%s\tformat is set to: %s\n", name, word_eol[4]);
+			hexchat_pluginpref_set_str (ph, "format", word_eol[4+offset]);
+			hexchat_printf (ph, "%s\tformat is set to: %s\n", name, word_eol[4+offset]);
 		}
-		else if (!g_ascii_strcasecmp ("percent", word[3]))
+		else if (!g_ascii_strcasecmp ("percent", word[3+offset]))
 		{
-			buffer = atoi (word[4]);	/* don't use word_eol, numbers must not contain spaces */
+			buffer = atoi (word[4+offset]);	/* don't use word_eol, numbers must not contain spaces */
 
 			if (buffer > 0 && buffer < INT_MAX)
 			{
@@ -762,10 +784,25 @@ sysinfo_cb (char *word[], char *word_eol[], void *userdata)
 				hexchat_printf (ph, "%s\tInvalid input!\n", name);
 			}
 		}
-		else if (!g_ascii_strcasecmp ("pciids", word[3]))
+		else if (!g_ascii_strcasecmp ("announce", word[3+offset]))
 		{
-			hexchat_pluginpref_set_str (ph, "pciids", word_eol[4]);
-			hexchat_printf (ph, "%s\tpciids is set to: %s\n", name, word_eol[4]);
+			buffer = atoi (word[4+offset]);	/* don't use word_eol, numbers must not contain spaces */
+
+			if (buffer > 0)
+			{
+				hexchat_pluginpref_set_int (ph, "announce", 1);
+				hexchat_printf (ph, "%s\tannounce is set to: On\n", name);
+			}
+			else
+			{
+				hexchat_pluginpref_set_int (ph, "announce", 0);
+				hexchat_printf (ph, "%s\tannounce is set to: Off\n", name);
+			}
+		}
+		else if (!g_ascii_strcasecmp ("pciids", word[3+offset]))
+		{
+			hexchat_pluginpref_set_str (ph, "pciids", word_eol[4+offset]);
+			hexchat_printf (ph, "%s\tpciids is set to: %s\n", name, word_eol[4+offset]);
 		}
 		else
 		{
@@ -775,58 +812,58 @@ sysinfo_cb (char *word[], char *word_eol[], void *userdata)
 
 		return HEXCHAT_EAT_ALL;
 	}
-	else if (!g_ascii_strcasecmp ("RESET", word[2]))
+	else if (!g_ascii_strcasecmp ("RESET", word[2+offset]))
 	{
 		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]))
+	else if (!g_ascii_strcasecmp ("OS", word[2+offset]))
 	{
 		print_os (announce, format);
 		return HEXCHAT_EAT_ALL;
 	}
-	else if (!g_ascii_strcasecmp ("DISTRO", word[2]))
+	else if (!g_ascii_strcasecmp ("DISTRO", word[2+offset]))
 	{
 		print_distro (announce, format);
 		return HEXCHAT_EAT_ALL;
 	}
-	else if (!g_ascii_strcasecmp ("CPU", word[2]))
+	else if (!g_ascii_strcasecmp ("CPU", word[2+offset]))
 	{
 		print_cpu (announce, format);
 		return HEXCHAT_EAT_ALL;
 	}
-	else if (!g_ascii_strcasecmp ("RAM", word[2]))
+	else if (!g_ascii_strcasecmp ("RAM", word[2+offset]))
 	{
 		print_ram (announce, format);
 		return HEXCHAT_EAT_ALL;
 	}
-	else if (!g_ascii_strcasecmp ("DISK", word[2]))
+	else if (!g_ascii_strcasecmp ("DISK", word[2+offset]))
 	{
 		print_disk (announce, format);
 		return HEXCHAT_EAT_ALL;
 	}
-	else if (!g_ascii_strcasecmp ("VGA", word[2]))
+	else if (!g_ascii_strcasecmp ("VGA", word[2+offset]))
 	{
 		print_vga (announce, format);
 		return HEXCHAT_EAT_ALL;
 	}
-	else if (!g_ascii_strcasecmp ("SOUND", word[2]))
+	else if (!g_ascii_strcasecmp ("SOUND", word[2+offset]))
 	{
 		print_sound (announce, format);
 		return HEXCHAT_EAT_ALL;
 	}
-	else if (!g_ascii_strcasecmp ("ETHERNET", word[2]))
+	else if (!g_ascii_strcasecmp ("ETHERNET", word[2+offset]))
 	{
 		print_ethernet (announce, format);
 		return HEXCHAT_EAT_ALL;
 	}
-	else if (!g_ascii_strcasecmp ("UPTIME", word[2]))
+	else if (!g_ascii_strcasecmp ("UPTIME", word[2+offset]))
 	{
 		print_uptime (announce, format);
 		return HEXCHAT_EAT_ALL;
 	}
-	else if (!g_ascii_strcasecmp ("", word[2]))
+	else if (!g_ascii_strcasecmp ("", word[2+offset]))
 	{
 		print_summary (announce, format);
 		return HEXCHAT_EAT_ALL;
@@ -867,6 +904,11 @@ hexchat_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **p
 		hexchat_pluginpref_set_int (ph, "percent", DEFAULT_PERCENT);
 	}
 
+	if (hexchat_pluginpref_get_int (ph, "announce") == -1)
+	{
+		hexchat_pluginpref_set_int (ph, "announce", DEFAULT_ANNOUNCE);
+	}
+
 	hexchat_command (ph, "MENU ADD \"Window/Send System Info\" \"SYSINFO\"");
 	hexchat_printf (ph, "%s plugin loaded\n", name);
 	return 1;
diff --git a/plugins/upd/upd.c b/plugins/upd/upd.c
index 5d61b4cb..7ebf95bc 100644
--- a/plugins/upd/upd.c
+++ b/plugins/upd/upd.c
@@ -27,8 +27,9 @@
 
 #include "hexchat-plugin.h"
 
-#define DEFAULT_DELAY 10	/* 10 seconds */
+#define DEFAULT_DELAY 30	/* 30 seconds */
 #define DEFAULT_FREQ 360	/* 6 hours */
+#define DOWNLOAD_URL "http://dl.hexchat.net/hexchat"
 
 static hexchat_plugin *ph;   /* plugin handle */
 static char name[] = "Update Checker";
@@ -39,61 +40,6 @@ static const char upd_help[] = "Update Checker Usage:\n  /UPDCHK, check for HexC
 static char*
 check_version ()
 {
-#if 0
-	HINTERNET hINet, hFile;
-	hINet = InternetOpen ("Update Checker", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
-
-	if (!hINet)
-	{
-		return "Unknown";
-	}
-
-	hFile = InternetOpenUrl (hINet,
-							"https://raw.github.com/hexchat/hexchat/master/win32/version.txt",
-							NULL,
-							0,
-							INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_RELOAD,
-							0);
-	if (hFile)
-	{
-		static char buffer[1024];
-		DWORD dwRead;
-		while (InternetReadFile (hFile, buffer, 1023, &dwRead))
-		{
-			if (dwRead == 0)
-			{
-				break;
-			}
-			buffer[dwRead] = 0;
-		}
-
-		InternetCloseHandle (hFile);
-		InternetCloseHandle (hINet);
-		if (strlen (buffer) == 5)
-			return buffer;
-		else
-			return "Unknown";
-	}
-
-	InternetCloseHandle (hINet);
-	return "Unknown";
-#endif
-
-	/* Google Code's messing up with requests, use HTTP/1.0 as suggested. More info:
-
-	   http://code.google.com/p/support/issues/detail?id=6095
-
-	   Of course it would be still too simple, coz IE will override settings, so
-	   you have to disable HTTP/1.1 manually and globally. More info:
-
-	   http://support.microsoft.com/kb/258425
-
-	   So this code's basically useless since disabling HTTP/1.1 will work with the
-	   above code too.
-
-	   Update: a Connection: close header seems to disable chunked encoding.
-	*/
-
 	HINTERNET hOpen, hConnect, hResource;
 
 	hOpen = InternetOpen (TEXT ("Update Checker"),
@@ -137,7 +83,11 @@ check_version ()
 	else
 	{
 		static char buffer[1024];
+		char infobuffer[32];
+		int statuscode;
+
 		DWORD dwRead;
+		DWORD infolen = sizeof(infobuffer);
 
 		HttpAddRequestHeaders (hResource, TEXT ("Connection: close\r\n"), -1L, HTTP_ADDREQ_FLAG_ADD);	/* workaround for GC bug */
 		HttpSendRequest (hResource, NULL, 0, NULL, 0);
@@ -151,10 +101,18 @@ check_version ()
 			buffer[dwRead] = 0;
 		}
 
+		HttpQueryInfo(hResource,
+					HTTP_QUERY_STATUS_CODE,
+					&infobuffer,
+					&infolen,
+					NULL);
+
 		InternetCloseHandle (hResource);
 		InternetCloseHandle (hConnect);
 		InternetCloseHandle (hOpen);
-		if (strlen (buffer) == 5)
+
+		statuscode = atoi(infobuffer);
+		if (statuscode == 200)
 			return buffer;
 		else
 			return "Unknown";
@@ -233,9 +191,9 @@ print_version (char *word[], char *word_eol[], void *userdata)
 		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:\nhttp://dl.hexchat.net/hexchat/HexChat%%20%s%%20x64.exe\n", name, version);
+			hexchat_printf (ph, "%s:\tA HexChat update is available! You can download it from here:\n%s/HexChat%%20%s%%20x64.exe\n", name, DOWNLOAD_URL, version);
 #else
-			hexchat_printf (ph, "%s\tA HexChat update is available! You can download it from here:\nhttp://dl.hexchat.net/hexchat/HexChat%%20%s%%20x86.exe\n", name, version);
+			hexchat_printf (ph, "%s:\tA HexChat update is available! You can download it from here:\n%s/HexChat%%20%s%%20x86.exe\n", name, DOWNLOAD_URL, version);
 #endif
 		}
 		return HEXCHAT_EAT_HEXCHAT;
@@ -256,9 +214,9 @@ print_version_quiet (void *userdata)
 	if (!(strcmp (version, hexchat_get_info (ph, "version")) == 0) && !(strcmp (version, "Unknown") == 0))
 	{
 #ifdef _WIN64 /* use this approach, the wProcessorArchitecture method always returns 0 (=x86) for plugins 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);
+		hexchat_printf (ph, "%s\tA HexChat update is available! You can download it from here:\n%s/HexChat%%20%s%%20x64.exe\n", name, DOWNLOAD_URL, 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);
+		hexchat_printf (ph, "%s\tA HexChat update is available! You can download it from here:\n%s/HexChat%%20%s%%20x86.exe\n", name, DOWNLOAD_URL, version);
 #endif
 		/* print update url once, then stop the timer */
 		return 0;