Mercurial > pidgin.yaz
comparison src/win32/win32dep.c @ 6848:060aa79a733e
[gaim-migrate @ 7393]
Using SHGetFolderPath to determine windows gaim home directory
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Mon, 15 Sep 2003 21:30:37 +0000 |
parents | 5aeba37b303c |
children | 4eee806af511 |
comparison
equal
deleted
inserted
replaced
6847:7de1b559cbbb | 6848:060aa79a733e |
---|---|
58 typedef struct _WGAIM_FLASH_INFO WGAIM_FLASH_INFO; | 58 typedef struct _WGAIM_FLASH_INFO WGAIM_FLASH_INFO; |
59 | 59 |
60 /* | 60 /* |
61 * LOCALS | 61 * LOCALS |
62 */ | 62 */ |
63 static char app_data_dir[MAX_PATH]; | |
63 static char install_dir[MAXPATHLEN]; | 64 static char install_dir[MAXPATHLEN]; |
64 static char lib_dir[MAXPATHLEN]; | 65 static char lib_dir[MAXPATHLEN]; |
65 static char locale_dir[MAXPATHLEN]; | 66 static char locale_dir[MAXPATHLEN]; |
66 static gboolean blink_turned_on = TRUE; | 67 static gboolean blink_turned_on = TRUE; |
67 | 68 |
73 | 74 |
74 /* | 75 /* |
75 * PROTOS | 76 * PROTOS |
76 */ | 77 */ |
77 BOOL (*MyFlashWindowEx)(PFLASHWINFO pfwi)=NULL; | 78 BOOL (*MyFlashWindowEx)(PFLASHWINFO pfwi)=NULL; |
79 HRESULT (*SHGetFolderPath)(HWND, int, HANDLE, DWORD, LPTSTR) = NULL; | |
80 | |
78 FARPROC wgaim_find_and_loadproc(char*, char*); | 81 FARPROC wgaim_find_and_loadproc(char*, char*); |
79 extern void wgaim_gtkspell_init(); | 82 extern void wgaim_gtkspell_init(); |
80 | 83 |
81 /* | 84 /* |
82 * STATIC CODE | 85 * STATIC CODE |
204 | 207 |
205 char* wgaim_locale_dir(void) { | 208 char* wgaim_locale_dir(void) { |
206 strcpy(locale_dir, wgaim_install_dir()); | 209 strcpy(locale_dir, wgaim_install_dir()); |
207 strcat(locale_dir, G_DIR_SEPARATOR_S "locale"); | 210 strcat(locale_dir, G_DIR_SEPARATOR_S "locale"); |
208 return (char*)&locale_dir; | 211 return (char*)&locale_dir; |
212 } | |
213 | |
214 char* wgaim_data_dir(void) { | |
215 return (char*)&app_data_dir; | |
209 } | 216 } |
210 | 217 |
211 /* Miscellaneous */ | 218 /* Miscellaneous */ |
212 | 219 |
213 gboolean wgaim_read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len) { | 220 gboolean wgaim_read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len) { |
409 | 416 |
410 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Locale set to: %s\n", locale); | 417 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Locale set to: %s\n", locale); |
411 } | 418 } |
412 | 419 |
413 /* Windows Initializations */ | 420 /* Windows Initializations */ |
421 typedef enum { | |
422 SHGFP_TYPE_CURRENT = 0, // current value for user, verify it exists | |
423 SHGFP_TYPE_DEFAULT = 1, // default value, may not exist | |
424 } SHGFP_TYPE; | |
425 | |
426 #define CSIDL_APPDATA 0x001a | |
414 | 427 |
415 void wgaim_pre_plugin_init(void) { | 428 void wgaim_pre_plugin_init(void) { |
416 char *perlenv, *newenv; | 429 char *perlenv, *newenv; |
417 | 430 |
418 /* Tell perl where to find Gaim's perl modules */ | 431 /* Tell perl where to find Gaim's perl modules */ |
423 wgaim_install_dir(), | 436 wgaim_install_dir(), |
424 "\\perlmod;"); | 437 "\\perlmod;"); |
425 if(putenv(newenv)<0) | 438 if(putenv(newenv)<0) |
426 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n"); | 439 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n"); |
427 g_free(newenv); | 440 g_free(newenv); |
441 | |
442 /* Set app data dir, where to save Gaim user settings */ | |
443 newenv = (char*)g_getenv("HOME"); | |
444 if(!newenv) { | |
445 SHGetFolderPath = (void*)wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"); | |
446 if(SHGetFolderPath) { | |
447 HRESULT hrResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, app_data_dir); | |
448 if(hrResult != S_FALSE && hrResult != E_FAIL && hrResult != E_INVALIDARG) { | |
449 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "APP DATA PATH set to: %s\n", app_data_dir); | |
450 } | |
451 else | |
452 strcpy(app_data_dir, "C:"); | |
453 } | |
454 | |
455 /* As of 0.69, using SHGetFolderPath to determine app settings directory. | |
456 Move app settings to new location if need be. */ | |
457 { | |
458 char *old_home = g_strdup_printf("%s%s", g_get_home_dir() ? g_get_home_dir() : "C:", "\\.gaim"); | |
459 char *new_home = g_strdup_printf("%s\\.gaim", wgaim_data_dir()); | |
460 GDir *dir_old, *dir_new; | |
461 | |
462 dir_old = g_dir_open(old_home, 0, NULL); | |
463 dir_new = g_dir_open(new_home, 0, NULL); | |
464 if(dir_old && !dir_new) { | |
465 if(MoveFile(old_home, new_home) != 0) | |
466 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Success moving '.gaim' directory\n"); | |
467 } | |
468 g_free(new_home); | |
469 g_free(old_home); | |
470 g_dir_close(dir_old); | |
471 g_dir_close(dir_new); | |
472 } | |
473 } | |
474 else { | |
475 strcpy(app_data_dir, newenv); | |
476 } | |
428 } | 477 } |
429 | 478 |
430 void wgaim_init(void) { | 479 void wgaim_init(void) { |
431 WORD wVersionRequested; | 480 WORD wVersionRequested; |
432 WSADATA wsaData; | 481 WSADATA wsaData; |