annotate src/audtool/audtool_handlers_playlist.c @ 4373:20c70e3a8272

Changed the wording of contact-section, recommending users to visit the forums, instead of IRC or e-mailing the developers.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 25 Mar 2008 21:26:45 +0200
parents ea194fd79267
children 0a2255b9e80b
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
4074
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
50 static gchar *
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
51 construct_uri(gchar *string)
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
52 {
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
53 gchar *filename = g_strdup(string);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
54 gchar *tmp, *path;
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
55 gchar *uri = NULL;
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
56
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
57 // case 1: filename is raw full path or uri
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
58 if (filename[0] == '/' || strstr(filename, "://")) {
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
59 uri = g_filename_to_uri(filename, NULL, NULL);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
60 if(!uri) {
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
61 uri = g_strdup(filename);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
62 }
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
63 g_free(filename);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
64 }
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
65 // case 2: filename is not raw full path nor uri.
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
66 // make full path with pwd. (using g_build_filename)
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
67 else {
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
68 path = g_get_current_dir();
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
69 tmp = g_build_filename(path, filename, NULL);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
70 g_free(path); g_free(filename);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
71 uri = g_filename_to_uri(tmp, NULL, NULL);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
72 g_free(tmp);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
73 }
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
74
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
75 return uri;
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
76 }
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
77
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
78 void playlist_add_url_string(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
79 {
4074
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
80 gchar *uri;
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
81
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
82 if (argc < 2)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
83 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
84 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
85 audtool_whine("syntax: %s <url>", argv[0]);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
86 exit(1);
2927
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
4074
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
89 uri = construct_uri(argv[1]);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
90 if (uri) {
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
91 audacious_remote_playlist_add_url_string(dbus_proxy, uri);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
92 }
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
93 g_free(uri);
2927
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
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
96 void playlist_delete(gint argc, gchar **argv)
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 gint playpos;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
99
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
100 if (argc < 2)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
101 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
102 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
103 audtool_whine("syntax: %s <position>", argv[0]);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
104 exit(1);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
105 }
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 playpos = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
108
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
109 if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
110 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
111 audtool_whine("invalid playlist position %d", playpos);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
112 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
113 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
114
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
115 audacious_remote_playlist_delete(dbus_proxy, playpos - 1);
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 void playlist_length(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
119 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
120 gint i;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
121
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
122 i = audacious_remote_get_playlist_length(dbus_proxy);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
123
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
124 audtool_report("%d", i);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
125 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
126
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
127 void playlist_song(gint argc, gchar **argv)
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 gint playpos;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
130 gchar *song;
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 (argc < 2)
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 parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
135 audtool_whine("syntax: %s <position>", argv[0]);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
136 exit(1);
2927
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
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
139 playpos = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
140
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
141 if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
142 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
143 audtool_whine("invalid playlist position %d", playpos);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
144 exit(1);
2927
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
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
147 song = audacious_remote_get_playlist_title(dbus_proxy, playpos - 1);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
148
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
149 audtool_report("%s", song);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
150 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
151
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
152
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
153 void playlist_song_length(gint argc, gchar **argv)
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 gint playpos, frames, length;
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 (argc < 2)
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 parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
160 audtool_whine("syntax: %s <position>", argv[0]);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
161 exit(1);
2927
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
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
164 playpos = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
165
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
166 if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
167 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
168 audtool_whine("invalid playlist position %d", playpos);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
169 exit(1);
2927
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
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
172 frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
173 length = frames / 1000;
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_report("%d:%.2d", length / 60, length % 60);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
176 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
177
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
178 void playlist_song_length_seconds(gint argc, gchar **argv)
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 gint playpos, frames, length;
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 (argc < 2)
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 parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
185 audtool_whine("syntax: %s <position>", argv[0]);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
186 exit(1);
2927
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
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
189 playpos = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
190
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
191 if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
192 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
193 audtool_whine("invalid playlist position %d", playpos);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
194 exit(1);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
195 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
196
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
197 frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
198 length = frames / 1000;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
199
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
200 audtool_report("%d", length);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
201 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
202
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
203 void playlist_song_length_frames(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
204 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
205 gint playpos, frames;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
206
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
207 if (argc < 2)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
208 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
209 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
210 audtool_whine("syntax: %s <position>", argv[0]);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
211 exit(1);
2927
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
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
214 playpos = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
215
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
216 if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
217 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
218 audtool_whine("invalid playlist position %d", playpos);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
219 exit(1);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
220 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
221
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
222 frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
223
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
224 audtool_report("%d", frames);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
225 }
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 void playlist_display(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
228 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
229 gint i, ii, frames, length, total;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
230 gchar *songname;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
231 gchar *fmt = NULL, *p;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
232 gint column;
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 i = audacious_remote_get_playlist_length(dbus_proxy);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
235
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
236 audtool_report("%d track%s.", i, i != 1 ? "s" : "");
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
237
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
238 total = 0;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
239
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
240 for (ii = 0; ii < i; ii++)
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 songname = audacious_remote_get_playlist_title(dbus_proxy, ii);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
243 frames = audacious_remote_get_playlist_time(dbus_proxy, ii);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
244 length = frames / 1000;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
245 total += length;
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 /* adjust width for multi byte characters */
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
248 column = 60;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
249 if(songname){
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
250 p = songname;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
251 while(*p){
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
252 gint stride;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
253 stride = g_utf8_next_char(p) - p;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
254 if(g_unichar_iswide(g_utf8_get_char(p))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
255 #if ( (GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION >= 12) )
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
256 || g_unichar_iswide_cjk(g_utf8_get_char(p))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
257 #endif
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
258 ){
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
259 column += (stride - 2);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
260 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
261 else {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
262 column += (stride - 1);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
263 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
264 p = g_utf8_next_char(p);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
265 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
266
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
267 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
268
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
269 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
270 audtool_report(fmt, ii + 1, songname, length / 60, length % 60);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
271 g_free(fmt);
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
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
274 audtool_report("Total length: %d:%.2d", total / 60, total % 60);
2927
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
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
277 void playlist_position(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
278 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
279 gint i;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
280
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
281 i = audacious_remote_get_playlist_pos(dbus_proxy);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
282
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
283 audtool_report("%d", i + 1);
2927
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
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
286 void playlist_song_filename(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
287 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
288 gint i;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
289
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
290 if (argc < 2)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
291 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
292 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
293 audtool_whine("syntax: %s <position>", argv[0]);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
294 exit(1);
2927
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
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
297 i = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
298
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
299 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
300 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
301 audtool_whine("invalid playlist position %d", i);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
302 exit(1);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
303 }
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("%s", audacious_remote_get_playlist_file(dbus_proxy, i - 1));
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
306 }
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 void playlist_jump(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
309 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
310 gint i;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
311
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
312 if (argc < 2)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
313 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
314 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
315 audtool_whine("syntax: %s <position>", argv[0]);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
316 exit(1);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
317 }
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 i = atoi(argv[1]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
320
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
321 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
322 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
323 audtool_whine("invalid playlist position %d", i);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
324 exit(1);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
325 }
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 audacious_remote_set_playlist_pos(dbus_proxy, i - 1);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
328 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
329
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
330 void playlist_clear(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
331 {
3917
b5ee3a4a8e3b libaudclient:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3903
diff changeset
332 audacious_remote_stop(dbus_proxy);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
333 audacious_remote_playlist_clear(dbus_proxy);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
334 }
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 void playlist_repeat_status(gint argc, gchar **argv)
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 if (audacious_remote_is_repeat(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
339 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
340 audtool_report("on");
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
341 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
342 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
343 else
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
344 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
345 audtool_report("off");
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
346 return;
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
347 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
348 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
349
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
350 void playlist_repeat_toggle(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
351 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
352 audacious_remote_toggle_repeat(dbus_proxy);
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 void playlist_shuffle_status(gint argc, gchar **argv)
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 (audacious_remote_is_shuffle(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_report("on");
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 else
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
363 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
364 audtool_report("off");
2927
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 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
368
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
369 void playlist_shuffle_toggle(gint argc, gchar **argv)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
370 {
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
371 audacious_remote_toggle_shuffle(dbus_proxy);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
372 }
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 void playlist_tuple_field_data(gint argc, gchar **argv)
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 gint i;
3902
1792ab581321 fix improper rendering of data
William Pitcock <nenolod@atheme.org>
parents: 3873
diff changeset
377 gchar *data;
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
378
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
379 if (argc < 3)
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
380 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
381 audtool_whine("invalid parameters for %s.", argv[0]);
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
382 audtool_whine("syntax: %s <fieldname> <position>", argv[0]);
3903
134cc28dc468 update tuple field suggestions
William Pitcock <nenolod@atheme.org>
parents: 3902
diff changeset
383 audtool_whine(" - fieldname example choices include but are not limited to:");
134cc28dc468 update tuple field suggestions
William Pitcock <nenolod@atheme.org>
parents: 3902
diff changeset
384 audtool_whine(" artist, album, title, track_number, year, date,");
134cc28dc468 update tuple field suggestions
William Pitcock <nenolod@atheme.org>
parents: 3902
diff changeset
385 audtool_whine(" genre, comment, file_name, file_ext, file_path,");
134cc28dc468 update tuple field suggestions
William Pitcock <nenolod@atheme.org>
parents: 3902
diff changeset
386 audtool_whine(" length, formatter, custom, mtime");
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
387 exit(1);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
388 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
389
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
390 i = atoi(argv[2]);
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
391
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
392 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy))
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
393 {
2934
c32036aa4b4d Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents: 2927
diff changeset
394 audtool_whine("invalid playlist position %d", i);
3873
f3341c2d6b9e audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
395 exit(1);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
396 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
397
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
398 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
399 {
3902
1792ab581321 fix improper rendering of data
William Pitcock <nenolod@atheme.org>
parents: 3873
diff changeset
400 return;
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
401 }
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
402
3902
1792ab581321 fix improper rendering of data
William Pitcock <nenolod@atheme.org>
parents: 3873
diff changeset
403 audtool_report("%s", data);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
404
3902
1792ab581321 fix improper rendering of data
William Pitcock <nenolod@atheme.org>
parents: 3873
diff changeset
405 g_free(data);
2927
dbba106b417f Split out playlist functions.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
406 }
4074
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
407
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
408 void playlist_ins_url_string(gint argc, gchar **argv)
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
409 {
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
410 gint pos = -1;
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
411 gchar *uri;
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
412
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
413 if (argc < 3)
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
414 {
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
415 audtool_whine("invalid parameters for %s.", argv[0]);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
416 audtool_whine("syntax: %s <url> <position>", argv[0]);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
417 exit(1);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
418 }
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
419
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
420 pos = atoi(argv[2]) - 1;
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
421 if(pos >= 0) {
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
422 uri = construct_uri(argv[1]);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
423 if (uri) {
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
424 audacious_remote_playlist_ins_url_string(dbus_proxy, uri, pos);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
425 }
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
426 g_free(uri);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
427 }
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
428 }
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
429
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
430 void playlist_enqueue_to_temp(gint argc, gchar **argv)
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
431 {
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
432 gchar *uri;
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
433
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
434 if (argc < 2)
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
435 {
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
436 audtool_whine("invalid parameters for %s.", argv[0]);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
437 audtool_whine("syntax: %s <url>", argv[0]);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
438 exit(1);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
439 }
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
440
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
441 uri = construct_uri(argv[1]);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
442 if (uri) {
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
443 audacious_remote_playlist_enqueue_to_temp(dbus_proxy, uri);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
444 }
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
445 g_free(uri);
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
446 }