/* make sure our script gets called with the right parameters */ static void test_pb_utils_install_plugins_do_callout (const gchar * const *details, GstInstallPluginsContext * ctx, const gchar * script, GstInstallPluginsReturn expected_result) { #ifdef G_OS_UNIX GstInstallPluginsReturn ret; GError *err = NULL; gchar *path; path = g_strdup_printf ("%s/gst-plugins-base-unit-test-helper.%s.%lu", g_get_tmp_dir (), (g_get_user_name ())? g_get_user_name () : "nobody", (gulong) getpid ()); if (!g_file_set_contents (path, script, -1, &err)) { GST_DEBUG ("Failed to write test script to %s: %s", path, err->message); g_error_free (err); goto done; } if (chmod (path, S_IRUSR | S_IWUSR | S_IXUSR) != 0) { GST_DEBUG ("Could not set mode u+rwx on '%s'", path); goto done; } /* test gst_install_plugins_supported() I */ g_setenv ("GST_INSTALL_PLUGINS_HELPER", "/i/do/not/ex.ist!", 1); fail_if (gst_install_plugins_supported ()); GST_LOG ("setting GST_INSTALL_PLUGINS_HELPER to '%s'", path); g_setenv ("GST_INSTALL_PLUGINS_HELPER", path, 1); /* test gst_install_plugins_supported() II */ fail_unless (gst_install_plugins_supported ()); /* test sync callout */ ret = gst_install_plugins_sync (details, ctx); fail_unless (ret == GST_INSTALL_PLUGINS_HELPER_MISSING || ret == expected_result, "gst_install_plugins_sync() failed with unexpected ret %d, which is " "neither HELPER_MISSING nor %d", ret, expected_result); /* test async callout */ marker = -333; ret = gst_install_plugins_async (details, ctx, result_cb, (gpointer) & marker); fail_unless (ret == GST_INSTALL_PLUGINS_HELPER_MISSING || ret == GST_INSTALL_PLUGINS_STARTED_OK, "gst_install_plugins_async() failed with unexpected ret %d", ret); if (ret == GST_INSTALL_PLUGINS_STARTED_OK) { while (marker == -333) { g_usleep (500); g_main_context_iteration (NULL, FALSE); } /* and check that the callback was called with the expected code */ fail_unless_equals_int (marker, expected_result); } done: unlink (path); g_free (path); #endif /* G_OS_UNIX */ }
static void start_next_batch (RBTrackTransferQueue *queue) { int count; int total; gboolean can_continue; GtkWidget *dialog; GtkWindow *window; GList *profiles = NULL; char *message; if (queue->priv->current != NULL) { return; } queue->priv->current = RB_TRACK_TRANSFER_BATCH (g_queue_pop_head (queue->priv->batch_queue)); g_object_notify (G_OBJECT (queue), "batch"); if (queue->priv->current == NULL) { /* indicate to anyone watching that we're not doing anything */ g_signal_emit (queue, signals[TRANSFER_PROGRESS], 0, 0, 0, 0.0, 0); return; } queue->priv->overwrite_decision = OVERWRITE_PROMPT; g_object_get (queue->priv->current, "total-entries", &total, NULL); count = 0; can_continue = rb_track_transfer_batch_check_profiles (queue->priv->current, &profiles, &count); if (can_continue && count == 0 && profiles == NULL) { /* no problems, go ahead */ actually_start_batch (queue); return; } if (profiles == NULL) { const char *str; str = ngettext ("%d file cannot be transferred as it must be converted into " "a format supported by the target device but no suitable " "encoding profiles are available", "%d files cannot be transferred as they must be converted into " "a format supported by the target device but no suitable " "encoding profiles are available", count); message = g_strdup_printf (str, count); } else { GPtrArray *descriptions; GstEncodingTarget *target; char *plugins; gboolean is_library; descriptions = get_missing_plugin_strings (profiles, TRUE); plugins = g_strjoinv ("\n", (char **)descriptions->pdata); /* this is a tiny bit hackish */ g_object_get (queue->priv->current, "encoding-target", &target, NULL); is_library = (g_strcmp0 (gst_encoding_target_get_name (target), "rhythmbox-library") == 0); gst_encoding_target_unref (target); if (is_library) { /* XXX should provide the option of picking a different format? */ message = g_strdup_printf (_("Additional software is required to encode media " "in your preferred format:\n%s"), plugins); } else { const char *str; str = ngettext ("Additional software is required to convert %d file " "into a format supported by the target device:\n%s", "Additional software is required to convert %d files " "into a format supported by the target device:\n%s", count); message = g_strdup_printf (str, count, plugins); } g_free (plugins); g_ptr_array_free (descriptions, TRUE); } g_object_get (queue->priv->shell, "window", &window, NULL); dialog = rb_alert_dialog_new (window, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE, _("Unable to transfer tracks"), message); g_object_unref (window); g_free (message); gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Cancel the transfer"), GTK_RESPONSE_CANCEL); if (can_continue) { gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Skip these files"), GTK_RESPONSE_YES); } if (profiles != NULL && gst_install_plugins_supported ()) { gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Install"), GTK_RESPONSE_ACCEPT); } rb_alert_dialog_set_details_label (RB_ALERT_DIALOG (dialog), NULL); g_signal_connect_object (dialog, "response", G_CALLBACK (missing_encoder_response_cb), queue, 0); gtk_widget_show (dialog); if (profiles != NULL) { g_list_free (profiles); } }