changeset 2585:c2b49ba4be45 trunk

[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
author nhjm449
date Mon, 26 Feb 2007 19:06:45 -0800
parents ea937605a48a
children 72ec866d6b81
files ChangeLog src/audacious/build_stamp.c src/audacious/controlsocket.c src/audacious/controlsocket.h src/audtool/audtool.c src/audtool/audtool.h src/libaudacious/beepctrl.c src/libaudacious/beepctrl.h
diffstat 8 files changed, 172 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Feb 26 10:30:06 2007 -0800
+++ b/ChangeLog	Mon Feb 26 19:06:45 2007 -0800
@@ -1,3 +1,12 @@
+2007-02-26 18:30:06 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
+  revision [4178]
+  - add explicit hints to show bit rate, sampling frequency and audio mode.
+  
+  trunk/skins/Classic/skin.hints |    4 ++++
+  trunk/skins/Default/skin.hints |    3 +++
+  2 files changed, 7 insertions(+)
+
+
 2007-02-26 14:14:54 +0000  Goetz Waschk <waschk@mandriva.org>
   revision [4176]
   fix wrong library symlink, there was a hardcoded libaudacious.so.4.0.0
--- a/src/audacious/build_stamp.c	Mon Feb 26 10:30:06 2007 -0800
+++ b/src/audacious/build_stamp.c	Mon Feb 26 19:06:45 2007 -0800
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070226-4176";
+const gchar *svn_stamp = "20070226-4178";
--- a/src/audacious/controlsocket.c	Mon Feb 26 10:30:06 2007 -0800
+++ b/src/audacious/controlsocket.c	Mon Feb 26 19:06:45 2007 -0800
@@ -55,6 +55,7 @@
 #include "ui_preferences.h"
 #include "libaudacious/beepctrl.h"
 #include "memorypool.h"
+#include "titlestring.h"
 #include "ui_jumptotrack.h"
 
 #define CTRLSOCKET_BACKLOG        100
@@ -561,6 +562,50 @@
             GDK_THREADS_LEAVE();
             ctrl_ack_packet(pkt);
             break;
+        case CMD_PLAYLIST_GET_TUPLE_DATA:
+            if (pkt->data) {
+                gint pos = *(gint *) pkt->data;
+                gchar *ptr = pkt->data;
+                ptr += sizeof(gint);
+                TitleInput *tuple = playlist_get_tuple(playlist_get_active(), pos);
+                if (!tuple) {
+                    ctrl_ack_packet(pkt);
+                    break;
+                }
+                if (!strcasecmp(ptr, "performer")) {
+                    ctrl_write_string(pkt->fd, tuple->performer);
+                } else if (!strcasecmp(ptr, "album_name")) {
+                    ctrl_write_string(pkt->fd, tuple->album_name);
+                } else if (!strcasecmp(ptr, "track_name")) {
+                    ctrl_write_string(pkt->fd, tuple->track_name);
+                } else if (!strcasecmp(ptr, "track_number")) {
+                    ctrl_write_gint(pkt->fd, tuple->track_number);
+                } else if (!strcasecmp(ptr, "year")) {
+                    ctrl_write_gint(pkt->fd, tuple->year);
+                } else if (!strcasecmp(ptr, "date")) {
+                    ctrl_write_string(pkt->fd, tuple->date);
+                } else if (!strcasecmp(ptr, "genre")) {
+                    ctrl_write_string(pkt->fd, tuple->genre);
+                } else if (!strcasecmp(ptr, "comment")) {
+                    ctrl_write_string(pkt->fd, tuple->comment);
+                } else if (!strcasecmp(ptr, "file_name")) {
+                    ctrl_write_string(pkt->fd, tuple->file_name);
+                } else if (!strcasecmp(ptr, "file_ext")) {
+                    ctrl_write_string(pkt->fd, g_strdup(tuple->file_ext));
+                } else if (!strcasecmp(ptr, "file_path")) {
+                    ctrl_write_string(pkt->fd, tuple->file_path);
+                } else if (!strcasecmp(ptr, "length")) {
+                    ctrl_write_gint(pkt->fd, tuple->length);
+                } else if (!strcasecmp(ptr, "album_name")) {
+                    ctrl_write_string(pkt->fd, tuple->album_name);
+                } else if (!strcasecmp(ptr, "formatter")) {
+                    ctrl_write_string(pkt->fd, tuple->formatter);
+                } else if (!strcasecmp(ptr, "mtime")) {
+                    ctrl_write_gint(pkt->fd, tuple->mtime);
+                }
+            }
+            ctrl_ack_packet(pkt);
+            break;
         case CMD_IS_MAIN_WIN:
             ctrl_write_gboolean(pkt->fd, cfg.player_visible);
             ctrl_ack_packet(pkt);
--- a/src/audacious/controlsocket.h	Mon Feb 26 10:30:06 2007 -0800
+++ b/src/audacious/controlsocket.h	Mon Feb 26 19:06:45 2007 -0800
@@ -53,7 +53,7 @@
     CMD_ACTIVATE, CMD_SHOW_JTF_BOX,
     CMD_PLAYQUEUE_CLEAR, CMD_PLAYQUEUE_IS_QUEUED,
     CMD_PLAYQUEUE_GET_POS, CMD_PLAYQUEUE_GET_QPOS,
-    CMD_PLAYLIST_ENQUEUE_TO_TEMP
+    CMD_PLAYLIST_ENQUEUE_TO_TEMP, CMD_PLAYLIST_GET_TUPLE_DATA
 };
 
 
