Mercurial > audlegacy
annotate src/audtool/audtool.c @ 2715:a20d843fe3f7 trunk
[svn] - some progress towards making audtool build again
author | nenolod |
---|---|
date | Wed, 09 May 2007 14:58:26 -0700 |
parents | 65073812a5cf |
children | 7a60a4236fb9 |
rev | line source |
---|---|
2313 | 1 /* Audtool -- Audacious scripting tool |
2 * Copyright (c) 2005-2007 Audacious development team | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * This program is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License | |
15 * along with this program; if not, write to the Free Software | |
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 */ | |
18 | |
19 #include <stdlib.h> | |
2327
921b2d8d9b2e
[svn] Fixed: audtool.c:883: warning: implicit declaration of function 'strncmp'
js
parents:
2313
diff
changeset
|
20 #include <string.h> |
2313 | 21 #include <glib.h> |
22 #include <locale.h> | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
23 #include "libaudclient/audctrl.h" |
2313 | 24 #include "audtool.h" |
25 | |
26 struct commandhandler handlers[] = { | |
27 {"<sep>", NULL, "Vital information"}, | |
28 {"current-song", get_current_song, "returns current song title"}, | |
29 {"current-song-filename", get_current_song_filename, "returns current song filename"}, | |
30 {"current-song-length", get_current_song_length, "returns current song length"}, | |
31 {"current-song-length-seconds", get_current_song_length_seconds, "returns current song length in seconds"}, | |
32 {"current-song-length-frames", get_current_song_length_frames, "returns current song length in frames"}, | |
33 {"current-song-output-length", get_current_song_output_length, "returns current song output length"}, | |
34 {"current-song-output-length-seconds", get_current_song_output_length_seconds, "returns current song output length in seconds"}, | |
35 {"current-song-output-length-frames", get_current_song_output_length_frames, "returns current song output length in frames"}, | |
36 {"current-song-bitrate", get_current_song_bitrate, "returns current song bitrate in bits per second"}, | |
37 {"current-song-bitrate-kbps", get_current_song_bitrate_kbps, "returns current song bitrate in kilobits per second"}, | |
38 {"current-song-frequency", get_current_song_frequency, "returns current song frequency in hertz"}, | |
39 {"current-song-frequency-khz", get_current_song_frequency_khz, "returns current song frequency in kilohertz"}, | |
40 {"current-song-channels", get_current_song_channels, "returns current song channels"}, | |
2585
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
41 {"current-song-tuple-data", get_current_song_tuple_field_data, "returns the value of a tuple field for the current song"}, |
2313 | 42 {"<sep>", NULL, "Playlist manipulation"}, |
43 {"playlist-advance", playlist_advance, "go to the next song in the playlist"}, | |
44 {"playlist-reverse", playlist_reverse, "go to the previous song in the playlist"}, | |
45 {"playlist-addurl", playlist_add_url_string, "adds a url to the playlist"}, | |
46 {"playlist-delete", playlist_delete, "deletes a song from the playlist"}, | |
47 {"playlist-length", playlist_length, "returns the total length of the playlist"}, | |
48 {"playlist-song", playlist_song, "returns the title of a song in the playlist"}, | |
49 {"playlist-song-filename", playlist_song_filename, "returns the filename of a song in the playlist"}, | |
50 {"playlist-song-length", playlist_song_length, "returns the length of a song in the playlist"}, | |
51 {"playlist-song-length-seconds", playlist_song_length_seconds, "returns the length of a song in the playlist in seconds"}, | |
52 {"playlist-song-length-frames", playlist_song_length_frames, "returns the length of a song in the playlist in frames"}, | |
53 {"playlist-display", playlist_display, "returns the entire playlist"}, | |
54 {"playlist-position", playlist_position, "returns the position in the playlist"}, | |
55 {"playlist-jump", playlist_jump, "jumps to a position in the playlist"}, | |
56 {"playlist-clear", playlist_clear, "clears the playlist"}, | |
57 {"playlist-repeat-status", playlist_repeat_status, "returns the status of playlist repeat"}, | |
58 {"playlist-repeat-toggle", playlist_repeat_toggle, "toggles playlist repeat"}, | |
59 {"playlist-shuffle-status", playlist_shuffle_status, "returns the status of playlist shuffle"}, | |
60 {"playlist-shuffle-toggle", playlist_shuffle_toggle, "toggles playlist shuffle"}, | |
2585
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
61 {"playlist-tuple-data", playlist_tuple_field_data, "returns the value of a tuple field for a song in the playlist"}, |
2313 | 62 {"<sep>", NULL, "Playqueue manipulation"}, |
63 {"playqueue-add", playqueue_add, "adds a song to the playqueue"}, | |
64 {"playqueue-remove", playqueue_remove, "removes a song from the playqueue"}, | |
65 {"playqueue-is-queued", playqueue_is_queued, "returns OK if a song is queued"}, | |
66 {"playqueue-get-position", playqueue_get_position, "returns the queue position of a song in the playlist"}, | |
67 {"playqueue-get-qposition", playqueue_get_qposition, "returns the playlist position of a song in the queue"}, | |
68 {"playqueue-length", playqueue_length, "returns the length of the playqueue"}, | |
69 {"playqueue-display", playqueue_display, "returns a list of currently-queued songs"}, | |
70 {"playqueue-clear", playqueue_clear, "clears the playqueue"}, | |
71 {"<sep>", NULL, "Playback manipulation"}, | |
72 {"playback-play", playback_play, "starts/unpauses song playback"}, | |
73 {"playback-pause", playback_pause, "(un)pauses song playback"}, | |
74 {"playback-playpause", playback_playpause, "plays/(un)pauses song playback"}, | |
75 {"playback-stop", playback_stop, "stops song playback"}, | |
76 {"playback-playing", playback_playing, "returns OK if audacious is playing"}, | |
77 {"playback-paused", playback_paused, "returns OK if audacious is paused"}, | |
78 {"playback-stopped", playback_stopped, "returns OK if audacious is stopped"}, | |
79 {"playback-status", playback_status, "returns the playback status"}, | |
80 {"playback-seek", playback_seek, "performs an absolute seek"}, | |
81 {"playback-seek-relative", playback_seek_relative, "performs a seek relative to the current position"}, | |
82 {"<sep>", NULL, "Volume control"}, | |
83 {"get-volume", get_volume, "returns the current volume level in percent"}, | |
84 {"set-volume", set_volume, "sets the current volume level in percent"}, | |
85 {"<sep>", NULL, "Miscellaneous"}, | |
86 {"mainwin-show", mainwin_show, "shows/hides the main window"}, | |
87 {"playlist-show", playlist_show, "shows/hides the playlist window"}, | |
88 {"equalizer-show", equalizer_show, "shows/hides the equalizer window"}, | |
89 {"preferences", show_preferences_window, "shows/hides the preferences window"}, | |
90 {"jumptofile", show_jtf_window, "shows the jump to file window"}, | |
91 {"shutdown", shutdown_audacious_server, "shuts down audacious"}, | |
92 {"<sep>", NULL, "Help system"}, | |
93 {"list-handlers", get_handlers_list, "shows handlers list"}, | |
94 {"help", get_handlers_list, "shows handlers list"}, | |
95 {NULL, NULL, NULL} | |
96 }; | |
97 | |
98 gint main(gint argc, gchar **argv) | |
99 { | |
100 gint i; | |
101 gchar *remote_uri; | |
102 | |
103 setlocale(LC_CTYPE, ""); | |
104 | |
105 if (argc < 2) | |
106 { | |
107 g_print("%s: usage: %s <command>\n", argv[0], argv[0]); | |
108 g_print("%s: use `%s help' to get a listing of available commands.\n", | |
109 argv[0], argv[0]); | |
110 exit(-2); | |
111 } | |
112 | |
113 if (!xmms_remote_is_running(0) && g_strcasecmp("help", argv[1]) | |
114 && g_strcasecmp("list-handlers", argv[1])) | |
115 { | |
116 g_print("%s: audacious server is not running!\n", argv[0]); | |
117 exit(-1); | |
118 } | |
119 | |
120 for (i = 0; handlers[i].name != NULL; i++) | |
121 { | |
122 if ((!g_strcasecmp(handlers[i].name, argv[1]) || | |
123 !g_strcasecmp(g_strconcat("--", handlers[i].name, NULL), argv[1])) | |
124 && g_strcasecmp("<sep>", handlers[i].name)) | |
125 { | |
126 handlers[i].handler(0, argc, argv); | |
127 exit(0); | |
128 } | |
129 } | |
130 | |
131 g_print("%s: invalid command '%s'\n", argv[0], argv[1]); | |
132 g_print("%s: use `%s help' to get a listing of available commands.\n", argv[0], argv[0]); | |
133 | |
134 return 0; | |
135 } | |
136 | |
137 /*** MOVE TO HANDLERS.C ***/ | |
138 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
139 void get_current_song(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 140 { |
141 gint playpos = xmms_remote_get_playlist_pos(session); | |
142 gchar *song = xmms_remote_get_playlist_title(session, playpos); | |
143 | |
144 if (!song) | |
145 { | |
146 g_print("No song playing.\n"); | |
147 return; | |
148 } | |
149 | |
150 g_print("%s\n", song); | |
151 } | |
152 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
153 void get_current_song_filename(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 154 { |
155 gint playpos = xmms_remote_get_playlist_pos(session); | |
156 | |
157 g_print("%s\n", xmms_remote_get_playlist_file(session, playpos)); | |
158 } | |
159 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
160 void get_current_song_output_length(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 161 { |
162 gint frames = xmms_remote_get_output_time(session); | |
163 gint length = frames / 1000; | |
164 | |
165 g_print("%d:%.2d\n", length / 60, length % 60); | |
166 } | |
167 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
168 void get_current_song_output_length_seconds(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 169 { |
170 gint frames = xmms_remote_get_output_time(session); | |
171 gint length = frames / 1000; | |
172 | |
173 g_print("%d\n", length); | |
174 } | |
175 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
176 void get_current_song_output_length_frames(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 177 { |
178 gint frames = xmms_remote_get_output_time(session); | |
179 | |
180 g_print("%d\n", frames); | |
181 } | |
182 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
183 void get_current_song_length(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 184 { |
185 gint playpos = xmms_remote_get_playlist_pos(session); | |
186 gint frames = xmms_remote_get_playlist_time(session, playpos); | |
187 gint length = frames / 1000; | |
188 | |
189 g_print("%d:%.2d\n", length / 60, length % 60); | |
190 } | |
191 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
192 void get_current_song_length_seconds(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 193 { |
194 gint playpos = xmms_remote_get_playlist_pos(session); | |
195 gint frames = xmms_remote_get_playlist_time(session, playpos); | |
196 gint length = frames / 1000; | |
197 | |
198 g_print("%d\n", length); | |
199 } | |
200 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
201 void get_current_song_length_frames(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 202 { |
203 gint playpos = xmms_remote_get_playlist_pos(session); | |
204 gint frames = xmms_remote_get_playlist_time(session, playpos); | |
205 | |
206 g_print("%d\n", frames); | |
207 } | |
208 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
209 void get_current_song_bitrate(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 210 { |
211 gint rate, freq, nch; | |
212 | |
213 xmms_remote_get_info(session, &rate, &freq, &nch); | |
214 | |
215 g_print("%d\n", rate); | |
216 } | |
217 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
218 void get_current_song_bitrate_kbps(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 219 { |
220 gint rate, freq, nch; | |
221 | |
222 xmms_remote_get_info(session, &rate, &freq, &nch); | |
223 | |
224 g_print("%d\n", rate / 1000); | |
225 } | |
226 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
227 void get_current_song_frequency(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 228 { |
229 gint rate, freq, nch; | |
230 | |
231 xmms_remote_get_info(session, &rate, &freq, &nch); | |
232 | |
233 g_print("%d\n", freq); | |
234 } | |
235 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
236 void get_current_song_frequency_khz(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 237 { |
238 gint rate, freq, nch; | |
239 | |
240 xmms_remote_get_info(session, &rate, &freq, &nch); | |
241 | |
242 g_print("%0.1f\n", (gfloat) freq / 1000); | |
243 } | |
244 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
245 void get_current_song_channels(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 246 { |
247 gint rate, freq, nch; | |
248 | |
249 xmms_remote_get_info(session, &rate, &freq, &nch); | |
250 | |
251 g_print("%d\n", nch); | |
252 } | |
253 | |
2585
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
254 |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
255 void get_current_song_tuple_field_data(DBusGProxy *session, gint argc, gchar **argv) |
2585
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
256 { |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
257 gpointer data; |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
258 |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
259 if (argc < 3) |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
260 { |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
261 g_print("%s: invalid parameters for current-song-tuple-data.\n", argv[0]); |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
262 g_print("%s: syntax: %s current-song-tuple-data <fieldname>\n", argv[0], argv[0]); |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
263 g_print("%s: - fieldname example choices: performer, album_name,\n", argv[0]); |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
264 g_print("%s: track_name, track_number, year, date, genre, comment,\n", argv[0]); |
2593
65073812a5cf
[svn] - custom field support for audacious_get_tuple_field_data()
nhjm449
parents:
2585
diff
changeset
|
265 g_print("%s: file_name, file_ext, file_path, length, formatter,\n", argv[0]); |
65073812a5cf
[svn] - custom field support for audacious_get_tuple_field_data()
nhjm449
parents:
2585
diff
changeset
|
266 g_print("%s: custom, mtime\n", argv[0]); |
2585
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
267 return; |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
268 } |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
269 |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
270 if (!(data = audacious_get_tuple_field_data(session, argv[2], xmms_remote_get_playlist_pos(session)))) |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
271 { |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
272 return; |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
273 } |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
274 |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
275 if (!strcasecmp(argv[2], "track_number") || !strcasecmp(argv[2], "year") || !strcasecmp(argv[2], "length") || !strcasecmp(argv[2], "mtime")) |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
276 { |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
277 if (*(gint *)data > 0) |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
278 { |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
279 g_print("%d\n", *(gint *)data); |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
280 } |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
281 return; |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
282 } |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
283 |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
284 g_print("%s\n", (gchar *)data); |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
285 } |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
286 |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
287 void playlist_reverse(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 288 { |
289 xmms_remote_playlist_prev(session); | |
290 } | |
291 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
292 void playlist_advance(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 293 { |
294 xmms_remote_playlist_next(session); | |
295 } | |
296 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
297 void playback_play(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 298 { |
299 xmms_remote_play(session); | |
300 } | |
301 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
302 void playback_pause(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 303 { |
304 xmms_remote_pause(session); | |
305 } | |
306 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
307 void playback_playpause(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 308 { |
309 if (xmms_remote_is_playing(session)) | |
310 { | |
311 xmms_remote_pause(session); | |
312 } | |
313 else | |
314 { | |
315 xmms_remote_play(session); | |
316 } | |
317 } | |
318 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
319 void playback_stop(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 320 { |
321 xmms_remote_stop(session); | |
322 } | |
323 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
324 void playback_playing(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 325 { |
326 if (!xmms_remote_is_paused(session)) | |
327 { | |
328 exit(!xmms_remote_is_playing(session)); | |
329 } | |
330 else | |
331 { | |
332 exit(1); | |
333 } | |
334 } | |
335 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
336 void playback_paused(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 337 { |
338 exit(!xmms_remote_is_paused(session)); | |
339 } | |
340 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
341 void playback_stopped(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 342 { |
343 if (!xmms_remote_is_playing(session) && !xmms_remote_is_paused(session)) | |
344 { | |
345 exit(0); | |
346 } | |
347 else | |
348 { | |
349 exit(1); | |
350 } | |
351 } | |
352 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
353 void playback_status(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 354 { |
355 if (xmms_remote_is_paused(session)) | |
356 { | |
357 g_print("paused\n"); | |
358 return; | |
359 } | |
360 else if (xmms_remote_is_playing(session)) | |
361 { | |
362 g_print("playing\n"); | |
363 return; | |
364 } | |
365 else | |
366 { | |
367 g_print("stopped\n"); | |
368 return; | |
369 } | |
370 } | |
371 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
372 void playback_seek(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 373 { |
374 if (argc < 3) | |
375 { | |
376 g_print("%s: invalid parameters for playback-seek.\n", argv[0]); | |
377 g_print("%s: syntax: %s playback-seek <position>\n", argv[0], argv[0]); | |
378 return; | |
379 } | |
380 | |
381 xmms_remote_jump_to_time(session, atoi(argv[2]) * 1000); | |
382 } | |
383 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
384 void playback_seek_relative(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 385 { |
386 gint oldtime, newtime, diff; | |
387 | |
388 if (argc < 3) | |
389 { | |
390 g_print("%s: invalid parameters for playback-seek-relative.\n", argv[0]); | |
391 g_print("%s: syntax: %s playback-seek <position>\n", argv[0], argv[0]); | |
392 return; | |
393 } | |
394 | |
395 oldtime = xmms_remote_get_output_time(session); | |
396 diff = atoi(argv[2]) * 1000; | |
397 newtime = oldtime + diff; | |
398 | |
399 xmms_remote_jump_to_time(session, newtime); | |
400 } | |
401 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
402 void playlist_add_url_string(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 403 { |
404 if (argc < 3) | |
405 { | |
406 g_print("%s: invalid parameters for playlist-addurl.\n", argv[0]); | |
407 g_print("%s: syntax: %s playlist-addurl <url>\n", argv[0], argv[0]); | |
408 return; | |
409 } | |
410 | |
411 xmms_remote_playlist_add_url_string(session, argv[2]); | |
412 } | |
413 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
414 void playlist_delete(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 415 { |
416 gint playpos; | |
417 | |
418 if (argc < 3) | |
419 { | |
420 g_print("%s: invalid parameters for playlist-delete.\n", argv[0]); | |
421 g_print("%s: syntax: %s playlist-delete <position>\n", argv[0], argv[0]); | |
422 return; | |
423 } | |
424 | |
425 playpos = atoi(argv[2]); | |
426 | |
427 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
428 { | |
429 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
430 return; | |
431 } | |
432 | |
433 xmms_remote_playlist_delete(session, playpos - 1); | |
434 } | |
435 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
436 void playlist_length(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 437 { |
438 gint i; | |
439 | |
440 i = xmms_remote_get_playlist_length(session); | |
441 | |
442 g_print("%d\n", i); | |
443 } | |
444 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
445 void playlist_song(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 446 { |
447 gint playpos; | |
448 gchar *song; | |
449 | |
450 if (argc < 3) | |
451 { | |
452 g_print("%s: invalid parameters for playlist-song-title.\n", argv[0]); | |
453 g_print("%s: syntax: %s playlist-song-title <position>\n", argv[0], argv[0]); | |
454 return; | |
455 } | |
456 | |
457 playpos = atoi(argv[2]); | |
458 | |
459 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
460 { | |
461 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
462 return; | |
463 } | |
464 | |
465 song = xmms_remote_get_playlist_title(session, playpos - 1); | |
466 | |
467 g_print("%s\n", song); | |
468 } | |
469 | |
470 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
471 void playlist_song_length(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 472 { |
473 gint playpos, frames, length; | |
474 | |
475 if (argc < 3) | |
476 { | |
477 g_print("%s: invalid parameters for playlist-song-length.\n", argv[0]); | |
478 g_print("%s: syntax: %s playlist-song-length <position>\n", argv[0], argv[0]); | |
479 return; | |
480 } | |
481 | |
482 playpos = atoi(argv[2]); | |
483 | |
484 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
485 { | |
486 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
487 return; | |
488 } | |
489 | |
490 frames = xmms_remote_get_playlist_time(session, playpos - 1); | |
491 length = frames / 1000; | |
492 | |
493 g_print("%d:%.2d\n", length / 60, length % 60); | |
494 } | |
495 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
496 void playlist_song_length_seconds(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 497 { |
498 gint playpos, frames, length; | |
499 | |
500 if (argc < 3) | |
501 { | |
502 g_print("%s: invalid parameters for playlist-song-length-seconds.\n", argv[0]); | |
503 g_print("%s: syntax: %s playlist-song-length-seconds <position>\n", argv[0], argv[0]); | |
504 return; | |
505 } | |
506 | |
507 playpos = atoi(argv[2]); | |
508 | |
509 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
510 { | |
511 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
512 return; | |
513 } | |
514 | |
515 frames = xmms_remote_get_playlist_time(session, playpos - 1); | |
516 length = frames / 1000; | |
517 | |
518 g_print("%d\n", length); | |
519 } | |
520 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
521 void playlist_song_length_frames(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 522 { |
523 gint playpos, frames; | |
524 | |
525 if (argc < 3) | |
526 { | |
527 g_print("%s: invalid parameters for playlist-song-length-frames.\n", argv[0]); | |
528 g_print("%s: syntax: %s playlist-song-length-frames <position>\n", argv[0], argv[0]); | |
529 return; | |
530 } | |
531 | |
532 playpos = atoi(argv[2]); | |
533 | |
534 if (playpos < 1 || playpos > xmms_remote_get_playlist_length(session)) | |
535 { | |
536 g_print("%s: invalid playlist position %d\n", argv[0], playpos); | |
537 return; | |
538 } | |
539 | |
540 frames = xmms_remote_get_playlist_time(session, playpos - 1); | |
541 | |
542 g_print("%d\n", frames); | |
543 } | |
544 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
545 void playlist_display(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 546 { |
547 gint i, ii, frames, length, total; | |
548 gchar *songname; | |
549 gchar *fmt = NULL, *p; | |
550 gint column; | |
551 | |
552 i = xmms_remote_get_playlist_length(session); | |
553 | |
554 g_print("%d tracks.\n", i); | |
555 | |
556 total = 0; | |
557 | |
558 for (ii = 0; ii < i; ii++) | |
559 { | |
560 songname = xmms_remote_get_playlist_title(session, ii); | |
561 frames = xmms_remote_get_playlist_time(session, ii); | |
562 length = frames / 1000; | |
563 total += length; | |
564 | |
565 /* adjust width for multi byte characters */ | |
566 column = 60; | |
567 if(songname){ | |
568 p = songname; | |
569 while(*p){ | |
570 gint stride; | |
571 stride = g_utf8_next_char(p) - p; | |
572 if(g_unichar_iswide(g_utf8_get_char(p)) | |
573 #if ( (GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION >= 12) ) | |
574 || g_unichar_iswide_cjk(g_utf8_get_char(p)) | |
575 #endif | |
576 ){ | |
577 column += (stride - 2); | |
578 } | |
579 else { | |
580 column += (stride - 1); | |
581 } | |
582 p = g_utf8_next_char(p); | |
583 } | |
584 | |
585 } | |
586 | |
587 fmt = g_strdup_printf("%%4d | %%-%ds | %%d:%%.2d\n", column); | |
588 g_print(fmt, ii + 1, songname, length / 60, length % 60); | |
589 g_free(fmt); | |
590 } | |
591 | |
592 g_print("Total length: %d:%.2d\n", total / 60, total % 60); | |
593 } | |
594 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
595 void playlist_position(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 596 { |
597 gint i; | |
598 | |
599 i = xmms_remote_get_playlist_pos(session); | |
600 | |
601 g_print("%d\n", i + 1); | |
602 } | |
603 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
604 void playlist_song_filename(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 605 { |
606 gint i; | |
607 | |
608 if (argc < 3) | |
609 { | |
610 g_print("%s: invalid parameters for playlist-filename.\n", argv[0]); | |
611 g_print("%s: syntax: %s playlist-filename <position>\n", argv[0], argv[0]); | |
612 return; | |
613 } | |
614 | |
615 i = atoi(argv[2]); | |
616 | |
617 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
618 { | |
619 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
620 return; | |
621 } | |
622 | |
623 g_print("%s\n", xmms_remote_get_playlist_file(session, i - 1)); | |
624 } | |
625 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
626 void playlist_jump(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 627 { |
628 gint i; | |
629 | |
630 if (argc < 3) | |
631 { | |
632 g_print("%s: invalid parameters for playlist-jump.\n", argv[0]); | |
633 g_print("%s: syntax: %s playlist-jump <position>\n", argv[0], argv[0]); | |
634 return; | |
635 } | |
636 | |
637 i = atoi(argv[2]); | |
638 | |
639 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
640 { | |
641 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
642 return; | |
643 } | |
644 | |
645 xmms_remote_set_playlist_pos(session, i - 1); | |
646 } | |
647 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
648 void playlist_clear(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 649 { |
650 xmms_remote_playlist_clear(session); | |
651 } | |
652 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
653 void playlist_repeat_status(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 654 { |
655 if (xmms_remote_is_repeat(session)) | |
656 { | |
657 g_print("on\n"); | |
658 return; | |
659 } | |
660 else | |
661 { | |
662 g_print("off\n"); | |
663 return; | |
664 } | |
665 } | |
666 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
667 void playlist_repeat_toggle(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 668 { |
669 xmms_remote_toggle_repeat(session); | |
670 } | |
671 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
672 void playlist_shuffle_status(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 673 { |
674 if (xmms_remote_is_shuffle(session)) | |
675 { | |
676 g_print("on\n"); | |
677 return; | |
678 } | |
679 else | |
680 { | |
681 g_print("off\n"); | |
682 return; | |
683 } | |
684 } | |
685 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
686 void playlist_shuffle_toggle(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 687 { |
688 xmms_remote_toggle_shuffle(session); | |
689 } | |
690 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
691 void playlist_tuple_field_data(DBusGProxy *session, gint argc, gchar **argv) |
2585
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
692 { |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
693 gint i; |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
694 gpointer data; |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
695 |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
696 if (argc < 4) |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
697 { |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
698 g_print("%s: invalid parameters for playlist-tuple-data.\n", argv[0]); |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
699 g_print("%s: syntax: %s playlist-tuple-data <fieldname> <position>\n", argv[0], argv[0]); |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
700 g_print("%s: - fieldname example choices: performer, album_name,\n", argv[0]); |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
701 g_print("%s: track_name, track_number, year, date, genre, comment,\n", argv[0]); |
2593
65073812a5cf
[svn] - custom field support for audacious_get_tuple_field_data()
nhjm449
parents:
2585
diff
changeset
|
702 g_print("%s: file_name, file_ext, file_path, length, formatter,\n", argv[0]); |
65073812a5cf
[svn] - custom field support for audacious_get_tuple_field_data()
nhjm449
parents:
2585
diff
changeset
|
703 g_print("%s: custom, mtime\n", argv[0]); |
2585
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
704 return; |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
705 } |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
706 |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
707 i = atoi(argv[3]); |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
708 |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
709 if (i < 1 || i > xmms_remote_get_playlist_length(session)) |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
710 { |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
711 g_print("%s: invalid playlist position %d\n", argv[0], i); |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
712 return; |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
713 } |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
714 |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
715 if (!(data = audacious_get_tuple_field_data(session, argv[2], i - 1))) |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
716 { |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
717 return; |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
718 } |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
719 |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
720 if (!strcasecmp(argv[2], "track_number") || !strcasecmp(argv[2], "year") || !strcasecmp(argv[2], "length") || !strcasecmp(argv[2], "mtime")) |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
721 { |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
722 if (*(gint *)data > 0) |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
723 { |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
724 g_print("%d\n", *(gint *)data); |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
725 } |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
726 return; |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
727 } |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
728 |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
729 g_print("%s\n", (gchar *)data); |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
730 } |
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2327
diff
changeset
|
731 |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
732 void playqueue_add(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 733 { |
734 gint i; | |
735 | |
736 if (argc < 3) | |
737 { | |
738 g_print("%s: invalid parameters for playqueue-add.\n", argv[0]); | |
739 g_print("%s: syntax: %s playqueue-add <position>\n", argv[0], argv[0]); | |
740 return; | |
741 } | |
742 | |
743 i = atoi(argv[2]); | |
744 | |
745 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
746 { | |
747 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
748 return; | |
749 } | |
750 | |
751 if (!(xmms_remote_playqueue_is_queued(session, i - 1))) | |
752 xmms_remote_playqueue_add(session, i - 1); | |
753 } | |
754 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
755 void playqueue_remove(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 756 { |
757 gint i; | |
758 | |
759 if (argc < 3) | |
760 { | |
761 g_print("%s: invalid parameters for playqueue-remove.\n", argv[0]); | |
762 g_print("%s: syntax: %s playqueue-remove <position>\n", argv[0], argv[0]); | |
763 return; | |
764 } | |
765 | |
766 i = atoi(argv[2]); | |
767 | |
768 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
769 { | |
770 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
771 return; | |
772 } | |
773 | |
774 if (xmms_remote_playqueue_is_queued(session, i - 1)) | |
775 xmms_remote_playqueue_remove(session, i - 1); | |
776 } | |
777 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
778 void playqueue_is_queued(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 779 { |
780 gint i; | |
781 | |
782 if (argc < 3) | |
783 { | |
784 g_print("%s: invalid parameters for playqueue-is-queued.\n", argv[0]); | |
785 g_print("%s: syntax: %s playqueue-is-queued <position>\n", argv[0], argv[0]); | |
786 return; | |
787 } | |
788 | |
789 i = atoi(argv[2]); | |
790 | |
791 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
792 { | |
793 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
794 return; | |
795 } | |
796 | |
797 exit(!(xmms_remote_playqueue_is_queued(session, i - 1))); | |
798 } | |
799 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
800 void playqueue_get_position(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 801 { |
802 gint i, pos; | |
803 | |
804 if (argc < 3) | |
805 { | |
806 g_print("%s: invalid parameters for playqueue-get-position.\n", argv[0]); | |
807 g_print("%s: syntax: %s playqueue-get-position <position>\n", argv[0], argv[0]); | |
808 return; | |
809 } | |
810 | |
811 i = atoi(argv[2]); | |
812 | |
813 if (i < 1 || i > xmms_remote_get_playlist_length(session)) | |
814 { | |
815 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
816 return; | |
817 } | |
818 | |
819 pos = xmms_remote_get_playqueue_position(session, i - 1) + 1; | |
820 | |
821 if (pos < 1) | |
822 return; | |
823 | |
824 g_print("%d\n", pos); | |
825 } | |
826 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
827 void playqueue_get_qposition(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 828 { |
829 gint i, pos; | |
830 | |
831 if (argc < 3) | |
832 { | |
833 g_print("%s: invalid parameters for playqueue-get-qposition.\n", argv[0]); | |
834 g_print("%s: syntax: %s playqueue-get-qposition <position>\n", argv[0], argv[0]); | |
835 return; | |
836 } | |
837 | |
838 i = atoi(argv[2]); | |
839 | |
840 if (i < 1 || i > xmms_remote_get_playqueue_length(session)) | |
841 { | |
842 g_print("%s: invalid playlist position %d\n", argv[0], i); | |
843 return; | |
844 } | |
845 | |
846 pos = xmms_remote_get_playqueue_queue_position(session, i - 1) + 1; | |
847 | |
848 if (pos < 1) | |
849 return; | |
850 | |
851 g_print("%d\n", pos); | |
852 } | |
853 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
854 void playqueue_display(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 855 { |
856 gint i, ii, position, frames, length, total; | |
857 gchar *songname; | |
858 gchar *fmt = NULL, *p; | |
859 gint column; | |
860 | |
861 i = xmms_remote_get_playqueue_length(session); | |
862 | |
863 g_print("%d queued tracks.\n", i); | |
864 | |
865 total = 0; | |
866 | |
867 for (ii = 0; ii < i; ii++) | |
868 { | |
869 position = xmms_remote_get_playqueue_queue_position(session, ii); | |
870 songname = xmms_remote_get_playlist_title(session, position); | |
871 frames = xmms_remote_get_playlist_time(session, position); | |
872 length = frames / 1000; | |
873 total += length; | |
874 | |
875 /* adjust width for multi byte characters */ | |
876 column = 60; | |
877 if(songname) { | |
878 p = songname; | |
879 while(*p){ | |
880 gint stride; | |
881 stride = g_utf8_next_char(p) - p; | |
882 if(g_unichar_iswide(g_utf8_get_char(p)) | |
883 #if ( (GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION >= 12) ) | |
884 || g_unichar_iswide_cjk(g_utf8_get_char(p)) | |
885 #endif | |
886 ){ | |
887 column += (stride - 2); | |
888 } | |
889 else { | |
890 column += (stride - 1); | |
891 } | |
892 p = g_utf8_next_char(p); | |
893 } | |
894 } | |
895 | |
896 fmt = g_strdup_printf("%%4d | %%4d | %%-%ds | %%d:%%.2d\n", column); | |
897 g_print(fmt, ii + 1, position + 1, songname, length / 60, length % 60); | |
898 g_free(fmt); | |
899 } | |
900 | |
901 g_print("Total length: %d:%.2d\n", total / 60, total % 60); | |
902 } | |
903 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
904 void playqueue_length(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 905 { |
906 gint i; | |
907 | |
908 i = xmms_remote_get_playqueue_length(session); | |
909 | |
910 g_print("%d\n", i); | |
911 } | |
912 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
913 void playqueue_clear(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 914 { |
915 xmms_remote_playqueue_clear(session); | |
916 } | |
917 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
918 void get_volume(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 919 { |
920 gint i; | |
921 | |
922 i = xmms_remote_get_main_volume(session); | |
923 | |
924 g_print("%d\n", i); | |
925 } | |
926 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
927 void set_volume(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 928 { |
929 gint i, current_volume; | |
930 | |
931 if (argc < 3) | |
932 { | |
933 g_print("%s: invalid parameters for set-volume.\n", argv[0]); | |
934 g_print("%s: syntax: %s set-volume <level>\n", argv[0], argv[0]); | |
935 return; | |
936 } | |
937 | |
938 current_volume = xmms_remote_get_main_volume(session); | |
939 switch (argv[2][0]) | |
940 { | |
941 case '+': | |
942 case '-': | |
943 i = current_volume + atoi(argv[2]); | |
944 break; | |
945 default: | |
946 i = atoi(argv[2]); | |
947 break; | |
948 } | |
949 | |
950 xmms_remote_set_main_volume(session, i); | |
951 } | |
952 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
953 void mainwin_show(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 954 { |
955 if (argc > 2) | |
956 { | |
957 if (!strncmp(argv[2],"on",2)) { | |
958 xmms_remote_main_win_toggle(session, TRUE); | |
959 return; | |
960 } | |
961 else if (!strncmp(argv[2],"off",3)) { | |
962 xmms_remote_main_win_toggle(session, FALSE); | |
963 return; | |
964 } | |
965 } | |
966 g_print("%s: invalid parameter for mainwin-show.\n",argv[0]); | |
967 g_print("%s: syntax: %s mainwin-show <on/off>\n",argv[0],argv[0]); | |
968 } | |
969 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
970 void playlist_show(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 971 { |
972 if (argc > 2) | |
973 { | |
974 if (!strncmp(argv[2],"on",2)) { | |
975 xmms_remote_pl_win_toggle(session, TRUE); | |
976 return; | |
977 } | |
978 else if (!strncmp(argv[2],"off",3)) { | |
979 xmms_remote_pl_win_toggle(session, FALSE); | |
980 return; | |
981 } | |
982 } | |
983 g_print("%s: invalid parameter for playlist-show.\n",argv[0]); | |
984 g_print("%s: syntax: %s playlist-show <on/off>\n",argv[0],argv[0]); | |
985 } | |
986 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
987 void equalizer_show(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 988 { |
989 if (argc > 2) | |
990 { | |
991 if (!strncmp(argv[2],"on",2)) { | |
992 xmms_remote_eq_win_toggle(session, TRUE); | |
993 return; | |
994 } | |
995 else if (!strncmp(argv[2],"off",3)) { | |
996 xmms_remote_eq_win_toggle(session, FALSE); | |
997 return; | |
998 } | |
999 } | |
1000 g_print("%s: invalid parameter for equalizer-show.\n",argv[0]); | |
1001 g_print("%s: syntax: %s equalizer-show <on/off>\n",argv[0],argv[0]); | |
1002 } | |
1003 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
1004 void show_preferences_window(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 1005 { |
1006 xmms_remote_show_prefs_box(session); | |
1007 } | |
1008 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
1009 void show_jtf_window(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 1010 { |
1011 xmms_remote_show_jtf_box(session); | |
1012 } | |
1013 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
1014 void shutdown_audacious_server(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 1015 { |
1016 xmms_remote_quit(session); | |
1017 } | |
1018 | |
2715
a20d843fe3f7
[svn] - some progress towards making audtool build again
nenolod
parents:
2593
diff
changeset
|
1019 void get_handlers_list(DBusGProxy *session, gint argc, gchar **argv) |
2313 | 1020 { |
1021 gint i; | |
1022 | |
1023 for (i = 0; handlers[i].name != NULL; i++) | |
1024 { | |
1025 if (!g_strcasecmp("<sep>", handlers[i].name)) | |
1026 g_print("%s%s:\n", i == 0 ? "" : "\n", handlers[i].desc); | |
1027 else | |
1028 g_print(" %-34s - %s\n", handlers[i].name, handlers[i].desc); | |
1029 } | |
1030 | |
1031 g_print("\nHandlers may be prefixed with `--' (GNU-style long-options) or not, your choice.\n"); | |
1032 g_print("Report bugs to http://bugs-meta.atheme.org/\n"); | |
1033 } |