diff libgaim/plugins/tcl/tcl.c @ 14851:036927fddcba

[gaim-migrate @ 17620] A couple patches from Lee Roach. -Delete the Perl loader link library when making clean. -Force the Tcl loader plugin to use the ActiveTcl installation. This will prevent 99.99% of the cygwin "hang on start" issues, at the cost of having the Tcl loader not work for some people - if you're one of the 5 or so people using the Tcl loader on win32, you can figure out how to fix it - maybe we'll add a faq entry. This should cut down on the frequent bug reports of gaim failing to start. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Sun, 29 Oct 2006 23:28:37 +0000
parents 60b1bc8dbf37
children
line wrap: on
line diff
--- a/libgaim/plugins/tcl/tcl.c	Sun Oct 29 15:59:05 2006 +0000
+++ b/libgaim/plugins/tcl/tcl.c	Sun Oct 29 23:28:37 2006 +0000
@@ -437,36 +437,50 @@
 #define Tk_Init wtk_Init
 
 static gboolean tcl_win32_init() {
-	gaim_debug(GAIM_DEBUG_INFO, "tcl",
-		"Initializing the Tcl runtime.  If Gaim doesn't load, it is "
-		"most likely because you have cygwin in your PATH and you "
-		"should remove it. See http://gaim.sf.net/win32 for more "
-		"information\n");
+	const char regkey[] = "SOFTWARE\\ActiveState\\ActiveTcl\\";
+	char *version = NULL;
+	gboolean retval = FALSE;
+
+	if ((version = wgaim_read_reg_string(HKEY_LOCAL_MACHINE, regkey, "CurrentVersion"))
+			|| (version = wgaim_read_reg_string(HKEY_CURRENT_USER, regkey, "CurrentVersion"))) {
+		char *path;
+		char *regkey2;
+
+		regkey2 = g_strdup_printf("%s%s\\", regkey, version);
+		if ((path = wgaim_read_reg_string(HKEY_LOCAL_MACHINE, regkey2, NULL)) || (path = wgaim_read_reg_string(HKEY_CURRENT_USER, regkey2, NULL))) {
+			char *tclpath;
+			char *tkpath;
+
+			gaim_debug(GAIM_DEBUG_INFO, "tcl", "Loading ActiveTCL version %s from \"%s\"\n", version, path);
 
-	if(!(wtcl_CreateInterp = (LPFNTCLCREATEINTERP) wgaim_find_and_loadproc("tcl84.dll", "Tcl_CreateInterp"))) {
-		gaim_debug(GAIM_DEBUG_INFO, "tcl", "tcl_win32_init error loading Tcl_CreateInterp\n");
-		return FALSE;
+			tclpath = g_build_filename(path, "bin", "tcl84.dll", NULL);
+			tkpath = g_build_filename(path, "bin", "tk84.dll", NULL);
+
+			if(!(wtcl_CreateInterp = (LPFNTCLCREATEINTERP) wgaim_find_and_loadproc(tclpath, "Tcl_CreateInterp"))) {
+				gaim_debug(GAIM_DEBUG_INFO, "tcl", "tcl_win32_init error loading Tcl_CreateInterp\n");
+			} else {
+				if(!(wtk_Init = (LPFNTKINIT) wgaim_find_and_loadproc(tkpath, "Tk_Init"))) {
+					HMODULE mod;
+					gaim_debug(GAIM_DEBUG_INFO, "tcl", "tcl_win32_init error loading Tk_Init\n");
+					if((mod = GetModuleHandle("tcl84.dll")))
+						FreeLibrary(mod);
+				} else {
+					retval = TRUE;
+				}
+			}
+			g_free(tclpath);
+			g_free(tkpath);
+		}
+		g_free(path);
+		g_free(regkey2);
 	}
 
-	if(!(wtk_Init = (LPFNTKINIT) wgaim_find_and_loadproc("tk84.dll", "Tk_Init"))) {
-		HMODULE mod;
-		gaim_debug(GAIM_DEBUG_INFO, "tcl", "tcl_win32_init error loading Tk_Init\n");
-		if((mod = GetModuleHandle("tcl84.dll")))
-			FreeLibrary(mod);
-		return FALSE;
-	}
+	g_free(version);
 
-	if (GetModuleHandle("cygwin1.dll")) {
-		HMODULE mod;
-		gaim_debug(GAIM_DEBUG_INFO, "tcl", "Cygwin has been loaded by tcl84.dll and/or tk84.dll. Disabling Tcl support to avoid problems.\n");
-		if((mod = GetModuleHandle("tcl84.dll")))
-			FreeLibrary(mod);
-		if((mod = GetModuleHandle("tk84.dll")))
-			FreeLibrary(mod);
-		return FALSE;
-	}
+	if (!retval)
+		gaim_debug(GAIM_DEBUG_INFO, "tcl", _("Unable to detect ActiveTCL installation. If you wish to use TCL plugins, install ActiveTCL from http://www.activestate.com\n"));
 
-	return TRUE;
+	return retval;
 }
 
 #endif /* _WIN32 */