chiark / gitweb /
Merge playlist support.
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 10 Oct 2009 20:03:23 +0000 (21:03 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sat, 10 Oct 2009 20:03:23 +0000 (21:03 +0100)
16 files changed:
1  2 
clients/disorder.c
disobedience/Makefile.am
disobedience/disobedience.c
disobedience/disobedience.h
disobedience/menu.c
doc/disorder.1.in
doc/disorder_protocol.5.in
lib/Makefile.am
lib/client.c
lib/configuration.c
lib/configuration.h
lib/trackdb.c
python/disorder.py.in
server/dump.c
server/server.c
tests/Makefile.am

@@@ -32,7 -32,7 +32,8 @@@
  #include <unistd.h>
  #include <pcre.h>
  #include <ctype.h>
 +#include <gcrypt.h>
+ #include <langinfo.h>
  
  #include "configuration.h"
  #include "syscalls.h"
@@@ -51,7 -51,7 +52,8 @@@
  #include "vector.h"
  #include "version.h"
  #include "dateparse.h"
 +#include "trackdb.h"
+ #include "inputline.h"
  
  static disorder_client *client;
  
@@@ -28,9 -28,9 +28,9 @@@ disobedience_SOURCES=disobedience.h dis
        choose.c choose-menu.c choose-search.c popup.c misc.c           \
        control.c properties.c menu.c log.c progress.c login.c rtp.c    \
        help.c ../lib/memgc.c settings.c users.c lookup.c choose.h      \
-       popup.h
+       popup.h playlists.c
  disobedience_LDADD=../lib/libdisorder.a $(LIBPCRE) $(LIBGC) $(LIBGCRYPT) \
 -      $(LIBASOUND) $(COREAUDIO) $(LIBDB)
 +      $(LIBASOUND) $(COREAUDIO) $(LIBDB) $(LIBICONV)
  disobedience_LDFLAGS=$(GTK_LIBS)
  
  install-exec-hook:
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc lib/Makefile.am
@@@ -78,12 -79,9 +78,13 @@@ libdisorder_a_SOURCES=charset.c charset
        table.c table.h                                 \
        timeval.h                                       \
        $(TRACKDB) trackdb.h trackdb-int.h              \
+       trackdb-playlists.c                             \
        trackname.c trackorder.c trackname.h            \
        tracksort.c                                     \
 +      uaudio.c uaudio-thread.c uaudio.h uaudio-apis.c \
 +      uaudio-oss.c uaudio-alsa.c                      \
 +      uaudio-coreaudio.c                              \
 +      uaudio-rtp.c uaudio-command.c uaudio-schedule.c \
        url.h url.c                                     \
        user.h user.c                                   \
        unicode.h unicode.c                             \
diff --cc lib/client.c
Simple merge
@@@ -945,8 -949,9 +945,10 @@@ static const struct conf conf[] = 
    { C(nice_speaker),     &type_integer,          validate_any },
    { C(noticed_history),  &type_integer,          validate_positive },
    { C(password),         &type_string,           validate_any },
 +  { C(pause_mode),       &type_string,           validate_pausemode },
    { C(player),           &type_stringlist_accum, validate_player },
+   { C(playlist_lock_timeout), &type_integer,     validate_positive },
+   { C(playlist_max) ,    &type_integer,          validate_positive },
    { C(plugins),          &type_string_accum,     validate_isdir },
    { C(prefsync),         &type_integer,          validate_positive },
    { C(queue_pad),        &type_integer,          validate_positive },
@@@ -182,9 -176,36 +182,15 @@@ struct config 
    /** @brief Sox syntax generation */
    long sox_generation;
  
 -  /** @brief API used to play sound
 -   *
 -   * Choices are @ref BACKEND_ALSA, @ref BACKEND_COMMAND or @ref
 -   * BACKEND_NETWORK.
 -   */
 -  int api;
 +  /** @brief API used to play sound */
 +  const char *api;
  
 -/* These values had better be non-negative */
 -#define BACKEND_ALSA 0                        /**< Use ALSA (Linux only) */
 -#define BACKEND_COMMAND 1             /**< Execute a command */
 -#define BACKEND_NETWORK 2             /**< Transmit RTP  */
 -#define BACKEND_COREAUDIO 3           /**< Use Core Audio (Mac only) */
 -#define BACKEND_OSS 4                 /**< Use OSS */
 -
 -#if HAVE_ALSA_ASOUNDLIB_H
 -# define DEFAULT_BACKEND BACKEND_ALSA
 -#elif HAVE_SYS_SOUNDCARD_H || EMPEG_HOST
 -# define DEFAULT_BACKEND BACKEND_OSS
 -#elif HAVE_COREAUDIO_AUDIOHARDWARE_H
 -# define DEFAULT_BACKEND BACKEND_COREAUDIO
 -#else
 -# error Cannot choose a default backend
 -#endif
 -
+   /** @brief Maximum size of a playlist */
+   long playlist_max;
+   /** @brief Maximum lifetime of a playlist lock */
+   long playlist_lock_timeout;
    /** @brief Home directory for state files */
    const char *home;
  
diff --cc lib/trackdb.c
@@@ -472,7 -479,8 +479,8 @@@ void trackdb_open(int flags) 
    trackdb_noticeddb = open_db("noticed.db",
                               DB_DUPSORT, DB_BTREE, dbflags, 0666);
    trackdb_scheduledb = open_db("schedule.db", 0, DB_HASH, dbflags, 0666);
 -  if(!trackdb_existing_database) {
 +  if(!trackdb_existing_database && !(flags & TRACKDB_READ_ONLY)) {
+   trackdb_playlistsdb = open_db("playlists.db", 0, DB_HASH, dbflags, 0666);
      /* Stash the database version */
      char buf[32];
  
Simple merge
diff --cc server/dump.c
Simple merge
diff --cc server/server.c
@@@ -1314,19 -1358,19 +1367,9 @@@ static int c_userinfo(struct conn *c
  static int c_users(struct conn *c,
                   char attribute((unused)) **vec,
                   int attribute((unused)) nvec) {
-   /* TODO de-dupe with c_tags */
-   char **users = trackdb_listusers();
-   sink_writes(ev_writer_sink(c->w), "253 User list follows\n");
-   while(*users) {
-     sink_printf(ev_writer_sink(c->w), "%s%s\n",
-               **users == '.' ? "." : "", *users);
-     ++users;
-   }
-   sink_writes(ev_writer_sink(c->w), ".\n");
-   return 1;                           /* completed */
+   return list_response(c, "User list follows", trackdb_listusers());
  }
  
 -/** @brief Base64 mapping table for confirmation strings
 - *
 - * This is used with generic_to_base64() and generic_base64().  We cannot use
 - * the MIME table as that contains '+' and '=' which get quoted when
 - * URL-encoding.  (The CGI still does the URL encoding but it is desirable to
 - * avoid it being necessary.)
 - */
 -static const char confirm_base64_table[] =
 -  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789/.*";
 -
  static int c_register(struct conn *c,
                      char **vec,
                      int attribute((unused)) nvec) {
@@@ -26,7 -26,7 +26,7 @@@ disorder_udplog_DEPENDENCIES=../lib/lib
  
  TESTS=cookie.py dbversion.py dump.py files.py play.py queue.py        \
        recode.py search.py user-upgrade.py user.py aliases.py  \
-       schedule.py hashes.py
 -      schedule.py playlists.py
++      schedule.py hashes.py playlists.py
  
  TESTS_ENVIRONMENT=${PYTHON} -u