diff options
Diffstat (limited to 'src/win32/win_easytag.c')
-rwxr-xr-x | src/win32/win_easytag.c | 147 |
1 files changed, 84 insertions, 63 deletions
diff --git a/src/win32/win_easytag.c b/src/win32/win_easytag.c index 21f4bac..8aaa825 100755 --- a/src/win32/win_easytag.c +++ b/src/win32/win_easytag.c @@ -112,34 +112,9 @@ static BOOL read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data return ret; } -static void dll_prep() { - char path[MAX_PATH + 1]; +static void common_dll_prep(const char *path) { HMODULE hmod; HKEY hkey; - char gtkpath[MAX_PATH + 1]; - DWORD plen; - - plen = sizeof(gtkpath); - hkey = HKEY_CURRENT_USER; - if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path", - (LPBYTE) >kpath, &plen)) { - hkey = HKEY_LOCAL_MACHINE; - if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path", - (LPBYTE) >kpath, &plen)) { - printf("GTK+ Path Registry Key not found. " - "Assuming GTK+ is in the PATH.\n"); - return; - } - } - - /* this value is replaced during a successful RegQueryValueEx() */ - plen = sizeof(path); - /* Determine GTK+ dll path .. */ - if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "DllPath", - (LPBYTE) &path, &plen)) { - strcpy(path, gtkpath); - strcat(path, "\\bin"); - } printf("GTK+ path found: %s\n", path); @@ -212,27 +187,49 @@ static void dll_prep() { } } -static char* lcid_to_posix(LCID lcid) { +static void dll_prep() { + char path[MAX_PATH + 1]; + HKEY hkey; + char gtkpath[MAX_PATH + 1]; + DWORD plen; + + plen = sizeof(gtkpath); + hkey = HKEY_CURRENT_USER; + if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path", + (LPBYTE) >kpath, &plen)) { + hkey = HKEY_LOCAL_MACHINE; + if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "Path", + (LPBYTE) >kpath, &plen)) { + printf("GTK+ Path Registry Key not found. " + "Assuming GTK+ is in the PATH.\n"); + return; + } + } + + /* this value is replaced during a successful RegQueryValueEx() */ + plen = sizeof(path); + /* Determine GTK+ dll path .. */ + if (!read_reg_string(hkey, "SOFTWARE\\GTK\\2.0", "DllPath", + (LPBYTE) &path, &plen)) { + strcpy(path, gtkpath); + strcat(path, "\\bin"); + } + + common_dll_prep(path); +} + +static char* wineasytag_lcid_to_posix(LCID lcid) { char *posix = NULL; int lang_id = PRIMARYLANGID(lcid); int sub_id = SUBLANGID(lcid); switch (lang_id) { + case LANG_AFRIKAANS: posix = "af"; break; case LANG_ARABIC: posix = "ar"; break; case LANG_AZERI: posix = "az"; break; case LANG_BENGALI: posix = "bn"; break; case LANG_BULGARIAN: posix = "bg"; break; case LANG_CATALAN: posix = "ca"; break; - case LANG_CHINESE: - switch (sub_id) { - case SUBLANG_CHINESE_SIMPLIFIED: - posix = "zh_CN"; break; - case SUBLANG_CHINESE_TRADITIONAL: - posix = "zh_TW"; break; - default: - posix = "zh"; break; - } - break; case LANG_CZECH: posix = "cs"; break; case LANG_DANISH: posix = "da"; break; case LANG_ESTONIAN: posix = "et"; break; @@ -261,9 +258,11 @@ static char* lcid_to_posix(LCID lcid) { case LANG_HINDI: posix = "hi"; break; case LANG_HUNGARIAN: posix = "hu"; break; case LANG_ICELANDIC: break; + case LANG_INDONESIAN: posix = "id"; break; case LANG_ITALIAN: posix = "it"; break; case LANG_JAPANESE: posix = "ja"; break; case LANG_GEORGIAN: posix = "ka"; break; + case LANG_KANNADA: posix = "kn"; break; case LANG_KOREAN: posix = "ko"; break; case LANG_LITHUANIAN: posix = "lt"; break; case LANG_MACEDONIAN: posix = "mk"; break; @@ -279,6 +278,7 @@ static char* lcid_to_posix(LCID lcid) { break; case LANG_PUNJABI: posix = "pa"; break; case LANG_POLISH: posix = "pl"; break; + case LANG_PASHTO: posix = "ps"; break; case LANG_PORTUGUESE: switch (sub_id) { case SUBLANG_PORTUGUESE_BRAZILIAN: @@ -289,6 +289,9 @@ static char* lcid_to_posix(LCID lcid) { break; case LANG_ROMANIAN: posix = "ro"; break; case LANG_RUSSIAN: posix = "ru"; break; + case LANG_SLOVAK: posix = "sk"; break; + case LANG_SLOVENIAN: posix = "sl"; break; + case LANG_ALBANIAN: posix = "sq"; break; /* LANG_CROATIAN == LANG_SERBIAN == LANG_BOSNIAN */ case LANG_SERBIAN: switch (sub_id) { @@ -303,9 +306,6 @@ static char* lcid_to_posix(LCID lcid) { posix = "hr"; break; } break; - case LANG_SLOVAK: posix = "sk"; break; - case LANG_SLOVENIAN: posix = "sl"; break; - case LANG_ALBANIAN: posix = "sq"; break; case LANG_SWEDISH: posix = "sv"; break; case LANG_TAMIL: posix = "ta"; break; case LANG_TELUGU: posix = "te"; break; @@ -314,12 +314,20 @@ static char* lcid_to_posix(LCID lcid) { case LANG_UKRAINIAN: posix = "uk"; break; case LANG_VIETNAMESE: posix = "vi"; break; case LANG_XHOSA: posix = "xh"; break; + case LANG_CHINESE: + switch (sub_id) { + case SUBLANG_CHINESE_SIMPLIFIED: + posix = "zh_CN"; break; + case SUBLANG_CHINESE_TRADITIONAL: + posix = "zh_TW"; break; + default: + posix = "zh"; break; + } + break; case LANG_URDU: break; - case LANG_INDONESIAN: break; case LANG_BELARUSIAN: break; case LANG_LATVIAN: break; case LANG_ARMENIAN: break; - case LANG_AFRIKAANS: break; case LANG_FAEROESE: break; case LANG_MALAY: break; case LANG_KAZAK: break; @@ -328,7 +336,6 @@ static char* lcid_to_posix(LCID lcid) { case LANG_UZBEK: break; case LANG_TATAR: break; case LANG_ORIYA: break; - case LANG_KANNADA: break; case LANG_MALAYALAM: break; case LANG_ASSAMESE: break; case LANG_MARATHI: break; @@ -358,7 +365,7 @@ static char* lcid_to_posix(LCID lcid) { - Check NSIS Installer Language reg value - Use default user locale */ -static const char *get_locale() { +static const char *wineasytag_get_locale() { const char *locale = NULL; LCID lcid = 0; char data[10]; @@ -373,23 +380,23 @@ static const char *get_locale() { if (read_reg_string(HKEY_CURRENT_USER, "SOFTWARE\\easytag", "Installer Language", (LPBYTE) &data, &datalen)) { - if ((locale = lcid_to_posix(atoi(data)))) + if ((locale = wineasytag_lcid_to_posix(atoi(data)))) return locale; } // List of LCID : http://www.microsoft.com/globaldev/reference/lcid-all.mspx lcid = GetUserDefaultLCID(); - if ((locale = lcid_to_posix(lcid))) + if ((locale = wineasytag_lcid_to_posix(lcid))) return locale; return "en"; } -static void set_locale() { +static void wineasytag_set_locale() { const char *locale = NULL; char envstr[25]; - locale = get_locale(); + locale = wineasytag_get_locale(); snprintf(envstr, 25, "LANG=%s", locale); printf("Setting locale: %s\n", envstr); @@ -397,9 +404,9 @@ static void set_locale() { } #if 0 -#define WM_FOCUS_REQUEST (WM_APP + 13) +#define EASYTAG_WM_FOCUS_REQUEST (WM_APP + 13) -static BOOL set_running() { +static BOOL wineasytag_set_running() { HANDLE h; if ((h = CreateMutex(NULL, FALSE, "easytag_is_running"))) { @@ -407,7 +414,7 @@ static BOOL set_running() { HWND msg_win; if((msg_win = FindWindow(TEXT("WineasytagMsgWinCls"), NULL))) - if(SendMessage(msg_win, WM_FOCUS_REQUEST, (WPARAM) NULL, (LPARAM) NULL)) + if(SendMessage(msg_win, EASYTAG_WM_FOCUS_REQUEST, (WPARAM) NULL, (LPARAM) NULL)) return FALSE; /* If we get here, the focus request wasn't successful */ @@ -476,13 +483,18 @@ int _stdcall WinMain (struct HINSTANCE__ *hInstance, struct HINSTANCE__ *hPrevInstance, char *lpszCmdLine, int nCmdShow) { char errbuf[512]; + char pidgin_dir[MAX_PATH]; + char exe_name[MAX_PATH]; HMODULE hmod; + char *tmp; + int easytag_argc = __argc; + char **easytag_argv = __argv; /* If debug or help or version flag used, create console for output */ if (strstr(lpszCmdLine, "-d") || strstr(lpszCmdLine, "-h") || strstr(lpszCmdLine, "-v")) { /* If stdout hasn't been redirected to a file, alloc a console * (_istty() doesn't work for stuff using the GUI subsystem) */ - if (_fileno(stdout) == -1) { + if (_fileno(stdout) == -1 || _fileno(stdout) == -2) { LPFNATTACHCONSOLE MyAttachConsole = NULL; if ((hmod = GetModuleHandle("kernel32.dll"))) { MyAttachConsole = @@ -496,12 +508,14 @@ WinMain (struct HINSTANCE__ *hInstance, struct HINSTANCE__ *hPrevInstance, } } } + #if 0 /* Load exception handler if we have it */ - if (GetModuleFileName(NULL, gaimdir, MAX_PATH) != 0) { - char *tmp = gaimdir; + if (GetModuleFileName(NULL, easytag_dir, MAX_PATH) != 0) { char *prev = NULL; + tmp = easytag_dir; + /* primitive dirname() */ while ((tmp = strchr(tmp, '\\'))) { prev = tmp; tmp++; @@ -509,9 +523,15 @@ WinMain (struct HINSTANCE__ *hInstance, struct HINSTANCE__ *hPrevInstance, if (prev) { prev[0] = '\0'; - strcat(gaimdir, "\\exchndl.dll"); - if (LoadLibrary(gaimdir)) + + /* prev++ will now point to the executable file name */ + strcpy(exe_name, prev + 1); + + strcat(easytag_dir, "\\exchndl.dll"); + if (LoadLibrary(easytag_dir)) printf("Loaded exchndl.dll\n"); + + prev[0] = '\0'; } } else { DWORD dw = GetLastError(); @@ -519,18 +539,19 @@ WinMain (struct HINSTANCE__ *hInstance, struct HINSTANCE__ *hPrevInstance, snprintf(errbuf, 512, "Error getting module filename. Error: (%u) %s", (UINT) dw, err_msg); - printf(errbuf); + printf("%s", errbuf); MessageBox(NULL, errbuf, NULL, MB_OK | MB_TOPMOST); + easytag_dir[0] = '\0'; } #endif dll_prep(); - set_locale(); + wineasytag_set_locale(); /* If help or version flag used, do not check Mutex */ - //if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v")) - // if (!getenv("GAIM_MULTI_INST") && !wgaim_set_running()) - // return 0; + /*if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v")) + if (!getenv("GAIM_MULTI_INST") && !wineasytag_set_running()) + return 0;*/ set_proxy(); @@ -548,11 +569,11 @@ WinMain (struct HINSTANCE__ *hInstance, struct HINSTANCE__ *hPrevInstance, (UINT) dw, err_msg, mod_not_found ? "\n" : "", mod_not_found ? "This probably means that a dependency (like GTK+, libogg or libvorbis) can't be found." : ""); - printf(errbuf); + printf("%s", errbuf); MessageBox(NULL, errbuf, TEXT("Error"), MB_OK | MB_TOPMOST); return 0; } - return easytag_main (hInstance, __argc, __argv); + return easytag_main (hInstance, easytag_argc, easytag_argv); } |