changeset 2926:f5ce83fdbf3e trunk

Split out vital information category into seperate source file.
author William Pitcock <nenolod@atheme.org>
date Fri, 29 Jun 2007 08:04:47 -0500
parents 90ca95b7277d
children dbba106b417f
files src/audtool/Makefile src/audtool/audtool_handlers_general.c src/audtool/audtool_handlers_vitals.c
diffstat 3 files changed, 194 insertions(+), 155 deletions(-) [+]
line wrap: on
line diff
--- a/src/audtool/Makefile	Fri Jun 29 08:00:20 2007 -0500
+++ b/src/audtool/Makefile	Fri Jun 29 08:04:47 2007 -0500
@@ -24,7 +24,8 @@
 
 SOURCES =	 			\
 	audtool_main.c			\
-	audtool_handlers_general.c
+	audtool_handlers_general.c	\
+	audtool_handlers_vitals.c
 
 OBJECTS = ${SOURCES:.c=.o}
 
--- a/src/audtool/audtool_handlers_general.c	Fri Jun 29 08:00:20 2007 -0500
+++ b/src/audtool/audtool_handlers_general.c	Fri Jun 29 08:04:47 2007 -0500
@@ -37,160 +37,6 @@
 #include "libaudclient/audctrl.h"
 #include "audtool.h"
 
