Mercurial > pidgin
changeset 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 | 7de1b559cbbb |
children | 3c885e6784ee |
files | gaim-installer.nsi src/util.c src/win32/win32dep.c src/win32/win32dep.h |
diffstat | 4 files changed, 60 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/gaim-installer.nsi Mon Sep 15 13:29:22 2003 +0000 +++ b/gaim-installer.nsi Mon Sep 15 21:30:37 2003 +0000 @@ -348,6 +348,14 @@ File ..\win32-dev\drmingw\exchndl.dll !endif + ; Install shfolder.dll if need be.. + SearchPath $R4 "shfolder.dll" + StrCmp $R4 "" 0 got_shfolder + SetOutPath "$SYSDIR" + File ..\win32-dev\ms-deps\shfolder.dll + SetOutPath "$INSTDIR" + got_shfolder: + ; Check if Perl is installed, If not remove perl plugin ReadRegStr $R2 HKLM ${PERL_REG_KEY} "" StrCmp $R2 "" 0 perl_exists
--- a/src/util.c Mon Sep 15 13:29:22 2003 +0000 +++ b/src/util.c Mon Sep 15 21:30:37 2003 +0000 @@ -641,16 +641,14 @@ const gchar *gaim_home_dir() { +#ifndef _WIN32 if(g_get_home_dir()) return g_get_home_dir(); else -#ifndef _WIN32 return NULL; #else - /* Win9x and WinME don't have a home dir */ - return "C:"; + return wgaim_data_dir(); #endif - } /* returns a string of the form ~/.gaim, where ~ is replaced by the user's home
--- a/src/win32/win32dep.c Mon Sep 15 13:29:22 2003 +0000 +++ b/src/win32/win32dep.c Mon Sep 15 21:30:37 2003 +0000 @@ -60,6 +60,7 @@ /* * LOCALS */ +static char app_data_dir[MAX_PATH]; static char install_dir[MAXPATHLEN]; static char lib_dir[MAXPATHLEN]; static char locale_dir[MAXPATHLEN]; @@ -75,6 +76,8 @@ * PROTOS */ BOOL (*MyFlashWindowEx)(PFLASHWINFO pfwi)=NULL; +HRESULT (*SHGetFolderPath)(HWND, int, HANDLE, DWORD, LPTSTR) = NULL; + FARPROC wgaim_find_and_loadproc(char*, char*); extern void wgaim_gtkspell_init(); @@ -208,6 +211,10 @@ return (char*)&locale_dir; } +char* wgaim_data_dir(void) { + return (char*)&app_data_dir; +} + /* Miscellaneous */ gboolean wgaim_read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len) { @@ -411,6 +418,12 @@ } /* Windows Initializations */ +typedef enum { + SHGFP_TYPE_CURRENT = 0, // current value for user, verify it exists + SHGFP_TYPE_DEFAULT = 1, // default value, may not exist +} SHGFP_TYPE; + +#define CSIDL_APPDATA 0x001a void wgaim_pre_plugin_init(void) { char *perlenv, *newenv; @@ -425,6 +438,42 @@ if(putenv(newenv)<0) gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n"); g_free(newenv); + + /* Set app data dir, where to save Gaim user settings */ + newenv = (char*)g_getenv("HOME"); + if(!newenv) { + SHGetFolderPath = (void*)wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"); + if(SHGetFolderPath) { + HRESULT hrResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, app_data_dir); + if(hrResult != S_FALSE && hrResult != E_FAIL && hrResult != E_INVALIDARG) { + gaim_debug(GAIM_DEBUG_INFO, "wgaim", "APP DATA PATH set to: %s\n", app_data_dir); + } + else + strcpy(app_data_dir, "C:"); + } + + /* As of 0.69, using SHGetFolderPath to determine app settings directory. + Move app settings to new location if need be. */ + { + char *old_home = g_strdup_printf("%s%s", g_get_home_dir() ? g_get_home_dir() : "C:", "\\.gaim"); + char *new_home = g_strdup_printf("%s\\.gaim", wgaim_data_dir()); + GDir *dir_old, *dir_new; + + dir_old = g_dir_open(old_home, 0, NULL); + dir_new = g_dir_open(new_home, 0, NULL); + if(dir_old && !dir_new) { + if(MoveFile(old_home, new_home) != 0) + gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Success moving '.gaim' directory\n"); + } + g_free(new_home); + g_free(old_home); + g_dir_close(dir_old); + g_dir_close(dir_new); + } + } + else { + strcpy(app_data_dir, newenv); + } } void wgaim_init(void) {
--- a/src/win32/win32dep.h Mon Sep 15 13:29:22 2003 +0000 +++ b/src/win32/win32dep.h Mon Sep 15 21:30:37 2003 +0000 @@ -44,6 +44,7 @@ extern char* wgaim_install_dir(void); extern char* wgaim_lib_dir(void); extern char* wgaim_locale_dir(void); +extern char* wgaim_data_dir(void); extern char* wgaim_escape_dirsep(char*); /* UI related */ extern void wgaim_im_blink(GtkWidget*);