Mercurial > audlegacy
annotate src/audtool/audtool_handlers_playqueue.c @ 3784:2c92b8947057
Maybe it works now.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 18 Oct 2007 18:02:10 +0300 |
parents | 7be518cc8e60 |
children | e48f2f4c116d |
rev | line source |
---|---|
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1 /* |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2 * Audtool2 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3 * Copyright (c) 2007 Audacious development team |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
4 * |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
5 * Redistribution and use in source and binary forms, with or without |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
6 * modification, are permitted provided that the following conditions are |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
7 * met: |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
8 * |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
9 * 1. Redistributions of source code must retain the above copyright notice, |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
10 * this list of conditions and the following disclaimer. |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
11 * |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
12 * 2. Redistributions in binary form must reproduce the above copyright |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
13 * notice, this list of conditions and the following disclaimer in the |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
14 * documentation and/or other materials provided with the distribution. |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
15 * |
b0ca7bddaec9
Split out playqueue 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 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
17 * derived from this software without specific prior written permission. |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
18 * |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
b0ca7bddaec9
Split out playqueue 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 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
29 * POSSIBILITY OF SUCH DAMAGE. |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
30 */ |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
31 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
32 #include <stdlib.h> |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
33 #include <string.h> |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
34 #include <glib.h> |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
35 #include <mowgli.h> |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
36 #include <locale.h> |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
37 #include "libaudclient/audctrl.h" |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
38 #include "audtool.h" |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
39 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
40 void playqueue_add(gint argc, gchar **argv) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
41 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
42 gint i; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
43 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
44 if (argc < 2) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
45 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
46 audtool_whine("invalid parameters for %s.", argv[0]); |
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
47 audtool_whine("syntax: %s <position>", argv[0]); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
48 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
49 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
50 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
51 i = atoi(argv[1]); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
52 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
53 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
54 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
55 audtool_whine("invalid playlist position %d", i); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
56 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
57 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
58 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
59 if (!(audacious_remote_playqueue_is_queued(dbus_proxy, i - 1))) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
60 audacious_remote_playqueue_add(dbus_proxy, i - 1); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
61 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
62 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
63 void playqueue_remove(gint argc, gchar **argv) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
64 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
65 gint i; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
66 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
67 if (argc < 2) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
68 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
69 audtool_whine("invalid parameters for %s.", argv[0]); |
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
70 audtool_whine("syntax: %s <position>", argv[0]); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
71 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
72 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
73 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
74 i = atoi(argv[1]); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
75 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
76 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
77 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
78 audtool_whine("invalid playlist position %d", i); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
79 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
80 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
81 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
82 if (audacious_remote_playqueue_is_queued(dbus_proxy, i - 1)) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
83 audacious_remote_playqueue_remove(dbus_proxy, i - 1); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
84 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
85 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
86 void playqueue_is_queued(gint argc, gchar **argv) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
87 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
88 gint i; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
89 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
90 if (argc < 2) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
91 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
92 audtool_whine("invalid parameters for playqueue-is-queued.", argv[0]); |
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
93 audtool_whine("syntax: %s playqueue-is-queued <position>", argv[0]); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
94 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
95 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
96 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
97 i = atoi(argv[1]); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
98 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
99 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
100 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
101 audtool_whine("invalid playlist position %d", i); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
102 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
103 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
104 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
105 exit(!(audacious_remote_playqueue_is_queued(dbus_proxy, i - 1))); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
106 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
107 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
108 void playqueue_get_position(gint argc, gchar **argv) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
109 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
110 gint i, pos; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
111 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
112 if (argc < 2) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
113 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
114 audtool_whine("invalid parameters for %s.", argv[0]); |
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
115 audtool_whine("syntax: %s <position>", argv[0]); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
116 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
117 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
118 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
119 i = atoi(argv[1]); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
120 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
121 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
122 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
123 audtool_whine("invalid playlist position %d", i); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
124 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
125 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
126 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
127 pos = audacious_remote_get_playqueue_position(dbus_proxy, i - 1) + 1; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
128 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
129 if (pos < 1) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
130 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
131 |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
132 audtool_report("%d", pos); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
133 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
134 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
135 void playqueue_get_qposition(gint argc, gchar **argv) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
136 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
137 gint i, pos; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
138 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
139 if (argc < 2) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
140 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
141 audtool_whine("invalid parameters for %s.", argv[0]); |
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
142 audtool_whine("syntax: %s <position>", argv[0]); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
143 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
144 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
145 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
146 i = atoi(argv[1]); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
147 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
148 if (i < 1 || i > audacious_remote_get_playqueue_length(dbus_proxy)) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
149 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
150 audtool_whine("invalid playlist position %d", i); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
151 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
152 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
153 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
154 pos = audacious_remote_get_playqueue_queue_position(dbus_proxy, i - 1) + 1; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
155 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
156 if (pos < 1) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
157 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
158 |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
159 audtool_report("%d", pos); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
160 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
161 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
162 void playqueue_display(gint argc, gchar **argv) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
163 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
164 gint i, ii, position, frames, length, total; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
165 gchar *songname; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
166 gchar *fmt = NULL, *p; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
167 gint column; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
168 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
169 i = audacious_remote_get_playqueue_length(dbus_proxy); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
170 |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
171 audtool_report("%d queued tracks.", i); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
172 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
173 total = 0; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
174 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
175 for (ii = 0; ii < i; ii++) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
176 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
177 position = audacious_remote_get_playqueue_queue_position(dbus_proxy, ii); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
178 songname = audacious_remote_get_playlist_title(dbus_proxy, position); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
179 frames = audacious_remote_get_playlist_time(dbus_proxy, position); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
180 length = frames / 1000; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
181 total += length; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
182 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
183 /* adjust width for multi byte characters */ |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
184 column = 60; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
185 if(songname) { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
186 p = songname; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
187 while(*p){ |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
188 gint stride; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
189 stride = g_utf8_next_char(p) - p; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
190 if(g_unichar_iswide(g_utf8_get_char(p)) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
191 #if ( (GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION >= 12) ) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
192 || g_unichar_iswide_cjk(g_utf8_get_char(p)) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
193 #endif |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
194 ){ |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
195 column += (stride - 2); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
196 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
197 else { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
198 column += (stride - 1); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
199 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
200 p = g_utf8_next_char(p); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
201 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
202 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
203 |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
204 fmt = g_strdup_printf("%%4d | %%4d | %%-%ds | %%d:%%.2d", column); |
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
205 audtool_report(fmt, ii + 1, position + 1, songname, length / 60, length % 60); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
206 g_free(fmt); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
207 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
208 |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
209 audtool_report("Total length: %d:%.2d", total / 60, total % 60); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
210 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
211 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
212 void playqueue_length(gint argc, gchar **argv) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
213 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
214 gint i; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
215 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
216 i = audacious_remote_get_playqueue_length(dbus_proxy); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
217 |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
218 audtool_report("%d", i); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
219 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
220 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
221 void playqueue_clear(gint argc, gchar **argv) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
222 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
223 audacious_remote_playqueue_clear(dbus_proxy); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
224 } |