chiark / gitweb /
queue() now uses the resolved name if available. This is looked up in
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 14 Jun 2008 17:27:14 +0000 (18:27 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sat, 14 Jun 2008 17:27:14 +0000 (18:27 +0100)
the usual lookup.c way, so it raises a lookup-completed event on
completion and therefore causes the choose screen to be updated using
the correct name for the track.

disobedience/disobedience.h
disobedience/lookup.c
disobedience/queue.c

index 33cd9ad..f709a27 100644 (file)
@@ -216,6 +216,7 @@ const char *namepart(const char *track,
                      const char *context,
                      const char *part);
 long namepart_length(const char *track);
+char *namepart_resolve(const char *track);
 
 void namepart_update(const char *track,
                      const char *context,
index 2052b30..51c06bf 100644 (file)
@@ -71,7 +71,6 @@ static void namepart_fill(const char *track,
                           const char *part,
                           const char *key) {
   D(("namepart_fill %s %s %s %s", track, context, part, key));
-  /* We limit the total number of lookups in flight */
   ++namepart_lookups_outstanding;
   D(("namepart_lookups_outstanding -> %d\n", namepart_lookups_outstanding));
   disorder_eclient_namepart(client, namepart_completed,
@@ -137,6 +136,25 @@ long namepart_length(const char *track) {
   return -1;
 }
 
+/** @brief Resolve a track name
+ *
+ * Returns the supplied track name if it doesn't have the answer yet.
+ */
+char *namepart_resolve(const char *track) {
+  char *key;
+
+  byte_xasprintf(&key, "resolve track=%s", track);
+  const char *value = cache_get(&cachetype_string, key);
+  if(!value) {
+    D(("deferring..."));
+    ++namepart_lookups_outstanding;
+    D(("namepart_lookups_outstanding -> %d\n", namepart_lookups_outstanding));
+    disorder_eclient_resolve(client, namepart_completed,
+                             track, (void *)key);
+    value = track;
+  }
+  return xstrdup(value);
+}
 
 /*
 Local Variables:
index fe9e707..f298b1f 100644 (file)
@@ -345,6 +345,8 @@ int queued(const char *track) {
   struct queue_entry *q;
 
   D(("queued %s", track));
+  /* Queue will contain resolved name */
+  track = namepart_resolve(track);
   for(q = ql_queue.q; q; q = q->next)
     if(!strcmp(q->track, track))
       return 1;