annotate src/audtool/main.c @ 4841:a8c464186ec9

Fix "audtool help playback-seek-relative" crash (Debian bug #512910)
author John Lindgren
date Thu, 09 Apr 2009 20:43:01 -0400
parents 62265a3a1870
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2734
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
1 /*
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
2 * Audtool2
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
3 * Copyright (c) 2007 Audacious development team
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
4 *
2734
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
5 * Redistribution and use in source and binary forms, with or without
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
6 * modification, are permitted provided that the following conditions are
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
7 * met:
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
8 *
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
9 * 1. Redistributions of source code must retain the above copyright notice,
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
10 * this list of conditions and the following disclaimer.
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
11 *
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
14 * documentation and/or other materials provided with the distribution.
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
15 *
2734
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
16 * 3. The name of the author may not be used to endorse or promote products
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
17 * derived from this software without specific prior written permission.
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
18 *
2734
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
29 * POSSIBILITY OF SUCH DAMAGE.
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
30 */
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
31
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
32 #include <stdlib.h>
2327
921b2d8d9b2e [svn] Fixed: audtool.c:883: warning: implicit declaration of function 'strncmp'
js
parents: 2313
diff changeset
33 #include <string.h>
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
34 #include <glib.h>
2734
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
35 #include <mowgli.h>
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
36 #include <locale.h>
2715
a20d843fe3f7 [svn] - some progress towards making audtool build again
nenolod
parents: 2593
diff changeset
37 #include "libaudclient/audctrl.h"
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
38 #include "audtool.h"
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
39
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
40 struct commandhandler handlers[] = {
2924
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
41 {"<sep>", NULL, "Vital information", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
42 {"current-song", get_current_song, "returns current song title", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
43 {"current-song-filename", get_current_song_filename, "returns current song filename", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
44 {"current-song-length", get_current_song_length, "returns current song length", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
45 {"current-song-length-seconds", get_current_song_length_seconds, "returns current song length in seconds", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
46 {"current-song-length-frames", get_current_song_length_frames, "returns current song length in frames", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
47 {"current-song-output-length", get_current_song_output_length, "returns current song output length", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
48 {"current-song-output-length-seconds", get_current_song_output_length_seconds, "returns current song output length in seconds", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
49 {"current-song-output-length-frames", get_current_song_output_length_frames, "returns current song output length in frames", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
50 {"current-song-bitrate", get_current_song_bitrate, "returns current song bitrate in bits per second", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
51 {"current-song-bitrate-kbps", get_current_song_bitrate_kbps, "returns current song bitrate in kilobits per second", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
52 {"current-song-frequency", get_current_song_frequency, "returns current song frequency in hertz", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
53 {"current-song-frequency-khz", get_current_song_frequency_khz, "returns current song frequency in kilohertz", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
54 {"current-song-channels", get_current_song_channels, "returns current song channels", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
55 {"current-song-tuple-data", get_current_song_tuple_field_data, "returns the value of a tuple field for the current song", 1},
4074
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
56 {"current-song-info", get_current_song_info, "returns current song bitrate, frequency and channels", 0},
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
57
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
58
2924
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
59 {"<sep>", NULL, "Playlist manipulation", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
60 {"playlist-advance", playlist_advance, "go to the next song in the playlist", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
61 {"playlist-reverse", playlist_reverse, "go to the previous song in the playlist", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
62 {"playlist-addurl", playlist_add_url_string, "adds a url to the playlist", 1},
4074
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
63 {"playlist-insurl", playlist_ins_url_string, "inserts a url at specified position in the playlist", 2},
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
64 {"playlist-addurl-to-new-playlist", playlist_enqueue_to_temp, "adds a url to the newly created playlist", 1},
2924
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
65 {"playlist-delete", playlist_delete, "deletes a song from the playlist", 1},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
66 {"playlist-length", playlist_length, "returns the total length of the playlist", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
67 {"playlist-song", playlist_song, "returns the title of a song in the playlist", 1},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
68 {"playlist-song-filename", playlist_song_filename, "returns the filename of a song in the playlist", 1},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
69 {"playlist-song-length", playlist_song_length, "returns the length of a song in the playlist", 1},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
70 {"playlist-song-length-seconds", playlist_song_length_seconds, "returns the length of a song in the playlist in seconds", 1},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
71 {"playlist-song-length-frames", playlist_song_length_frames, "returns the length of a song in the playlist in frames", 1},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
72 {"playlist-display", playlist_display, "returns the entire playlist", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
73 {"playlist-position", playlist_position, "returns the position in the playlist", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
74 {"playlist-jump", playlist_jump, "jumps to a position in the playlist", 1},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
75 {"playlist-clear", playlist_clear, "clears the playlist", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
76 {"playlist-repeat-status", playlist_repeat_status, "returns the status of playlist repeat", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
77 {"playlist-repeat-toggle", playlist_repeat_toggle, "toggles playlist repeat", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
78 {"playlist-shuffle-status", playlist_shuffle_status, "returns the status of playlist shuffle", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
79 {"playlist-shuffle-toggle", playlist_shuffle_toggle, "toggles playlist shuffle", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
80 {"playlist-tuple-data", playlist_tuple_field_data, "returns the value of a tuple field for a song in the playlist", 2},
4074
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
81
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
82
2924
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
83 {"<sep>", NULL, "Playqueue manipulation", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
84 {"playqueue-add", playqueue_add, "adds a song to the playqueue", 1},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
85 {"playqueue-remove", playqueue_remove, "removes a song from the playqueue", 1},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
86 {"playqueue-is-queued", playqueue_is_queued, "returns OK if a song is queued", 1},
3867
e48f2f4c116d - many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
87 {"playqueue-get-queue-position", playqueue_get_queue_position, "returns the playqueue position of a song in the given poition in the playlist", 1},
e48f2f4c116d - many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
88 {"playqueue-get-list-position", playqueue_get_list_position, "returns the playlist position of a song in the given position in the playqueue", 1},
2924
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
89 {"playqueue-length", playqueue_length, "returns the length of the playqueue", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
90 {"playqueue-display", playqueue_display, "returns a list of currently-queued songs", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
91 {"playqueue-clear", playqueue_clear, "clears the playqueue", 0},
4074
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
92
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
93
2924
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
94 {"<sep>", NULL, "Playback manipulation", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
95 {"playback-play", playback_play, "starts/unpauses song playback", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
96 {"playback-pause", playback_pause, "(un)pauses song playback", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
97 {"playback-playpause", playback_playpause, "plays/(un)pauses song playback", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
98 {"playback-stop", playback_stop, "stops song playback", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
99 {"playback-playing", playback_playing, "returns OK if audacious is playing", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
100 {"playback-paused", playback_paused, "returns OK if audacious is paused", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
101 {"playback-stopped", playback_stopped, "returns OK if audacious is stopped", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
102 {"playback-status", playback_status, "returns the playback status", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
103 {"playback-seek", playback_seek, "performs an absolute seek", 1},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
104 {"playback-seek-relative", playback_seek_relative, "performs a seek relative to the current position", 1},
4074
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
105
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
106
2924
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
107 {"<sep>", NULL, "Volume control", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
108 {"get-volume", get_volume, "returns the current volume level in percent", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
109 {"set-volume", set_volume, "sets the current volume level in percent", 1},
4074
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
110
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
111
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
112 {"<sep>", NULL, "Equalizer manipulation", 0},
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
113 {"equalizer-activate", equalizer_active, "activates/deactivates the equalizer", 1},
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
114 {"equalizer-get", equalizer_get_eq, "gets the equalizer settings", 0},
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
115 {"equalizer-set", equalizer_set_eq, "sets the equalizer settings", 11},
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
116 {"equalizer-get-preamp", equalizer_get_eq_preamp, "gets the equalizer pre-amplification", 0},
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
117 {"equalizer-set-preamp", equalizer_set_eq_preamp, "sets the equalizer pre-amplification", 1},
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
118 {"equalizer-get-band", equalizer_get_eq_band, "gets the equalizer value in specified band", 1},
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
119 {"equalizer-set-band", equalizer_set_eq_band, "sets the equalizer value in the specified band", 2},
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
120
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
121
2924
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
122 {"<sep>", NULL, "Miscellaneous", 0},
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2924
diff changeset
123 {"mainwin-show", mainwin_show, "shows/hides the main window", 1},
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2924
diff changeset
124 {"playlist-show", playlist_show, "shows/hides the playlist window", 1},
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2924
diff changeset
125 {"equalizer-show", equalizer_show, "shows/hides the equalizer window", 1},
3917
b5ee3a4a8e3b libaudclient:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3915
diff changeset
126
4074
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
127 {"filebrowser-show", show_filebrowser, "shows/hides the filebrowser", 1},
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
128 {"jumptofile-show", show_jtf_window, "shows/hides the jump to file window", 1},
3917
b5ee3a4a8e3b libaudclient:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3915
diff changeset
129 {"preferences-show", show_preferences_window, "shows/hides the preferences window", 1},
b5ee3a4a8e3b libaudclient:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3915
diff changeset
130 {"about-show", show_about_window, "shows/hides the about window", 1},
b5ee3a4a8e3b libaudclient:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3915
diff changeset
131
4074
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
132 {"activate", activate, "activates and raises audacious", 0},
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
133 {"always-on-top", toggle_aot, "on/off always on top", 1},
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
134 {"version", get_version, "shows audaciuos version", 0},
2924
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
135 {"shutdown", shutdown_audacious_server, "shuts down audacious", 0},
4074
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
136
ea194fd79267 audtool maintenance:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3917
diff changeset
137
2924
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
138 {"<sep>", NULL, "Help system", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
139 {"list-handlers", get_handlers_list, "shows handlers list", 0},
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
140 {"help", get_handlers_list, "shows handlers list", 0},
3867
e48f2f4c116d - many remained audacious remote functions have been implemented.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2939
diff changeset
141
4796
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
142
2924
cf35109c4c33 Add the amount of arguments each command takes.
William Pitcock <nenolod@atheme.org>
parents: 2922
diff changeset
143 {NULL, NULL, NULL, 0}
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
144 };
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
145
2737
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents: 2734
diff changeset
146 mowgli_error_context_t *e = NULL;
b189991f7417 [svn] - split handlers out to handlers.c
nenolod
parents: 2734
diff changeset
147 DBusGProxy *dbus_proxy = NULL;
2731
f4a5f8fa3836 [svn] Added stubs in audctrl.c for the unimplemented functions defined in audctrl.h.
magma
parents: 2723
diff changeset
148 static DBusGConnection *connection = NULL;
f4a5f8fa3836 [svn] Added stubs in audctrl.c for the unimplemented functions defined in audctrl.h.
magma
parents: 2723
diff changeset
149
4796
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
150 static void
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
151 audtool_connect(void)
2719
7a60a4236fb9 [svn] - make this build again, most functionality does not work
nenolod
parents: 2715
diff changeset
152 {
2723
5051af882447 [svn] - bind to the right dbus interfaces, but this still has problems building
nenolod
parents: 2720
diff changeset
153 GError *error = NULL;
2734
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
154
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
155 mowgli_error_context_push(e, "While attempting to connect to the D-Bus session bus");
2731
f4a5f8fa3836 [svn] Added stubs in audctrl.c for the unimplemented functions defined in audctrl.h.
magma
parents: 2723
diff changeset
156 connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
2719
7a60a4236fb9 [svn] - make this build again, most functionality does not work
nenolod
parents: 2715
diff changeset
157
7a60a4236fb9 [svn] - make this build again, most functionality does not work
nenolod
parents: 2715
diff changeset
158 if (connection == NULL)
2747
8b7e1929aec1 [svn] - change the appearance that backtraces are presented as
nenolod
parents: 2737
diff changeset
159 mowgli_error_context_display_with_error(e, ":\n * ", g_strdup_printf("D-Bus Error: %s", error->message));
2723
5051af882447 [svn] - bind to the right dbus interfaces, but this still has problems building
nenolod
parents: 2720
diff changeset
160
2734
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
161 mowgli_error_context_pop(e);
2719
7a60a4236fb9 [svn] - make this build again, most functionality does not work
nenolod
parents: 2715
diff changeset
162
2731
f4a5f8fa3836 [svn] Added stubs in audctrl.c for the unimplemented functions defined in audctrl.h.
magma
parents: 2723
diff changeset
163 dbus_proxy = dbus_g_proxy_new_for_name(connection, AUDACIOUS_DBUS_SERVICE,
f4a5f8fa3836 [svn] Added stubs in audctrl.c for the unimplemented functions defined in audctrl.h.
magma
parents: 2723
diff changeset
164 AUDACIOUS_DBUS_PATH,
f4a5f8fa3836 [svn] Added stubs in audctrl.c for the unimplemented functions defined in audctrl.h.
magma
parents: 2723
diff changeset
165 AUDACIOUS_DBUS_INTERFACE);
2719
7a60a4236fb9 [svn] - make this build again, most functionality does not work
nenolod
parents: 2715
diff changeset
166 }
7a60a4236fb9 [svn] - make this build again, most functionality does not work
nenolod
parents: 2715
diff changeset
167
4796
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
168 static void
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
169 audtool_disconnect(void)
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
170 {
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
171 g_object_unref(dbus_proxy);
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
172 dbus_proxy = NULL;
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
173 }
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
174
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
175 gint
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
176 main(gint argc, gchar **argv)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
177 {
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2924
diff changeset
178 gint i, j = 0, k = 0;
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
179
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
180 setlocale(LC_CTYPE, "");
2719
7a60a4236fb9 [svn] - make this build again, most functionality does not work
nenolod
parents: 2715
diff changeset
181 g_type_init();
2734
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
182 mowgli_init();
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
183
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
184 e = mowgli_error_context_create();
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
185 mowgli_error_context_push(e, "In program %s", argv[0]);
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
186
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
187 audtool_connect();
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
188
eda1f3186687 [svn] - BSDify code
nenolod
parents: 2731
diff changeset
189 mowgli_error_context_push(e, "While processing the commandline");
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
190
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
191 if (argc < 2)
3917
b5ee3a4a8e3b libaudclient:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3915
diff changeset
192 mowgli_error_context_display_with_error(e, ":\n * ", "not enough parameters, use \'audtool help\' for more information.");
2731
f4a5f8fa3836 [svn] Added stubs in audctrl.c for the unimplemented functions defined in audctrl.h.
magma
parents: 2723
diff changeset
193
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2924
diff changeset
194 for (j = 1; j < argc; j++)
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
195 {
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2924
diff changeset
196 for (i = 0; handlers[i].name != NULL; i++)
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2924
diff changeset
197 {
2939
964413953abd Use portable g_ascii_strcasecmp().
William Pitcock <nenolod@atheme.org>
parents: 2925
diff changeset
198 if ((!g_ascii_strcasecmp(handlers[i].name, argv[j]) ||
964413953abd Use portable g_ascii_strcasecmp().
William Pitcock <nenolod@atheme.org>
parents: 2925
diff changeset
199 !g_ascii_strcasecmp(g_strconcat("--", handlers[i].name, NULL), argv[j]))
964413953abd Use portable g_ascii_strcasecmp().
William Pitcock <nenolod@atheme.org>
parents: 2925
diff changeset
200 && g_ascii_strcasecmp("<sep>", handlers[i].name))
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2924
diff changeset
201 {
4841
a8c464186ec9 Fix "audtool help playback-seek-relative" crash (Debian bug #512910)
John Lindgren
parents: 4796
diff changeset
202 int numargs = handlers[i].args + 1 < argc - j ? handlers[i].args + 1 : argc - j;
3917
b5ee3a4a8e3b libaudclient:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3915
diff changeset
203 handlers[i].handler(numargs, &argv[j]);
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2924
diff changeset
204 j += handlers[i].args;
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2924
diff changeset
205 k++;
3917
b5ee3a4a8e3b libaudclient:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3915
diff changeset
206 if(j >= argc)
b5ee3a4a8e3b libaudclient:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3915
diff changeset
207 break;
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2924
diff changeset
208 }
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
209 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
210 }
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
211
2925
90ca95b7277d Convert code where necessary to work with the new data passed to it.
William Pitcock <nenolod@atheme.org>
parents: 2924
diff changeset
212 if (k == 0)
3917
b5ee3a4a8e3b libaudclient:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3915
diff changeset
213 mowgli_error_context_display_with_error(e, ":\n * ", g_strdup_printf("Unknown command '%s' encountered, use \'audtool help\' for a command list.", argv[1]));
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
214
4796
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
215 audtool_disconnect();
62265a3a1870 added audtool_disconnect().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4708
diff changeset
216
2313
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
217 return 0;
3149d4b1a9a9 [svn] - objective-make autodepend fixes
nenolod
parents:
diff changeset
218 }