Mercurial > audlegacy
annotate src/audtool/audtool_handlers_general.c @ 4180:bf6092a180f6
Remove --session. It is legacy from before Audacious used DBus. (Bugzilla #97)
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Fri, 11 Jan 2008 11:46:07 -0600 |
parents | ea194fd79267 |
children | b9587e67eb02 |
rev | line source |
---|---|
2737 | 1 /* |
2 * Audtool2 | |
3 * Copyright (c) 2007 Audacious development team | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions are | |
7 * met: | |
8 * | |
9 * 1. Redistributions of source code must retain the above copyright notice, | |
10 * this list of conditions and the following disclaimer. | |
11 * | |
12 * 2. Redistributions in binary form must reproduce the above copyright | |
13 * notice, this list of conditions and the following disclaimer in the | |
14 * documentation and/or other materials provided with the distribution. | |
15 * | |
16 * 3. The name of the author may not be used to endorse or promote products | |
17 * derived from this software without specific prior written permission. | |
18 * | |
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 * POSSIBILITY OF SUCH DAMAGE. | |
30 */ | |
31 | |
32 #include <stdlib.h> | |
33 #include <string.h> | |
34 #include <glib.h> | |
35 #include <mowgli.h> | |
36 #include <locale.h> | |
37 #include "libaudclient/audctrl.h" | |
38 #include "audtool.h" | |
39 | |
40 void get_volume(gint argc, gchar **argv) | |
41 { | |
42 gint i; | |
43 | |
44 i = audacious_remote_get_main_volume(dbus_proxy); | |
45 | |
2932
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
46 audtool_report("%d", i); |
2737 | 47 } |
48 | |
49 void set_volume(gint argc, gchar **argv) | |
50 { | |
51 gint i, current_volume; | |
52 | |
2925
90ca95b7277d
Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents:
2922
diff
changeset
|
53 if (argc < 2) |
2737 | 54 { |
2932
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
55 audtool_whine("invalid parameters for %s.", argv[0]); |
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
56 audtool_whine("syntax: %s <level>", argv[0]); |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
57 exit(1); |
2737 | 58 } |
59 | |
60 current_volume = audacious_remote_get_main_volume(dbus_proxy); | |
2925
90ca95b7277d
Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents:
2922
diff
changeset
|
61 switch (argv[1][0]) |
2737 | 62 { |
63 case '+': | |
64 case '-': | |
2925
90ca95b7277d
Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents:
2922
diff
changeset
|
65 i = current_volume + atoi(argv[1]); |
2737 | 66 break; |
67 default: | |
2925
90ca95b7277d
Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents:
2922
diff
changeset
|
68 i = atoi(argv[1]); |
2737 | 69 break; |
70 } | |
71 | |
72 audacious_remote_set_main_volume(dbus_proxy, i); | |
73 } | |
74 | |
75 void mainwin_show(gint argc, gchar **argv) | |
76 { | |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
77 if (argc < 2) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
78 audtool_whine("invalid parameter for %s.", argv[0]); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
79 audtool_whine("syntax: %s <on/off>", argv[0]); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
80 exit(1); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
81 } |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
82 |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
83 if (!g_ascii_strcasecmp(argv[1], "on")) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
84 audacious_remote_main_win_toggle(dbus_proxy, TRUE); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
85 return; |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
86 } |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
87 else if (!g_ascii_strcasecmp(argv[1], "off")) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
88 audacious_remote_main_win_toggle(dbus_proxy, FALSE); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
89 return; |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
90 } |
2737 | 91 } |
92 | |
93 void playlist_show(gint argc, gchar **argv) | |
94 { | |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
95 if (argc < 2) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
96 audtool_whine("invalid parameter for %s.", argv[0]); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
97 audtool_whine("syntax: %s <on/off>", argv[0]); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
98 exit(1); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
99 } |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
100 |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
101 if (!g_ascii_strcasecmp(argv[1], "on")) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
102 audacious_remote_pl_win_toggle(dbus_proxy, TRUE); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
103 return; |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
104 } |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
105 else if (!g_ascii_strcasecmp(argv[1], "off")) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
106 audacious_remote_pl_win_toggle(dbus_proxy, FALSE); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
107 return; |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
108 } |
2737 | 109 } |
110 | |
111 void equalizer_show(gint argc, gchar **argv) | |
112 { | |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
113 if (argc < 2) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
114 audtool_whine("invalid parameter for %s.", argv[0]); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
115 audtool_whine("syntax: %s <on/off>", argv[0]); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
116 exit(1); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
117 } |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
118 |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
119 if (!g_ascii_strcasecmp(argv[1] ,"on")) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
120 audacious_remote_eq_win_toggle(dbus_proxy, TRUE); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
121 return; |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
122 } |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
123 else if (!g_ascii_strcasecmp(argv[1] ,"off")) { |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
124 audacious_remote_eq_win_toggle(dbus_proxy, FALSE); |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
125 return; |
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
126 } |
2737 | 127 } |
128 | |
129 void show_preferences_window(gint argc, gchar **argv) | |
130 { | |
3917 | 131 gboolean show = TRUE; |
132 | |
133 if (argc < 2) { | |
134 #if 0 | |
135 audtool_whine("invalid parameter for %s.", argv[0]); | |
136 audtool_whine("syntax: %s <on/off>", argv[0]); | |
137 exit(1); | |
138 #else | |
139 audacious_remote_toggle_prefs_box(dbus_proxy, show); | |
140 return; | |
141 #endif | |
142 } | |
143 | |
144 if (!g_ascii_strcasecmp(argv[1], "on")) | |
145 show = TRUE; | |
146 else if (!g_ascii_strcasecmp(argv[1], "off")) | |
147 show = FALSE; | |
148 else { | |
149 audtool_whine("invalid parameter for %s.", argv[0]); | |
150 audtool_whine("syntax: %s <on/off>", argv[0]); | |
151 exit (1); | |
152 } | |
153 | |
154 audacious_remote_toggle_prefs_box(dbus_proxy, show); | |
2737 | 155 } |
156 | |
3867
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2940
diff
changeset
|
157 void show_about_window(gint argc, gchar **argv) |
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2940
diff
changeset
|
158 { |
3917 | 159 gboolean show = TRUE; |
160 | |
161 if (argc < 2) { | |
162 #if 0 | |
163 audtool_whine("invalid parameter for %s.", argv[0]); | |
164 audtool_whine("syntax: %s <on/off>", argv[0]); | |
165 exit(1); | |
166 #else | |
167 audacious_remote_toggle_about_box(dbus_proxy, show); | |
168 return; | |
169 #endif | |
170 } | |
171 | |
172 if (!g_ascii_strcasecmp(argv[1], "on")) | |
173 show = TRUE; | |
174 else if (!g_ascii_strcasecmp(argv[1], "off")) | |
175 show = FALSE; | |
176 else { | |
177 audtool_whine("invalid parameter for %s.", argv[0]); | |
178 audtool_whine("syntax: %s <on/off>", argv[0]); | |
179 exit (1); | |
180 } | |
181 | |
182 audacious_remote_toggle_about_box(dbus_proxy, show); | |
3867
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2940
diff
changeset
|
183 } |
e48f2f4c116d
- many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2940
diff
changeset
|
184 |
2737 | 185 void show_jtf_window(gint argc, gchar **argv) |
186 { | |
3917 | 187 gboolean show = TRUE; |
188 | |
189 if (argc < 2) { | |
190 #if 0 | |
191 audtool_whine("invalid parameter for %s.", argv[0]); | |
192 audtool_whine("syntax: %s <on/off>", argv[0]); | |
193 exit(1); | |
194 #else | |
195 audacious_remote_toggle_jtf_box(dbus_proxy, show); | |
196 return; | |
197 #endif | |
198 } | |
199 if (!g_ascii_strcasecmp(argv[1], "on")) | |
200 show = TRUE; | |
201 else if (!g_ascii_strcasecmp(argv[1], "off")) | |
202 show = FALSE; | |
203 else { | |
204 audtool_whine("invalid parameter for %s.", argv[0]); | |
205 audtool_whine("syntax: %s <on/off>", argv[0]); | |
206 exit (1); | |
207 } | |
208 | |
209 audacious_remote_toggle_jtf_box(dbus_proxy, show); | |
210 } | |
211 | |
212 void show_filebrowser(gint argc, gchar **argv) | |
213 { | |
214 gboolean show = TRUE; | |
215 | |
216 if (argc < 2) { | |
217 #if 0 | |
218 audtool_whine("invalid parameter for %s.", argv[0]); | |
219 audtool_whine("syntax: %s <on/off>", argv[0]); | |
220 exit(1); | |
221 #else | |
222 audacious_remote_toggle_filebrowser(dbus_proxy, show); | |
223 return; | |
224 #endif | |
225 } | |
226 | |
227 if (!g_ascii_strcasecmp(argv[1], "on")) | |
228 show = TRUE; | |
229 else if (!g_ascii_strcasecmp(argv[1], "off")) | |
230 show = FALSE; | |
231 else { | |
232 audtool_whine("invalid parameter for %s.", argv[0]); | |
233 audtool_whine("syntax: %s <on/off>", argv[0]); | |
234 exit (1); | |
235 } | |
236 | |
237 audacious_remote_toggle_filebrowser(dbus_proxy, show); | |
2737 | 238 } |
239 | |
240 void shutdown_audacious_server(gint argc, gchar **argv) | |
241 { | |
242 audacious_remote_quit(dbus_proxy); | |
243 } | |
244 | |
245 void get_handlers_list(gint argc, gchar **argv) | |
246 { | |
247 gint i; | |
248 | |
249 for (i = 0; handlers[i].name != NULL; i++) | |
250 { | |
2939
964413953abd
Use portable g_ascii_strcasecmp().
William Pitcock <nenolod@atheme.org>
parents:
2935
diff
changeset
|
251 if (!g_ascii_strcasecmp("<sep>", handlers[i].name)) |
2935
fc8a2ebb2e13
Fix display of help system.
William Pitcock <nenolod@atheme.org>
parents:
2932
diff
changeset
|
252 audtool_report("%s%s:", i == 0 ? "" : "\n", handlers[i].desc); |
2737 | 253 else |
2932
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
254 audtool_report(" %-34s - %s", handlers[i].name, handlers[i].desc); |
2737 | 255 } |
256 | |
3873
f3341c2d6b9e
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3867
diff
changeset
|
257 audtool_report(""); |
2932
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
258 audtool_report("Handlers may be prefixed with `--' (GNU-style long-options) or not, your choice."); |
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
259 audtool_report("Report bugs to http://bugs-meta.atheme.org/"); |
2737 | 260 } |
4074 | 261 |
262 void activate(gint argc, gchar **argv) | |
263 { | |
264 audacious_remote_activate(dbus_proxy); | |
265 } | |
266 | |
267 void toggle_aot(gint argc, gchar **argv) | |
268 { | |
269 if (argc < 2) | |
270 { | |
271 audtool_whine("invalid parameters for %s.", argv[0]); | |
272 audtool_whine("syntax: %s <on/off>", argv[0]); | |
273 exit(1); | |
274 } | |
275 | |
276 if (!g_ascii_strcasecmp(argv[1], "on")) { | |
277 audacious_remote_toggle_aot(dbus_proxy, TRUE); | |
278 return; | |
279 } | |
280 else if (!g_ascii_strcasecmp(argv[1], "off")) { | |
281 audacious_remote_toggle_aot(dbus_proxy, FALSE); | |
282 return; | |
283 } | |
284 } | |
285 | |
286 void get_skin(gint argc, gchar **argv) | |
287 { | |
288 gchar *skin = NULL; | |
289 skin = audacious_remote_get_skin(dbus_proxy); | |
290 audtool_report("%s", skin); | |
291 g_free(skin); | |
292 } | |
293 | |
294 void set_skin(gint argc, gchar **argv) | |
295 { | |
296 if (argc < 2) | |
297 { | |
298 audtool_whine("invalid parameters for %s.", argv[0]); | |
299 audtool_whine("syntax: %s <skin>", argv[0]); | |
300 exit(1); | |
301 } | |
302 | |
303 if(!argv[1] || !strcmp(argv[1], "")) | |
304 return; | |
305 | |
306 audacious_remote_set_skin(dbus_proxy, argv[1]); | |
307 } | |
308 | |
309 void get_version(gint argc, gchar **argv) | |
310 { | |
311 gchar *version = NULL; | |
312 version = audacious_remote_get_version(dbus_proxy); | |
313 if(version) | |
314 audtool_report("Audacious %s", version); | |
315 g_free(version); | |
316 } |