Mercurial > audlegacy
changeset 3873:f3341c2d6b9e
audacious remote functions:
- playlist_ins_url_string() and playlist_enqueue_to_temp() have been implemented.
- now get_version() returns audacious version instead of protocol version.
audtool:
- now argc check works properly.
- some cleanups.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Tue, 30 Oct 2007 22:12:47 +0900 |
parents | b02853ac8466 |
children | d21eee9b841b |
files | src/audacious/dbus-service.h src/audacious/dbus.c src/audacious/objects.xml src/audtool/audtool.h src/audtool/audtool_handlers_general.c src/audtool/audtool_handlers_playback.c src/audtool/audtool_handlers_playlist.c src/audtool/audtool_handlers_playqueue.c src/audtool/audtool_handlers_test.c src/audtool/audtool_handlers_vitals.c src/audtool/audtool_main.c src/libaudclient/audctrl.c src/libaudclient/audctrl.h |
diffstat | 13 files changed, 161 insertions(+), 465 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/dbus-service.h Tue Oct 30 18:17:55 2007 +0900 +++ b/src/audacious/dbus-service.h Tue Oct 30 22:12:47 2007 +0900 @@ -111,8 +111,7 @@ /* Legacy API */ // Audacious General Information -gboolean audacious_rc_version(RemoteObject *obj, gchar **version, - GError **error); +gboolean audacious_rc_version(RemoteObject *obj, gchar **version, GError **error); gboolean audacious_rc_quit(RemoteObject *obj, GError **error); gboolean audacious_rc_eject(RemoteObject *obj, GError **error); gboolean audacious_rc_main_win_visible(RemoteObject *obj, @@ -201,10 +200,11 @@ gboolean audacious_rc_playqueue_remove(RemoteObject *obj, gint pos, GError **error); gboolean audacious_rc_playqueue_clear(RemoteObject *obj, GError **error); gboolean audacious_rc_playqueue_is_queued(RemoteObject *obj, gint pos, gboolean *is_queued, GError **error); +gboolean audacious_rc_playlist_ins_url_string(RemoteObject *obj, gchar *url, gint pos, GError **error); + /* in progress */ -gboolean audacious_rc_playlist_ins_url_string(RemoteObject *obj, gchar *url, gint *pos, GError **error); gboolean audacious_rc_playlist_add(RemoteObject *obj, gpointer list, GError **error); -gboolean audacious_rc_playlist_enqueue_to_temp(RemoteObject *obj, char *list, gint num, gboolean enqueue, GError **error); +gboolean audacious_rc_playlist_enqueue_to_temp(RemoteObject *obj, gchar *url, GError **error); #endif // !_DBUS_SERVICE_H
--- a/src/audacious/dbus.c Tue Oct 30 18:17:55 2007 +0900 +++ b/src/audacious/dbus.c Tue Oct 30 22:12:47 2007 +0900 @@ -486,8 +486,7 @@ } // Audacious General Information -gboolean audacious_rc_version(RemoteObject *obj, gchar **version, - GError **error) { +gboolean audacious_rc_version(RemoteObject *obj, gchar **version, GError **error) { *version = g_strdup(VERSION); return TRUE; } @@ -890,28 +889,45 @@ return TRUE; } - +gboolean audacious_rc_playlist_ins_url_string(RemoteObject *obj, gchar *url, gint pos, GError **error) { + if (pos >= 0 && url && strlen(url)) { + playlist_ins_url(playlist_get_active(), url, pos); + } + return TRUE; +} -/* In Progress */ -static void call_add_url(GList *list, gpointer *data) { +static void call_playlist_add_url(GList *list, gpointer *data) { playlist_add_url(playlist_get_active(), list->data); } gboolean audacious_rc_playlist_add(RemoteObject *obj, gpointer list, GError **error) { - g_list_foreach((GList *)list, (GFunc)call_add_url, NULL); + g_list_foreach((GList *)list, (GFunc)call_playlist_add_url, NULL); return TRUE; } -gboolean audacious_rc_playlist_enqueue_to_temp(RemoteObject *obj, char *list, gint num, gboolean enqueue, GError **error) { +gboolean audacious_rc_playlist_enqueue_to_temp(RemoteObject *obj, gchar *url, GError **error) { + GList *playlists = NULL; + Playlist *new_pl = playlist_new(); + gchar *pl_name = NULL; + + pl_name = (gchar*)playlist_get_current_name(new_pl); + if(!pl_name) + pl_name = g_strdup("New Playlist"); + playlist_set_current_name(new_pl, pl_name); + g_free(pl_name); + + playlists = playlist_get_playlists(); + playlist_add_playlist(new_pl); + +// DISABLE_MANAGER_UPDATE(); + playlist_select_playlist(new_pl); +// ENABLE_MANAGER_UPDATE(); + + playlist_add_url(new_pl, url); + return TRUE; } -gboolean audacious_rc_playlist_ins_url_string(RemoteObject *obj, gchar *url, gint *pos, GError **error) { - if (url && strlen(url)) { - playlist_ins_url(playlist_get_active(), url, *pos); - } - return TRUE; -} /********************************************************************************/
--- a/src/audacious/objects.xml Tue Oct 30 18:17:55 2007 +0900 +++ b/src/audacious/objects.xml Tue Oct 30 22:12:47 2007 +0900 @@ -19,7 +19,7 @@ <!-- Defined: - CMD_GET_VERSION + CMD_GET_VERSION //CHANGED: now it returns audacious version instead of protocol version. CMD_PLAY CMD_PAUSE CMD_STOP @@ -60,7 +60,7 @@ CMD_SHOW_ABOUT_BOX CMD_SHOW_JTF_BOX - New: + Newly defined: CMD_PLAY_PAUSE CMD_ACTIVATE CMD_GET_SKIN @@ -71,16 +71,12 @@ CMD_PLAYQUEUE_ADD CMD_PLAYQUEUE_REMOVE CMD_PLAYQUEUE_CLEAR - CMD_PLAYQUEUE_GET_LPOS //CHANGED: get list position by queue position - CMD_PLAYQUEUE_GET_QPOS //CHANGED: get queue position by list postion + CMD_PLAYQUEUE_GET_LIST_POS //CHANGED: get list position by queue position + CMD_PLAYQUEUE_GET_QUEUE_POS //CHANGED: get queue position by list postion CMD_PLAYQUEUE_IS_QUEUED - - - In Progress: CMD_PLAYLIST_INS_URL_STRING + CMD_PLAYLIST_ENQUEUE_TO_TEMP CMD_PLAYLIST_ADD - CMD_PLAYLIST_ENQUEUE_TO_TEMP - Remaining: CMD_PLAYLIST_INS //unnecessary?
--- a/src/audtool/audtool.h Tue Oct 30 18:17:55 2007 +0900 +++ b/src/audtool/audtool.h Tue Oct 30 22:12:47 2007 +0900 @@ -120,5 +120,7 @@ extern void test_get_skin(gint argc, gchar **argv); extern void test_set_skin(gint argc, gchar **argv); extern void test_get_info(gint argc, gchar **argv); +extern void test_ins_url_string(gint argc, gchar **argv); +extern void test_get_version(gint argc, gchar **argv); #endif
--- a/src/audtool/audtool_handlers_general.c Tue Oct 30 18:17:55 2007 +0900 +++ b/src/audtool/audtool_handlers_general.c Tue Oct 30 22:12:47 2007 +0900 @@ -54,7 +54,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <level>", argv[0]); - return; + exit(1); } current_volume = audacious_remote_get_main_volume(dbus_proxy); @@ -74,53 +74,56 @@ void mainwin_show(gint argc, gchar **argv) { - if (argc > 1) - { - if (!g_ascii_strcasecmp(argv[1], "on")) { - audacious_remote_main_win_toggle(dbus_proxy, TRUE); - return; - } - else if (!g_ascii_strcasecmp(argv[1], "off")) { - audacious_remote_main_win_toggle(dbus_proxy, FALSE); - return; - } - } - audtool_whine("invalid parameter for %s.", argv[0]); - audtool_whine("syntax: %s <on/off>", argv[0]); + if (argc < 2) { + audtool_whine("invalid parameter for %s.", argv[0]); + audtool_whine("syntax: %s <on/off>", argv[0]); + exit(1); + } + + if (!g_ascii_strcasecmp(argv[1], "on")) { + audacious_remote_main_win_toggle(dbus_proxy, TRUE); + return; + } + else if (!g_ascii_strcasecmp(argv[1], "off")) { + audacious_remote_main_win_toggle(dbus_proxy, FALSE); + return; + } } void playlist_show(gint argc, gchar **argv) { - if (argc > 1) - { - if (!g_ascii_strcasecmp(argv[1], "on")) { - audacious_remote_pl_win_toggle(dbus_proxy, TRUE); - return; - } - else if (!g_ascii_strcasecmp(argv[1], "off")) { - audacious_remote_pl_win_toggle(dbus_proxy, FALSE); - return; - } - } - audtool_whine("invalid parameter for %s.", argv[0]); - audtool_whine("syntax: %s <on/off>", argv[0]); + if (argc < 2) { + audtool_whine("invalid parameter for %s.", argv[0]); + audtool_whine("syntax: %s <on/off>", argv[0]); + exit(1); + } + + if (!g_ascii_strcasecmp(argv[1], "on")) { + audacious_remote_pl_win_toggle(dbus_proxy, TRUE); + return; + } + else if (!g_ascii_strcasecmp(argv[1], "off")) { + audacious_remote_pl_win_toggle(dbus_proxy, FALSE); + return; + } } void equalizer_show(gint argc, gchar **argv) { - if (argc > 1) - { - if (!g_ascii_strcasecmp(argv[1] ,"on")) { - audacious_remote_eq_win_toggle(dbus_proxy, TRUE); - return; - } - else if (!g_ascii_strcasecmp(argv[1] ,"off")) { - audacious_remote_eq_win_toggle(dbus_proxy, FALSE); - return; - } - } - audtool_whine("invalid parameter for %s.", argv[0]); - audtool_whine("syntax: %s <on/off>", argv[0]); + if (argc < 2) { + audtool_whine("invalid parameter for %s.", argv[0]); + audtool_whine("syntax: %s <on/off>", argv[0]); + exit(1); + } + + if (!g_ascii_strcasecmp(argv[1] ,"on")) { + audacious_remote_eq_win_toggle(dbus_proxy, TRUE); + return; + } + else if (!g_ascii_strcasecmp(argv[1] ,"off")) { + audacious_remote_eq_win_toggle(dbus_proxy, FALSE); + return; + } } void show_preferences_window(gint argc, gchar **argv) @@ -155,6 +158,7 @@ audtool_report(" %-34s - %s", handlers[i].name, handlers[i].desc); } + audtool_report(""); audtool_report("Handlers may be prefixed with `--' (GNU-style long-options) or not, your choice."); audtool_report("Report bugs to http://bugs-meta.atheme.org/"); }
--- a/src/audtool/audtool_handlers_playback.c Tue Oct 30 18:17:55 2007 +0900 +++ b/src/audtool/audtool_handlers_playback.c Tue Oct 30 22:12:47 2007 +0900 @@ -118,7 +118,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <position>", argv[0]); - return; + exit(1); } audacious_remote_jump_to_time(dbus_proxy, atoi(argv[1]) * 1000); @@ -132,7 +132,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <position>", argv[0]); - return; + exit(1); } oldtime = audacious_remote_get_output_time(dbus_proxy);
--- a/src/audtool/audtool_handlers_playlist.c Tue Oct 30 18:17:55 2007 +0900 +++ b/src/audtool/audtool_handlers_playlist.c Tue Oct 30 22:12:47 2007 +0900 @@ -53,7 +53,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <url>", argv[0]); - return; + exit(1); } audacious_remote_playlist_add_url_string(dbus_proxy, argv[1]); @@ -67,7 +67,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <position>", argv[0]); - return; + exit(1); } playpos = atoi(argv[1]); @@ -99,7 +99,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <position>", argv[0]); - return; + exit(1); } playpos = atoi(argv[1]); @@ -107,7 +107,7 @@ if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy)) { audtool_whine("invalid playlist position %d", playpos); - return; + exit(1); } song = audacious_remote_get_playlist_title(dbus_proxy, playpos - 1); @@ -124,7 +124,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <position>", argv[0]); - return; + exit(1); } playpos = atoi(argv[1]); @@ -132,7 +132,7 @@ if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy)) { audtool_whine("invalid playlist position %d", playpos); - return; + exit(1); } frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1); @@ -149,7 +149,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <position>", argv[0]); - return; + exit(1); } playpos = atoi(argv[1]); @@ -157,7 +157,7 @@ if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy)) { audtool_whine("invalid playlist position %d", playpos); - return; + exit(1); } frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1); @@ -174,7 +174,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <position>", argv[0]); - return; + exit(1); } playpos = atoi(argv[1]); @@ -182,7 +182,7 @@ if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy)) { audtool_whine("invalid playlist position %d", playpos); - return; + exit(1); } frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1); @@ -257,7 +257,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <position>", argv[0]); - return; + exit(1); } i = atoi(argv[1]); @@ -265,7 +265,7 @@ if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) { audtool_whine("invalid playlist position %d", i); - return; + exit(1); } audtool_report("%s", audacious_remote_get_playlist_file(dbus_proxy, i - 1)); @@ -279,7 +279,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <position>", argv[0]); - return; + exit(1); } i = atoi(argv[1]); @@ -287,7 +287,7 @@ if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) { audtool_whine("invalid playlist position %d", i); - return; + exit(1); } audacious_remote_set_playlist_pos(dbus_proxy, i - 1); @@ -349,7 +349,7 @@ audtool_whine(" track_name, track_number, year, date, genre, comment,"); audtool_whine(" file_name, file_ext, file_path, length, formatter,"); audtool_whine(" custom, mtime"); - return; + exit(1); } i = atoi(argv[2]); @@ -357,12 +357,12 @@ if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) { audtool_whine("invalid playlist position %d", i); - return; + exit(1); } if (!(data = audacious_get_tuple_field_data(dbus_proxy, argv[1], i - 1))) { - return; + return; //XXX ??? --yaz } if (!g_ascii_strcasecmp(argv[1], "track_number") || !g_ascii_strcasecmp(argv[1], "year") || !g_ascii_strcasecmp(argv[1], "length") || !g_ascii_strcasecmp(argv[1], "mtime"))
--- a/src/audtool/audtool_handlers_playqueue.c Tue Oct 30 18:17:55 2007 +0900 +++ b/src/audtool/audtool_handlers_playqueue.c Tue Oct 30 22:12:47 2007 +0900 @@ -45,7 +45,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <position>", argv[0]); - return; + exit(1); } i = atoi(argv[1]); @@ -53,7 +53,7 @@ if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) { audtool_whine("invalid playlist position %d", i); - return; + exit(1); } if (!(audacious_remote_playqueue_is_queued(dbus_proxy, i - 1))) @@ -68,7 +68,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <position>", argv[0]); - return; + exit(1); } i = atoi(argv[1]); @@ -76,7 +76,7 @@ if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) { audtool_whine("invalid playlist position %d", i); - return; + exit(1); } if (audacious_remote_playqueue_is_queued(dbus_proxy, i - 1)) @@ -91,7 +91,7 @@ { audtool_whine("invalid parameters for playqueue-is-queued.", argv[0]); audtool_whine("syntax: %s playqueue-is-queued <position>", argv[0]); - return; + exit(1); } i = atoi(argv[1]); @@ -99,7 +99,7 @@ if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) { audtool_whine("invalid playlist position %d", i); - return; + exit(1); } if(audacious_remote_playqueue_is_queued(dbus_proxy, i - 1)) { audtool_report("OK"); @@ -117,7 +117,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <position>", argv[0]); - return; + exit(1); } i = atoi(argv[1]); @@ -125,7 +125,7 @@ if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) { audtool_whine("invalid playlist position %d", i); - return; + exit(1); } pos = audacious_remote_get_playqueue_queue_position(dbus_proxy, i - 1) + 1; @@ -144,7 +144,7 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <position>", argv[0]); - return; + exit(1); } i = atoi(argv[1]); @@ -152,7 +152,7 @@ if (i < 1 || i > audacious_remote_get_playqueue_length(dbus_proxy)) { audtool_whine("invalid playlist position %d", i); - return; + exit(1); } pos = audacious_remote_get_playqueue_list_position(dbus_proxy, i - 1) + 1;
--- a/src/audtool/audtool_handlers_test.c Tue Oct 30 18:17:55 2007 +0900 +++ b/src/audtool/audtool_handlers_test.c Tue Oct 30 22:12:47 2007 +0900 @@ -44,47 +44,40 @@ void test_enqueue_to_temp(gint argc, gchar **argv) { - gint playpos; - if (argc < 2) { audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <position>", argv[0]); - return; + audtool_whine("syntax: %s <url>", argv[0]); + exit(1); } - playpos = atoi(argv[1]); - - if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy)) - { - audtool_whine("invalid playlist position %d", playpos); - return; - } - - audacious_remote_get_playqueue_queue_position(dbus_proxy, playpos - 1); // xxx playpos - 1? + audacious_remote_playlist_enqueue_to_temp(dbus_proxy, argv[1]); } void test_toggle_aot(gint argc, gchar **argv) { - gboolean ontop; - if (argc < 2) { audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <boolean>", argv[0]); - return; + audtool_whine("syntax: %s <on/off>", argv[0]); + exit(1); } - ontop = (gboolean)atoi(argv[1]); - printf("ontop = %d\n", ontop); - audacious_remote_toggle_aot(dbus_proxy, ontop); + if (!g_ascii_strcasecmp(argv[1], "on")) { + audacious_remote_toggle_aot(dbus_proxy, TRUE); + return; + } + else if (!g_ascii_strcasecmp(argv[1], "off")) { + audacious_remote_toggle_aot(dbus_proxy, FALSE); + return; + } } void test_get_skin(gint argc, gchar **argv) { gchar *skin = NULL; skin = audacious_remote_get_skin(dbus_proxy); - printf("skin = %s\n", skin); + audtool_report("%s", skin); g_free(skin); } @@ -94,11 +87,8 @@ { audtool_whine("invalid parameters for %s.", argv[0]); audtool_whine("syntax: %s <skin>", argv[0]); - return; + exit(1); } - printf("argc = %d\n", argc); - printf("skin = %p\n", argv[1]); - if(!argv[1] || !strcmp(argv[1], "")) return; @@ -111,350 +101,30 @@ gint rate, freq, nch; audacious_remote_get_info(dbus_proxy, &rate, &freq, &nch); - printf("rate = %d freq = %d nch = %d\n", rate, freq, nch); -} - - - - -#if 0 -void playlist_reverse(gint argc, gchar **argv) -{ - audacious_remote_playlist_prev(dbus_proxy); -} - -void playlist_advance(gint argc, gchar **argv) -{ - audacious_remote_playlist_next(dbus_proxy); -} - -void playlist_add_url_string(gint argc, gchar **argv) -{ - if (argc < 2) - { - audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <url>", argv[0]); - return; - } - - audacious_remote_playlist_add_url_string(dbus_proxy, argv[1]); -} - -void playlist_delete(gint argc, gchar **argv) -{ - gint playpos; - - if (argc < 2) - { - audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <position>", argv[0]); - return; - } - - playpos = atoi(argv[1]); - - if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy)) - { - audtool_whine("invalid playlist position %d", playpos); - return; - } - - audacious_remote_playlist_delete(dbus_proxy, playpos - 1); -} - -void playlist_length(gint argc, gchar **argv) -{ - gint i; - - i = audacious_remote_get_playlist_length(dbus_proxy); - - audtool_report("%d", i); -} - -void playlist_song(gint argc, gchar **argv) -{ - gint playpos; - gchar *song; - - if (argc < 2) - { - audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <position>", argv[0]); - return; - } - - playpos = atoi(argv[1]); - - if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy)) - { - audtool_whine("invalid playlist position %d", playpos); - return; - } - - song = audacious_remote_get_playlist_title(dbus_proxy, playpos - 1); - - audtool_report("%s", song); -} - - -void playlist_song_length(gint argc, gchar **argv) -{ - gint playpos, frames, length; - - if (argc < 2) - { - audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <position>", argv[0]); - return; - } - - playpos = atoi(argv[1]); - - if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy)) - { - audtool_whine("invalid playlist position %d", playpos); - return; - } - - frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1); - length = frames / 1000; - - audtool_report("%d:%.2d", length / 60, length % 60); -} - -void playlist_song_length_seconds(gint argc, gchar **argv) -{ - gint playpos, frames, length; - - if (argc < 2) - { - audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <position>", argv[0]); - return; - } - - playpos = atoi(argv[1]); - - if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy)) - { - audtool_whine("invalid playlist position %d", playpos); - return; - } - - frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1); - length = frames / 1000; - - audtool_report("%d", length); + audtool_report("rate = %d freq = %d nch = %d", rate, freq, nch); } -void playlist_song_length_frames(gint argc, gchar **argv) -{ - gint playpos, frames; - - if (argc < 2) - { - audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <position>", argv[0]); - return; - } - - playpos = atoi(argv[1]); - - if (playpos < 1 || playpos > audacious_remote_get_playlist_length(dbus_proxy)) - { - audtool_whine("invalid playlist position %d", playpos); - return; - } - - frames = audacious_remote_get_playlist_time(dbus_proxy, playpos - 1); - - audtool_report("%d", frames); -} - -void playlist_display(gint argc, gchar **argv) -{ - gint i, ii, frames, length, total; - gchar *songname; - gchar *fmt = NULL, *p; - gint column; - - i = audacious_remote_get_playlist_length(dbus_proxy); - - audtool_report("%d track%s.", i, i != 1 ? "s" : ""); - - total = 0; - - for (ii = 0; ii < i; ii++) - { - songname = audacious_remote_get_playlist_title(dbus_proxy, ii); - frames = audacious_remote_get_playlist_time(dbus_proxy, ii); - length = frames / 1000; - total += length; - - /* adjust width for multi byte characters */ - column = 60; - if(songname){ - p = songname; - while(*p){ - gint stride; - stride = g_utf8_next_char(p) - p; - if(g_unichar_iswide(g_utf8_get_char(p)) -#if ( (GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION >= 12) ) - || g_unichar_iswide_cjk(g_utf8_get_char(p)) -#endif - ){ - column += (stride - 2); - } - else { - column += (stride - 1); - } - p = g_utf8_next_char(p); - } - - } - - fmt = g_strdup_printf("%%4d | %%-%ds | %%d:%%.2d", column); - audtool_report(fmt, ii + 1, songname, length / 60, length % 60); - g_free(fmt); - } - - audtool_report("Total length: %d:%.2d", total / 60, total % 60); -} - -void playlist_position(gint argc, gchar **argv) -{ - gint i; - - i = audacious_remote_get_playlist_pos(dbus_proxy); - - audtool_report("%d", i + 1); -} - -void playlist_song_filename(gint argc, gchar **argv) +void test_ins_url_string(gint argc, gchar **argv) { - gint i; - - if (argc < 2) - { - audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <position>", argv[0]); - return; - } - - i = atoi(argv[1]); - - if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) - { - audtool_whine("invalid playlist position %d", i); - return; - } - - audtool_report("%s", audacious_remote_get_playlist_file(dbus_proxy, i - 1)); -} - -void playlist_jump(gint argc, gchar **argv) -{ - gint i; - - if (argc < 2) - { - audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <position>", argv[0]); - return; - } - - i = atoi(argv[1]); - - if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) - { - audtool_whine("invalid playlist position %d", i); - return; - } - - audacious_remote_set_playlist_pos(dbus_proxy, i - 1); -} - -void playlist_clear(gint argc, gchar **argv) -{ - audacious_remote_playlist_clear(dbus_proxy); -} - -void playlist_repeat_status(gint argc, gchar **argv) -{ - if (audacious_remote_is_repeat(dbus_proxy)) - { - audtool_report("on"); - return; - } - else - { - audtool_report("off"); - return; - } -} - -void playlist_repeat_toggle(gint argc, gchar **argv) -{ - audacious_remote_toggle_repeat(dbus_proxy); -} - -void playlist_shuffle_status(gint argc, gchar **argv) -{ - if (audacious_remote_is_shuffle(dbus_proxy)) - { - audtool_report("on"); - return; - } - else - { - audtool_report("off"); - return; - } -} - -void playlist_shuffle_toggle(gint argc, gchar **argv) -{ - audacious_remote_toggle_shuffle(dbus_proxy); -} - -void playlist_tuple_field_data(gint argc, gchar **argv) -{ - gint i; - gpointer data; + gint pos = -1; if (argc < 3) { audtool_whine("invalid parameters for %s.", argv[0]); - audtool_whine("syntax: %s <fieldname> <position>", argv[0]); - audtool_whine(" - fieldname example choices: performer, album_name,"); - audtool_whine(" track_name, track_number, year, date, genre, comment,"); - audtool_whine(" file_name, file_ext, file_path, length, formatter,"); - audtool_whine(" custom, mtime"); - return; - } - - i = atoi(argv[2]); - - if (i < 1 || i > audacious_remote_get_playlist_length(dbus_proxy)) - { - audtool_whine("invalid playlist position %d", i); - return; + audtool_whine("syntax: %s <url> <position>", argv[0]); + exit(1); } - if (!(data = audacious_get_tuple_field_data(dbus_proxy, argv[1], i - 1))) - { - return; - } - - if (!g_ascii_strcasecmp(argv[1], "track_number") || !g_ascii_strcasecmp(argv[1], "year") || !g_ascii_strcasecmp(argv[1], "length") || !g_ascii_strcasecmp(argv[1], "mtime")) - { - if (*(gint *)data > 0) - { - audtool_report("%d", *(gint *)data); - } - return; - } + pos = atoi(argv[2]) - 1; + if(pos >= 0) + audacious_remote_playlist_ins_url_string(dbus_proxy, argv[1], pos); +} - audtool_report("%s", (gchar *)data); +void test_get_version(gint argc, gchar **argv) +{ + gchar *version = NULL; + version = audacious_remote_get_version(dbus_proxy); + if(version) + audtool_report("Audacious %s", version); + g_free(version); } -#endif
--- a/src/audtool/audtool_handlers_vitals.c Tue Oct 30 18:17:55 2007 +0900 +++ b/src/audtool/audtool_handlers_vitals.c Tue Oct 30 22:12:47 2007 +0900 @@ -171,7 +171,7 @@ audtool_whine(" track_name, track_number, year, date, genre, comment,"); audtool_whine(" file_name, file_ext, file_path, length, formatter,"); audtool_whine(" custom, mtime"); - return; + exit(1); } if (!(data = audacious_get_tuple_field_data(dbus_proxy, argv[1], audacious_remote_get_playlist_pos(dbus_proxy))))
--- a/src/audtool/audtool_main.c Tue Oct 30 18:17:55 2007 +0900 +++ b/src/audtool/audtool_main.c Tue Oct 30 22:12:47 2007 +0900 @@ -111,11 +111,13 @@ /* test suite */ {"<sep>", NULL, "Test suite", 0}, {"activate", test_activate, "activate", 0}, - {"playlist-enqueue-to-temp", test_enqueue_to_temp, "enqueue_to_temp", 1}, - {"toggle-aot", test_toggle_aot, "specify allways on top or not", 1}, // xxx need to be improved. + {"playlist-addurl-to-new-playlist", test_enqueue_to_temp, "adds a url to the newly created playlist", 1}, + {"always-on-top", test_toggle_aot, "on/off always on top", 1}, {"get-skin", test_get_skin, "get skin", 0}, {"set-skin", test_set_skin, "set skin", 1}, {"get-info", test_get_info, "get info", 0}, + {"playlist-insurl", test_ins_url_string, "inserts a url at specified position in the playlist", 2}, + {"get-version", test_get_version, "get version of audacious", 0}, {NULL, NULL, NULL, 0} }; @@ -167,7 +169,9 @@ !g_ascii_strcasecmp(g_strconcat("--", handlers[i].name, NULL), argv[j])) && g_ascii_strcasecmp("<sep>", handlers[i].name)) { - handlers[i].handler(handlers[i].args + 1, &argv[j]); +// handlers[i].handler(handlers[i].args + 1, &argv[j]); + handlers[i].handler(handlers[i].args + 1 < argc - 1 ? handlers[i].args + 1 : argc - 1, + &argv[j]); // to enable argc check --yaz j += handlers[i].args; k++; }
--- a/src/libaudclient/audctrl.c Tue Oct 30 18:17:55 2007 +0900 +++ b/src/libaudclient/audctrl.c Tue Oct 30 22:12:47 2007 +0900 @@ -67,12 +67,16 @@ * audacious_remote_get_version: * @proxy: DBus proxy for audacious * - * Queries audacious for it's protocol version. + * Queries audacious for it's version. * - * Return value: The protocol version used by Audacious. + * Return value: The version of Audacious. **/ -gint audacious_remote_get_version(DBusGProxy *proxy) { - return 0x09a3; // XXX should do actual dbus call. +gchar *audacious_remote_get_version(DBusGProxy *proxy) { + char *string = NULL; + org_atheme_audacious_version(proxy, &string, &error); + g_clear_error(&error); + + return (string ? string : NULL); } /**
--- a/src/libaudclient/audctrl.h Tue Oct 30 18:17:55 2007 +0900 +++ b/src/libaudclient/audctrl.h Tue Oct 30 22:12:47 2007 +0900 @@ -29,7 +29,7 @@ void audacious_remote_playlist(DBusGProxy *proxy, gchar **list, gint num, gboolean enqueue); - gint audacious_remote_get_version(DBusGProxy *proxy); + gchar *audacious_remote_get_version(DBusGProxy *proxy); void audacious_remote_playlist_add(DBusGProxy *proxy, GList *list); void audacious_remote_playlist_delete(DBusGProxy *proxy, guint pos); void audacious_remote_play(DBusGProxy *proxy);