--- a/src/audtool/audtool.c	Mon Feb 26 10:30:06 2007 -0800
+++ b/src/audtool/audtool.c	Mon Feb 26 19:06:45 2007 -0800
@@ -38,6 +38,7 @@
 	{"current-song-frequency", get_current_song_frequency, "returns current song frequency in hertz"},
 	{"current-song-frequency-khz", get_current_song_frequency_khz, "returns current song frequency in kilohertz"},
 	{"current-song-channels", get_current_song_channels, "returns current song channels"},
+	{"current-song-tuple-data", get_current_song_tuple_field_data, "returns the value of a tuple field for the current song"},
 	{"<sep>", NULL, "Playlist manipulation"},
 	{"playlist-advance", playlist_advance, "go to the next song in the playlist"},
 	{"playlist-reverse", playlist_reverse, "go to the previous song in the playlist"},
@@ -57,6 +58,7 @@
 	{"playlist-repeat-toggle", playlist_repeat_toggle, "toggles playlist repeat"},
 	{"playlist-shuffle-status", playlist_shuffle_status, "returns the status of playlist shuffle"},
 	{"playlist-shuffle-toggle", playlist_shuffle_toggle, "toggles playlist shuffle"},
+	{"playlist-tuple-data", playlist_tuple_field_data, "returns the value of a tuple field for a song in the playlist"},
 	{"<sep>", NULL, "Playqueue manipulation"},
 	{"playqueue-add", playqueue_add, "adds a song to the playqueue"},
 	{"playqueue-remove", playqueue_remove, "removes a song from the playqueue"},
@@ -252,6 +254,38 @@
 	g_print("%d\n", nch);
 }
 
+
+void get_current_song_tuple_field_data(gint session, gint argc, gchar **argv)
+{
+	gpointer data;
+
+	if (argc < 3)
+	{
+		g_print("%s: invalid parameters for current-song-tuple-data.\n", argv[0]);
+		g_print("%s: syntax: %s current-song-tuple-data <fieldname>\n", argv[0], argv[0]);
+		g_print("%s:   - fieldname example choices: performer, album_name,\n", argv[0]);
+		g_print("%s:       track_name, track_number, year, date, genre, comment,\n", argv[0]);
+		g_print("%s:       file_name, file_ext, file_path, length, formatter, mtime\n", argv[0]);
+		return;
+	}
+
+	if (!(data = audacious_get_tuple_field_data(session, argv[2], xmms_remote_get_playlist_pos(session))))
+	{
+		return;
+	}
+	
+	if (!strcasecmp(argv[2], "track_number") || !strcasecmp(argv[2], "year") || !strcasecmp(argv[2], "length") || !strcasecmp(argv[2], "mtime"))
+	{
+		if (*(gint *)data > 0)
+		{
+			g_print("%d\n", *(gint *)data);
+		}
+		return;
+	}
+
+	g_print("%s\n", (gchar *)data);
+}
+
 void playlist_reverse(gint session, gint argc, gchar **argv)
 {
 	xmms_remote_playlist_prev(session);
@@ -656,6 +690,46 @@
 	xmms_remote_toggle_shuffle(session);
 }
 
