diff libgaim/plugins/log_reader.c @ 14272:7635195195c0

[gaim-migrate @ 16957] -Updated the win32dep debug function to correctly match the core function (the core was apparently changed a while ago and this was never updated). -Updated wgaim_read_reg_string() to deal with non-ascii strings correctly, created corresponding wgaim_write_reg_string(). Use these in various places. -Update some win32dep arguments and return values to be correctly marked as having constant values. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 21 Aug 2006 20:58:20 +0000
parents a54ff7cafc2a
children 5025e146a876
line wrap: on
line diff
--- a/libgaim/plugins/log_reader.c	Mon Aug 21 17:13:16 2006 +0000
+++ b/libgaim/plugins/log_reader.c	Mon Aug 21 20:58:20 2006 +0000
@@ -1577,6 +1577,7 @@
 	char *path;
 #ifdef _WIN32
 	char *folder;
+	gboolean found = FALSE;
 #endif
 
 	g_return_if_fail(plugin != NULL);
@@ -1685,45 +1686,31 @@
 	/* XXX: While a major hack, this is the most reliable way I could
 	 * think of to determine the Trillian installation directory.
 	 */
-	HKEY hKey;
-	char buffer[1024] = "";
-	DWORD size = (sizeof(buffer) - 1);
-	DWORD type;
-	gboolean found = FALSE;
 
 	path = NULL;
-	/* TODO: Test this after removing the trailing "\\". */
-	if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\",
-				0, KEY_QUERY_VALUE, &hKey)) {
-
-		if(ERROR_SUCCESS == RegQueryValueEx(hKey, "", NULL, &type, (LPBYTE)buffer, &size)) {
-			char *value = buffer;
-			char *temp;
-
-			/* Ensure the data is null terminated. */
-			value[size] = '\0';
+	if ((folder = wgaim_read_reg_string(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", NULL))) {
+		char *value = folder;
+		char *temp;
 
-			/* Break apart buffer. */
-			if (*value == '"') {
-				value++;
-				temp = value;
-				while (*temp && *temp != '"')
-					temp++;
-			} else {
-				temp = value;
-				while (*temp && *temp != ' ')
-					temp++;
-			}
-			*temp = '\0';
+		/* Break apart buffer. */
+		if (*value == '"') {
+			value++;
+			temp = value;
+			while (*temp && *temp != '"')
+				temp++;
+		} else {
+			temp = value;
+			while (*temp && *temp != ' ')
+				temp++;
+		}
+		*temp = '\0';
 
-			/* Set path. */
-			if (gaim_str_has_suffix(value, "trillian.exe"))
-			{
-				value[strlen(value) - (sizeof("trillian.exe") - 1)] = '\0';
-				path = g_build_filename(value, "users", "default", "talk.ini", NULL);
-			}
+		/* Set path. */
+		if (gaim_str_has_suffix(value, "trillian.exe")) {
+			value[strlen(value) - (sizeof("trillian.exe") - 1)] = '\0';
+			path = g_build_filename(value, "users", "default", "talk.ini", NULL);
 		}
-		RegCloseKey(hKey);
+		g_free(folder);
 	}
 
 	if (!path) {