Obtain afs status items directly from afs.
[paraslash.git] / command.c
index 1ca54da90191fd270c98b3001d16a4b5f5c04c53..e6a16e53e5f3367cd9b10bf959ace284d8086ebd 100644 (file)
--- a/command.c
+++ b/command.c
@@ -11,6 +11,7 @@
 #include <sys/types.h>
 #include <dirent.h>
 #include <openssl/rc4.h>
+#include <osl.h>
 
 #include "para.h"
 #include "error.h"
@@ -127,8 +128,7 @@ static char *get_status(struct misc_meta_data *nmmd)
                "%s: %li\n" /* offset */
                "%s: %s\n" /* afs mode */
                "%s: %lu.%lu\n" /* stream start */
-               "%s: %lu.%lu\n" /* current server time */
-               "%s", /* afs status info */
+               "%s: %lu.%lu\n", /* current server time */
                status_item_list[SI_FILE_SIZE], nmmd->size / 1024,
                status_item_list[SI_MTIME], mtime,
                status_item_list[SI_STATUS], status,
@@ -142,10 +142,7 @@ static char *get_status(struct misc_meta_data *nmmd)
                        (long unsigned)nmmd->stream_start.tv_usec,
                status_item_list[SI_CURRENT_TIME],
                        (long unsigned)current_time.tv_sec,
-                       (long unsigned)current_time.tv_usec,
-
-               nmmd->afd.verbose_ls_output
-
+                       (long unsigned)current_time.tv_usec
        );
        free(flags);
        free(status);
@@ -304,6 +301,70 @@ int com_version(int fd, int argc, __a_unused char * const * argv)
        );
 }
 
+/**
+ * Write a list of audio-file related status items with empty values.
+ *
+ * This is used by vss when currently no audio file is open.
+ */
+static char *empty_status_items(void)
+{
+       return make_message(
+               "%s: \n" /* path */
+               "%s: \n" /* dirname */
+               "%s: \n" /* basename */
+               "%s: \n" /* score */
+               "%s: \n" /* attributes bitmap */
+               "%s: \n" /* attributes txt */
+               "%s: \n" /* hash */
+               "%s: \n" /* image id */
+               "%s: \n" /* image name */
+               "%s: \n" /* lyrics id */
+               "%s: \n" /* lyrics name */
+               "%s: \n" /* bitrate */
+               "%s: \n" /* format */
+               "%s: \n" /* frequency */
+               "%s: \n" /* channels */
+               "%s: \n" /* duration */
+               "%s: \n" /* seconds total */
+               "%s: \n" /* num played */
+               "%s: \n" /* last played */
+               "%s: \n" /* techinfo */
+               "%s: \n" /* artist */
+               "%s: \n" /* title */
+               "%s: \n" /* year */
+               "%s: \n" /* album */
+               "%s: \n" /* comment */
+               "%s: \n" /* amplification */
+               ,
+               status_item_list[SI_PATH],
+               status_item_list[SI_DIRECTORY],
+               status_item_list[SI_BASENAME],
+               status_item_list[SI_SCORE],
+               status_item_list[SI_ATTRIBUTES_BITMAP],
+               status_item_list[SI_ATTRIBUTES_TXT],
+               status_item_list[SI_HASH],
+               status_item_list[SI_IMAGE_ID],
+               status_item_list[SI_IMAGE_NAME],
+               status_item_list[SI_LYRICS_ID],
+               status_item_list[SI_LYRICS_NAME],
+               status_item_list[SI_BITRATE],
+               status_item_list[SI_FORMAT],
+               status_item_list[SI_FREQUENCY],
+               status_item_list[SI_CHANNELS],
+               status_item_list[SI_DURATION],
+               status_item_list[SI_SECONDS_TOTAL],
+               status_item_list[SI_NUM_PLAYED],
+               status_item_list[SI_LAST_PLAYED],
+               status_item_list[SI_TECHINFO],
+               status_item_list[SI_ARTIST],
+               status_item_list[SI_TITLE],
+               status_item_list[SI_YEAR],
+               status_item_list[SI_ALBUM],
+               status_item_list[SI_COMMENT],
+               status_item_list[SI_AMPLIFICATION]
+       );
+}
+
 /* stat */
 int com_stat(int fd, int argc, char * const * argv)
 {
@@ -325,6 +386,15 @@ int com_stat(int fd, int argc, char * const * argv)
                free(s);
                if (ret < 0)
                        goto out;
+               if (nmmd->vss_status_flags & VSS_NEXT) {
+                       static char *esi;
+                       if (!esi)
+                               esi = empty_status_items();
+                       ret = send_buffer(fd, esi);
+                       if (ret < 0)
+                               goto out;
+               } else
+                       send_afs_status(fd);
                ret = 1;
                if (num > 0 && !--num)
                        goto out;