# HG changeset patch # User Daniel Atallah # Date 1127268308 0 # Node ID 71945305a87e3838986b38bd671fffd7b6b73d48 # Parent c3bbfca00e85c45a6c80e54106cdcb421196d62d [gaim-migrate @ 13825] Some stuff to make Wingaim run nicely from a USB Drive committer: Tailor Script diff -r c3bbfca00e85 -r 71945305a87e src/Makefile.mingw --- a/src/Makefile.mingw Tue Sep 20 23:48:20 2005 +0000 +++ b/src/Makefile.mingw Wed Sep 21 02:05:08 2005 +0000 @@ -31,6 +31,10 @@ DEFINES = -D_WIN32_WINNT=0x0501 +ifeq ($(MAKECMDGOALS), $(TARGET)-portable.exe) +DEFINES := $(DEFINES) -DPORTABLE +endif + LDFLAGS = -mwindows #-mconsole @@ -231,6 +235,10 @@ $(TARGET).exe: $(TARGET).dll $(EXE_OBJECTS) $(CC) $(LDFLAGS) $(EXE_OBJECTS) $(LIB_PATHS) $(EXE_LIBS) -o $(TARGET).exe +$(TARGET)-portable.exe: clean_exe $(EXE_OBJECTS) + $(CC) $(LDFLAGS) $(EXE_OBJECTS) $(LIB_PATHS) $(EXE_LIBS) -o $(TARGET)-portable.exe + rm win_gaim.o + ## ## CLEAN RULES ## @@ -241,3 +249,6 @@ rm -rf $(TARGET).dll rm -rf $(TARGET).lib rm -rf $(TARGET).exe + +clean_exe: + rm -rf win_gaim.o diff -r c3bbfca00e85 -r 71945305a87e src/win32/wspell.c --- a/src/win32/wspell.c Tue Sep 20 23:48:20 2005 +0000 +++ b/src/win32/wspell.c Wed Sep 21 02:05:08 2005 +0000 @@ -67,11 +67,16 @@ static char* lookup_aspell_path() { char *path = NULL; + const char *tmp; HKEY reg_key; DWORD type; DWORD nbytes; gboolean found_reg_key; LPCTSTR subkey = NULL; + + if ((tmp = g_getenv("GAIM_ASPELL_DIR"))) + return g_strdup(tmp); + if (G_WIN32_HAVE_WIDECHAR_API ()) { if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Aspell", 0, KEY_QUERY_VALUE, diff -r c3bbfca00e85 -r 71945305a87e src/win_gaim.c --- a/src/win_gaim.c Tue Sep 20 23:48:20 2005 +0000 +++ b/src/win_gaim.c Wed Sep 21 02:05:08 2005 +0000 @@ -82,11 +82,53 @@ } static void dll_prep() { + char path[MAX_PATH + 1]; + HMODULE hmod; + HKEY hkey; +#ifdef PORTABLE + /* We assume that GTK+ is installed under \\path\to\Gaim\..\GTK + * First we find \\path\to + */ + if (GetModuleFileName(NULL, path, MAX_PATH) != 0) { + char *tmp = path; + char *prev = NULL; + char *prev2 = NULL; + + while ((tmp = strchr(tmp, '\\'))) { + prev2 = prev; + prev = tmp; + tmp++; + } + + if (prev2) { + prev2[0] = '\0'; + } + } else { + printf("Unable to determine current executable path. \n" + "This will prevent the settings dir from being set.\n" + "Assuming GTK+ is in the PATH.\n"); + } + + if (path) { + /* Set up the settings dir base to be \\path\to + * The actual settings dir will be \\path\to\.gaim */ + char settingsdir[strlen(path) + strlen("GAIMHOME=") + 1]; + char aspelldir[strlen(path) + strlen("GAIM_ASPELL_DIR=\\Aspell\\bin") + 1]; + + snprintf(settingsdir, sizeof(settingsdir), "GAIMHOME=%s", path); + printf("Setting settings dir: %s\n", settingsdir); + putenv(settingsdir); + + snprintf(aspelldir, sizeof(aspelldir), "GAIM_ASPELL_DIR=%s\\Aspell\\bin", path); + printf(aspelldir); + + /* set the GTK+ path to be \\path\to\GTK\bin */ + strcat(path, "\\GTK\\bin"); + } else + return; +#else /* PORTABLE */ char gtkpath[MAX_PATH + 1]; - char path[MAX_PATH + 1]; DWORD plen; - HKEY hkey; - HMODULE hmod; plen = sizeof(gtkpath); hkey = HKEY_CURRENT_USER; @@ -109,7 +151,7 @@ strcpy(path, gtkpath); strcat(path, "\\bin"); } - +#endif printf("GTK+ path found: %s\n", path); if ((hmod = GetModuleHandle("kernel32.dll"))) { @@ -236,19 +278,23 @@ */ static const char *wgaim_get_locale() { const char *locale = NULL; + LCID lcid; +#ifndef PORTABLE char data[10]; DWORD datalen = 10; - LCID lcid; +#endif /* Check if user set GAIMLANG env var */ if ((locale = getenv("GAIMLANG"))) return locale; +#ifndef PORTABLE if (read_reg_string(HKEY_CURRENT_USER, "SOFTWARE\\gaim", "Installer Language", (LPBYTE) &data, &datalen)) { if ((locale = wgaim_lcid_to_posix(atoi(data)))) return locale; } +#endif lcid = GetUserDefaultLCID(); if ((locale = wgaim_lcid_to_posix(lcid))) @@ -374,7 +420,9 @@ MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); } +#ifndef PORTABLE if (!getenv("GAIM_NO_DLL_CHECK")) +#endif dll_prep(); wgaim_set_locale();