Mercurial > audlegacy
comparison src/libaudclient/audctrl.c @ 2814:77a012c3b521 trunk
[svn] - give default values to audacious_remote_* functions. if dbus call fails, default value will be returned.
- now audacious_rc_song_filename() calls str_to_utf8() to ensure that the string to return is in utf-8.
| author | yaz |
|---|---|
| date | Mon, 28 May 2007 10:28:41 -0700 |
| parents | f42a5b531c03 |
| children | 1cdfc508d758 |
comparison
equal
deleted
inserted
replaced
| 2813:49f3d1b43518 | 2814:77a012c3b521 |
|---|---|
| 51 * Queries audacious for it's protocol version. | 51 * Queries audacious for it's protocol version. |
| 52 * | 52 * |
| 53 * Return value: The protocol version used by Audacious. | 53 * Return value: The protocol version used by Audacious. |
| 54 **/ | 54 **/ |
| 55 gint audacious_remote_get_version(DBusGProxy *proxy) { | 55 gint audacious_remote_get_version(DBusGProxy *proxy) { |
| 56 //XXX | 56 return 0x09a3; // XXX should do actual dbus call. |
| 57 return 0; | |
| 58 } | 57 } |
| 59 | 58 |
| 60 /** | 59 /** |
| 61 * audacious_remote_playlist_add: | 60 * audacious_remote_playlist_add: |
| 62 * @proxy: DBus proxy for audacious | 61 * @proxy: DBus proxy for audacious |
| 119 * Queries audacious about whether it is playing or not. | 118 * Queries audacious about whether it is playing or not. |
| 120 * | 119 * |
| 121 * Return value: TRUE if playing, FALSE otherwise. | 120 * Return value: TRUE if playing, FALSE otherwise. |
| 122 **/ | 121 **/ |
| 123 gboolean audacious_remote_is_playing(DBusGProxy *proxy) { | 122 gboolean audacious_remote_is_playing(DBusGProxy *proxy) { |
| 124 gboolean is_playing; | 123 gboolean is_playing = FALSE; |
| 125 org_atheme_audacious_playing(proxy, &is_playing, &error); | 124 org_atheme_audacious_playing(proxy, &is_playing, &error); |
| 126 g_clear_error(&error); | 125 g_clear_error(&error); |
| 127 return is_playing; | 126 return is_playing; |
| 128 } | 127 } |
| 129 | 128 |
| 134 * Queries audacious about whether it is paused or not. | 133 * Queries audacious about whether it is paused or not. |
| 135 * | 134 * |
| 136 * Return value: TRUE if playing, FALSE otherwise. | 135 * Return value: TRUE if playing, FALSE otherwise. |
| 137 **/ | 136 **/ |
| 138 gboolean audacious_remote_is_paused(DBusGProxy *proxy) { | 137 gboolean audacious_remote_is_paused(DBusGProxy *proxy) { |
| 139 gboolean is_paused; | 138 gboolean is_paused = FALSE; |
| 140 org_atheme_audacious_paused(proxy, &is_paused, &error); | 139 org_atheme_audacious_paused(proxy, &is_paused, &error); |
| 141 g_clear_error(&error); | 140 g_clear_error(&error); |
| 142 return is_paused; | 141 return is_paused; |
| 143 } | 142 } |
| 144 | 143 |
| 149 * Queries audacious about the current playlist position. | 148 * Queries audacious about the current playlist position. |
| 150 * | 149 * |
| 151 * Return value: The current playlist position. | 150 * Return value: The current playlist position. |
| 152 **/ | 151 **/ |
| 153 gint audacious_remote_get_playlist_pos(DBusGProxy *proxy) { | 152 gint audacious_remote_get_playlist_pos(DBusGProxy *proxy) { |
| 154 guint pos; | 153 guint pos = 0; |
| 155 org_atheme_audacious_position(proxy, &pos, &error); | 154 org_atheme_audacious_position(proxy, &pos, &error); |
| 156 g_clear_error(&error); | 155 g_clear_error(&error); |
| 157 return pos; | 156 return pos; |
| 158 } | 157 } |
| 159 | 158 |
| 176 * Queries audacious about the current playlist length. | 175 * Queries audacious about the current playlist length. |
| 177 * | 176 * |
| 178 * Return value: The amount of entries in the playlist. | 177 * Return value: The amount of entries in the playlist. |
| 179 **/ | 178 **/ |
| 180 gint audacious_remote_get_playlist_length(DBusGProxy *proxy) { | 179 gint audacious_remote_get_playlist_length(DBusGProxy *proxy) { |
| 181 gint len; | 180 gint len = 0; |
| 182 org_atheme_audacious_length(proxy, &len, &error); | 181 org_atheme_audacious_length(proxy, &len, &error); |
| 183 g_clear_error(&error); | 182 g_clear_error(&error); |
| 184 return len; | 183 return len; |
| 185 } | 184 } |
| 186 | 185 |
| 202 * Queries audacious about the current output position. | 201 * Queries audacious about the current output position. |
| 203 * | 202 * |
| 204 * Return value: The current output position. | 203 * Return value: The current output position. |
| 205 **/ | 204 **/ |
| 206 gint audacious_remote_get_output_time(DBusGProxy *proxy) { | 205 gint audacious_remote_get_output_time(DBusGProxy *proxy) { |
| 207 guint time; | 206 guint time = 0; |
| 208 org_atheme_audacious_time(proxy, &time, &error); | 207 org_atheme_audacious_time(proxy, &time, &error); |
| 209 g_clear_error(&error); | 208 g_clear_error(&error); |
| 210 return time; | 209 return time; |
| 211 } | 210 } |
| 212 | 211 |
| 242 * Queries audacious about the current volume. | 241 * Queries audacious about the current volume. |
| 243 * | 242 * |
| 244 * Return value: The current volume. | 243 * Return value: The current volume. |
| 245 **/ | 244 **/ |
| 246 gint audacious_remote_get_main_volume(DBusGProxy *proxy) { | 245 gint audacious_remote_get_main_volume(DBusGProxy *proxy) { |
| 247 gint vl, vr; | 246 gint vl = 0, vr = 0; |
| 248 | 247 |
| 249 audacious_remote_get_volume(proxy, &vl, &vr); | 248 audacious_remote_get_volume(proxy, &vl, &vr); |
| 250 | 249 |
| 251 return (vl > vr) ? vl : vr; | 250 return (vl > vr) ? vl : vr; |
| 252 } | 251 } |
| 258 * Queries audacious about the current balance. | 257 * Queries audacious about the current balance. |
| 259 * | 258 * |
| 260 * Return value: The current balance. | 259 * Return value: The current balance. |
| 261 **/ | 260 **/ |
| 262 gint audacious_remote_get_balance(DBusGProxy *proxy) { | 261 gint audacious_remote_get_balance(DBusGProxy *proxy) { |
| 263 gint balance; | 262 gint balance = 50; |
| 264 org_atheme_audacious_balance(proxy, &balance, &error); | 263 org_atheme_audacious_balance(proxy, &balance, &error); |
| 265 g_clear_error(&error); | 264 g_clear_error(&error); |
| 266 return balance; | 265 return balance; |
| 267 } | 266 } |
| 268 | 267 |
| 286 * @v: The volume to set. | 285 * @v: The volume to set. |
| 287 * | 286 * |
| 288 * Sets the volume in Audacious. | 287 * Sets the volume in Audacious. |
| 289 **/ | 288 **/ |
| 290 void audacious_remote_set_main_volume(DBusGProxy *proxy, gint v) { | 289 void audacious_remote_set_main_volume(DBusGProxy *proxy, gint v) { |
| 291 gint b, vl, vr; | 290 gint b = 50, vl = 0, vr = 0; |
| 292 | 291 |
| 293 b = audacious_remote_get_balance(proxy); | 292 b = audacious_remote_get_balance(proxy); |
| 294 | 293 |
| 295 if (b < 0) { | 294 if (b < 0) { |
| 296 vl = v; | 295 vl = v; |
| 309 * @b: The balance to set. | 308 * @b: The balance to set. |
| 310 * | 309 * |
| 311 * Sets the balance in Audacious. | 310 * Sets the balance in Audacious. |
| 312 **/ | 311 **/ |
| 313 void audacious_remote_set_balance(DBusGProxy *proxy, gint b) { | 312 void audacious_remote_set_balance(DBusGProxy *proxy, gint b) { |
| 314 gint v, vl, vr; | 313 gint v = 0, vl = 0, vr = 0; |
| 315 | 314 |
| 316 if (b < -100) | 315 if (b < -100) |
| 317 b = -100; | 316 b = -100; |
| 318 if (b > 100) | 317 if (b > 100) |
| 319 b = 100; | 318 b = 100; |
| 363 * Queries Audacious about a playlist entry's file. | 362 * Queries Audacious about a playlist entry's file. |
| 364 * | 363 * |
| 365 * Return value: A path to the file in the playlist at %pos position. | 364 * Return value: A path to the file in the playlist at %pos position. |
| 366 **/ | 365 **/ |
| 367 gchar *audacious_remote_get_playlist_file(DBusGProxy *proxy, guint pos) { | 366 gchar *audacious_remote_get_playlist_file(DBusGProxy *proxy, guint pos) { |
| 368 gchar *out; | 367 gchar *out = NULL; |
| 369 org_atheme_audacious_song_filename(proxy, pos, &out, &error); | 368 org_atheme_audacious_song_filename(proxy, pos, &out, &error); |
| 370 g_clear_error(&error); | 369 g_clear_error(&error); |
| 371 return out; | 370 return out; |
| 372 } | 371 } |
| 373 | 372 |
| 379 * Queries Audacious about a playlist entry's title. | 378 * Queries Audacious about a playlist entry's title. |
| 380 * | 379 * |
| 381 * Return value: The title for the entry in the playlist at %pos position. | 380 * Return value: The title for the entry in the playlist at %pos position. |
| 382 **/ | 381 **/ |
| 383 gchar *audacious_remote_get_playlist_title(DBusGProxy *proxy, guint pos) { | 382 gchar *audacious_remote_get_playlist_title(DBusGProxy *proxy, guint pos) { |
| 384 gchar *out; | 383 gchar *out = NULL; |
| 385 org_atheme_audacious_song_title(proxy, pos, &out, &error); | 384 org_atheme_audacious_song_title(proxy, pos, &out, &error); |
| 386 g_clear_error(&error); | 385 g_clear_error(&error); |
| 387 return out; | 386 return out; |
| 388 } | 387 } |
| 389 | 388 |
| 395 * Queries Audacious about a playlist entry's length. | 394 * Queries Audacious about a playlist entry's length. |
| 396 * | 395 * |
| 397 * Return value: The length of the entry in the playlist at %pos position. | 396 * Return value: The length of the entry in the playlist at %pos position. |
| 398 **/ | 397 **/ |
| 399 gint audacious_remote_get_playlist_time(DBusGProxy *proxy, guint pos) { | 398 gint audacious_remote_get_playlist_time(DBusGProxy *proxy, guint pos) { |
| 400 gint out; | 399 gint out = 0; |
| 401 org_atheme_audacious_song_frames(proxy, pos, &out, &error); | 400 org_atheme_audacious_song_frames(proxy, pos, &out, &error); |
| 402 g_clear_error(&error); | 401 g_clear_error(&error); |
| 403 return out; | 402 return out; |
| 404 } | 403 } |
| 405 | 404 |
| 424 * @show: Whether or not to show the main window. | 423 * @show: Whether or not to show the main window. |
| 425 * | 424 * |
| 426 * Toggles the main window's visibility. | 425 * Toggles the main window's visibility. |
| 427 **/ | 426 **/ |
| 428 void audacious_remote_main_win_toggle(DBusGProxy *proxy, gboolean show) { | 427 void audacious_remote_main_win_toggle(DBusGProxy *proxy, gboolean show) { |
| 429 const char* path = dbus_g_proxy_get_path(proxy); | |
| 430 g_print("path: %s\n", path); | |
| 431 org_atheme_audacious_show_main_win(proxy, show, &error); | 428 org_atheme_audacious_show_main_win(proxy, show, &error); |
| 432 g_clear_error(&error); | 429 g_clear_error(&error); |
| 433 } | 430 } |
| 434 | 431 |
| 435 /** | 432 /** |
| 463 * Queries Audacious about the main window's visibility. | 460 * Queries Audacious about the main window's visibility. |
| 464 * | 461 * |
| 465 * Return value: TRUE if visible, FALSE otherwise. | 462 * Return value: TRUE if visible, FALSE otherwise. |
| 466 **/ | 463 **/ |
| 467 gboolean audacious_remote_is_main_win(DBusGProxy *proxy) { | 464 gboolean audacious_remote_is_main_win(DBusGProxy *proxy) { |
| 468 gboolean visible; | 465 gboolean visible = TRUE; |
| 469 org_atheme_audacious_main_win_visible(proxy, &visible, &error); | 466 org_atheme_audacious_main_win_visible(proxy, &visible, &error); |
| 470 g_clear_error(&error); | 467 g_clear_error(&error); |
| 471 return visible; | 468 return visible; |
| 472 } | 469 } |
| 473 | 470 |
| 478 * Queries Audacious about the playlist window's visibility. | 475 * Queries Audacious about the playlist window's visibility. |
| 479 * | 476 * |
| 480 * Return value: TRUE if visible, FALSE otherwise. | 477 * Return value: TRUE if visible, FALSE otherwise. |
| 481 **/ | 478 **/ |
| 482 gboolean audacious_remote_is_pl_win(DBusGProxy *proxy) { | 479 gboolean audacious_remote_is_pl_win(DBusGProxy *proxy) { |
| 483 gboolean visible; | 480 gboolean visible = TRUE; |
| 484 org_atheme_audacious_playlist_visible(proxy, &visible, &error); | 481 org_atheme_audacious_playlist_visible(proxy, &visible, &error); |
| 485 g_clear_error(&error); | 482 g_clear_error(&error); |
| 486 return visible; | 483 return visible; |
| 487 } | 484 } |
| 488 | 485 |
| 493 * Queries Audacious about the equalizer window's visibility. | 490 * Queries Audacious about the equalizer window's visibility. |
| 494 * | 491 * |
| 495 * Return value: TRUE if visible, FALSE otherwise. | 492 * Return value: TRUE if visible, FALSE otherwise. |
| 496 **/ | 493 **/ |
| 497 gboolean audacious_remote_is_eq_win(DBusGProxy *proxy) { | 494 gboolean audacious_remote_is_eq_win(DBusGProxy *proxy) { |
| 498 gboolean visible; | 495 gboolean visible = FALSE; |
| 499 org_atheme_audacious_equalizer_visible(proxy, &visible, &error); | 496 org_atheme_audacious_equalizer_visible(proxy, &visible, &error); |
| 500 g_clear_error(&error); | 497 g_clear_error(&error); |
| 501 return visible; | 498 return visible; |
| 502 } | 499 } |
| 503 | 500 |
| 807 * Queries audacious about whether or not the no-playlist-advance feature is active. | 804 * Queries audacious about whether or not the no-playlist-advance feature is active. |
| 808 * | 805 * |
| 809 * Return value: TRUE if yes, otherwise FALSE. | 806 * Return value: TRUE if yes, otherwise FALSE. |
| 810 **/ | 807 **/ |
| 811 gboolean audacious_remote_is_advance(DBusGProxy *proxy) { | 808 gboolean audacious_remote_is_advance(DBusGProxy *proxy) { |
| 812 gboolean is_advance; | 809 gboolean is_advance = FALSE; |
| 813 org_atheme_audacious_auto_advance(proxy, &is_advance, &error); | 810 org_atheme_audacious_auto_advance(proxy, &is_advance, &error); |
| 814 g_clear_error(&error); | 811 g_clear_error(&error); |
| 815 return is_advance; | 812 return is_advance; |
| 816 } | 813 } |
| 817 | 814 |