-void get_current_song(gint argc, gchar **argv)
-{
-	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
-	gchar *song = audacious_remote_get_playlist_title(dbus_proxy, playpos);
-
-	if (!song)
-	{
-		g_print("No song playing.\n");
-		return;
-	}
-
-	g_print("%s\n", song);
-}
-
-void get_current_song_filename(gint argc, gchar **argv)
-{
-	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
-	gchar *file = audacious_remote_get_playlist_file(dbus_proxy, playpos);
-
-	if (!file)
-	{
-		g_print("No song playing.\n");
-		return;
-	}
-        
-	g_print("%s\n", file);
-}
-
-void get_current_song_output_length(gint argc, gchar **argv)
-{
-	gint frames = audacious_remote_get_output_time(dbus_proxy);
-	gint length = frames / 1000;
-
-	g_print("%d:%.2d\n", length / 60, length % 60);
-}
-
-void get_current_song_output_length_seconds(gint argc, gchar **argv)
-{
-	gint frames = audacious_remote_get_output_time(dbus_proxy);
-	gint length = frames / 1000;
-
-	g_print("%d\n", length);
-}
-
-void get_current_song_output_length_frames(gint argc, gchar **argv)
-{
-	gint frames = audacious_remote_get_output_time(dbus_proxy);
-
-	g_print("%d\n", frames);
-}
-
-void get_current_song_length(gint argc, gchar **argv)
-{
-	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
-	gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos);
-	gint length = frames / 1000;
-
-	g_print("%d:%.2d\n", length / 60, length % 60);
-}
-
-void get_current_song_length_seconds(gint argc, gchar **argv)
-{
-	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
-	gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos);
-	gint length = frames / 1000;
-
-	g_print("%d\n", length);
-}
-
-void get_current_song_length_frames(gint argc, gchar **argv)
-{
-	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
-	gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos);
-
-	g_print("%d\n", frames);
-}
-
-void get_current_song_bitrate(gint argc, gchar **argv)
-{
-	gint rate, freq, nch;
-
-	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
-
-	g_print("%d\n", rate);
-}
-
-void get_current_song_bitrate_kbps(gint argc, gchar **argv)
-{
-	gint rate, freq, nch;
-
-	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
-
-	g_print("%d\n", rate / 1000);
-}
-
-void get_current_song_frequency(gint argc, gchar **argv)
-{
-	gint rate, freq, nch;
-
-	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
-
-	g_print("%d\n", freq);
-}
-
-void get_current_song_frequency_khz(gint argc, gchar **argv)
-{
-	gint rate, freq, nch;
-
-	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
-
-	g_print("%0.1f\n", (gfloat) freq / 1000);
-}
-
-void get_current_song_channels(gint argc, gchar **argv)
-{
-	gint rate, freq, nch;
-
-	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
-
-	g_print("%d\n", nch);
-}
-
-void get_current_song_tuple_field_data(gint argc, gchar **argv)
-{
-	gpointer data;
-
-	if (argc < 2)
-	{
-		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,\n", argv[0]);
-		g_print("%s:       custom, mtime\n", argv[0]);
-		return;
-	}
-
-	if (!(data = audacious_get_tuple_field_data(dbus_proxy, argv[1], audacious_remote_get_playlist_pos(dbus_proxy))))
-	{
-		return;
-	}
-	
-	if (!strcasecmp(argv[1], "track_number") || !strcasecmp(argv[1], "year") || !strcasecmp(argv[1], "length") || !strcasecmp(argv[1], "mtime"))
-	{
-		if (*(gint *)data > 0)
-		{
-			g_print("%d\n", *(gint *)data);
-		}
-		return;
-	}
-
-	g_print("%s\n", (gchar *)data);
-}
-
 void playlist_reverse(gint argc, gchar **argv)
 {
 	audacious_remote_playlist_prev(dbus_proxy);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audtool/audtool_handlers_vitals.c	Fri Jun 29 08:04:47 2007 -0500
@@ -0,0 +1,192 @@
+/*
+ * Audtool2
+ * Copyright (c) 2007 Audacious development team
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <mowgli.h>
+#include <locale.h>
+#include "libaudclient/audctrl.h"
+#include "audtool.h"
+
+void get_current_song(gint argc, gchar **argv)
+{
+	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
+	gchar *song = audacious_remote_get_playlist_title(dbus_proxy, playpos);
+
+	if (!song)
+	{
+		g_print("No song playing.\n");
+		return;
+	}
+
+	g_print("%s\n", song);
+}
+
+void get_current_song_filename(gint argc, gchar **argv)
+{
+	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
+	gchar *file = audacious_remote_get_playlist_file(dbus_proxy, playpos);
+
+	if (!file)
+	{
+		g_print("No song playing.\n");
+		return;
+	}
+        
+	g_print("%s\n", file);
+}
+
+void get_current_song_output_length(gint argc, gchar **argv)
+{
+	gint frames = audacious_remote_get_output_time(dbus_proxy);
+	gint length = frames / 1000;
+
+	g_print("%d:%.2d\n", length / 60, length % 60);
+}
+
+void get_current_song_output_length_seconds(gint argc, gchar **argv)
+{
+	gint frames = audacious_remote_get_output_time(dbus_proxy);
+	gint length = frames / 1000;
+
+	g_print("%d\n", length);
+}
+
+void get_current_song_output_length_frames(gint argc, gchar **argv)
+{
+	gint frames = audacious_remote_get_output_time(dbus_proxy);
+
+	g_print("%d\n", frames);
+}
+
+void get_current_song_length(gint argc, gchar **argv)
+{
+	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
+	gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos);
+	gint length = frames / 1000;
+
+	g_print("%d:%.2d\n", length / 60, length % 60);
+}
+
+void get_current_song_length_seconds(gint argc, gchar **argv)
+{
+	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
+	gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos);
+	gint length = frames / 1000;
+
+	g_print("%d\n", length);
+}
+
+void get_current_song_length_frames(gint argc, gchar **argv)
+{
+	gint playpos = audacious_remote_get_playlist_pos(dbus_proxy);
+	gint frames = audacious_remote_get_playlist_time(dbus_proxy, playpos);
+
+	g_print("%d\n", frames);
+}
+
+void get_current_song_bitrate(gint argc, gchar **argv)
+{
+	gint rate, freq, nch;
+
+	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
+
+	g_print("%d\n", rate);
+}
+
+void get_current_song_bitrate_kbps(gint argc, gchar **argv)
+{
+	gint rate, freq, nch;
+
+	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
+
+	g_print("%d\n", rate / 1000);
+}
+
+void get_current_song_frequency(gint argc, gchar **argv)
+{
+	gint rate, freq, nch;
+
+	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
+
+	g_print("%d\n", freq);
+}
+
+void get_current_song_frequency_khz(gint argc, gchar **argv)
+{
+	gint rate, freq, nch;
+
+	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
+
+	g_print("%0.1f\n", (gfloat) freq / 1000);
+}
+
+void get_current_song_channels(gint argc, gchar **argv)
+{
+	gint rate, freq, nch;
+
+	audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch);
+
+	g_print("%d\n", nch);
+}
+
+void get_current_song_tuple_field_data(gint argc, gchar **argv)
+{
+	gpointer data;
+
+	if (argc < 2)
+	{
+		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,\n", argv[0]);
+		g_print("%s:       custom, mtime\n", argv[0]);
+		return;
+	}
+
+	if (!(data = audacious_get_tuple_field_data(dbus_proxy, argv[1], audacious_remote_get_playlist_pos(dbus_proxy))))
+	{
+		return;
+	}
+	
+	if (!strcasecmp(argv[1], "track_number") || !strcasecmp(argv[1], "year") || !strcasecmp(argv[1], "length") || !strcasecmp(argv[1], "mtime"))
+	{
+		if (*(gint *)data > 0)
+		{
+			g_print("%d\n", *(gint *)data);
+		}
+		return;
+	}
+
+	g_print("%s\n", (gchar *)data);
+}