| 1 | /* |
| 2 | * This file is part of DisOrder. |
| 3 | * Copyright (C) 2004, 2005, 2006, 2007 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 SERVER_QUEUE_H |
| 22 | #define SERVER_QUEUE_H |
| 23 | |
| 24 | extern struct queue_entry qhead; |
| 25 | /* queue of things yet to be played. the head will be played |
| 26 | * soonest. */ |
| 27 | |
| 28 | extern struct queue_entry phead; |
| 29 | /* things that have been played in the past. the head is the oldest. */ |
| 30 | |
| 31 | void queue_read(void); |
| 32 | /* read the queue in. Calls @fatal@ on error. */ |
| 33 | |
| 34 | void queue_write(void); |
| 35 | /* write the queue out. Calls @fatal@ on error. */ |
| 36 | |
| 37 | void recent_read(void); |
| 38 | /* read the recently played list in. Calls @fatal@ on error. */ |
| 39 | |
| 40 | void recent_write(void); |
| 41 | /* write the recently played list out. Calls @fatal@ on error. */ |
| 42 | |
| 43 | struct queue_entry *queue_add(const char *track, const char *submitter, |
| 44 | int where); |
| 45 | #define WHERE_START 0 /* Add to head of queue */ |
| 46 | #define WHERE_END 1 /* Add to end of queue */ |
| 47 | #define WHERE_BEFORE_RANDOM 2 /* End, or before random track */ |
| 48 | /* add an entry to the queue. Return a pointer to the new entry. */ |
| 49 | |
| 50 | void queue_remove(struct queue_entry *q, const char *who); |
| 51 | /* remove an from the queue */ |
| 52 | |
| 53 | struct queue_entry *queue_find(const char *key); |
| 54 | /* find a track in the queue by name or ID */ |
| 55 | |
| 56 | void queue_played(struct queue_entry *q); |
| 57 | /* add @q@ to the played list */ |
| 58 | |
| 59 | int queue_move(struct queue_entry *q, int delta, const char *who); |
| 60 | /* move element @q@ in the queue towards the front (@delta@ > 0) or towards the |
| 61 | * back (@delta@ < 0). The return value is the leftover delta once we've hit |
| 62 | * the end in whichever direction we were going. */ |
| 63 | |
| 64 | void queue_moveafter(struct queue_entry *target, |
| 65 | int nqs, struct queue_entry **qs, const char *who); |
| 66 | /* Move all the elements QS to just after TARGET, or to the head if |
| 67 | * TARGET=0. */ |
| 68 | |
| 69 | void queue_fix_sofar(struct queue_entry *q); |
| 70 | /* Fix up the sofar field for standalone players */ |
| 71 | |
| 72 | #endif /* SERVER_QUEUE_H */ |
| 73 | |
| 74 | |
| 75 | /* |
| 76 | Local Variables: |
| 77 | c-basic-offset:2 |
| 78 | comment-column:40 |
| 79 | fill-column:79 |
| 80 | indent-tabs-mode:nil |
| 81 | End: |
| 82 | */ |