Add a new 'origin' field to queue entries. This records the origin of
[disorder] / lib / queue.h
index e466c95..7ca9b4f 100644 (file)
@@ -2,22 +2,25 @@
  * This file is part of DisOrder.
  * Copyright (C) 2004-2008 Richard Kettlewell
  *
- * This program is free software; you can redistribute it and/or modify
+ * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
+ * 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
 
@@ -37,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 {
@@ -48,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 */