Mercurial > audlegacy
annotate src/audtool/audtool_handlers_general.c @ 2947:13591e28d89e trunk
cleanup
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Sun, 01 Jul 2007 12:52:58 +0200 |
parents | b51cc33881c2 |
children | e48f2f4c116d |
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]); |
2737 | 57 return; |
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 { | |
2925
90ca95b7277d
Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents:
2922
diff
changeset
|
77 if (argc > 1) |
2737 | 78 { |
2940
b51cc33881c2
Use g_ascii_strcasecmp() instead of strncmp().
William Pitcock <nenolod@atheme.org>
parents:
2939
diff
changeset
|
79 if (!g_ascii_strcasecmp(argv[1], "on")) { |
2737 | 80 audacious_remote_main_win_toggle(dbus_proxy, TRUE); |
81 return; | |
82 } | |
2940
b51cc33881c2
Use g_ascii_strcasecmp() instead of strncmp().
William Pitcock <nenolod@atheme.org>
parents:
2939
diff
changeset
|
83 else if (!g_ascii_strcasecmp(argv[1], "off")) { |
2737 | 84 audacious_remote_main_win_toggle(dbus_proxy, FALSE); |
85 return; | |
86 } | |
87 } | |
2932
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
88 audtool_whine("invalid parameter for %s.", argv[0]); |
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
89 audtool_whine("syntax: %s <on/off>", argv[0]); |
2737 | 90 } |
91 | |
92 void playlist_show(gint argc, gchar **argv) | |
93 { | |
2925
90ca95b7277d
Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents:
2922
diff
changeset
|
94 if (argc > 1) |
2737 | 95 { |
2940
b51cc33881c2
Use g_ascii_strcasecmp() instead of strncmp().
William Pitcock <nenolod@atheme.org>
parents:
2939
diff
changeset
|
96 if (!g_ascii_strcasecmp(argv[1], "on")) { |
2737 | 97 audacious_remote_pl_win_toggle(dbus_proxy, TRUE); |
98 return; | |
99 } | |
2940
b51cc33881c2
Use g_ascii_strcasecmp() instead of strncmp().
William Pitcock <nenolod@atheme.org>
parents:
2939
diff
changeset
|
100 else if (!g_ascii_strcasecmp(argv[1], "off")) { |
2737 | 101 audacious_remote_pl_win_toggle(dbus_proxy, FALSE); |
102 return; | |
103 } | |
104 } | |
2932
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
105 audtool_whine("invalid parameter for %s.", argv[0]); |
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
106 audtool_whine("syntax: %s <on/off>", argv[0]); |
2737 | 107 } |
108 | |
109 void equalizer_show(gint argc, gchar **argv) | |
110 { | |
2925
90ca95b7277d
Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents:
2922
diff
changeset
|
111 if (argc > 1) |
2737 | 112 { |
2940
b51cc33881c2
Use g_ascii_strcasecmp() instead of strncmp().
William Pitcock <nenolod@atheme.org>
parents:
2939
diff
changeset
|
113 if (!g_ascii_strcasecmp(argv[1] ,"on")) { |
2737 | 114 audacious_remote_eq_win_toggle(dbus_proxy, TRUE); |
115 return; | |
116 } | |
2940
b51cc33881c2
Use g_ascii_strcasecmp() instead of strncmp().
William Pitcock <nenolod@atheme.org>
parents:
2939
diff
changeset
|
117 else if (!g_ascii_strcasecmp(argv[1] ,"off")) { |
2737 | 118 audacious_remote_eq_win_toggle(dbus_proxy, FALSE); |
119 return; | |
120 } | |
121 } | |
2932
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
122 audtool_whine("invalid parameter for %s.", argv[0]); |
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
123 audtool_whine("syntax: %s <on/off>", argv[0]); |
2737 | 124 } |
125 | |
126 void show_preferences_window(gint argc, gchar **argv) | |
127 { | |
128 audacious_remote_show_prefs_box(dbus_proxy); | |
129 } | |
130 | |
131 void show_jtf_window(gint argc, gchar **argv) | |
132 { | |
133 audacious_remote_show_jtf_box(dbus_proxy); | |
134 } | |
135 | |
136 void shutdown_audacious_server(gint argc, gchar **argv) | |
137 { | |
138 audacious_remote_quit(dbus_proxy); | |
139 } | |
140 | |
141 void get_handlers_list(gint argc, gchar **argv) | |
142 { | |
143 gint i; | |
144 | |
145 for (i = 0; handlers[i].name != NULL; i++) | |
146 { | |
2939
964413953abd
Use portable g_ascii_strcasecmp().
William Pitcock <nenolod@atheme.org>
parents:
2935
diff
changeset
|
147 if (!g_ascii_strcasecmp("<sep>", handlers[i].name)) |
2935
fc8a2ebb2e13
Fix display of help system.
William Pitcock <nenolod@atheme.org>
parents:
2932
diff
changeset
|
148 audtool_report("%s%s:", i == 0 ? "" : "\n", handlers[i].desc); |
2737 | 149 else |
2932
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
150 audtool_report(" %-34s - %s", handlers[i].name, handlers[i].desc); |
2737 | 151 } |
152 | |
2932
fe27b67d8c37
Transition to audtool_report()/audtool_whine().
William Pitcock <nenolod@atheme.org>
parents:
2929
diff
changeset
|
153 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
|
154 audtool_report("Report bugs to http://bugs-meta.atheme.org/"); |
2737 | 155 } |