Mercurial > pidgin
comparison src/gtkpounce.c @ 10921:9f75886e4f1f
[gaim-migrate @ 12688]
Buddy pounce commands now work in non-ASCII paths (win32)
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Sun, 15 May 2005 18:55:28 +0000 |
parents | 44e91a7708eb |
children | 096020ae09a9 |
comparison
equal
deleted
inserted
replaced
10920:6a8440e9edba | 10921:9f75886e4f1f |
---|---|
1012 } | 1012 } |
1013 | 1013 |
1014 if (gaim_pounce_action_is_enabled(pounce, "execute-command")) | 1014 if (gaim_pounce_action_is_enabled(pounce, "execute-command")) |
1015 { | 1015 { |
1016 const char *command; | 1016 const char *command; |
1017 char *localecmd; | 1017 |
1018 | 1018 command = gaim_pounce_action_get_attribute(pounce, |
1019 command = gaim_pounce_action_get_attribute(pounce, "execute-command", | 1019 "execute-command", "command"); |
1020 "command"); | 1020 |
1021 localecmd = g_locale_from_utf8(command, -1, NULL, NULL, NULL); | 1021 if (command != NULL) |
1022 | |
1023 if (localecmd != NULL) | |
1024 { | 1022 { |
1025 #ifndef _WIN32 | 1023 #ifndef _WIN32 |
1026 int pid = fork(); | 1024 char *localecmd = g_locale_from_utf8(command, -1, NULL, |
1027 | 1025 NULL, NULL); |
1028 if (pid == 0) { | 1026 |
1029 char *args[4]; | 1027 if (localecmd != NULL) |
1030 | 1028 { |
1031 args[0] = "sh"; | 1029 int pid = fork(); |
1032 args[1] = "-c"; | 1030 |
1033 args[2] = (char *)localecmd; | 1031 if (pid == 0) { |
1034 args[3] = NULL; | 1032 char *args[4]; |
1035 | 1033 |
1036 execvp(args[0], args); | 1034 args[0] = "sh"; |
1037 | 1035 args[1] = "-c"; |
1038 _exit(0); | 1036 args[2] = (char *)localecmd; |
1037 args[3] = NULL; | |
1038 | |
1039 execvp(args[0], args); | |
1040 | |
1041 _exit(0); | |
1042 } | |
1043 g_free(localecmd); | |
1039 } | 1044 } |
1040 #else /* !_WIN32 */ | 1045 #else /* !_WIN32 */ |
1041 STARTUPINFO StartInfo; | 1046 PROCESS_INFORMATION pi; |
1042 PROCESS_INFORMATION ProcInfo; | 1047 BOOL retval; |
1043 | 1048 gchar *message = NULL; |
1044 memset(&ProcInfo, 0, sizeof(ProcInfo)); | 1049 |
1045 memset(&StartInfo, 0 , sizeof(StartInfo)); | 1050 memset(&pi, 0, sizeof(pi)); |
1046 StartInfo.cb = sizeof(StartInfo); | 1051 |
1047 CreateProcess(NULL, (char *)command, NULL, NULL, 0, 0, NULL, | 1052 if (G_WIN32_HAVE_WIDECHAR_API ()) { |
1048 NULL, &StartInfo, &ProcInfo); | 1053 STARTUPINFOW si; |
1054 wchar_t *wc_cmd = g_utf8_to_utf16(command, | |
1055 -1, NULL, NULL, NULL); | |
1056 | |
1057 memset(&si, 0 , sizeof(si)); | |
1058 si.cb = sizeof(si); | |
1059 | |
1060 retval = CreateProcessW(NULL, wc_cmd, NULL, | |
1061 NULL, 0, 0, NULL, NULL, | |
1062 &si, &pi); | |
1063 g_free(wc_cmd); | |
1064 } else { | |
1065 STARTUPINFOA si; | |
1066 char *l_cmd = g_locale_from_utf8(command, | |
1067 -1, NULL, NULL, NULL); | |
1068 | |
1069 memset(&si, 0 , sizeof(si)); | |
1070 si.cb = sizeof(si); | |
1071 | |
1072 retval = CreateProcessA(NULL, l_cmd, NULL, | |
1073 NULL, 0, 0, NULL, NULL, | |
1074 &si, &pi); | |
1075 g_free(l_cmd); | |
1076 } | |
1077 | |
1078 if (retval) { | |
1079 CloseHandle(pi.hProcess); | |
1080 CloseHandle(pi.hThread); | |
1081 } else { | |
1082 message = g_win32_error_message(GetLastError()); | |
1083 } | |
1084 | |
1049 gaim_debug_info("pounce", | 1085 gaim_debug_info("pounce", |
1050 "Pounce execute command called for: %s\n", | 1086 "Pounce execute command called for: " |
1051 command); | 1087 "%s\n%s%s%s", |
1088 command, | |
1089 retval ? "" : "Error: ", | |
1090 retval ? "" : message, | |
1091 retval ? "" : "\n"); | |
1092 g_free(message); | |
1052 #endif /* !_WIN32 */ | 1093 #endif /* !_WIN32 */ |
1053 } | 1094 } |
1054 g_free(localecmd); | |
1055 } | 1095 } |
1056 | 1096 |
1057 if (gaim_pounce_action_is_enabled(pounce, "play-sound")) | 1097 if (gaim_pounce_action_is_enabled(pounce, "play-sound")) |
1058 { | 1098 { |
1059 const char *sound; | 1099 const char *sound; |