chiark / gitweb /
Grey out edit playlists menu item if server does not appear to support
[disorder] / lib / queue.h
1 /*
2  * This file is part of DisOrder.
3  * Copyright (C) 2004-2008 Richard Kettlewell
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA
19  */
20
21 #ifndef QUEUE_H
22 #define QUEUE_H
23
24 #include <time.h>
25
26
27 enum playing_state {
28   playing_failed,                       /* failed to play */
29   playing_isscratch,                    /* this is a scratch track */
30   playing_no_player,                    /* couldn't find a player */
31   playing_ok,                           /* played OK */
32   playing_paused,                       /* started but paused */
33   playing_quitting,                     /* interrupt because server quit */
34   playing_random,                       /* unplayed randomly chosen track */
35   playing_scratched,                    /* was scratched */
36   playing_started,                      /* started to play */
37   playing_unplayed                      /* haven't played this track yet */
38 };
39
40 extern const char *playing_states[];
41
42 /* queue entries form a circular doubly-linked list */
43 struct queue_entry {
44   struct queue_entry *next;             /* next entry */
45   struct queue_entry *prev;             /* previous entry */
46   const char *track;                    /* path to track */
47   const char *submitter;                /* name of submitter */
48   time_t when;                          /* time submitted */
49   time_t played;                        /* when played */
50   enum playing_state state;             /* state */
51   long wstat;                           /* wait status */
52   const char *scratched;                /* scratched by */
53   const char *id;                       /* queue entry ID */
54   time_t expected;                      /* expected started time */
55   /* for playing or soon-to-be-played tracks only: */
56   unsigned long type;                   /* type word from plugin */
57   const struct plugin *pl;              /* plugin that's playing this track */
58   void *data;                           /* player data */
59   long sofar;                           /* how much played so far */
60   int prepared;                         /* true when connected to speaker */
61   /* For DISORDER_PLAYER_PAUSES only: */
62   time_t lastpaused, lastresumed;       /* when last paused/resumed, or 0 */
63   long uptopause;                       /* how much played up to last pause */
64   /* For Disobedience */
65   struct queuelike *ql;                 /* owning queue */
66 };
67
68 void queue_insert_entry(struct queue_entry *b, struct queue_entry *n);
69 void queue_delete_entry(struct queue_entry *node);
70
71 int queue_unmarshall(struct queue_entry *q, const char *s,
72                      void (*error_handler)(const char *, void *),
73                      void *u);
74 /* unmarshall UTF-8 string @s@ into @q@ */
75
76 int queue_unmarshall_vec(struct queue_entry *q, int nvec, char **vec,
77                      void (*error_handler)(const char *, void *),
78                      void *u);
79 /* unmarshall pre-split string @vec@ into @q@ */
80
81 char *queue_marshall(const struct queue_entry *q);
82 /* marshall @q@ into a UTF-8 string */
83
84 #endif /* QUEUE_H */
85
86 /*
87 Local Variables:
88 c-basic-offset:2
89 comment-column:40
90 fill-column:79
91 End:
92 */