Mercurial > pidgin.yaz
changeset 29493:224f9674a57e
Remove some win9x specific code.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 04 Sep 2009 02:57:26 +0000 |
parents | 4e13885b1a6a |
children | d6dff41a6d4c |
files | libpurple/win32/win32dep.c pidgin/gtkft.c pidgin/gtkpounce.c pidgin/gtksound.c pidgin/gtkutils.c pidgin/win32/gtkwin32dep.c |
diffstat | 6 files changed, 89 insertions(+), 233 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/win32/win32dep.c Fri Sep 04 02:49:15 2009 +0000 +++ b/libpurple/win32/win32dep.c Fri Sep 04 02:57:26 2009 +0000 @@ -115,7 +115,6 @@ /* Get paths to special Windows folders. */ gchar *wpurple_get_special_folder(int folder_type) { - static LPFNSHGETFOLDERPATHA MySHGetFolderPathA = NULL; static LPFNSHGETFOLDERPATHW MySHGetFolderPathW = NULL; gchar *retval = NULL; @@ -133,21 +132,6 @@ } } - if (!retval) { - if (!MySHGetFolderPathA) { - MySHGetFolderPathA = (LPFNSHGETFOLDERPATHA) - wpurple_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"); - } - if (MySHGetFolderPathA) { - char locale_dir[MAX_PATH + 1]; - - if (SUCCEEDED(MySHGetFolderPathA(NULL, folder_type, NULL, - SHGFP_TYPE_CURRENT, locale_dir))) { - retval = g_locale_to_utf8(locale_dir, -1, NULL, NULL, NULL); - } - } - } - return retval; } @@ -156,20 +140,11 @@ if (!initialized) { char *tmp = NULL; - if (G_WIN32_HAVE_WIDECHAR_API()) { - wchar_t winstall_dir[MAXPATHLEN]; - if (GetModuleFileNameW(NULL, winstall_dir, - MAXPATHLEN) > 0) { - tmp = g_utf16_to_utf8(winstall_dir, -1, - NULL, NULL, NULL); - } - } else { - gchar cpinstall_dir[MAXPATHLEN]; - if (GetModuleFileNameA(NULL, cpinstall_dir, - MAXPATHLEN) > 0) { - tmp = g_locale_to_utf8(cpinstall_dir, - -1, NULL, NULL, NULL); - } + wchar_t winstall_dir[MAXPATHLEN]; + if (GetModuleFileNameW(NULL, winstall_dir, + MAXPATHLEN) > 0) { + tmp = g_utf16_to_utf8(winstall_dir, -1, + NULL, NULL, NULL); } if (tmp == NULL) { @@ -246,61 +221,33 @@ HKEY reg_key; gboolean success = FALSE; - if(G_WIN32_HAVE_WIDECHAR_API()) { - wchar_t *wc_subkey = g_utf8_to_utf16(subkey, -1, NULL, - NULL, NULL); - - if(RegOpenKeyExW(rootkey, wc_subkey, 0, - KEY_SET_VALUE, ®_key) == ERROR_SUCCESS) { - wchar_t *wc_valname = NULL; - - if (valname) - wc_valname = g_utf8_to_utf16(valname, -1, - NULL, NULL, NULL); + wchar_t *wc_subkey = g_utf8_to_utf16(subkey, -1, NULL, + NULL, NULL); - if(value) { - wchar_t *wc_value = g_utf8_to_utf16(value, -1, - NULL, NULL, NULL); - int len = (wcslen(wc_value) * sizeof(wchar_t)) + 1; - if(RegSetValueExW(reg_key, wc_valname, 0, REG_SZ, - (LPBYTE)wc_value, len - ) == ERROR_SUCCESS) - success = TRUE; - g_free(wc_value); - } else - if(RegDeleteValueW(reg_key, wc_valname) == ERROR_SUCCESS) - success = TRUE; + if(RegOpenKeyExW(rootkey, wc_subkey, 0, + KEY_SET_VALUE, ®_key) == ERROR_SUCCESS) { + wchar_t *wc_valname = NULL; + + if (valname) + wc_valname = g_utf8_to_utf16(valname, -1, + NULL, NULL, NULL); - g_free(wc_valname); - } - g_free(wc_subkey); - } else { - char *cp_subkey = g_locale_from_utf8(subkey, -1, NULL, - NULL, NULL); - if(RegOpenKeyExA(rootkey, cp_subkey, 0, - KEY_SET_VALUE, ®_key) == ERROR_SUCCESS) { - char *cp_valname = NULL; - if(valname) - cp_valname = g_locale_from_utf8(valname, -1, - NULL, NULL, NULL); + if(value) { + wchar_t *wc_value = g_utf8_to_utf16(value, -1, + NULL, NULL, NULL); + int len = (wcslen(wc_value) * sizeof(wchar_t)) + 1; + if(RegSetValueExW(reg_key, wc_valname, 0, REG_SZ, + (LPBYTE)wc_value, len + ) == ERROR_SUCCESS) + success = TRUE; + g_free(wc_value); + } else + if(RegDeleteValueW(reg_key, wc_valname) == ERROR_SUCCESS) + success = TRUE; - if (value) { - char *cp_value = g_locale_from_utf8(value, -1, - NULL, NULL, NULL); - int len = strlen(cp_value) + 1; - if(RegSetValueExA(reg_key, cp_valname, 0, REG_SZ, - cp_value, len - ) == ERROR_SUCCESS) - success = TRUE; - g_free(cp_value); - } else - if(RegDeleteValueA(reg_key, cp_valname) == ERROR_SUCCESS) - success = TRUE; - - g_free(cp_valname); - } - g_free(cp_subkey); + g_free(wc_valname); } + g_free(wc_subkey); if(reg_key != NULL) RegCloseKey(reg_key); @@ -312,17 +259,11 @@ HKEY reg_key = NULL; LONG rv; - if(G_WIN32_HAVE_WIDECHAR_API()) { - wchar_t *wc_subkey = g_utf8_to_utf16(subkey, -1, NULL, - NULL, NULL); - rv = RegOpenKeyExW(rootkey, wc_subkey, 0, access, ®_key); - g_free(wc_subkey); - } else { - char *cp_subkey = g_locale_from_utf8(subkey, -1, NULL, - NULL, NULL); - rv = RegOpenKeyExA(rootkey, cp_subkey, 0, access, ®_key); - g_free(cp_subkey); - } + wchar_t *wc_subkey = g_utf8_to_utf16(subkey, -1, NULL, + NULL, NULL); + rv = RegOpenKeyExW(rootkey, wc_subkey, 0, access, ®_key); + + g_free(wc_subkey); if (rv != ERROR_SUCCESS) { char *errmsg = g_win32_error_message(rv); @@ -340,19 +281,11 @@ static gboolean _reg_read(HKEY reg_key, const char *valname, LPDWORD type, LPBYTE data, LPDWORD data_len) { LONG rv; - if(G_WIN32_HAVE_WIDECHAR_API()) { - wchar_t *wc_valname = NULL; - if (valname) - wc_valname = g_utf8_to_utf16(valname, -1, NULL, NULL, NULL); - rv = RegQueryValueExW(reg_key, wc_valname, 0, type, data, data_len); - g_free(wc_valname); - } else { - char *cp_valname = NULL; - if(valname) - cp_valname = g_locale_from_utf8(valname, -1, NULL, NULL, NULL); - rv = RegQueryValueExA(reg_key, cp_valname, 0, type, data, data_len); - g_free(cp_valname); - } + wchar_t *wc_valname = NULL; + if (valname) + wc_valname = g_utf8_to_utf16(valname, -1, NULL, NULL, NULL); + rv = RegQueryValueExW(reg_key, wc_valname, 0, type, data, data_len); + g_free(wc_valname); if (rv != ERROR_SUCCESS) { char *errmsg = g_win32_error_message(rv); @@ -389,24 +322,13 @@ if(reg_key) { if(_reg_read(reg_key, valname, &type, NULL, &nbytes) && type == REG_SZ) { - LPBYTE data; - if(G_WIN32_HAVE_WIDECHAR_API()) - data = (LPBYTE) g_new(wchar_t, ((nbytes + 1) / sizeof(wchar_t)) + 1); - else - data = (LPBYTE) g_malloc(nbytes + 1); + LPBYTE data = (LPBYTE) g_new(wchar_t, ((nbytes + 1) / sizeof(wchar_t)) + 1); if(_reg_read(reg_key, valname, &type, data, &nbytes)) { - if(G_WIN32_HAVE_WIDECHAR_API()) { - wchar_t *wc_temp = (wchar_t*) data; - wc_temp[nbytes / sizeof(wchar_t)] = '\0'; - result = g_utf16_to_utf8(wc_temp, -1, - NULL, NULL, NULL); - } else { - char *cp_temp = (char*) data; - cp_temp[nbytes] = '\0'; - result = g_locale_to_utf8(cp_temp, -1, - NULL, NULL, NULL); - } + wchar_t *wc_temp = (wchar_t*) data; + wc_temp[nbytes / sizeof(wchar_t)] = '\0'; + result = g_utf16_to_utf8(wc_temp, -1, + NULL, NULL, NULL); } g_free(data); }
--- a/pidgin/gtkft.c Fri Sep 04 02:49:15 2009 +0000 +++ b/pidgin/gtkft.c Fri Sep 04 02:57:26 2009 +0000 @@ -458,27 +458,15 @@ #ifdef _WIN32 /* If using Win32... */ int code; - if (G_WIN32_HAVE_WIDECHAR_API ()) { - wchar_t *wc_filename = g_utf8_to_utf16( - purple_xfer_get_local_filename( - dialog->selected_xfer), - -1, NULL, NULL, NULL); - - code = (int) ShellExecuteW(NULL, NULL, wc_filename, NULL, NULL, - SW_SHOW); + wchar_t *wc_filename = g_utf8_to_utf16( + purple_xfer_get_local_filename( + dialog->selected_xfer), + -1, NULL, NULL, NULL); - g_free(wc_filename); - } else { - char *l_filename = g_locale_from_utf8( - purple_xfer_get_local_filename( - dialog->selected_xfer), - -1, NULL, NULL, NULL); + code = (int) ShellExecuteW(NULL, NULL, wc_filename, NULL, NULL, + SW_SHOW); - code = (int) ShellExecuteA(NULL, NULL, l_filename, NULL, NULL, - SW_SHOW); - - g_free(l_filename); - } + g_free(wc_filename); if (code == SE_ERR_ASSOCINCOMPLETE || code == SE_ERR_NOASSOC) {
--- a/pidgin/gtkpounce.c Fri Sep 04 02:49:15 2009 +0000 +++ b/pidgin/gtkpounce.c Fri Sep 04 02:57:26 2009 +0000 @@ -1536,34 +1536,19 @@ PROCESS_INFORMATION pi; BOOL retval; gchar *message = NULL; + STARTUPINFOW si; + + wchar_t *wc_cmd = g_utf8_to_utf16(command, + -1, NULL, NULL, NULL); memset(&pi, 0, sizeof(pi)); - - if (G_WIN32_HAVE_WIDECHAR_API ()) { - STARTUPINFOW si; - wchar_t *wc_cmd = g_utf8_to_utf16(command, - -1, NULL, NULL, NULL); - - memset(&si, 0 , sizeof(si)); - si.cb = sizeof(si); + memset(&si, 0 , sizeof(si)); + si.cb = sizeof(si); - retval = CreateProcessW(NULL, wc_cmd, NULL, - NULL, 0, 0, NULL, NULL, - &si, &pi); - g_free(wc_cmd); - } else { - STARTUPINFOA si; - char *l_cmd = g_locale_from_utf8(command, - -1, NULL, NULL, NULL); - - memset(&si, 0 , sizeof(si)); - si.cb = sizeof(si); - - retval = CreateProcessA(NULL, l_cmd, NULL, - NULL, 0, 0, NULL, NULL, - &si, &pi); - g_free(l_cmd); - } + retval = CreateProcessW(NULL, wc_cmd, NULL, + NULL, 0, 0, NULL, NULL, + &si, &pi); + g_free(wc_cmd); if (retval) { CloseHandle(pi.hProcess);
--- a/pidgin/gtksound.c Fri Sep 04 02:49:15 2009 +0000 +++ b/pidgin/gtksound.c Fri Sep 04 02:57:26 2009 +0000 @@ -537,18 +537,12 @@ #else /* _WIN32 */ purple_debug_info("sound", "Playing %s\n", filename); - if (G_WIN32_HAVE_WIDECHAR_API ()) { + { wchar_t *wc_filename = g_utf8_to_utf16(filename, -1, NULL, NULL, NULL); if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); g_free(wc_filename); - } else { - char *l_filename = g_locale_from_utf8(filename, - -1, NULL, NULL, NULL); - if (!PlaySoundA(l_filename, NULL, SND_ASYNC | SND_FILENAME)) - purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); - g_free(l_filename); } #endif /* _WIN32 */
--- a/pidgin/gtkutils.c Fri Sep 04 02:49:15 2009 +0000 +++ b/pidgin/gtkutils.c Fri Sep 04 02:57:26 2009 +0000 @@ -3107,23 +3107,13 @@ #ifdef _WIN32 /* If using Win32... */ int code; - if (G_WIN32_HAVE_WIDECHAR_API()) { - wchar_t *wc_filename = g_utf8_to_utf16( - uri, -1, NULL, NULL, NULL); - - code = (int)ShellExecuteW(NULL, NULL, wc_filename, NULL, NULL, - SW_SHOW); - - g_free(wc_filename); - } else { - char *l_filename = g_locale_from_utf8( - uri, -1, NULL, NULL, NULL); - - code = (int)ShellExecuteA(NULL, NULL, l_filename, NULL, NULL, - SW_SHOW); - - g_free(l_filename); - } + wchar_t *wc_filename = g_utf8_to_utf16( + uri, -1, NULL, NULL, NULL); + + code = (int)ShellExecuteW(NULL, NULL, wc_filename, NULL, NULL, + SW_SHOW); + + g_free(wc_filename); if (code == SE_ERR_ASSOCINCOMPLETE || code == SE_ERR_NOASSOC) {
--- a/pidgin/win32/gtkwin32dep.c Fri Sep 04 02:49:15 2009 +0000 +++ b/pidgin/win32/gtkwin32dep.c Fri Sep 04 02:57:26 2009 +0000 @@ -142,56 +142,33 @@ void winpidgin_shell_execute(const char *target, const char *verb, const char *clazz) { + SHELLEXECUTEINFOW wsinfo; + wchar_t *w_uri, *w_verb, *w_clazz = NULL; + g_return_if_fail(target != NULL); g_return_if_fail(verb != NULL); - if (G_WIN32_HAVE_WIDECHAR_API()) { - SHELLEXECUTEINFOW wsinfo; - wchar_t *w_uri, *w_verb, *w_clazz = NULL; - - w_uri = g_utf8_to_utf16(target, -1, NULL, NULL, NULL); - w_verb = g_utf8_to_utf16(verb, -1, NULL, NULL, NULL); - - memset(&wsinfo, 0, sizeof(wsinfo)); - wsinfo.cbSize = sizeof(wsinfo); - wsinfo.lpVerb = w_verb; - wsinfo.lpFile = w_uri; - wsinfo.nShow = SW_SHOWNORMAL; - if (clazz != NULL) { - w_clazz = g_utf8_to_utf16(clazz, -1, NULL, NULL, NULL); - wsinfo.fMask |= SEE_MASK_CLASSNAME; - wsinfo.lpClass = w_clazz; - } - - if(!ShellExecuteExW(&wsinfo)) - purple_debug_error("winpidgin", "Error opening URI: %s error: %d\n", - target, (int) wsinfo.hInstApp); + w_uri = g_utf8_to_utf16(target, -1, NULL, NULL, NULL); + w_verb = g_utf8_to_utf16(verb, -1, NULL, NULL, NULL); - g_free(w_uri); - g_free(w_verb); - g_free(w_clazz); - } else { - SHELLEXECUTEINFOA sinfo; - gchar *locale_uri; - - locale_uri = g_locale_from_utf8(target, -1, NULL, NULL, NULL); + memset(&wsinfo, 0, sizeof(wsinfo)); + wsinfo.cbSize = sizeof(wsinfo); + wsinfo.lpVerb = w_verb; + wsinfo.lpFile = w_uri; + wsinfo.nShow = SW_SHOWNORMAL; + if (clazz != NULL) { + w_clazz = g_utf8_to_utf16(clazz, -1, NULL, NULL, NULL); + wsinfo.fMask |= SEE_MASK_CLASSNAME; + wsinfo.lpClass = w_clazz; + } - memset(&sinfo, 0, sizeof(sinfo)); - sinfo.cbSize = sizeof(sinfo); - sinfo.lpVerb = verb; - sinfo.lpFile = locale_uri; - sinfo.nShow = SW_SHOWNORMAL; - if (clazz != NULL) { - sinfo.fMask |= SEE_MASK_CLASSNAME; - sinfo.lpClass = clazz; - } + if(!ShellExecuteExW(&wsinfo)) + purple_debug_error("winpidgin", "Error opening URI: %s error: %d\n", + target, (int) wsinfo.hInstApp); - if(!ShellExecuteExA(&sinfo)) - purple_debug_error("winpidgin", "Error opening URI: %s error: %d\n", - target, (int) sinfo.hInstApp); - - g_free(locale_uri); - } + g_free(w_uri); + g_free(w_verb); + g_free(w_clazz); }