+void playlist_tuple_field_data(gint session, gint argc, gchar **argv)
+{
+	gint i;
+	gpointer data;
+
+	if (argc < 4)
+	{
+		g_print("%s: invalid parameters for playlist-tuple-data.\n", argv[0]);
+		g_print("%s: syntax: %s playlist-tuple-data <fieldname> <position>\n", argv[0], argv[0]);
+		g_print("%s:   - fieldname example choices: performer, album_name,\n", argv[0]);
+		g_print("%s:       track_name, track_number, year, date, genre, comment,\n", argv[0]);
+		g_print("%s:       file_name, file_ext, file_path, length, formatter, mtime\n", argv[0]);
+		return;
+	}
+
+	i = atoi(argv[3]);
+
+	if (i < 1 || i > xmms_remote_get_playlist_length(session))
+	{
+		g_print("%s: invalid playlist position %d\n", argv[0], i);
+		return;
+	}
+
+	if (!(data = audacious_get_tuple_field_data(session, argv[2], i - 1)))
+	{
+		return;
+	}
+	
+	if (!strcasecmp(argv[2], "track_number") || !strcasecmp(argv[2], "year") || !strcasecmp(argv[2], "length") || !strcasecmp(argv[2], "mtime"))
+	{
+		if (*(gint *)data > 0)
+		{
+			g_print("%d\n", *(gint *)data);
+		}
+		return;
+	}
+
+	g_print("%s\n", (gchar *)data);
+}
+
 void playqueue_add(gint session, gint argc, gchar **argv)
 {
 	gint i;
--- a/src/audtool/audtool.h	Mon Feb 26 10:30:06 2007 -0800
+++ b/src/audtool/audtool.h	Mon Feb 26 19:06:45 2007 -0800
@@ -39,6 +39,7 @@
 extern void get_current_song_frequency(gint, gint, gchar **);
 extern void get_current_song_frequency_khz(gint, gint, gchar **);
 extern void get_current_song_channels(gint, gint, gchar **);
+extern void get_current_song_tuple_field_data(gint session, gint argc, gchar **argv);
 extern void get_volume(gint, gint, gchar **);
 extern void set_volume(gint, gint, gchar **);
 extern void playlist_position(gint, gint, gchar **);
@@ -60,6 +61,7 @@
 extern void playlist_repeat_toggle(gint, gint, gchar **);
 extern void playlist_shuffle_status(gint, gint, gchar **);
 extern void playlist_shuffle_toggle(gint, gint, gchar **);
+extern void playlist_tuple_field_data(gint session, gint argc, gchar **argv);
 extern void playqueue_add(gint, gint, gchar **);
 extern void playqueue_remove(gint, gint, gchar **);
 extern void playqueue_is_queued(gint, gint, gchar **);
--- a/src/libaudacious/beepctrl.c	Mon Feb 26 10:30:06 2007 -0800
+++ b/src/libaudacious/beepctrl.c	Mon Feb 26 19:06:45 2007 -0800
@@ -436,6 +436,42 @@
 }
 
 /**
+ * audacious_get_tuple_field_data:
+ * @session: Legacy XMMS-style session identifier.
+ * @field: The name of the tuple field to retrieve.
+ * @pos: The playlist position to query for.
+ *
+ * Queries Audacious about a playlist entry's tuple information.
+ *
+ * Return value: The requested field's data for the entry in the playlist at %pos position.
+ **/
+gchar *
+audacious_get_tuple_field_data(gint session, gchar * field, gint pos)
+{
+    gint fd, size;
+    gchar *packet;
+    gpointer data;
+
+    if (field == NULL)
+        return NULL;
+
+    size = strlen(field) + 1 + sizeof(gint);
+
+    if ((fd = xmms_connect_to_session(session)) == -1)
+        return NULL;
+
+    packet = g_malloc0(size);
+    *((gint *) packet) = pos;
+    strcpy(packet + sizeof(gint), field);
+    remote_send_packet(fd, CMD_PLAYLIST_GET_TUPLE_DATA, packet, size);
+    data = remote_read_packet(fd);
+    remote_read_ack(fd);
+    close(fd);
+    g_free(packet);
+    return data;
+}
+
+/**
  * xmms_connect_to_session:
  * @session: Legacy XMMS-style session identifier.
  *
--- a/src/libaudacious/beepctrl.h	Mon Feb 26 10:30:06 2007 -0800
+++ b/src/libaudacious/beepctrl.h	Mon Feb 26 19:06:45 2007 -0800
@@ -78,7 +78,6 @@
     void xmms_remote_playlist_prev(gint session);
     void xmms_remote_playlist_next(gint session);
     void xmms_remote_playlist_add_url_string(gint session, gchar * string);
-    void xmms_remote_playlist_enqueue_to_temp(gint session, gchar * string);
     gboolean xmms_remote_is_running(gint session);
     void xmms_remote_toggle_repeat(gint session);
     void xmms_remote_toggle_shuffle(gint session);
@@ -122,6 +121,10 @@
     gchar *audacious_get_session_uri(gint session);
     void audacious_set_session_type(gint type);
 
+/* Added in Audacious 1.3 */
+    void xmms_remote_playlist_enqueue_to_temp(gint session, gchar * string);
+    gchar *audacious_get_tuple_field_data(gint session, gchar * field, gint pos);
+
 #ifdef __cplusplus
 };
 #endif