| 54 */ |
55 */ |
| 55 |
56 |
| 56 /* For shfolder.dll */ |
57 /* For shfolder.dll */ |
| 57 typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHA)(HWND, int, HANDLE, DWORD, LPSTR); |
58 typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHA)(HWND, int, HANDLE, DWORD, LPSTR); |
| 58 typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHW)(HWND, int, HANDLE, DWORD, LPWSTR); |
59 typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHW)(HWND, int, HANDLE, DWORD, LPWSTR); |
| 59 |
|
| 60 typedef enum { |
|
| 61 SHGFP_TYPE_CURRENT = 0, /* current value for user, verify it exists */ |
|
| 62 SHGFP_TYPE_DEFAULT = 1, /* default value, may not exist */ |
|
| 63 } SHGFP_TYPE; |
|
| 64 |
60 |
| 65 /* |
61 /* |
| 66 * LOCALS |
62 * LOCALS |
| 67 */ |
63 */ |
| 68 static char *app_data_dir, *install_dir, *lib_dir, *locale_dir; |
64 static char *app_data_dir, *install_dir, *lib_dir, *locale_dir; |
| 135 return ret; |
131 return ret; |
| 136 } |
132 } |
| 137 |
133 |
| 138 /* Determine whether the specified dll contains the specified procedure. |
134 /* Determine whether the specified dll contains the specified procedure. |
| 139 If so, load it (if not already loaded). */ |
135 If so, load it (if not already loaded). */ |
| 140 FARPROC wgaim_find_and_loadproc( char* dllname, char* procedure ) { |
136 FARPROC wgaim_find_and_loadproc(char* dllname, char* procedure) { |
| 141 HMODULE hmod; |
137 HMODULE hmod; |
| 142 int did_load=0; |
138 BOOL did_load = FALSE; |
| 143 FARPROC proc = 0; |
139 FARPROC proc = 0; |
| 144 |
140 |
| 145 if(!(hmod=GetModuleHandle(dllname))) { |
141 if(!(hmod = GetModuleHandle(dllname))) { |
| 146 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "%s not found. Loading it..\n", dllname); |
142 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "%s not found. Loading it..\n", dllname); |
| 147 if(!(hmod = LoadLibrary(dllname))) { |
143 if(!(hmod = LoadLibrary(dllname))) { |
| 148 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Could not load: %s\n", dllname); |
144 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Could not load: %s\n", dllname); |
| 149 return NULL; |
145 return NULL; |
| 150 } |
146 } |
| 151 else |
147 else |
| 152 did_load = 1; |
148 did_load = TRUE; |
| 153 } |
149 } |
| 154 |
150 |
| 155 if((proc=GetProcAddress(hmod, procedure))) { |
151 if((proc = GetProcAddress(hmod, procedure))) { |
| 156 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "This version of %s contains %s\n", |
152 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "This version of %s contains %s\n", |
| 157 dllname, procedure); |
153 dllname, procedure); |
| 158 return proc; |
154 return proc; |
| 159 } |
155 } |
| 160 else { |
156 else { |
| 161 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Function %s not found in dll %s\n", |
157 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Function %s not found in dll %s\n", |
| 162 procedure, dllname); |
158 procedure, dllname); |
| 163 if(did_load) { |
159 if(did_load) { |
| 164 /* unload dll */ |
160 /* unload dll */ |
| 165 FreeLibrary(hmod); |
161 FreeLibrary(hmod); |
| 166 } |
162 } |
| 167 return NULL; |
163 return NULL; |
| 282 |
278 |
| 283 return locale_dir; |
279 return locale_dir; |
| 284 } |
280 } |
| 285 |
281 |
| 286 char* wgaim_data_dir(void) { |
282 char* wgaim_data_dir(void) { |
| 287 return app_data_dir; |
283 return app_data_dir; |
| 288 } |
284 } |
| 289 |
285 |
| 290 /* Miscellaneous */ |
286 /* Miscellaneous */ |
| 291 |
287 |
| 292 gboolean wgaim_read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len) { |
288 gboolean wgaim_read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len) { |
| 293 HKEY hkey; |
289 HKEY hkey; |
| 294 gboolean ret = FALSE; |
290 gboolean ret = FALSE; |
| 295 |
291 |
| 296 if(ERROR_SUCCESS == RegOpenKeyEx(key, |
292 if(ERROR_SUCCESS == RegOpenKeyEx(key, sub_key, 0, KEY_QUERY_VALUE, |
| 297 sub_key, |
293 &hkey)) { |
| 298 0, KEY_QUERY_VALUE, &hkey)) { |
294 if(ERROR_SUCCESS == RegQueryValueEx(hkey, val_name, 0, NULL, |
| 299 if(ERROR_SUCCESS == RegQueryValueEx(hkey, val_name, 0, NULL, data, data_len)) |
295 data, data_len)) |
| 300 ret = TRUE; |
296 ret = TRUE; |
| 301 RegCloseKey(key); |
297 RegCloseKey(key); |
| 302 } |
298 } |
| 303 return ret; |
299 return ret; |
| 304 } |
300 } |
| 305 |
301 |
| 306 int wgaim_gz_decompress(const char* in, const char* out) { |
302 int wgaim_gz_decompress(const char* in, const char* out) { |
| 307 gzFile fin; |
303 gzFile fin; |
| 308 FILE *fout; |
304 FILE *fout; |
| 364 |
360 |
| 365 void wgaim_notify_uri(const char *uri) { |
361 void wgaim_notify_uri(const char *uri) { |
| 366 SHELLEXECUTEINFO sinfo; |
362 SHELLEXECUTEINFO sinfo; |
| 367 |
363 |
| 368 memset(&sinfo, 0, sizeof(sinfo)); |
364 memset(&sinfo, 0, sizeof(sinfo)); |
| 369 sinfo.cbSize = sizeof(sinfo); |
365 sinfo.cbSize = sizeof(sinfo); |
| 370 sinfo.fMask = SEE_MASK_CLASSNAME; |
366 sinfo.fMask = SEE_MASK_CLASSNAME; |
| 371 sinfo.lpVerb = "open"; |
367 sinfo.lpVerb = "open"; |
| 372 sinfo.lpFile = uri; |
368 sinfo.lpFile = uri; |
| 373 sinfo.nShow = SW_SHOWNORMAL; |
369 sinfo.nShow = SW_SHOWNORMAL; |
| 374 sinfo.lpClass = "http"; |
370 sinfo.lpClass = "http"; |
| 375 |
371 |
| 376 /* We'll allow whatever URI schemes are supported by the |
372 /* We'll allow whatever URI schemes are supported by the |
| 377 default http browser. |
373 default http browser. |
| 378 */ |
374 */ |
| 379 if(!ShellExecuteEx(&sinfo)) |
375 if(!ShellExecuteEx(&sinfo)) |
| 380 gaim_debug_error("wgaim", "Error opening URI: %s error: %d\n", uri, (int)sinfo.hInstApp); |
376 gaim_debug_error("wgaim", "Error opening URI: %s error: %d\n", |
| |
377 uri, (int) sinfo.hInstApp); |
| 381 } |
378 } |
| 382 |
379 |
| 383 void wgaim_init(HINSTANCE hint) { |
380 void wgaim_init(HINSTANCE hint) { |
| 384 WORD wVersionRequested; |
381 WORD wVersionRequested; |
| 385 WSADATA wsaData; |
382 WSADATA wsaData; |
| 386 char *perlenv; |
383 const char *perlenv; |
| 387 char *newenv; |
384 char *newenv; |
| 388 |
385 |
| 389 gaim_debug_set_ui_ops(&ops); |
386 gaim_debug_set_ui_ops(&ops); |
| 390 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init start\n"); |
387 gaim_debug_info("wgaim", "wgaim_init start\n"); |
| |
388 |
| |
389 gaim_debug_info("wgaim", "Glib:%u.%u.%u\n", |
| |
390 glib_major_version, glib_minor_version, glib_micro_version); |
| 391 |
391 |
| 392 gaimexe_hInstance = hint; |
392 gaimexe_hInstance = hint; |
| 393 |
393 |
| 394 /* Winsock init */ |
394 /* Winsock init */ |
| 395 wVersionRequested = MAKEWORD( 2, 2 ); |
395 wVersionRequested = MAKEWORD(2, 2); |
| 396 WSAStartup( wVersionRequested, &wsaData ); |
396 WSAStartup(wVersionRequested, &wsaData); |
| 397 |
397 |
| 398 /* Confirm that the winsock DLL supports 2.2 */ |
398 /* Confirm that the winsock DLL supports 2.2 */ |
| 399 /* Note that if the DLL supports versions greater than |
399 /* Note that if the DLL supports versions greater than |
| 400 2.2 in addition to 2.2, it will still return 2.2 in |
400 2.2 in addition to 2.2, it will still return 2.2 in |
| 401 wVersion since that is the version we requested. */ |
401 wVersion since that is the version we requested. */ |
| 402 if ( LOBYTE( wsaData.wVersion ) != 2 || |
402 if(LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) { |
| 403 HIBYTE( wsaData.wVersion ) != 2 ) { |
|
| 404 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Could not find a usable WinSock DLL. Oh well.\n"); |
403 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Could not find a usable WinSock DLL. Oh well.\n"); |
| 405 WSACleanup(); |
404 WSACleanup(); |
| 406 } |
405 } |
| 407 |
406 |
| 408 /* Set Environmental Variables */ |
407 /* Set Environmental Variables */ |
| 409 /* Tell perl where to find Gaim's perl modules */ |
408 /* Tell perl where to find Gaim's perl modules */ |
| 410 perlenv = (char*) g_getenv("PERL5LIB"); |
409 perlenv = g_getenv("PERL5LIB"); |
| 411 newenv = g_strdup_printf("PERL5LIB=%s%s%s%s", |
410 newenv = g_strdup_printf("PERL5LIB=%s%s%s%s", |
| 412 perlenv ? perlenv : "", |
411 perlenv ? perlenv : "", |
| 413 perlenv ? ";" : "", |
412 perlenv ? ";" : "", |
| 414 wgaim_install_dir(), |
413 wgaim_install_dir(), |
| 415 "\\perlmod;"); |
414 "\\perlmod;"); |
| 416 if (putenv(newenv) < 0) |
415 if (putenv(newenv) < 0) |
| 417 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n"); |
416 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n"); |
| 418 g_free(newenv); |
417 g_free(newenv); |
| 419 |
418 |
| 420 /* Set app data dir, used by gaim_home_dir */ |
419 /* Set app data dir, used by gaim_home_dir */ |
| 421 newenv = (char*) g_getenv("GAIMHOME"); |
420 newenv = (char*) g_getenv("GAIMHOME"); |
| 422 if (newenv) { |
421 if (newenv) { |
| 423 app_data_dir = g_strdup(newenv); |
422 app_data_dir = g_strdup(newenv); |
| 424 } else { |
423 } else { |
| 425 app_data_dir = wgaim_get_special_folder(CSIDL_APPDATA); |
424 app_data_dir = wgaim_get_special_folder(CSIDL_APPDATA); |
| 426 if (!app_data_dir) { |
425 if (!app_data_dir) { |
| 427 app_data_dir = g_strdup("C:"); |
426 app_data_dir = g_strdup("C:"); |
| 428 } |
427 } |
| 429 } |
428 } |
| 430 |
429 |
| 431 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Gaim settings dir: %s\n", app_data_dir); |
430 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Gaim settings dir: %s\n", app_data_dir); |
| 432 |
431 |
| 433 /* IdleTracker Initialization */ |
432 /* IdleTracker Initialization */ |
| 434 if(!wgaim_set_idlehooks()) |
433 if(!wgaim_set_idlehooks()) |
| 435 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Failed to initialize idle tracker\n"); |
434 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Failed to initialize idle tracker\n"); |
| 436 |
435 |
| 437 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init end\n"); |
436 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init end\n"); |
| 438 } |
437 } |
| 439 |
438 |
| 440 /* Windows Cleanup */ |
439 /* Windows Cleanup */ |