static void * pidgin_notify_uri(const char *uri) { #ifndef _WIN32 char *escaped = g_shell_quote(uri); char *command = NULL; char *remote_command = NULL; const char *web_browser; int place; web_browser = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/browsers/browser"); place = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/browsers/place"); /* if they are running gnome, use the gnome web browser */ if (purple_running_gnome() == TRUE) { char *tmp = g_find_program_in_path("xdg-open"); if (tmp == NULL) command = g_strdup_printf("gnome-open %s", escaped); else command = g_strdup_printf("xdg-open %s", escaped); g_free(tmp); } else if (purple_running_osx() == TRUE) { command = g_strdup_printf("open %s", escaped); } else if (!strcmp(web_browser, "epiphany") || !strcmp(web_browser, "galeon")) { if (place == PIDGIN_BROWSER_NEW_WINDOW) command = g_strdup_printf("%s -w %s", web_browser, escaped); else if (place == PIDGIN_BROWSER_NEW_TAB) command = g_strdup_printf("%s -n %s", web_browser, escaped); else command = g_strdup_printf("%s %s", web_browser, escaped); } else if (!strcmp(web_browser, "xdg-open")) { command = g_strdup_printf("xdg-open %s", escaped); } else if (!strcmp(web_browser, "gnome-open")) { command = g_strdup_printf("gnome-open %s", escaped); } else if (!strcmp(web_browser, "kfmclient")) { command = g_strdup_printf("kfmclient openURL %s", escaped); /* * Does Konqueror have options to open in new tab * and/or current window? */ } else if (!strcmp(web_browser, "mozilla") || !strcmp(web_browser, "mozilla-firebird") || !strcmp(web_browser, "firefox") || !strcmp(web_browser, "seamonkey")) { char *args = ""; command = g_strdup_printf("%s %s", web_browser, escaped); /* * Firefox 0.9 and higher require a "-a firefox" option when * using -remote commands. This breaks older versions of * mozilla. So we include this other handly little string * when calling firefox. If the API for remote calls changes * any more in firefox then firefox should probably be split * apart from mozilla-firebird and mozilla... but this is good * for now. */ if (!strcmp(web_browser, "firefox")) args = "-a firefox"; if (place == PIDGIN_BROWSER_NEW_WINDOW) remote_command = g_strdup_printf("%s %s -remote " "openURL(%s,new-window)", web_browser, args, escaped); else if (place == PIDGIN_BROWSER_NEW_TAB) remote_command = g_strdup_printf("%s %s -remote " "openURL(%s,new-tab)", web_browser, args, escaped); else if (place == PIDGIN_BROWSER_CURRENT) remote_command = g_strdup_printf("%s %s -remote " "openURL(%s)", web_browser, args, escaped); } else if (!strcmp(web_browser, "netscape")) { command = g_strdup_printf("netscape %s", escaped); if (place == PIDGIN_BROWSER_NEW_WINDOW) { remote_command = g_strdup_printf("netscape -remote " "openURL(%s,new-window)", escaped); } else if (place == PIDGIN_BROWSER_CURRENT) { remote_command = g_strdup_printf("netscape -remote " "openURL(%s)", escaped); } } else if (!strcmp(web_browser, "opera")) { if (place == PIDGIN_BROWSER_NEW_WINDOW) command = g_strdup_printf("opera -newwindow %s", escaped); else if (place == PIDGIN_BROWSER_NEW_TAB) command = g_strdup_printf("opera -newpage %s", escaped); else if (place == PIDGIN_BROWSER_CURRENT) { remote_command = g_strdup_printf("opera -remote " "openURL(%s)", escaped); command = g_strdup_printf("opera %s", escaped); } else command = g_strdup_printf("opera %s", escaped); } else if (!strcmp(web_browser, "custom")) { const char *web_command; web_command = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/browsers/command"); if (web_command == NULL || *web_command == '\0') { purple_notify_error(NULL, NULL, _("Unable to open URL"), _("The 'Manual' browser command has been " "chosen, but no command has been set.")); return NULL; } if (strstr(web_command, "%s")) command = purple_strreplace(web_command, "%s", escaped); else { /* * There is no "%s" in the browser command. Assume the user * wanted the URL tacked on to the end of the command. */ command = g_strdup_printf("%s %s", web_command, escaped); } } g_free(escaped); if (remote_command != NULL) { /* try the remote command first */ if (uri_command(remote_command, TRUE) != 0) uri_command(command, FALSE); g_free(remote_command); } else uri_command(command, FALSE); g_free(command); #else /* !_WIN32 */ winpidgin_notify_uri(uri); #endif /* !_WIN32 */ return NULL; }
static void finch_sound_play_file(const char *filename) { const char *method; #ifdef USE_GSTREAMER float volume; char *uri; GstElement *sink = NULL; GstElement *play = NULL; GstBus *bus = NULL; #endif if (purple_prefs_get_bool(make_pref("/mute"))) return; method = purple_prefs_get_string(make_pref("/method")); if (!strcmp(method, "nosound")) { return; } else if (!strcmp(method, "beep")) { beep(); return; } if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { purple_debug_error("gntsound", "sound file (%s) does not exist.\n", filename); return; } #ifndef _WIN32 if (!strcmp(method, "custom")) { const char *sound_cmd; char *command; char *esc_filename; GError *error = NULL; sound_cmd = purple_prefs_get_path(make_pref("/command")); if (!sound_cmd || *sound_cmd == '\0') { purple_debug_error("gntsound", "'Command' sound method has been chosen, " "but no command has been set."); return; } esc_filename = g_shell_quote(filename); if (strstr(sound_cmd, "%s")) command = purple_strreplace(sound_cmd, "%s", esc_filename); else command = g_strdup_printf("%s %s", sound_cmd, esc_filename); if (!g_spawn_command_line_async(command, &error)) { purple_debug_error("gntsound", "sound command could not be launched: %s\n", error->message); g_error_free(error); } g_free(esc_filename); g_free(command); return; } #ifdef USE_GSTREAMER if (gst_init_failed) /* Perhaps do beep instead? */ return; volume = (float)(CLAMP(purple_prefs_get_int(make_pref("/volume")), 0, 100)) / 50; if (!strcmp(method, "automatic")) { if (purple_running_gnome()) { sink = gst_element_factory_make("gconfaudiosink", "sink"); } if (!sink) sink = gst_element_factory_make("autoaudiosink", "sink"); if (!sink) { purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); return; } } else if (!strcmp(method, "esd")) { sink = gst_element_factory_make("esdsink", "sink"); if (!sink) { purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); return; } } else if (!strcmp(method, "alsa")) { sink = gst_element_factory_make("alsasink", "sink"); if (!sink) { purple_debug_error("sound", "Unable to create GStreamer audiosink.\n"); return; } } else { purple_debug_error("sound", "Unknown sound method '%s'\n", method); return; } play = gst_element_factory_make("playbin", "play"); if (play == NULL) { return; } uri = g_strdup_printf("file://%s", filename); g_object_set(G_OBJECT(play), "uri", uri, "volume", volume, "audio-sink", sink, NULL); bus = gst_pipeline_get_bus(GST_PIPELINE(play)); gst_bus_add_watch(bus, bus_call, play); gst_element_set_state(play, GST_STATE_PLAYING); gst_object_unref(bus); g_free(uri); #else /* USE_GSTREAMER */ beep(); return; #endif /* USE_GSTREAMER */ #else /* _WIN32 */ purple_debug_info("sound", "Playing %s\n", filename); { 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); } #endif /* _WIN32 */ }
static void open_button_cb(GtkButton *button, PidginXferDialog *dialog) { #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); 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) ShellExecuteA(NULL, NULL, l_filename, NULL, NULL, SW_SHOW); g_free(l_filename); } if (code == SE_ERR_ASSOCINCOMPLETE || code == SE_ERR_NOASSOC) { purple_notify_error(dialog, NULL, _("There is no application configured to open this type of file."), NULL); } else if (code < 32) { purple_notify_error(dialog, NULL, _("An error occurred while opening the file."), NULL); purple_debug_warning("ft", "filename: %s; code: %d\n", purple_xfer_get_local_filename(dialog->selected_xfer), code); } #else const char *filename = purple_xfer_get_local_filename(dialog->selected_xfer); char *command = NULL; char *tmp = NULL; GError *error = NULL; if (purple_running_gnome()) { char *escaped = g_shell_quote(filename); command = g_strdup_printf("gnome-open %s", escaped); g_free(escaped); } else if (purple_running_kde()) { char *escaped = g_shell_quote(filename); if (purple_str_has_suffix(filename, ".desktop")) command = g_strdup_printf("kfmclient openURL %s 'text/plain'", escaped); else command = g_strdup_printf("kfmclient openURL %s", escaped); g_free(escaped); } else { purple_notify_uri(NULL, filename); return; } if (purple_program_is_valid(command)) { gint exit_status; if (!g_spawn_command_line_sync(command, NULL, NULL, &exit_status, &error)) { tmp = g_strdup_printf(_("Error launching %s: %s"), purple_xfer_get_local_filename(dialog->selected_xfer), error->message); purple_notify_error(dialog, NULL, _("Unable to open file."), tmp); g_free(tmp); g_error_free(error); } if (exit_status != 0) { char *primary = g_strdup_printf(_("Error running %s"), command); char *secondary = g_strdup_printf(_("Process returned error code %d"), exit_status); purple_notify_error(dialog, NULL, primary, secondary); g_free(tmp); } } #endif }