annotate src/audtool/audtool_handlers_playlist.c @ 3806:fbe7468efaea trunk

Automated merge with file:/home/ccr/audacious/core
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 01 Oct 2007 21:25:24 +0300
parents 964413953abd
children f3341c2d6b9e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
1 /*
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
2 * Audtool2
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
3 * Copyright (c) 2007 Audacious development team
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
4 *
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
5 * Redistribution and use in source and binary forms, with or without
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
6 * modification, are permitted provided that the following conditions are
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
7 * met:
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
8 *
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright notice,
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
10 * this list of conditions and the following disclaimer.
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
11 *
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
15 *
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
16 * 3. The name of the author may not be used to endorse or promote products
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
17 * derived from this software without specific prior written permission.
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
18 *
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
29 * POSSIBILITY OF SUCH DAMAGE.
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
30 */
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
31
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
32 #include <stdlib.h>
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
33 #include <string.h>
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
34 #include <glib.h>
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
35 #include <mowgli.h>
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
36 #include <locale.h>
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
37 #include "libaudclient/audctrl.h"
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
38 #include "audtool.h"
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
39
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
40 void playlist_reverse(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
41 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
42 audacious_remote_playlist_prev(dbus_proxy);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
43 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
44
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
45 void playlist_advance(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
46 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
47 audacious_remote_playlist_next(dbus_proxy);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
48 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
49
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
50 void playlist_add_url_string(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
51 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
52 if (argc < 2)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
53 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
54 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
55 audtool_whine("syntax: %s <url>", argv[0]);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
56 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
57 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
58
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
59 audacious_remote_playlist_add_url_string(dbus_proxy, argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
60 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
61
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
62 void playlist_delete(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
63 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
64 gint playpos;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
65
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
66 if (argc < 2)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
67 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
68 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
69 audtool_whine("syntax: %s <position>", argv[0]);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
70 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
71 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
72
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
73 playpos = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
74
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
75 if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
76 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
77 audtool_whine("invalid playlist position %d", playpos);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
78 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
79 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
80
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
81 audacious_remote_playlist_delete(dbus_proxy, playpos - 1);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
82 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
83
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
84 void playlist_length(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
85 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
86 gint i;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
87
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
88 i = audacious_remote_get_playlist_length(dbus_proxy);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
89
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
90 audtool_report("%d", i);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
91 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
92
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
93 void playlist_song(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
94 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
95 gint playpos;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
96 gchar *song;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
97
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
98 if (argc < 2)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
99 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
100 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
101 audtool_whine("syntax: %s <position>", argv[0]);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
102 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
103 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
104
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
105 playpos = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
106
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
107 if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
108 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
109 audtool_whine("invalid playlist position %d", playpos);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
110 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
111 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
112
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
113 song = audacious_remote_get_playlist_title(dbus_proxy, playpos - 1);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
114
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
115 audtool_report("%s", song);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
116 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
117
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
118
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
119 void playlist_song_length(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
120 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
121 gint playpos, frames, length;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
122
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
123 if (argc < 2)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
124 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
125 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
126 audtool_whine("syntax: %s <position>", argv[0]);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
127 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
128 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
129
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
130 playpos = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
131
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
132 if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
133 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
134 audtool_whine("invalid playlist position %d", playpos);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
135 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
136 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
137
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
138 frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
139 length = frames / 1000;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
140
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
141 audtool_report("%d:%.2d", length / 60, length % 60);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
142 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
143
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
144 void playlist_song_length_seconds(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
145 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
146 gint playpos, frames, length;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
147
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
148 if (argc < 2)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
149 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
150 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
151 audtool_whine("syntax: %s <position>", argv[0]);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
152 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
153 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
154
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
155 playpos = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
156
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
157 if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
158 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
159 audtool_whine("invalid playlist position %d", playpos);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
160 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
161 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
162
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
163 frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
164 length = frames / 1000;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
165
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
166 audtool_report("%d", length);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
167 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
168
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
169 void playlist_song_length_frames(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
170 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
171 gint playpos, frames;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
172
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
173 if (argc < 2)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
174 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
175 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
176 audtool_whine("syntax: %s <position>", argv[0]);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
177 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
178 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
179
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
180 playpos = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
181
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
182 if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
183 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
184 audtool_whine("invalid playlist position %d", playpos);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
185 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
186 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
187
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
188 frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
189
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
190 audtool_report("%d", frames);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
191 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
192
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
193 void playlist_display(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
194 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
195 gint i, ii, frames, length, total;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
196 gchar *songname;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
197 gchar *fmt = NULL, *p;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
198 gint column;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
199
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
200 i = audacious_remote_get_playlist_length(dbus_proxy);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
201
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
202 audtool_report("%d track%s.", i, i != 1 ? "s" : "");
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
203
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
204 total = 0;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
205
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
206 for (ii = 0; ii < i; ii++)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
207 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
208 songname = audacious_remote_get_playlist_title(dbus_proxy, ii);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
209 frames = audacious_remote_get_playlist_time(dbus_proxy, ii);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
210 length = frames / 1000;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
211 total += length;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
212
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
213 /* adjust width for multi byte characters */
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
214 column = 60;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
215 if(songname){
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
216 p = songname;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
217 while(*p){
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
218 gint stride;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
219 stride = g_utf8_next_char(p) - p;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
220 if(g_unichar_iswide(g_utf8_get_char(p))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
221 #if ( (GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION >= 12) )
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
222 || g_unichar_iswide_cjk(g_utf8_get_char(p))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
223 #endif
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
224 ){
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
225 column += (stride - 2);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
226 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
227 else {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
228 column += (stride - 1);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
229 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
230 p = g_utf8_next_char(p);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
231 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
232
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
233 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
234
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
235 fmt = g_strdup_printf("%%4d | %%-%ds | %%d:%%.2d", column);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
236 audtool_report(fmt, ii + 1, songname, length / 60, length % 60);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
237 g_free(fmt);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
238 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
239
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
240 audtool_report("Total length: %d:%.2d", total / 60, total % 60);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
241 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
242
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
243 void playlist_position(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
244 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
245 gint i;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
246
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
247 i = audacious_remote_get_playlist_pos(dbus_proxy);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
248
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
249 audtool_report("%d", i + 1);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
250 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
251
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
252 void playlist_song_filename(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
253 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
254 gint i;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
255
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
256 if (argc < 2)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
257 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
258 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
259 audtool_whine("syntax: %s <position>", argv[0]);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
260 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
261 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
262
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
263 i = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
264
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
265 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
266 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
267 audtool_whine("invalid playlist position %d", i);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
268 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
269 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
270
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
271 audtool_report("%s", audacious_remote_get_playlist_file(dbus_proxy, i - 1));
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
272 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
273
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
274 void playlist_jump(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
275 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
276 gint i;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
277
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
278 if (argc < 2)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
279 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
280 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
281 audtool_whine("syntax: %s <position>", argv[0]);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
282 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
283 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
284
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
285 i = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
286
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
287 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
288 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
289 audtool_whine("invalid playlist position %d", i);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
290 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
291 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
292
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
293 audacious_remote_set_playlist_pos(dbus_proxy, i - 1);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
294 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
295
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
296 void playlist_clear(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
297 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
298 audacious_remote_playlist_clear(dbus_proxy);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
299 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
300
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
301 void playlist_repeat_status(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
302 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
303 if (audacious_remote_is_repeat(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
304 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
305 audtool_report("on");
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
306 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
307 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
308 else
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
309 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
310 audtool_report("off");
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
311 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
312 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
313 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
314
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
315 void playlist_repeat_toggle(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
316 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
317 audacious_remote_toggle_repeat(dbus_proxy);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
318 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
319
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
320 void playlist_shuffle_status(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
321 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
322 if (audacious_remote_is_shuffle(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
323 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
324 audtool_report("on");
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
325 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
326 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
327 else
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
328 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
329 audtool_report("off");
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
330 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
331 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
332 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
333
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
334 void playlist_shuffle_toggle(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
335 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
336 audacious_remote_toggle_shuffle(dbus_proxy);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
337 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
338
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
339 void playlist_tuple_field_data(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
340 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
341 gint i;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
342 gpointer data;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
343
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
344 if (argc < 3)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
345 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
346 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
347 audtool_whine("syntax: %s <fieldname> <position>", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
348 audtool_whine(" - fieldname example choices: performer, album_name,");
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
349 audtool_whine(" track_name, track_number, year, date, genre, comment,");
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
350 audtool_whine(" file_name, file_ext, file_path, length, formatter,");
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
351 audtool_whine(" custom, mtime");
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
352 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
353 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
354
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
355 i = atoi(argv[2]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
356
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
357 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
358 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
359 audtool_whine("invalid playlist position %d", i);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
360 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
361 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
362
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
363 if (!(data = audacious_get_tuple_field_data(dbus_proxy, argv[1], i - 1)))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
364 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
365 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
366 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
367
2939
964413953abd Use portable g_ascii_strcasecmp().
William Pitcock <nenolod@atheme.org>
parents: 2934
diff changeset
368 if (!g_ascii_strcasecmp(argv[1], "track_number") || !g_ascii_strcasecmp(argv[1], "year") || !g_ascii_strcasecmp(argv[1], "length") || !g_ascii_strcasecmp(argv[1], "mtime"))
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
369 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
370 if (*(gint *)data > 0)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
371 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
372 audtool_report("%d", *(gint *)data);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
373 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
374 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
375 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
376
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
377 audtool_report("%s", (gchar *)data);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
378 }