static void search_complete_cb (OlLyricSourceSearchTask *task, enum OlLyricSourceStatus status, GList *results, gpointer userdata) { printf ("search complete: "); print_status (status); ol_test_expect (status == (gsize)userdata); if (status == OL_LYRIC_SOURCE_STATUS_SUCCESS) { if (results) { test_download (OL_LYRIC_SOURCE_CANDIDATE (results->data)); test_download_cancel (OL_LYRIC_SOURCE_CANDIDATE (results->data)); } for (; results; results = results->next) { OlLyricSourceCandidate *candidate; candidate = OL_LYRIC_SOURCE_CANDIDATE (results->data); printf ("(%s)%s - %s - %s\n", ol_lyric_source_candidate_get_sourceid (candidate), ol_lyric_source_candidate_get_title (candidate), ol_lyric_source_candidate_get_artist (candidate), ol_lyric_source_candidate_get_album (candidate)); } } task_cnt--; check_quit (); }
OlLyricSourceDownloadTask * ol_lyric_source_download (OlLyricSource *source, OlLyricSourceCandidate *candidate) { ol_assert_ret (OL_IS_LYRIC_SOURCE (source), NULL); ol_assert_ret (OL_IS_LYRIC_SOURCE_CANDIDATE (candidate), NULL); OlLyricSourceDownloadTask *task = NULL; GVariant *ret = NULL; GError *error = NULL; ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (source), "Download", g_variant_new ("(sv)", ol_lyric_source_candidate_get_sourceid (candidate), ol_lyric_source_candidate_get_downloadinfo (candidate)), G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, /* timeout */ NULL, /* cancellable */ &error); if (ret) { OlLyricSourcePrivate *priv; priv = OL_LYRIC_SOURCE_GET_PRIVATE (source); int taskid = 0; g_variant_get (ret, "(i)", &taskid); task = ol_lyric_source_download_task_new (source, taskid); g_hash_table_insert (priv->download_tasks, GINT_TO_POINTER (taskid), task); g_variant_unref (ret); } else { ol_errorf ("Fail to call download: %s\n", error->message); g_error_free (error); } return task; }