Add a new 'origin' field to queue entries. This records the origin of
[disorder] / lib / queue.h
index ad70b34..7ca9b4f 100644 (file)
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-
+/** @file lib/queue.h
+ * @brief Track queues
+ *
+ * Used for the queue, the recently played list and the currently playing
+ * track, both in the server and in clients.
+ */
 #ifndef QUEUE_H
 #define QUEUE_H
 
@@ -35,7 +40,48 @@ enum playing_state {
   playing_unplayed                     /* haven't played this track yet */
 };
 
-extern const char *playing_states[];
+extern const char *const playing_states[];
+
+/** @brief Possible track origins
+ *
+ * This is a newly introduced field.  The aim is ultimately to separate the
+ * concepts of the track origin and its current state.  NB that both are
+ * potentially mutable!
+ */
+enum track_origin {
+  /** @brief Track was picked at random and then adopted by a user
+   *
+   * @c submitter identifies who adopted it.  This isn't implemented
+   * yet.
+   */
+  origin_adopted,
+
+  /** @brief Track was picked by a user
+   *
+   * @c submitter identifies who picked it
+   */
+  origin_picked,
+
+  /** @brief Track was picked at random
+   *
+   * @c submitter will be NULL
+   */
+  origin_random,
+
+  /** @brief Track was scheduled by a user
+   *
+   * @c submitter identifies who picked it
+   */
+  origin_scheduled,
+
+  /** @brief Track is a scratch
+   *
+   * @c submitter identifies who did the scratching
+   */
+  origin_scratch
+};
+
+extern const char *const track_origins[];
 
 /* queue entries form a circular doubly-linked list */
 struct queue_entry {
@@ -46,6 +92,7 @@ struct queue_entry {
   time_t when;                         /* time submitted */
   time_t played;                       /* when played */
   enum playing_state state;            /* state */
+  enum track_origin origin;             /* where track came from */
   long wstat;                          /* wait status */
   const char *scratched;               /* scratched by */
   const char *id;                      /* queue entry ID */