--- a/src/win32/win32dep.c Sun Aug 21 13:13:43 2005 -0400
+++ b/src/win32/win32dep.c Sun Aug 21 16:10:33 2005 -0400
@@ -31,12 +31,7 @@
-#if GLIB_CHECK_VERSION(2,6,0)
-# include <glib/gstdio.h>
-# define g_unlink unlink
+#include <glib/gstdio.h> #include <gdk/gdkwin32.h>
@@ -83,10 +78,7 @@
-static char app_data_dir[MAX_PATH + 1] = "C:";
-static char install_dir[MAXPATHLEN];
-static char lib_dir[MAXPATHLEN];
-static char locale_dir[MAXPATHLEN];
+static char *app_data_dir, *install_dir, *lib_dir, *locale_dir; static gboolean blink_turned_on = TRUE;
@@ -234,43 +226,76 @@
/* Determine Gaim Paths during Runtime */
char* wgaim_install_dir(void) {
+ static gboolean initialized = FALSE; - hmod = GetModuleHandle(NULL);
- buf = g_win32_error_message( GetLastError() );
- gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "GetModuleHandle error: %s\n", buf);
+ if (G_WIN32_HAVE_WIDECHAR_API()) { + wchar_t winstall_dir[MAXPATHLEN]; + if (GetModuleFileNameW(NULL, winstall_dir, + tmp = g_utf16_to_utf8(winstall_dir, -1, + gchar cpinstall_dir[MAXPATHLEN]; + if (GetModuleFileNameA(NULL, cpinstall_dir, + tmp = g_locale_to_utf8(cpinstall_dir, + tmp = g_win32_error_message(GetLastError()); + gaim_debug(GAIM_DEBUG_ERROR, "wgaim", + "GetModuleFileName error: %s\n", tmp); + install_dir = g_path_get_dirname(tmp); - if(GetModuleFileName( hmod, (char*)&install_dir, MAXPATHLEN ) == 0) {
- buf = g_win32_error_message( GetLastError() );
- gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "GetModuleFileName error: %s\n", buf);
- buf = g_path_get_dirname( install_dir );
- strcpy( (char*)&install_dir, buf );
- return (char*)&install_dir;
char* wgaim_lib_dir(void) {
- strcpy(lib_dir, wgaim_install_dir());
- g_strlcat(lib_dir, G_DIR_SEPARATOR_S "plugins", sizeof(lib_dir));
- return (char*)&lib_dir;
+ static gboolean initialized = FALSE; + char *inst_dir = wgaim_install_dir(); + if (inst_dir != NULL) { + lib_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "plugins", inst_dir); char* wgaim_locale_dir(void) {
- strcpy(locale_dir, wgaim_install_dir());
- g_strlcat(locale_dir, G_DIR_SEPARATOR_S "locale", sizeof(locale_dir));
- return (char*)&locale_dir;
+ static gboolean initialized = FALSE; + char *inst_dir = wgaim_install_dir(); + if (inst_dir != NULL) { + locale_dir = g_strdup_printf("%s" G_DIR_SEPARATOR_S "locale", inst_dir); char* wgaim_data_dir(void) {
- return (char*)&app_data_dir;
@@ -416,9 +441,9 @@
- gaim_debug_set_ui_ops(&ops);
+ gaim_debug_set_ui_ops(&ops); gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init start\n");
gaimexe_hInstance = hint;
@@ -439,60 +464,45 @@
- /* Set Environmental Variables */
- /* Tell perl where to find Gaim's perl modules */
- perlenv = (char*)g_getenv("PERL5LIB");
- newenv = g_strdup_printf("PERL5LIB=%s%s%s%s",
- perlenv ? perlenv : "",
+ /* Set Environmental Variables */ + /* Tell perl where to find Gaim's perl modules */ + perlenv = (char*) g_getenv("PERL5LIB"); + newenv = g_strdup_printf("PERL5LIB=%s%s%s%s", + perlenv ? perlenv : "", + if (putenv(newenv) < 0) gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n");
- /* Set app data dir, used by gaim_home_dir */
- newenv = (char*)g_getenv("GAIMHOME");
-#if GLIB_CHECK_VERSION(2,6,0)
+ /* Set app data dir, used by gaim_home_dir */ + newenv = (char*) g_getenv("GAIMHOME"); if ((MySHGetFolderPathW = (LPFNSHGETFOLDERPATHW) wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathW"))) {
wchar_t utf_16_dir[MAX_PATH +1];
MySHGetFolderPathW(NULL, CSIDL_APPDATA, NULL,
SHGFP_TYPE_CURRENT, utf_16_dir);
- temp = g_utf16_to_utf8(utf_16_dir, -1, NULL, NULL, NULL);
- g_strlcpy(app_data_dir, temp, sizeof(app_data_dir));
+ app_data_dir = g_utf16_to_utf8(utf_16_dir, -1, NULL, NULL, NULL); } else if ((MySHGetFolderPathA = (LPFNSHGETFOLDERPATHA) wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"))) {
char locale_dir[MAX_PATH + 1];
MySHGetFolderPathA(NULL, CSIDL_APPDATA, NULL,
SHGFP_TYPE_CURRENT, locale_dir);
- temp = g_locale_to_utf8(locale_dir, -1, NULL, NULL, NULL);
- g_strlcpy(app_data_dir, temp, sizeof(app_data_dir));
- if ((MySHGetFolderPathA = (LPFNSHGETFOLDERPATHA) wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"))) {
- MySHGetFolderPathA(NULL, CSIDL_APPDATA, NULL,
- SHGFP_TYPE_CURRENT, app_data_dir);
+ app_data_dir = g_locale_to_utf8(locale_dir, -1, NULL, NULL, NULL); + app_data_dir = g_strdup("C:");
- strcpy(app_data_dir, "C:");
- g_strlcpy(app_data_dir, newenv, sizeof(app_data_dir));
- gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Gaim settings dir: %s\n", app_data_dir);
+ app_data_dir = g_strdup(newenv); + gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Gaim settings dir: %s\n", app_data_dir); /* IdleTracker Initialization */
if(!wgaim_set_idlehooks())
gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Failed to initialize idle tracker\n");
- gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init end\n");
+ gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init end\n");