NEWS update.
[paraslash.git] / playlist_selector.c
index 010c9d21e05a6bbde2092e6433d458d65e7657c7..d1149269b9312e512a5148b034b6c2f0e4704ce8 100644 (file)
@@ -1,30 +1,19 @@
 /*
 /*
- * Copyright (C) 2006 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006-2007 Andre Noll <maan@systemlinux.org>
  *
  *
- *     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
- *     (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.
- *
- *     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, USA.
+ * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
 /** \file playlist_selector.c The playlist audio file selector of paraslash  */
 
 #include "server.h"
  */
 
 /** \file playlist_selector.c The playlist audio file selector of paraslash  */
 
 #include "server.h"
-#include "db.h"
+#include "afs.h"
 #include "error.h"
 #include "net.h"
 #include "string.h"
 #include "ipc.h"
 #include "user_list.h"
 #include "error.h"
 #include "net.h"
 #include "string.h"
 #include "ipc.h"
 #include "user_list.h"
+#include "playlist_selector_command_list.h"
 
 /**
  * structure used for transmission of the playlist
 
 /**
  * structure used for transmission of the playlist
@@ -62,34 +51,8 @@ static unsigned playlist_len, playlist_size, current_playlist_entry;
 static char **playlist;
 static struct audio_file_selector *self;
 
 static char **playlist;
 static struct audio_file_selector *self;
 
-static int com_ppl(int, int, char **);
-static int com_lpl(int, int, char **);
 extern struct misc_meta_data *mmd;
 
 extern struct misc_meta_data *mmd;
 
-/* array of supported commands */
-static struct server_command cmds[] = {
-{
-.name = "ppl",
-.handler = com_ppl,
-.perms = DB_READ,
-.description = "print playlist",
-.synopsis = "ppl",
-.help =
-"Print out the current playlist"
-}, {
-.name = "lpl",
-.handler = com_lpl,
-.perms = DB_WRITE,
-.description = "load playlist",
-.synopsis = "lpl",
-.help =
-"Read a new playlist from stdin. Example:\n"
-"\tfind /audio -name '*.mp3' | para_client lpl"
-}, {
-.name = NULL,
-}
-};
-
 static void playlist_add(char *path)
 {
        if (playlist_len >= playlist_size) {
 static void playlist_add(char *path)
 {
        if (playlist_len >= playlist_size) {
@@ -143,7 +106,7 @@ out:
        return ret;
 }
 
        return ret;
 }
 
-static int com_lpl(int fd, __a_unused int argc, __a_unused char *argv[])
+int com_lpl(int fd, __a_unused int argc, __a_unused char *argv[])
 {
        unsigned loaded = 0;
        size_t bufsize = 4096; /* guess that's enough */
 {
        unsigned loaded = 0;
        size_t bufsize = 4096; /* guess that's enough */
@@ -174,7 +137,7 @@ out:
        return ret;
 }
 
        return ret;
 }
 
-static int com_ppl(int fd, __a_unused int argc, __a_unused char *argv[])
+int com_ppl(int fd, __a_unused int argc, __a_unused char *argv[])
 {
        unsigned i;
 
 {
        unsigned i;
 
@@ -270,7 +233,7 @@ static size_t string_offset(const char *str, size_t max)
        return l - max;
 }
 
        return l - max;
 }
 
-void pls_update_audio_file(char *audio_file)
+static void pls_update_audio_file(char *audio_file)
 {
        unsigned i;
        char *dir = para_dirname(audio_file),
 {
        unsigned i;
        char *dir = para_dirname(audio_file),
@@ -304,25 +267,27 @@ void pls_update_audio_file(char *audio_file)
 /**
  * the init function for the playlist selector
  *
 /**
  * the init function for the playlist selector
  *
- * Init all function pointers of \a db
+ * \param afs pointer to the struct to initialize
+ *
+ * Init all function pointers of \a afs
  *
  * \sa struct audio_file_selector, misc_meta_data::selector_info, mysql.c
  * random_selector.c.
  */
  *
  * \sa struct audio_file_selector, misc_meta_data::selector_info, mysql.c
  * random_selector.c.
  */
-int playlist_selector_init(struct audio_file_selector *db)
+int playlist_selector_init(struct audio_file_selector *afs)
 {
        int ret;
        struct private_pls_data *ppd = NULL;
        void *shm = NULL;
 
 {
        int ret;
        struct private_pls_data *ppd = NULL;
        void *shm = NULL;
 
-       self = db;
-       db->cmd_list = cmds;
-       db->get_audio_file_list = pls_get_audio_file_list;
-       db->shutdown = pls_shutdown;
-       db->post_select = pls_post_select;
-       db->update_audio_file = pls_update_audio_file;
+       self = afs;
+       afs->cmd_list = playlist_selector_cmds;
+       afs->get_audio_file_list = pls_get_audio_file_list;
+       afs->shutdown = pls_shutdown;
+       afs->post_select = pls_post_select;
+       afs->update_audio_file = pls_update_audio_file;
        ppd = para_calloc(sizeof(struct private_pls_data));
        ppd = para_calloc(sizeof(struct private_pls_data));
-       db->private_data = ppd;
+       afs->private_data = ppd;
 
        ppd->client_mutex = -1;
        ppd->server_mutex = -1;
 
        ppd->client_mutex = -1;
        ppd->server_mutex = -1;