comparison 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
comparison
equal deleted inserted replaced
14850:2405b9e6f05f 14851:036927fddcba
435 #define Tcl_CreateInterp wtcl_CreateInterp 435 #define Tcl_CreateInterp wtcl_CreateInterp
436 #undef Tk_Init 436 #undef Tk_Init
437 #define Tk_Init wtk_Init 437 #define Tk_Init wtk_Init
438 438
439 static gboolean tcl_win32_init() { 439 static gboolean tcl_win32_init() {
440 gaim_debug(GAIM_DEBUG_INFO, "tcl", 440 const char regkey[] = "SOFTWARE\\ActiveState\\ActiveTcl\\";
441 "Initializing the Tcl runtime. If Gaim doesn't load, it is " 441 char *version = NULL;
442 "most likely because you have cygwin in your PATH and you " 442 gboolean retval = FALSE;
443 "should remove it. See http://gaim.sf.net/win32 for more " 443
444 "information\n"); 444 if ((version = wgaim_read_reg_string(HKEY_LOCAL_MACHINE, regkey, "CurrentVersion"))
445 445 || (version = wgaim_read_reg_string(HKEY_CURRENT_USER, regkey, "CurrentVersion"))) {
446 if(!(wtcl_CreateInterp = (LPFNTCLCREATEINTERP) wgaim_find_and_loadproc("tcl84.dll", "Tcl_CreateInterp"))) { 446 char *path;
447 gaim_debug(GAIM_DEBUG_INFO, "tcl", "tcl_win32_init error loading Tcl_CreateInterp\n"); 447 char *regkey2;
448 return FALSE; 448
449 } 449 regkey2 = g_strdup_printf("%s%s\\", regkey, version);
450 450 if ((path = wgaim_read_reg_string(HKEY_LOCAL_MACHINE, regkey2, NULL)) || (path = wgaim_read_reg_string(HKEY_CURRENT_USER, regkey2, NULL))) {
451 if(!(wtk_Init = (LPFNTKINIT) wgaim_find_and_loadproc("tk84.dll", "Tk_Init"))) { 451 char *tclpath;
452 HMODULE mod; 452 char *tkpath;
453 gaim_debug(GAIM_DEBUG_INFO, "tcl", "tcl_win32_init error loading Tk_Init\n"); 453
454 if((mod = GetModuleHandle("tcl84.dll"))) 454 gaim_debug(GAIM_DEBUG_INFO, "tcl", "Loading ActiveTCL version %s from \"%s\"\n", version, path);
455 FreeLibrary(mod); 455
456 return FALSE; 456 tclpath = g_build_filename(path, "bin", "tcl84.dll", NULL);
457 } 457 tkpath = g_build_filename(path, "bin", "tk84.dll", NULL);
458 458
459 if (GetModuleHandle("cygwin1.dll")) { 459 if(!(wtcl_CreateInterp = (LPFNTCLCREATEINTERP) wgaim_find_and_loadproc(tclpath, "Tcl_CreateInterp"))) {
460 HMODULE mod; 460 gaim_debug(GAIM_DEBUG_INFO, "tcl", "tcl_win32_init error loading Tcl_CreateInterp\n");
461 gaim_debug(GAIM_DEBUG_INFO, "tcl", "Cygwin has been loaded by tcl84.dll and/or tk84.dll. Disabling Tcl support to avoid problems.\n"); 461 } else {
462 if((mod = GetModuleHandle("tcl84.dll"))) 462 if(!(wtk_Init = (LPFNTKINIT) wgaim_find_and_loadproc(tkpath, "Tk_Init"))) {
463 FreeLibrary(mod); 463 HMODULE mod;
464 if((mod = GetModuleHandle("tk84.dll"))) 464 gaim_debug(GAIM_DEBUG_INFO, "tcl", "tcl_win32_init error loading Tk_Init\n");
465 FreeLibrary(mod); 465 if((mod = GetModuleHandle("tcl84.dll")))
466 return FALSE; 466 FreeLibrary(mod);
467 } 467 } else {
468 468 retval = TRUE;
469 return TRUE; 469 }
470 }
471 g_free(tclpath);
472 g_free(tkpath);
473 }
474 g_free(path);
475 g_free(regkey2);
476 }
477
478 g_free(version);
479
480 if (!retval)
481 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"));
482
483 return retval;
470 } 484 }
471 485
472 #endif /* _WIN32 */ 486 #endif /* _WIN32 */
473 487
474 static void tcl_init_plugin(GaimPlugin *plugin) 488 static void tcl_init_plugin(GaimPlugin *plugin)