comparison src/win_gaim.c @ 11561:71945305a87e

[gaim-migrate @ 13825] Some stuff to make Wingaim run nicely from a USB Drive committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 21 Sep 2005 02:05:08 +0000
parents 4da9e0d4e8d2
children f1e07c3332d9
comparison
equal deleted inserted replaced
11560:c3bbfca00e85 11561:71945305a87e
80 80
81 return ret; 81 return ret;
82 } 82 }
83 83
84 static void dll_prep() { 84 static void dll_prep() {
85 char path[MAX_PATH + 1];
86 HMODULE hmod;
87 HKEY hkey;
88 #ifdef PORTABLE
89 /* We assume that GTK+ is installed under \\path\to\Gaim\..\GTK
90 * First we find \\path\to
91 */
92 if (GetModuleFileName(NULL, path, MAX_PATH) != 0) {
93 char *tmp = path;
94 char *prev = NULL;
95 char *prev2 = NULL;
96
97 while ((tmp = strchr(tmp, '\\'))) {
98 prev2 = prev;
99 prev = tmp;
100 tmp++;
101 }
102
103 if (prev2) {
104 prev2[0] = '\0';
105 }
106 } else {
107 printf("Unable to determine current executable path. \n"
108 "This will prevent the settings dir from being set.\n"
109 "Assuming GTK+ is in the PATH.\n");
110 }
111
112 if (path) {
113 /* Set up the settings dir base to be \\path\to
114 * The actual settings dir will be \\path\to\.gaim */
115 char settingsdir[strlen(path) + strlen("GAIMHOME=") + 1];
116 char aspelldir[strlen(path) + strlen("GAIM_ASPELL_DIR=\\Aspell\\bin") + 1];
117
118 snprintf(settingsdir, sizeof(settingsdir), "GAIMHOME=%s", path);
119 printf("Setting settings dir: %s\n", settingsdir);
120 putenv(settingsdir);
121
122 snprintf(aspelldir, sizeof(aspelldir), "GAIM_ASPELL_DIR=%s\\Aspell\\bin", path);
123 printf(aspelldir);
124
125 /* set the GTK+ path to be \\path\to\GTK\bin */
126 strcat(path, "\\GTK\\bin");
127 } else
128 return;
129 #else /* PORTABLE */
85 char gtkpath[MAX_PATH + 1]; 130 char gtkpath[MAX_PATH + 1];
86 char path[MAX_PATH + 1];
87 DWORD plen; 131 DWORD plen;
88 HKEY hkey;
89 HMODULE hmod;
90 132
91 plen = sizeof(gtkpath); 133 plen = sizeof(gtkpath);
92 hkey = HKEY_CURRENT_USER; 134 hkey = HKEY_CURRENT_USER;
93 if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path", 135 if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path",
94 (LPBYTE) &gtkpath, &plen)) { 136 (LPBYTE) &gtkpath, &plen)) {
107 if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "DllPath", 149 if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "DllPath",
108 (LPBYTE) &path, &plen)) { 150 (LPBYTE) &path, &plen)) {
109 strcpy(path, gtkpath); 151 strcpy(path, gtkpath);
110 strcat(path, "\\bin"); 152 strcat(path, "\\bin");
111 } 153 }
112 154 #endif
113 printf("GTK+ path found: %s\n", path); 155 printf("GTK+ path found: %s\n", path);
114 156
115 if ((hmod = GetModuleHandle("kernel32.dll"))) { 157 if ((hmod = GetModuleHandle("kernel32.dll"))) {
116 MySetDllDirectory = (LPFNSETDLLDIRECTORY) GetProcAddress( 158 MySetDllDirectory = (LPFNSETDLLDIRECTORY) GetProcAddress(
117 hmod, "SetDllDirectoryA"); 159 hmod, "SetDllDirectoryA");
234 - Check NSIS Installer Language reg value 276 - Check NSIS Installer Language reg value
235 - Use default user locale 277 - Use default user locale
236 */ 278 */
237 static const char *wgaim_get_locale() { 279 static const char *wgaim_get_locale() {
238 const char *locale = NULL; 280 const char *locale = NULL;
281 LCID lcid;
282 #ifndef PORTABLE
239 char data[10]; 283 char data[10];
240 DWORD datalen = 10; 284 DWORD datalen = 10;
241 LCID lcid; 285 #endif
242 286
243 /* Check if user set GAIMLANG env var */ 287 /* Check if user set GAIMLANG env var */
244 if ((locale = getenv("GAIMLANG"))) 288 if ((locale = getenv("GAIMLANG")))
245 return locale; 289 return locale;
246 290
291 #ifndef PORTABLE
247 if (read_reg_string(HKEY_CURRENT_USER, "SOFTWARE\\gaim", 292 if (read_reg_string(HKEY_CURRENT_USER, "SOFTWARE\\gaim",
248 "Installer Language", (LPBYTE) &data, &datalen)) { 293 "Installer Language", (LPBYTE) &data, &datalen)) {
249 if ((locale = wgaim_lcid_to_posix(atoi(data)))) 294 if ((locale = wgaim_lcid_to_posix(atoi(data))))
250 return locale; 295 return locale;
251 } 296 }
297 #endif
252 298
253 lcid = GetUserDefaultLCID(); 299 lcid = GetUserDefaultLCID();
254 if ((locale = wgaim_lcid_to_posix(lcid))) 300 if ((locale = wgaim_lcid_to_posix(lcid)))
255 return locale; 301 return locale;
256 302
372 "Error getting module filename. Error: %u", 418 "Error getting module filename. Error: %u",
373 (UINT) GetLastError()); 419 (UINT) GetLastError());
374 MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); 420 MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST);
375 } 421 }
376 422
423 #ifndef PORTABLE
377 if (!getenv("GAIM_NO_DLL_CHECK")) 424 if (!getenv("GAIM_NO_DLL_CHECK"))
425 #endif
378 dll_prep(); 426 dll_prep();
379 427
380 wgaim_set_locale(); 428 wgaim_set_locale();
381 /* If help or version flag used, do not check Mutex */ 429 /* If help or version flag used, do not check Mutex */
382 if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v")) 430 if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v"))