X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/599f5a8b53fc39cc7f1d1fe24bb67b4f55041ab1..3035257f2c6be10a639ee4bb4b343831763da02c:/disobedience/choose.c diff --git a/disobedience/choose.c b/disobedience/choose.c index 6658a45..bfeae10 100644 --- a/disobedience/choose.c +++ b/disobedience/choose.c @@ -215,7 +215,7 @@ static struct choosenode *newnode(struct choosenode *parent, static void fill_root_node(struct choosenode *cn); static void fill_directory_node(struct choosenode *cn); static void got_files(void *v, int nvec, char **vec); -static void got_resolved_file(void *v, const char *track); +static void got_resolved_file(void *v, const char *error, const char *track); static void got_dirs(void *v, int nvec, char **vec); static void expand_node(struct choosenode *cn, int contingent); @@ -429,14 +429,13 @@ static void got_files(void *v, int nvec, char **vec) { int n; D(("got_files %d files for %s %s", nvec, cn->path, cnflags(cn))); - /* Complicated by the need to resolve aliases. We can save a bit of effort - * by re-using cbd though. */ + /* Complicated by the need to resolve aliases. */ cn->flags &= ~CN_GETTING_FILES; --gets_in_flight; if((cn->pending = nvec)) { cn->flags |= CN_RESOLVING_FILES; for(n = 0; n < nvec; ++n) { - disorder_eclient_resolve(client, got_resolved_file, vec[n], cbd); + disorder_eclient_resolve(client, got_resolved_file, vec[n], cn); ++gets_in_flight; } } @@ -449,23 +448,26 @@ static void got_files(void *v, int nvec, char **vec) { } /** @brief Called with an alias resolved filename */ -static void got_resolved_file(void *v, const char *track) { - struct callbackdata *cbd = v; - struct choosenode *cn = cbd->u.choosenode, *file_cn; - - D(("resolved %s %s %d left", cn->path, cnflags(cn), cn->pending - 1)); - /* TODO as below */ - file_cn = newnode(cn, track, - trackname_transform("track", track, "display"), - trackname_transform("track", track, "sort"), - 0/*flags*/, 0/*fill*/); - --gets_in_flight; - /* Only bother updating when we've got the lot */ - if(--cn->pending == 0) { - cn->flags &= ~CN_RESOLVING_FILES; - updated_node(cn, gets_in_flight == 0, "got_resolved_file"); - if(!(cn->flags & CN_GETTING_ANY)) - filled(cn); +static void got_resolved_file(void *v, const char *error, const char *track) { + struct choosenode *const cn = v, *file_cn; + + if(error) { + popup_protocol_error(0, error); + } else { + D(("resolved %s %s %d left", cn->path, cnflags(cn), cn->pending - 1)); + /* TODO as below */ + file_cn = newnode(cn, track, + trackname_transform("track", track, "display"), + trackname_transform("track", track, "sort"), + 0/*flags*/, 0/*fill*/); + --gets_in_flight; + /* Only bother updating when we've got the lot */ + if(--cn->pending == 0) { + cn->flags &= ~CN_RESOLVING_FILES; + updated_node(cn, gets_in_flight == 0, "got_resolved_file"); + if(!(cn->flags & CN_GETTING_ANY)) + filled(cn); + } } } @@ -1086,6 +1088,13 @@ static void clear_selection(struct choosenode *cn) { /* User actions ------------------------------------------------------------ */ +/** @brief Called when disorder_eclient_play completes */ +void play_completed(void attribute((unused)) *v, + const char *error) { + if(error) + popup_protocol_error(0, error); +} + /** @brief Clicked on something * * This implements playing, all the modifiers for selection, etc. @@ -1160,7 +1169,7 @@ static void clicked_choosenode(GtkWidget attribute((unused)) *widget, clear_selection(root); set_selection(cn, 1); gtk_label_set_text(GTK_LABEL(report_label), "adding track to queue"); - disorder_eclient_play(client, cn->path, 0, 0); + disorder_eclient_play(client, cn->path, play_completed, 0); last_click = 0; } } else if(event->type == GDK_BUTTON_PRESS @@ -1236,7 +1245,7 @@ static void activate_track_play(GtkMenuItem attribute((unused)) *menuitem, gtk_label_set_text(GTK_LABEL(report_label), "adding track to queue"); for(n = 0; tracks[n]; ++n) - disorder_eclient_play(client, tracks[n], 0, 0); + disorder_eclient_play(client, tracks[n], play_completed, 0); } /** @brief Called when the menu's properties option is activated */ @@ -1284,7 +1293,7 @@ static void play_dir(struct choosenode *cn, gtk_label_set_text(GTK_LABEL(report_label), "adding track to queue"); for(n = 0; n < ntracks; ++n) - disorder_eclient_play(client, tracks[n], 0, 0); + disorder_eclient_play(client, tracks[n], play_completed, 0); } static void properties_dir(struct choosenode *cn,