Mercurial > audlegacy
annotate src/audtool/audtool_handlers_playqueue.c @ 4325:309e8f970517
removed report_error() and reimplemented some error routines
author | mf0102 <0102@gmx.at> |
---|---|
date | Thu, 13 Mar 2008 16:31:48 +0100 |
parents | f3341c2d6b9e |
children | 30782d57c7e6 |
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]); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
48 exit(1); |
2929
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); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
56 exit(1); |
2929
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]); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
71 exit(1); |
2929
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); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
79 exit(1); |
2929
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]); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
94 exit(1); |
2929
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); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
102 exit(1); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
103 } |
3867
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2933
diff
changeset
|
104 if(audacious_remote_playqueue_is_queued(dbus_proxy, i - 1)) { |
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2933
diff
changeset
|
105 audtool_report("OK"); |
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2933
diff
changeset
|
106 exit(0); |
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2933
diff
changeset
|
107 } |
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2933
diff
changeset
|
108 else |
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2933
diff
changeset
|
109 exit(1); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
110 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
111 |
3867
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2933
diff
changeset
|
112 void playqueue_get_queue_position(gint argc, gchar **argv) |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
113 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
114 gint i, pos; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
115 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
116 if (argc < 2) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
117 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
118 audtool_whine("invalid parameters for %s.", argv[0]); |
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
119 audtool_whine("syntax: %s <position>", argv[0]); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
120 exit(1); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
121 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
122 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
123 i = atoi(argv[1]); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
124 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
125 if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
126 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
127 audtool_whine("invalid playlist position %d", i); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
128 exit(1); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
129 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
130 |
3867
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2933
diff
changeset
|
131 pos = audacious_remote_get_playqueue_queue_position(dbus_proxy, i - 1) + 1; |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
132 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
133 if (pos < 1) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
134 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
135 |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
136 audtool_report("%d", pos); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
137 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
138 |
3867
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2933
diff
changeset
|
139 void playqueue_get_list_position(gint argc, gchar **argv) |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
140 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
141 gint i, pos; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
142 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
143 if (argc < 2) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
144 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
145 audtool_whine("invalid parameters for %s.", argv[0]); |
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
146 audtool_whine("syntax: %s <position>", argv[0]); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
147 exit(1); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
148 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
149 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
150 i = atoi(argv[1]); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
151 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
152 if (i < 1 || i > audacious_remote_get_playqueue_length(dbus_proxy)) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
153 { |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
154 audtool_whine("invalid playlist position %d", i); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
155 exit(1); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
156 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
157 |
3867
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2933
diff
changeset
|
158 pos = audacious_remote_get_playqueue_list_position(dbus_proxy, i - 1) + 1; |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
159 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
160 if (pos < 1) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
161 return; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
162 |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
163 audtool_report("%d", pos); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
164 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
165 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
166 void playqueue_display(gint argc, gchar **argv) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
167 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
168 gint i, ii, position, frames, length, total; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
169 gchar *songname; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
170 gchar *fmt = NULL, *p; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
171 gint column; |
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 i = audacious_remote_get_playqueue_length(dbus_proxy); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
174 |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
175 audtool_report("%d queued tracks.", i); |
2929
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 total = 0; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
178 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
179 for (ii = 0; ii < i; ii++) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
180 { |
3867
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2933
diff
changeset
|
181 position = audacious_remote_get_playqueue_list_position(dbus_proxy, ii); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
182 songname = audacious_remote_get_playlist_title(dbus_proxy, position); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
183 frames = audacious_remote_get_playlist_time(dbus_proxy, position); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
184 length = frames / 1000; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
185 total += length; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
186 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
187 /* adjust width for multi byte characters */ |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
188 column = 60; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
189 if(songname) { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
190 p = songname; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
191 while(*p){ |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
192 gint stride; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
193 stride = g_utf8_next_char(p) - p; |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
194 if(g_unichar_iswide(g_utf8_get_char(p)) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
195 #if ( (GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION >= 12) ) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
196 || g_unichar_iswide_cjk(g_utf8_get_char(p)) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
197 #endif |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
198 ){ |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
199 column += (stride - 2); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
200 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
201 else { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
202 column += (stride - 1); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
203 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
204 p = g_utf8_next_char(p); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
205 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
206 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
207 |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
208 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
|
209 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
|
210 g_free(fmt); |
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 |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
213 audtool_report("Total length: %d:%.2d", total / 60, total % 60); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
214 } |
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 void playqueue_length(gint argc, gchar **argv) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
217 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
218 gint i; |
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 i = audacious_remote_get_playqueue_length(dbus_proxy); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
221 |
2933
7be518cc8e60
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
222 audtool_report("%d", i); |
2929
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
223 } |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
224 |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
225 void playqueue_clear(gint argc, gchar **argv) |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
226 { |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
227 audacious_remote_playqueue_clear(dbus_proxy); |
b0ca7bddaec9
Split out playqueue functions.
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
228 } |