Mercurial > audlegacy
annotate src/libaudacious/beepctrl.c @ 2606:7c19bb5516db trunk
[svn] - Removed some of the horrible code duplication in the file popup code
| author | mf0102 |
|---|---|
| date | Sun, 04 Mar 2007 10:43:38 -0800 |
| parents | c2b49ba4be45 |
| children |
| rev | line source |
|---|---|
| 2313 | 1 /* Audacious |
| 2 * Copyright (C) 2005-2007 Audacious team | |
| 3 * | |
| 4 * XMMS - Cross-platform multimedia player | |
| 5 * Copyright (C) 1998-2003 Peter Alm, Mikael Alm, Olle Hallnas, | |
| 6 * Thomas Nilsson and 4Front Technologies | |
| 7 * Copyright (C) 1999-2003 Haavard Kvaalen | |
| 8 * | |
| 9 * This program is free software; you can redistribute it and/or modify | |
| 10 * it under the terms of the GNU General Public License as published by | |
| 11 * the Free Software Foundation; under version 2 of the License. | |
| 12 * | |
| 13 * This program is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 * GNU General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU General Public License | |
| 19 * along with this program; if not, write to the Free Software | |
| 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| 21 */ | |
| 22 | |
| 23 #ifdef HAVE_CONFIG_H | |
| 24 # include "config.h" | |
| 25 #endif | |
| 26 | |
| 27 #include <glib.h> | |
| 28 #include <sys/types.h> | |
| 29 #include <sys/stat.h> | |
| 30 #include <sys/socket.h> | |
| 31 #include <sys/un.h> | |
| 32 #include <arpa/inet.h> | |
| 33 #include <netdb.h> | |
| 34 #include <errno.h> | |
| 35 #include <stdio.h> | |
| 36 #include <stdlib.h> | |
| 37 #include <string.h> | |
| 38 #include "beepctrl.h" | |
| 39 #include "audacious/controlsocket.h" | |
| 40 #include "libaudacious/configdb.h" | |
| 41 | |
| 42 #include <netdb.h> | |
| 43 #include <netinet/in.h> | |
| 44 #include <unistd.h> | |
| 45 #include <grp.h> | |
| 46 #include <sys/time.h> | |
| 47 #include <sys/wait.h> | |
| 48 #include <sys/resource.h> | |
| 49 #include <sys/socket.h> | |
| 50 #include <fcntl.h> | |
| 51 #include <arpa/inet.h> | |
| 52 | |
| 53 /* overrides audacious_get_session_uri(). */ | |
| 54 gchar *audacious_session_uri = NULL; | |
| 55 gint audacious_session_type = 0; | |
| 56 | |
| 57 #ifdef HAVE_UNISTD_H | |
| 58 #include <unistd.h> | |
| 59 #endif | |
| 60 | |
| 61 static gpointer | |
| 62 remote_read_packet(gint fd) | |
| 63 { | |
| 64 gpointer data = NULL; | |
| 65 ServerPktHeader pkt_hdr = { 0, 0 }; | |
| 66 | |
| 67 if (read(fd, &pkt_hdr, sizeof(ServerPktHeader)) == | |
| 68 sizeof(ServerPktHeader)) | |
| 69 { | |
| 70 if (pkt_hdr.version == XMMS_PROTOCOL_VERSION && | |
| 71 pkt_hdr.data_length > 0) | |
| 72 { | |
| 73 size_t data_length = pkt_hdr.data_length; | |
| 74 data = g_malloc0(data_length); | |
| 75 if ((size_t)read(fd, data, data_length) < data_length) | |
| 76 { | |
| 77 g_free(data); | |
| 78 data = NULL; | |
| 79 } | |
| 80 } | |
| 81 } | |
| 82 | |
| 83 return data; | |
| 84 } | |
| 85 | |
| 86 static void | |
| 87 remote_read_ack(gint fd) | |
| 88 { | |
| 89 gpointer data; | |
| 90 | |
| 91 data = remote_read_packet(fd); | |
| 92 if (data) | |
| 93 g_free(data); | |
| 94 | |
| 95 } | |
| 96 | |
| 97 static void | |
| 98 remote_send_packet(gint fd, guint32 command, gpointer data, | |
| 2517 | 99 gsize data_length) |
| 2313 | 100 { |
| 101 ClientPktHeader pkt_hdr; | |
| 102 | |
| 103 memset(&pkt_hdr, '\0', sizeof(ClientPktHeader)); | |
| 104 | |
| 105 pkt_hdr.version = XMMS_PROTOCOL_VERSION; | |
| 106 pkt_hdr.command = command; | |
| 107 pkt_hdr.data_length = data_length; | |
| 108 if ((size_t)write(fd, &pkt_hdr, sizeof(ClientPktHeader)) < sizeof(pkt_hdr)) | |
|
2361
f24ae4f40e29
[svn] - security and warning fixes from ssommer@suse
nenolod
parents:
2313
diff
changeset
|
109 { |
|
f24ae4f40e29
[svn] - security and warning fixes from ssommer@suse
nenolod
parents:
2313
diff
changeset
|
110 g_warning("remote_send_packet: failed to write packet header"); |
| 2313 | 111 return; |
|
2361
f24ae4f40e29
[svn] - security and warning fixes from ssommer@suse
nenolod
parents:
2313
diff
changeset
|
112 } |
| 2313 | 113 if (data_length && data) |
| 2517 | 114 if( data_length != (gsize) write(fd, data, data_length)) |
|
2361
f24ae4f40e29
[svn] - security and warning fixes from ssommer@suse
nenolod
parents:
2313
diff
changeset
|
115 { |
|
f24ae4f40e29
[svn] - security and warning fixes from ssommer@suse
nenolod
parents:
2313
diff
changeset
|
116 g_warning("remote_send_packet: failed to write packet"); |
|
f24ae4f40e29
[svn] - security and warning fixes from ssommer@suse
nenolod
parents:
2313
diff
changeset
|
117 return; |
|
f24ae4f40e29
[svn] - security and warning fixes from ssommer@suse
nenolod
parents:
2313
diff
changeset
|
118 } |
| 2313 | 119 } |
| 120 | |
| 121 static void | |
| 122 remote_send_guint32(gint session, guint32 cmd, guint32 val) | |
| 123 { | |
| 124 gint fd; | |
| 125 | |
| 126 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 127 return; | |
| 128 remote_send_packet(fd, cmd, &val, sizeof(guint32)); | |
| 129 remote_read_ack(fd); | |
| 130 close(fd); | |
| 131 } | |
| 132 | |
| 133 static void | |
| 134 remote_send_boolean(gint session, guint32 cmd, gboolean val) | |
| 135 { | |
| 136 gint fd; | |
| 137 | |
| 138 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 139 return; | |
| 140 remote_send_packet(fd, cmd, &val, sizeof(gboolean)); | |
| 141 remote_read_ack(fd); | |
| 142 close(fd); | |
| 143 } | |
| 144 | |
| 145 static void | |
| 146 remote_send_gfloat(gint session, guint32 cmd, gfloat value) | |
| 147 { | |
| 148 gint fd; | |
| 149 | |
| 150 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 151 return; | |
| 152 remote_send_packet(fd, cmd, &value, sizeof(gfloat)); | |
| 153 remote_read_ack(fd); | |
| 154 close(fd); | |
| 155 } | |
| 156 | |
| 157 static void | |
| 158 remote_send_string(gint session, guint32 cmd, gchar * string) | |
| 159 { | |
| 160 gint fd; | |
| 161 | |
| 162 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 163 return; | |
| 164 remote_send_packet(fd, cmd, string, string ? strlen(string) + 1 : 0); | |
| 165 remote_read_ack(fd); | |
| 166 close(fd); | |
| 167 } | |
| 168 | |
| 169 static gboolean | |
| 170 remote_cmd(gint session, guint32 cmd) | |
| 171 { | |
| 172 gint fd; | |
| 173 | |
| 174 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 175 return FALSE; | |
| 176 remote_send_packet(fd, cmd, NULL, 0); | |
| 177 remote_read_ack(fd); | |
| 178 close(fd); | |
| 179 | |
| 180 return TRUE; | |
| 181 } | |
| 182 | |
| 183 static gboolean | |
| 184 remote_get_gboolean(gint session, gint cmd) | |
| 185 { | |
| 186 gboolean ret = FALSE; | |
| 187 gpointer data; | |
| 188 gint fd; | |
| 189 | |
| 190 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 191 return ret; | |
| 192 remote_send_packet(fd, cmd, NULL, 0); | |
| 193 data = remote_read_packet(fd); | |
| 194 if (data) { | |
| 195 ret = *((gboolean *) data); | |
| 196 g_free(data); | |
| 197 } | |
| 198 remote_read_ack(fd); | |
| 199 close(fd); | |
| 200 | |
| 201 return ret; | |
| 202 } | |
| 203 | |
| 204 static guint32 | |
| 205 remote_get_gint(gint session, gint cmd) | |
| 206 { | |
| 207 gpointer data; | |
| 208 gint fd, ret = 0; | |
| 209 | |
| 210 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 211 return ret; | |
| 212 remote_send_packet(fd, cmd, NULL, 0); | |
| 213 data = remote_read_packet(fd); | |
| 214 if (data) { | |
| 215 ret = *((gint *) data); | |
| 216 g_free(data); | |
| 217 } | |
| 218 remote_read_ack(fd); | |
| 219 close(fd); | |
| 220 return ret; | |
| 221 } | |
| 222 | |
| 223 static gfloat | |
| 224 remote_get_gfloat(gint session, gint cmd) | |
| 225 { | |
| 226 gpointer data; | |
| 227 gint fd; | |
| 228 gfloat ret = 0.0; | |
| 229 | |
| 230 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 231 return ret; | |
| 232 remote_send_packet(fd, cmd, NULL, 0); | |
| 233 data = remote_read_packet(fd); | |
| 234 if (data) { | |
| 235 ret = *((gfloat *) data); | |
| 236 g_free(data); | |
| 237 } | |
| 238 remote_read_ack(fd); | |
| 239 close(fd); | |
| 240 return ret; | |
| 241 } | |
| 242 | |
| 243 gchar * | |
| 244 remote_get_string(gint session, gint cmd) | |
| 245 { | |
| 246 gpointer data; | |
| 247 gint fd; | |
| 248 | |
| 249 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 250 return NULL; | |
| 251 remote_send_packet(fd, cmd, NULL, 0); | |
| 252 data = remote_read_packet(fd); | |
| 253 remote_read_ack(fd); | |
| 254 close(fd); | |
| 255 return data; | |
| 256 } | |
| 257 | |
| 258 gchar * | |
| 259 remote_get_string_pos(gint session, gint cmd, guint32 pos) | |
| 260 { | |
| 261 gpointer data; | |
| 262 gint fd; | |
| 263 | |
| 264 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 265 return NULL; | |
| 266 remote_send_packet(fd, cmd, &pos, sizeof(guint32)); | |
| 267 data = remote_read_packet(fd); | |
| 268 remote_read_ack(fd); | |
| 269 close(fd); | |
| 270 return data; | |
| 271 } | |
| 272 | |
| 273 /** | |
| 274 * audacious_set_session_uri: | |
| 275 * @uri: The session URI to set the client API to. | |
| 276 * | |
| 277 * Sets the Session URI where Audacious can be reached at. | |
| 278 **/ | |
| 279 void | |
| 280 audacious_set_session_uri(gchar *uri) | |
| 281 { | |
| 282 audacious_session_uri = uri; | |
| 283 } | |
| 284 | |
| 285 /** | |
| 286 * audacious_get_session_uri: | |
| 287 * @session: Legacy XMMS session id (usually 0). | |
| 288 * | |
| 289 * Attempts to determine what the Session URI may be. | |
| 290 * | |
| 291 * Return value: A session URI. | |
| 292 **/ | |
| 293 gchar * | |
| 294 audacious_get_session_uri(gint session) | |
| 295 { | |
| 296 ConfigDb *db; | |
| 297 gchar *value = NULL; | |
| 298 | |
| 299 if (audacious_session_uri != NULL) | |
| 300 { | |
| 301 return g_strdup(audacious_session_uri); | |
| 302 } | |
| 303 | |
| 304 if (audacious_session_type != AUDACIOUS_TYPE_UNIX) | |
| 305 { | |
| 306 db = bmp_cfg_db_open(); | |
| 307 | |
| 308 bmp_cfg_db_get_string(db, NULL, "listen_uri_base", &value); | |
| 309 | |
| 310 bmp_cfg_db_close(db); | |
| 311 } | |
| 312 | |
| 313 if (value == NULL) | |
| 314 return g_strdup_printf("unix://localhost/%s/%s_%s.%d", g_get_tmp_dir(), | |
| 315 CTRLSOCKET_NAME, g_get_user_name(), session); | |
| 316 | |
| 317 audacious_session_uri = value; | |
| 318 | |
| 319 return value; | |
| 320 } | |
| 321 | |
| 322 /** | |
| 323 * audacious_set_session_type: | |
| 324 * @type: The type to set the session type to. | |
| 325 * | |
| 326 * Sets the type of session used by the audacious server. | |
| 327 **/ | |
| 328 void | |
| 329 audacious_set_session_type(gint type) | |
| 330 { | |
| 331 audacious_session_type = type; | |
| 332 } | |
| 333 | |
| 334 /** | |
| 335 * audacious_determine_session_type: | |
| 336 * @session: Legacy XMMS session id (usually 0). | |
| 337 * | |
| 338 * Attempts to determine what the session type may be. | |
| 339 **/ | |
| 340 gint | |
| 341 audacious_determine_session_type(gint session) | |
| 342 { | |
| 343 gchar *uri = NULL; | |
| 344 | |
| 345 if (audacious_session_type != 0) | |
| 346 { | |
| 347 return audacious_session_type; | |
| 348 } | |
| 349 | |
| 350 uri = audacious_get_session_uri(session); | |
| 351 | |
| 352 if (!g_strncasecmp(uri, "tcp://", 6)) | |
| 353 audacious_session_type = AUDACIOUS_TYPE_TCP; | |
| 354 else | |
| 355 audacious_session_type = AUDACIOUS_TYPE_UNIX; | |
| 356 | |
| 357 if (audacious_session_type == 0) | |
| 358 audacious_session_type = AUDACIOUS_TYPE_UNIX; | |
| 359 | |
| 360 /* memory leak! */ | |
| 361 g_free(uri); | |
| 362 | |
| 363 return audacious_session_type; | |
| 364 } | |
| 365 | |
| 366 /* tcp://192.168.100.1:5900/zyzychynxi389xvmfewqaxznvnw */ | |
| 367 | |
| 368 /** | |
| 369 * audacious_decode_tcp_uri: | |
| 370 * @session: The legacy XMMS session id (usually 0). | |
| 371 * @in: A TCP:// Session URI to decode. | |
| 372 * @host: Pointer to a host buffer. | |
| 373 * @port: Pointer to the TCP port. | |
| 374 * @key: Pointer to a security key buffer. | |
| 375 * | |
| 376 * Decodes a tcp:// session URI. | |
| 377 **/ | |
| 378 void | |
| 379 audacious_decode_tcp_uri(gint session, gchar *in, gchar **host, gint *port, gchar **key) | |
| 380 { | |
| 381 static gchar *workbuf, *keybuf; | |
| 382 gint iport; | |
| 383 gchar *tmp = g_strdup(in); | |
| 384 | |
| 385 /* split out the host/port and key */ | |
| 386 workbuf = tmp; | |
| 387 workbuf += 6; | |
| 388 | |
| 389 keybuf = strchr(workbuf, '/'); | |
| 390 *keybuf++ = '\0'; | |
| 391 | |
| 392 *key = g_strdup(keybuf); | |
| 393 | |
| 394 if (strchr(workbuf, ':') == NULL) | |
| 395 { | |
| 396 *host = g_strdup(workbuf); | |
| 397 *port = 37370 + session; | |
| 398 } | |
| 399 else | |
| 400 { | |
| 401 gchar *hostbuf = NULL; | |
| 402 sscanf(workbuf, "%s:%d", hostbuf, &iport); | |
| 403 | |
| 404 *port = iport + session; | |
| 405 } | |
| 406 | |
| 407 g_free(tmp); | |
| 408 } | |
| 409 | |
| 410 /* unix://localhost/tmp/audacious_nenolod.0 */ | |
| 411 | |
| 412 /** | |
| 413 * audacious_decode_unix_uri: | |
| 414 * @session: The legacy XMMS session id (usually 0). | |
| 415 * @in: A UNIX:// Session URI to decode. | |
| 416 * @key: Pointer to a UNIX path buffer. | |
| 417 * | |
| 418 * Decodes a unix:// session URI. | |
| 419 **/ | |
| 420 void | |
| 421 audacious_decode_unix_uri(gint session, gchar *in, gchar **key) | |
| 422 { | |
| 423 static gchar *workbuf, *keybuf; | |
| 424 gchar *tmp = g_strdup(in); | |
| 425 | |
| 426 /* split out the host/port and key */ | |
| 427 workbuf = tmp; | |
| 428 workbuf += 7; | |
| 429 | |
| 430 keybuf = strchr(workbuf, '/'); | |
| 431 *keybuf++ = '\0'; | |
| 432 | |
| 433 *key = g_strdup(keybuf); | |
| 434 | |
| 435 g_free(tmp); | |
| 436 } | |
| 437 | |
| 438 /** | |
|
2585
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
439 * audacious_get_tuple_field_data: |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
440 * @session: Legacy XMMS-style session identifier. |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
441 * @field: The name of the tuple field to retrieve. |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
442 * @pos: The playlist position to query for. |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
443 * |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
444 * Queries Audacious about a playlist entry's tuple information. |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
445 * |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
446 * Return value: The requested field's data for the entry in the playlist at %pos position. |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
447 **/ |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
448 gchar * |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
449 audacious_get_tuple_field_data(gint session, gchar * field, gint pos) |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
450 { |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
451 gint fd, size; |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
452 gchar *packet; |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
453 gpointer data; |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
454 |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
455 if (field == NULL) |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
456 return NULL; |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
457 |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
458 size = strlen(field) + 1 + sizeof(gint); |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
459 |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
460 if ((fd = xmms_connect_to_session(session)) == -1) |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
461 return NULL; |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
462 |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
463 packet = g_malloc0(size); |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
464 *((gint *) packet) = pos; |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
465 strcpy(packet + sizeof(gint), field); |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
466 remote_send_packet(fd, CMD_PLAYLIST_GET_TUPLE_DATA, packet, size); |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
467 data = remote_read_packet(fd); |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
468 remote_read_ack(fd); |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
469 close(fd); |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
470 g_free(packet); |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
471 return data; |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
472 } |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
473 |
|
c2b49ba4be45
[svn] - tuple reading now available through audtool with audacious_get_tuple_field_data()
nhjm449
parents:
2517
diff
changeset
|
474 /** |
| 2313 | 475 * xmms_connect_to_session: |
| 476 * @session: Legacy XMMS-style session identifier. | |
| 477 * | |
| 478 * Connects to an audacious server. | |
| 479 * | |
| 480 * Return value: an FD on success, otherwise -1. | |
| 481 **/ | |
| 482 gint | |
| 483 xmms_connect_to_session(gint session) | |
| 484 { | |
| 485 gint fd; | |
| 486 gint type = audacious_determine_session_type(session); | |
| 487 gchar *uri = audacious_get_session_uri(session); | |
| 488 | |
| 489 if (type == AUDACIOUS_TYPE_UNIX) | |
| 490 { | |
| 491 if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) | |
| 492 { | |
| 493 uid_t stored_uid, euid; | |
| 494 struct sockaddr_un saddr; | |
| 495 gchar *path; | |
| 496 | |
| 497 saddr.sun_family = AF_UNIX; | |
| 498 stored_uid = getuid(); | |
| 499 euid = geteuid(); | |
| 500 setuid(euid); | |
| 501 | |
| 502 audacious_decode_unix_uri(session, uri, &path); | |
| 503 | |
| 504 g_strlcpy(saddr.sun_path, path, 108); | |
| 505 g_free(path); | |
| 506 setreuid(stored_uid, euid); | |
| 507 | |
| 508 g_free(uri); | |
| 509 | |
| 510 if (connect(fd, (struct sockaddr *) &saddr, sizeof(saddr)) != -1) | |
| 511 return fd; | |
| 512 } | |
| 513 } | |
| 514 else | |
| 515 { | |
| 516 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) != -1) | |
| 517 { | |
| 518 struct hostent *hp; | |
| 519 struct sockaddr_in saddr; | |
| 520 gchar *host, *key; | |
| 521 gint port; | |
| 522 | |
| 523 audacious_decode_tcp_uri(session, uri, &host, &port, &key); | |
| 524 | |
| 525 /* resolve it */ | |
| 526 if ((hp = gethostbyname(host)) == NULL) | |
| 527 { | |
| 528 close(fd); | |
| 529 return -1; | |
| 530 } | |
| 531 | |
| 532 memset(&saddr, '\0', sizeof(saddr)); | |
| 533 saddr.sin_family = AF_INET; | |
| 534 saddr.sin_port = htons(port); | |
| 535 memcpy(&saddr.sin_addr, hp->h_addr, hp->h_length); | |
| 536 | |
| 537 g_free(host); | |
| 538 g_free(key); | |
| 539 | |
| 540 g_free(uri); | |
| 541 | |
| 542 if (connect(fd, (struct sockaddr *) &saddr, sizeof(saddr)) != -1) | |
| 543 return fd; | |
| 544 } | |
| 545 } | |
| 546 | |
| 547 close(fd); | |
| 548 return -1; | |
| 549 } | |
| 550 | |
| 551 /** | |
| 552 * xmms_remote_playlist: | |
| 553 * @session: Legacy XMMS-style session identifier. | |
| 554 * @list: A list of URIs to play. | |
| 555 * @num: Number of URIs to play. | |
| 556 * @enqueue: Whether or not the new playlist should be added on, or replace the current playlist. | |
| 557 * | |
| 558 * Sends a playlist to audacious. | |
| 559 **/ | |
| 560 void | |
| 561 xmms_remote_playlist(gint session, gchar ** list, gint num, gboolean enqueue) | |
| 562 { | |
| 563 gint fd, i; | |
| 564 gchar *data, *ptr; | |
| 565 gint data_length; | |
| 566 guint32 len; | |
| 567 | |
| 568 g_return_if_fail(list != NULL); | |
| 569 g_return_if_fail(num > 0); | |
| 570 | |
| 571 if (!enqueue) | |
| 572 xmms_remote_playlist_clear(session); | |
| 573 | |
| 574 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 575 return; | |
| 576 | |
| 577 for (i = 0, data_length = 0; i < num; i++) | |
| 578 data_length += (((strlen(list[i]) + 1) + 3) / 4) * 4 + 4; | |
| 579 if (data_length) { | |
| 580 data_length += 4; | |
| 581 data = g_malloc(data_length); | |
| 582 for (i = 0, ptr = data; i < num; i++) { | |
| 583 len = strlen(list[i]) + 1; | |
| 584 *((guint32 *) ptr) = len; | |
| 585 ptr += 4; | |
| 586 memcpy(ptr, list[i], len); | |
| 587 ptr += ((len + 3) / 4) * 4; | |
| 588 } | |
| 589 *((guint32 *) ptr) = 0; | |
| 590 remote_send_packet(fd, CMD_PLAYLIST_ADD, data, data_length); | |
| 591 remote_read_ack(fd); | |
| 592 close(fd); | |
| 593 g_free(data); | |
| 594 } | |
| 595 | |
| 596 if (!enqueue) | |
| 597 xmms_remote_play(session); | |
| 598 } | |
| 599 | |
| 600 /** | |
| 601 * xmms_remote_get_version: | |
| 602 * @session: Legacy XMMS-style session identifier. | |
| 603 * | |
| 604 * Queries audacious for it's protocol version. | |
| 605 * | |
| 606 * Return value: The protocol version used by Audacious. | |
| 607 **/ | |
| 608 gint | |
| 609 xmms_remote_get_version(gint session) | |
| 610 { | |
| 611 return remote_get_gint(session, CMD_GET_VERSION); | |
| 612 } | |
| 613 | |
| 614 /** | |
| 615 * xmms_remote_play_files: | |
| 616 * @session: Legacy XMMS-style session identifier. | |
| 617 * @list: A GList of URIs to play. | |
| 618 * | |
| 619 * Sends a list of URIs to Audacious to play. | |
| 620 **/ | |
| 621 void | |
| 622 xmms_remote_play_files(gint session, GList * list) | |
| 623 { | |
| 624 g_return_if_fail(list != NULL); | |
| 625 | |
| 626 xmms_remote_playlist_clear(session); | |
| 627 xmms_remote_playlist_add(session, list); | |
| 628 xmms_remote_play(session); | |
| 629 } | |
| 630 | |
| 631 /** | |
| 632 * xmms_remote_playlist_add: | |
| 633 * @session: Legacy XMMS-style session identifier. | |
| 634 * @list: A GList of URIs to add to the playlist. | |
| 635 * | |
| 636 * Sends a list of URIs to Audacious to add to the playlist. | |
| 637 **/ | |
| 638 void | |
| 639 xmms_remote_playlist_add(gint session, GList * list) | |
| 640 { | |
| 641 gchar **str_list; | |
| 642 GList *node; | |
| 643 gint i, num; | |
| 644 | |
| 645 g_return_if_fail(list != NULL); | |
| 646 | |
| 647 num = g_list_length(list); | |
| 648 str_list = g_malloc0(num * sizeof(gchar *)); | |
| 649 for (i = 0, node = list; i < num && node; i++, node = g_list_next(node)) | |
| 650 str_list[i] = node->data; | |
| 651 | |
| 652 xmms_remote_playlist(session, str_list, num, TRUE); | |
| 653 g_free(str_list); | |
| 654 } | |
| 655 | |
| 656 /** | |
| 657 * xmms_remote_playlist_delete: | |
| 658 * @session: Legacy XMMS-style session identifier. | |
| 659 * @pos: The playlist position to delete. | |
| 660 * | |
| 661 * Deletes a playlist entry. | |
| 662 **/ | |
| 663 void | |
| 664 xmms_remote_playlist_delete(gint session, gint pos) | |
| 665 { | |
| 666 remote_send_guint32(session, CMD_PLAYLIST_DELETE, pos); | |
| 667 } | |
| 668 | |
| 669 /** | |
| 670 * xmms_remote_play: | |
| 671 * @session: Legacy XMMS-style session identifier. | |
| 672 * | |
| 673 * Tells audacious to begin playback. | |
| 674 **/ | |
| 675 void | |
| 676 xmms_remote_play(gint session) | |
| 677 { | |
| 678 remote_cmd(session, CMD_PLAY); | |
| 679 } | |
| 680 | |
| 681 /** | |
| 682 * xmms_remote_pause: | |
| 683 * @session: Legacy XMMS-style session identifier. | |
| 684 * | |
| 685 * Tells audacious to pause. | |
| 686 **/ | |
| 687 void | |
| 688 xmms_remote_pause(gint session) | |
| 689 { | |
| 690 remote_cmd(session, CMD_PAUSE); | |
| 691 } | |
| 692 | |
| 693 /** | |
| 694 * xmms_remote_stop: | |
| 695 * @session: Legacy XMMS-style session identifier. | |
| 696 * | |
| 697 * Tells audacious to stop. | |
| 698 **/ | |
| 699 void | |
| 700 xmms_remote_stop(gint session) | |
| 701 { | |
| 702 remote_cmd(session, CMD_STOP); | |
| 703 } | |
| 704 | |
| 705 /** | |
| 706 * xmms_remote_play_pause: | |
| 707 * @session: Legacy XMMS-style session identifier. | |
| 708 * | |
| 709 * Tells audacious to either play or pause. | |
| 710 **/ | |
| 711 void | |
| 712 xmms_remote_play_pause(gint session) | |
| 713 { | |
| 714 remote_cmd(session, CMD_PLAY_PAUSE); | |
| 715 } | |
| 716 | |
| 717 /** | |
| 718 * xmms_remote_is_playing: | |
| 719 * @session: Legacy XMMS-style session identifier. | |
| 720 * | |
| 721 * Queries audacious about whether it is playing or not. | |
| 722 * | |
| 723 * Return value: TRUE if playing, FALSE otherwise. | |
| 724 **/ | |
| 725 gboolean | |
| 726 xmms_remote_is_playing(gint session) | |
| 727 { | |
| 728 return remote_get_gboolean(session, CMD_IS_PLAYING); | |
| 729 } | |
| 730 | |
| 731 /** | |
| 732 * xmms_remote_is_paused: | |
| 733 * @session: Legacy XMMS-style session identifier. | |
| 734 * | |
| 735 * Queries audacious about whether it is paused or not. | |
| 736 * | |
| 737 * Return value: TRUE if playing, FALSE otherwise. | |
| 738 **/ | |
| 739 gboolean | |
| 740 xmms_remote_is_paused(gint session) | |
| 741 { | |
| 742 return remote_get_gboolean(session, CMD_IS_PAUSED); | |
| 743 } | |
| 744 | |
| 745 /** | |
| 746 * xmms_remote_get_playlist_pos: | |
| 747 * @session: Legacy XMMS-style session identifier. | |
| 748 * | |
| 749 * Queries audacious about the current playlist position. | |
| 750 * | |
| 751 * Return value: The current playlist position. | |
| 752 **/ | |
| 753 gint | |
| 754 xmms_remote_get_playlist_pos(gint session) | |
| 755 { | |
| 756 return remote_get_gint(session, CMD_GET_PLAYLIST_POS); | |
| 757 } | |
| 758 | |
| 759 /** | |
| 760 * xmms_remote_set_playlist_pos: | |
| 761 * @session: Legacy XMMS-style session identifier. | |
| 762 * @pos: Playlist position to jump to. | |
| 763 * | |
| 764 * Tells audacious to jump to a different playlist position. | |
| 765 **/ | |
| 766 void | |
| 767 xmms_remote_set_playlist_pos(gint session, gint pos) | |
| 768 { | |
| 769 remote_send_guint32(session, CMD_SET_PLAYLIST_POS, pos); | |
| 770 } | |
| 771 | |
| 772 /** | |
| 773 * xmms_remote_get_playlist_length: | |
| 774 * @session: Legacy XMMS-style session identifier. | |
| 775 * | |
| 776 * Queries audacious about the current playlist length. | |
| 777 * | |
| 778 * Return value: The amount of entries in the playlist. | |
| 779 **/ | |
| 780 gint | |
| 781 xmms_remote_get_playlist_length(gint session) | |
| 782 { | |
| 783 return remote_get_gint(session, CMD_GET_PLAYLIST_LENGTH); | |
| 784 } | |
| 785 | |
| 786 /** | |
| 787 * xmms_remote_playlist_clear: | |
| 788 * @session: Legacy XMMS-style session identifier. | |
| 789 * | |
| 790 * Clears the playlist. | |
| 791 **/ | |
| 792 void | |
| 793 xmms_remote_playlist_clear(gint session) | |
| 794 { | |
| 795 remote_cmd(session, CMD_PLAYLIST_CLEAR); | |
| 796 } | |
| 797 | |
| 798 /** | |
| 799 * xmms_remote_get_output_time: | |
| 800 * @session: Legacy XMMS-style session identifier. | |
| 801 * | |
| 802 * Queries audacious about the current output position. | |
| 803 * | |
| 804 * Return value: The current output position. | |
| 805 **/ | |
| 806 gint | |
| 807 xmms_remote_get_output_time(gint session) | |
| 808 { | |
| 809 return remote_get_gint(session, CMD_GET_OUTPUT_TIME); | |
| 810 } | |
| 811 | |
| 812 /** | |
| 813 * xmms_remote_jump_to_time: | |
| 814 * @session: Legacy XMMS-style session identifier. | |
| 815 * @pos: The time (in milliseconds) to jump to. | |
| 816 * | |
| 817 * Tells audacious to seek to a new time position. | |
| 818 **/ | |
| 819 void | |
| 820 xmms_remote_jump_to_time(gint session, gint pos) | |
| 821 { | |
| 822 remote_send_guint32(session, CMD_JUMP_TO_TIME, pos); | |
| 823 } | |
| 824 | |
| 825 /** | |
| 826 * xmms_remote_get_volume: | |
| 827 * @session: Legacy XMMS-style session identifier. | |
| 828 * @vl: Pointer to integer containing the left channel's volume. | |
| 829 * @vr: Pointer to integer containing the right channel's volume. | |
| 830 * | |
| 831 * Queries audacious about the current volume. | |
| 832 **/ | |
| 833 void | |
| 834 xmms_remote_get_volume(gint session, gint * vl, gint * vr) | |
| 835 { | |
| 836 gint fd; | |
| 837 gpointer data; | |
| 838 | |
| 839 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 840 return; | |
| 841 | |
| 842 remote_send_packet(fd, CMD_GET_VOLUME, NULL, 0); | |
| 843 data = remote_read_packet(fd); | |
| 844 if (data) { | |
| 845 *vl = ((guint32 *) data)[0]; | |
| 846 *vr = ((guint32 *) data)[1]; | |
| 847 g_free(data); | |
| 848 } | |
| 849 remote_read_ack(fd); | |
| 850 close(fd); | |
| 851 } | |
| 852 | |
| 853 /** | |
| 854 * xmms_remote_get_main_volume: | |
| 855 * @session: Legacy XMMS-style session identifier. | |
| 856 * | |
| 857 * Queries audacious about the current volume. | |
| 858 * | |
| 859 * Return value: The current volume. | |
| 860 **/ | |
| 861 gint | |
| 862 xmms_remote_get_main_volume(gint session) | |
| 863 { | |
| 864 gint vl, vr; | |
| 865 | |
| 866 xmms_remote_get_volume(session, &vl, &vr); | |
| 867 | |
| 868 return (vl > vr) ? vl : vr; | |
| 869 } | |
| 870 | |
| 871 /** | |
| 872 * xmms_remote_get_balance: | |
| 873 * @session: Legacy XMMS-style session identifier. | |
| 874 * | |
| 875 * Queries audacious about the current balance. | |
| 876 * | |
| 877 * Return value: The current balance. | |
| 878 **/ | |
| 879 gint | |
| 880 xmms_remote_get_balance(gint session) | |
| 881 { | |
| 882 return remote_get_gint(session, CMD_GET_BALANCE); | |
| 883 } | |
| 884 | |
| 885 /** | |
| 886 * xmms_remote_set_volume: | |
| 887 * @session: Legacy XMMS-style session identifier. | |
| 888 * @vl: The volume for the left channel. | |
| 889 * @vr: The volume for the right channel. | |
| 890 * | |
| 891 * Sets the volume for the left and right channels in Audacious. | |
| 892 **/ | |
| 893 void | |
| 894 xmms_remote_set_volume(gint session, gint vl, gint vr) | |
| 895 { | |
| 896 gint fd; | |
| 897 guint32 v[2]; | |
| 898 | |
| 899 if (vl < 0) | |
| 900 vl = 0; | |
| 901 if (vl > 100) | |
| 902 vl = 100; | |
| 903 if (vr < 0) | |
| 904 vr = 0; | |
| 905 if (vr > 100) | |
| 906 vr = 100; | |
| 907 | |
| 908 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 909 return; | |
| 910 v[0] = vl; | |
| 911 v[1] = vr; | |
| 912 remote_send_packet(fd, CMD_SET_VOLUME, v, 2 * sizeof(guint32)); | |
| 913 remote_read_ack(fd); | |
| 914 close(fd); | |
| 915 } | |
| 916 | |
| 917 /** | |
| 918 * xmms_remote_set_main_volume: | |
| 919 * @session: Legacy XMMS-style session identifier. | |
| 920 * @v: The volume to set. | |
| 921 * | |
| 922 * Sets the volume in Audacious. | |
| 923 **/ | |
| 924 void | |
| 925 xmms_remote_set_main_volume(gint session, gint v) | |
| 926 { | |
| 927 gint b, vl, vr; | |
| 928 | |
| 929 b = xmms_remote_get_balance(session); | |
| 930 | |
| 931 if (b < 0) { | |
| 932 vl = v; | |
| 933 vr = (v * (100 - abs(b))) / 100; | |
| 934 } | |
| 935 else if (b > 0) { | |
| 936 vl = (v * (100 - b)) / 100; | |
| 937 vr = v; | |
| 938 } | |
| 939 else | |
| 940 vl = vr = v; | |
| 941 xmms_remote_set_volume(session, vl, vr); | |
| 942 } | |
| 943 | |
| 944 /** | |
| 945 * xmms_remote_set_balance: | |
| 946 * @session: Legacy XMMS-style session identifier. | |
| 947 * @b: The balance to set. | |
| 948 * | |
| 949 * Sets the balance in Audacious. | |
| 950 **/ | |
| 951 void | |
| 952 xmms_remote_set_balance(gint session, gint b) | |
| 953 { | |
| 954 gint v, vl, vr; | |
| 955 | |
| 956 if (b < -100) | |
| 957 b = -100; | |
| 958 if (b > 100) | |
| 959 b = 100; | |
| 960 | |
| 961 v = xmms_remote_get_main_volume(session); | |
| 962 | |
| 963 if (b < 0) { | |
| 964 vl = v; | |
| 965 vr = (v * (100 - abs(b))) / 100; | |
| 966 } | |
| 967 else if (b > 0) { | |
| 968 vl = (v * (100 - b)) / 100; | |
| 969 vr = v; | |
| 970 } | |
| 971 else | |
| 972 vl = vr = v; | |
| 973 xmms_remote_set_volume(session, vl, vr); | |
| 974 } | |
| 975 | |
| 976 /** | |
| 977 * xmms_remote_get_skin: | |
| 978 * @session: Legacy XMMS-style session identifier. | |
| 979 * | |
| 980 * Queries Audacious about it's skin. | |
| 981 * | |
| 982 * Return value: A path to the currently selected skin. | |
| 983 **/ | |
| 984 gchar * | |
| 985 xmms_remote_get_skin(gint session) | |
| 986 { | |
| 987 return remote_get_string(session, CMD_GET_SKIN); | |
| 988 } | |
| 989 | |
| 990 /** | |
| 991 * xmms_remote_set_skin: | |
| 992 * @session: Legacy XMMS-style session identifier. | |
| 993 * @skinfile: Path to a skinfile to use with Audacious. | |
| 994 * | |
| 995 * Tells audacious to start using the skinfile provided. | |
| 996 **/ | |
| 997 void | |
| 998 xmms_remote_set_skin(gint session, gchar * skinfile) | |
| 999 { | |
| 1000 remote_send_string(session, CMD_SET_SKIN, skinfile); | |
| 1001 } | |
| 1002 | |
| 1003 /** | |
| 1004 * xmms_remote_get_playlist_file: | |
| 1005 * @session: Legacy XMMS-style session identifier. | |
| 1006 * @pos: The playlist position to query for. | |
| 1007 * | |
| 1008 * Queries Audacious about a playlist entry's file. | |
| 1009 * | |
| 1010 * Return value: A path to the file in the playlist at %pos position. | |
| 1011 **/ | |
| 1012 gchar * | |
| 1013 xmms_remote_get_playlist_file(gint session, gint pos) | |
| 1014 { | |
| 1015 return remote_get_string_pos(session, CMD_GET_PLAYLIST_FILE, pos); | |
| 1016 } | |
| 1017 | |
| 1018 /** | |
| 1019 * xmms_remote_get_playlist_title: | |
| 1020 * @session: Legacy XMMS-style session identifier. | |
| 1021 * @pos: The playlist position to query for. | |
| 1022 * | |
| 1023 * Queries Audacious about a playlist entry's title. | |
| 1024 * | |
| 1025 * Return value: The title for the entry in the playlist at %pos position. | |
| 1026 **/ | |
| 1027 gchar * | |
| 1028 xmms_remote_get_playlist_title(gint session, gint pos) | |
| 1029 { | |
| 1030 return remote_get_string_pos(session, CMD_GET_PLAYLIST_TITLE, pos); | |
| 1031 } | |
| 1032 | |
| 1033 /** | |
| 1034 * xmms_remote_get_playlist_time: | |
| 1035 * @session: Legacy XMMS-style session identifier. | |
| 1036 * @pos: The playlist position to query for. | |
| 1037 * | |
| 1038 * Queries Audacious about a playlist entry's length. | |
| 1039 * | |
| 1040 * Return value: The length of the entry in the playlist at %pos position. | |
| 1041 **/ | |
| 1042 gint | |
| 1043 xmms_remote_get_playlist_time(gint session, gint pos) | |
| 1044 { | |
| 1045 gpointer data; | |
| 1046 gint fd, ret = 0; | |
| 1047 guint32 p = pos; | |
| 1048 | |
| 1049 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 1050 return ret; | |
| 1051 remote_send_packet(fd, CMD_GET_PLAYLIST_TIME, &p, sizeof(guint32)); | |
| 1052 data = remote_read_packet(fd); | |
| 1053 if (data) { | |
| 1054 ret = *((gint *) data); | |
| 1055 g_free(data); | |
| 1056 } | |
| 1057 remote_read_ack(fd); | |
| 1058 close(fd); | |
| 1059 return ret; | |
| 1060 } | |
| 1061 | |
| 1062 /** | |
| 1063 * xmms_remote_get_info: | |
| 1064 * @session: Legacy XMMS-style session identifier. | |
| 1065 * @rate: Pointer to an integer containing the bitrate. | |
| 1066 * @freq: Pointer to an integer containing the frequency. | |
| 1067 * @nch: Pointer to an integer containing the number of channels. | |
| 1068 * | |
| 1069 * Queries Audacious about the current audio format. | |
| 1070 **/ | |
| 1071 void | |
| 1072 xmms_remote_get_info(gint session, gint * rate, gint * freq, gint * nch) | |
| 1073 { | |
| 1074 gint fd; | |
| 1075 gpointer data; | |
| 1076 | |
| 1077 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 1078 return; | |
| 1079 remote_send_packet(fd, CMD_GET_INFO, NULL, 0); | |
| 1080 data = remote_read_packet(fd); | |
| 1081 if (data) { | |
| 1082 *rate = ((guint32 *) data)[0]; | |
| 1083 *freq = ((guint32 *) data)[1]; | |
| 1084 *nch = ((guint32 *) data)[2]; | |
| 1085 g_free(data); | |
| 1086 } | |
| 1087 remote_read_ack(fd); | |
| 1088 close(fd); | |
| 1089 } | |
| 1090 | |
| 1091 /** | |
| 1092 * xmms_remote_get_eq_data: | |
| 1093 * @session: Legacy XMMS-style session identifier. | |
| 1094 * | |
| 1095 * Not implemented, present for compatibility with libxmms API. | |
| 1096 **/ | |
| 1097 void | |
| 1098 xmms_remote_get_eq_data(gint session) | |
| 1099 { | |
| 1100 /* Obsolete */ | |
| 1101 } | |
| 1102 | |
| 1103 /** | |
| 1104 * xmms_remote_set_eq_data: | |
| 1105 * @session: Legacy XMMS-style session identifier. | |
| 1106 * | |
| 1107 * Not implemented, present for compatibility with libxmms API. | |
| 1108 **/ | |
| 1109 void | |
| 1110 xmms_remote_set_eq_data(gint session) | |
| 1111 { | |
| 1112 /* Obsolete */ | |
| 1113 } | |
| 1114 | |
| 1115 /** | |
| 1116 * xmms_remote_pl_win_toggle: | |
| 1117 * @session: Legacy XMMS-style session identifier. | |
| 1118 * @show: Whether or not to show the playlist window. | |
| 1119 * | |
| 1120 * Toggles the playlist window's visibility. | |
| 1121 **/ | |
| 1122 void | |
| 1123 xmms_remote_pl_win_toggle(gint session, gboolean show) | |
| 1124 { | |
| 1125 remote_send_boolean(session, CMD_PL_WIN_TOGGLE, show); | |
| 1126 } | |
| 1127 | |
| 1128 /** | |
| 1129 * xmms_remote_eq_win_toggle: | |
| 1130 * @session: Legacy XMMS-style session identifier. | |
| 1131 * @show: Whether or not to show the equalizer window. | |
| 1132 * | |
| 1133 * Toggles the equalizer window's visibility. | |
| 1134 **/ | |
| 1135 void | |
| 1136 xmms_remote_eq_win_toggle(gint session, gboolean show) | |
| 1137 { | |
| 1138 remote_send_boolean(session, CMD_EQ_WIN_TOGGLE, show); | |
| 1139 } | |
| 1140 | |
| 1141 /** | |
| 1142 * xmms_remote_main_win_toggle: | |
| 1143 * @session: Legacy XMMS-style session identifier. | |
| 1144 * @show: Whether or not to show the main window. | |
| 1145 * | |
| 1146 * Toggles the main window's visibility. | |
| 1147 **/ | |
| 1148 void | |
| 1149 xmms_remote_main_win_toggle(gint session, gboolean show) | |
| 1150 { | |
| 1151 remote_send_boolean(session, CMD_MAIN_WIN_TOGGLE, show); | |
| 1152 } | |
| 1153 | |
| 1154 /** | |
| 1155 * xmms_remote_is_main_win: | |
| 1156 * @session: Legacy XMMS-style session identifier. | |
| 1157 * | |
| 1158 * Queries Audacious about the main window's visibility. | |
| 1159 * | |
| 1160 * Return value: TRUE if visible, FALSE otherwise. | |
| 1161 **/ | |
| 1162 gboolean | |
| 1163 xmms_remote_is_main_win(gint session) | |
| 1164 { | |
| 1165 return remote_get_gboolean(session, CMD_IS_MAIN_WIN); | |
| 1166 } | |
| 1167 | |
| 1168 /** | |
| 1169 * xmms_remote_is_pl_win: | |
| 1170 * @session: Legacy XMMS-style session identifier. | |
| 1171 * | |
| 1172 * Queries Audacious about the playlist window's visibility. | |
| 1173 * | |
| 1174 * Return value: TRUE if visible, FALSE otherwise. | |
| 1175 **/ | |
| 1176 gboolean | |
| 1177 xmms_remote_is_pl_win(gint session) | |
| 1178 { | |
| 1179 return remote_get_gboolean(session, CMD_IS_PL_WIN); | |
| 1180 } | |
| 1181 | |
| 1182 /** | |
| 1183 * xmms_remote_is_eq_win: | |
| 1184 * @session: Legacy XMMS-style session identifier. | |
| 1185 * | |
| 1186 * Queries Audacious about the equalizer window's visibility. | |
| 1187 * | |
| 1188 * Return value: TRUE if visible, FALSE otherwise. | |
| 1189 **/ | |
| 1190 gboolean | |
| 1191 xmms_remote_is_eq_win(gint session) | |
| 1192 { | |
| 1193 return remote_get_gboolean(session, CMD_IS_EQ_WIN); | |
| 1194 } | |
| 1195 | |
| 1196 /** | |
| 1197 * xmms_remote_show_prefs_box: | |
| 1198 * @session: Legacy XMMS-style session identifier. | |
| 1199 * | |
| 1200 * Tells audacious to show the preferences pane. | |
| 1201 **/ | |
| 1202 void | |
| 1203 xmms_remote_show_prefs_box(gint session) | |
| 1204 { | |
| 1205 remote_cmd(session, CMD_SHOW_PREFS_BOX); | |
| 1206 } | |
| 1207 | |
| 1208 /** | |
| 1209 * xmms_remote_show_jtf_box: | |
| 1210 * @session: Legacy XMMS-style session identifier. | |
| 1211 * | |
| 1212 * Tells audacious to show the Jump-to-File pane. | |
| 1213 **/ | |
| 1214 void | |
| 1215 xmms_remote_show_jtf_box(gint session) | |
| 1216 { | |
| 1217 remote_cmd(session, CMD_SHOW_JTF_BOX); | |
| 1218 } | |
| 1219 | |
| 1220 /** | |
| 1221 * xmms_remote_toggle_aot: | |
| 1222 * @session: Legacy XMMS-style session identifier. | |
| 1223 * @ontop: Whether or not Audacious should be always-on-top. | |
| 1224 * | |
| 1225 * Tells audacious to toggle the always-on-top feature. | |
| 1226 **/ | |
| 1227 void | |
| 1228 xmms_remote_toggle_aot(gint session, gboolean ontop) | |
| 1229 { | |
| 1230 remote_send_boolean(session, CMD_TOGGLE_AOT, ontop); | |
| 1231 } | |
| 1232 | |
| 1233 /** | |
| 1234 * xmms_remote_show_about_box: | |
| 1235 * @session: Legacy XMMS-style session identifier. | |
| 1236 * | |
| 1237 * Tells audacious to show the about pane. | |
| 1238 **/ | |
| 1239 void | |
| 1240 xmms_remote_show_about_box(gint session) | |
| 1241 { | |
| 1242 remote_cmd(session, CMD_SHOW_ABOUT_BOX); | |
| 1243 } | |
| 1244 | |
| 1245 /** | |
| 1246 * xmms_remote_eject: | |
| 1247 * @session: Legacy XMMS-style session identifier. | |
| 1248 * | |
| 1249 * Tells audacious to display the open files pane. | |
| 1250 **/ | |
| 1251 void | |
| 1252 xmms_remote_eject(gint session) | |
| 1253 { | |
| 1254 remote_cmd(session, CMD_EJECT); | |
| 1255 } | |
| 1256 | |
| 1257 /** | |
| 1258 * xmms_remote_playlist_prev: | |
| 1259 * @session: Legacy XMMS-style session identifier. | |
| 1260 * | |
| 1261 * Tells audacious to move backwards in the playlist. | |
| 1262 **/ | |
| 1263 void | |
| 1264 xmms_remote_playlist_prev(gint session) | |
| 1265 { | |
| 1266 remote_cmd(session, CMD_PLAYLIST_PREV); | |
| 1267 } | |
| 1268 | |
| 1269 /** | |
| 1270 * xmms_remote_playlist_next: | |
| 1271 * @session: Legacy XMMS-style session identifier. | |
| 1272 * | |
| 1273 * Tells audacious to move forward in the playlist. | |
| 1274 **/ | |
| 1275 void | |
| 1276 xmms_remote_playlist_next(gint session) | |
| 1277 { | |
| 1278 remote_cmd(session, CMD_PLAYLIST_NEXT); | |
| 1279 } | |
| 1280 | |
| 1281 /** | |
| 1282 * xmms_remote_playlist_add_url_string: | |
| 1283 * @session: Legacy XMMS-style session identifier. | |
| 1284 * @string: The URI to add. | |
| 1285 * | |
| 1286 * Tells audacious to add an URI to the playlist. | |
| 1287 **/ | |
| 1288 void | |
| 1289 xmms_remote_playlist_add_url_string(gint session, gchar * string) | |
| 1290 { | |
| 1291 g_return_if_fail(string != NULL); | |
| 1292 remote_send_string(session, CMD_PLAYLIST_ADD_URL_STRING, string); | |
| 1293 } | |
| 1294 | |
| 1295 /** | |
| 1296 * xmms_remote_playlist_enqueue_to_temp: | |
| 1297 * @session: Legacy XMMS-style session identifier. | |
| 1298 * @string: The URI to enqueue to a temporary playlist. | |
| 1299 * | |
| 1300 * Tells audacious to add an URI to a temporary playlist. | |
| 1301 **/ | |
| 1302 void | |
| 1303 xmms_remote_playlist_enqueue_to_temp(gint session, gchar * string) | |
| 1304 { | |
| 1305 g_return_if_fail(string != NULL); | |
| 1306 remote_send_string(session, CMD_PLAYLIST_ENQUEUE_TO_TEMP, string); | |
| 1307 } | |
| 1308 | |
| 1309 /** | |
| 1310 * xmms_remote_playlist_ins_url_string: | |
| 1311 * @session: Legacy XMMS-style session identifier. | |
| 1312 * @string: The URI to add. | |
| 1313 * @pos: The position to add the URI at. | |
| 1314 * | |
| 1315 * Tells audacious to add an URI to the playlist at a specific position. | |
| 1316 **/ | |
| 1317 void | |
| 1318 xmms_remote_playlist_ins_url_string(gint session, gchar * string, gint pos) | |
| 1319 { | |
| 1320 gint fd, size; | |
| 1321 gchar *packet; | |
| 1322 | |
| 1323 g_return_if_fail(string != NULL); | |
| 1324 | |
| 1325 size = strlen(string) + 1 + sizeof(gint); | |
| 1326 | |
| 1327 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 1328 return; | |
| 1329 | |
| 1330 packet = g_malloc0(size); | |
| 1331 *((gint *) packet) = pos; | |
| 1332 strcpy(packet + sizeof(gint), string); | |
| 1333 remote_send_packet(fd, CMD_PLAYLIST_INS_URL_STRING, packet, size); | |
| 1334 remote_read_ack(fd); | |
| 1335 close(fd); | |
| 1336 g_free(packet); | |
| 1337 } | |
| 1338 | |
| 1339 /** | |
| 1340 * xmms_remote_is_running: | |
| 1341 * @session: Legacy XMMS-style session identifier. | |
| 1342 * | |
| 1343 * Checks to see if an Audacious server is running. | |
| 1344 * | |
| 1345 * Return value: TRUE if yes, otherwise FALSE. | |
| 1346 **/ | |
| 1347 gboolean | |
| 1348 xmms_remote_is_running(gint session) | |
| 1349 { | |
| 1350 return remote_cmd(session, CMD_PING); | |
| 1351 } | |
| 1352 | |
| 1353 /** | |
| 1354 * xmms_remote_toggle_repeat: | |
| 1355 * @session: Legacy XMMS-style session identifier. | |
| 1356 * | |
| 1357 * Tells audacious to toggle the repeat feature. | |
| 1358 **/ | |
| 1359 void | |
| 1360 xmms_remote_toggle_repeat(gint session) | |
| 1361 { | |
| 1362 remote_cmd(session, CMD_TOGGLE_REPEAT); | |
| 1363 } | |
| 1364 | |
| 1365 /** | |
| 1366 * xmms_remote_toggle_shuffle: | |
| 1367 * @session: Legacy XMMS-style session identifier. | |
| 1368 * | |
| 1369 * Tells audacious to toggle the shuffle feature. | |
| 1370 **/ | |
| 1371 void | |
| 1372 xmms_remote_toggle_shuffle(gint session) | |
| 1373 { | |
| 1374 remote_cmd(session, CMD_TOGGLE_SHUFFLE); | |
| 1375 } | |
| 1376 | |
| 1377 /** | |
| 1378 * xmms_remote_toggle_advance: | |
| 1379 * @session: Legacy XMMS-style session identifier. | |
| 1380 * | |
| 1381 * Tells audacious to toggle the no-playlist-advance feature. | |
| 1382 **/ | |
| 1383 void | |
| 1384 xmms_remote_toggle_advance(int session) | |
| 1385 { | |
| 1386 remote_cmd(session, CMD_TOGGLE_ADVANCE); | |
| 1387 } | |
| 1388 | |
| 1389 /** | |
| 1390 * xmms_remote_is_repeat: | |
| 1391 * @session: Legacy XMMS-style session identifier. | |
| 1392 * | |
| 1393 * Queries audacious about whether or not the repeat feature is active. | |
| 1394 * | |
| 1395 * Return value: TRUE if yes, otherwise FALSE. | |
| 1396 **/ | |
| 1397 gboolean | |
| 1398 xmms_remote_is_repeat(gint session) | |
| 1399 { | |
| 1400 return remote_get_gboolean(session, CMD_IS_REPEAT); | |
| 1401 } | |
| 1402 | |
| 1403 /** | |
| 1404 * xmms_remote_is_shuffle: | |
| 1405 * @session: Legacy XMMS-style session identifier. | |
| 1406 * | |
| 1407 * Queries audacious about whether or not the shuffle feature is active. | |
| 1408 * | |
| 1409 * Return value: TRUE if yes, otherwise FALSE. | |
| 1410 **/ | |
| 1411 gboolean | |
| 1412 xmms_remote_is_shuffle(gint session) | |
| 1413 { | |
| 1414 return remote_get_gboolean(session, CMD_IS_SHUFFLE); | |
| 1415 } | |
| 1416 | |
| 1417 /** | |
| 1418 * xmms_remote_is_advance: | |
| 1419 * @session: Legacy XMMS-style session identifier. | |
| 1420 * | |
| 1421 * Queries audacious about whether or not the no-playlist-advance feature is active. | |
| 1422 * | |
| 1423 * Return value: TRUE if yes, otherwise FALSE. | |
| 1424 **/ | |
| 1425 gboolean | |
| 1426 xmms_remote_is_advance(gint session) | |
| 1427 { | |
| 1428 return remote_get_gboolean(session, CMD_IS_ADVANCE); | |
| 1429 } | |
| 1430 | |
| 1431 /** | |
| 1432 * xmms_remote_playqueue_add: | |
| 1433 * @session: Legacy XMMS-style session identifier. | |
| 1434 * @pos: The playlist position to add to the queue. | |
| 1435 * | |
| 1436 * Tells audacious to add a playlist entry to the playqueue. | |
| 1437 **/ | |
| 1438 void | |
| 1439 xmms_remote_playqueue_add(gint session, gint pos) | |
| 1440 { | |
| 1441 remote_send_guint32(session, CMD_PLAYQUEUE_ADD, pos); | |
| 1442 } | |
| 1443 | |
| 1444 /** | |
| 1445 * xmms_remote_playqueue_remove: | |
| 1446 * @session: Legacy XMMS-style session identifier. | |
| 1447 * @pos: The playlist position to remove from the queue. | |
| 1448 * | |
| 1449 * Tells audacious to remove a playlist entry from the playqueue. | |
| 1450 **/ | |
| 1451 void | |
| 1452 xmms_remote_playqueue_remove(gint session, gint pos) | |
| 1453 { | |
| 1454 remote_send_guint32(session, CMD_PLAYQUEUE_REMOVE, pos); | |
| 1455 } | |
| 1456 | |
| 1457 /** | |
| 1458 * xmms_remote_playqueue_clear: | |
| 1459 * @session: Legacy XMMS-style session identifier. | |
| 1460 * | |
| 1461 * Tells audacious to clear the playqueue. | |
| 1462 **/ | |
| 1463 void | |
| 1464 xmms_remote_playqueue_clear(gint session) | |
| 1465 { | |
| 1466 remote_cmd(session, CMD_PLAYQUEUE_CLEAR); | |
| 1467 } | |
| 1468 | |
| 1469 /** | |
| 1470 * xmms_remote_get_playqueue_length: | |
| 1471 * @session: Legacy XMMS-style session identifier. | |
| 1472 * | |
| 1473 * Queries audacious about the playqueue's length. | |
| 1474 * | |
| 1475 * Return value: The number of entries in the playqueue. | |
| 1476 **/ | |
| 1477 gint | |
| 1478 xmms_remote_get_playqueue_length(gint session) | |
| 1479 { | |
| 1480 return remote_get_gint(session, CMD_GET_PLAYQUEUE_LENGTH); | |
| 1481 } | |
| 1482 | |
| 1483 /** | |
| 1484 * xmms_remote_playqueue_is_queued: | |
| 1485 * @session: Legacy XMMS-style session identifier. | |
| 1486 * @pos: Position to check queue for. | |
| 1487 * | |
| 1488 * Queries audacious about whether or not a playlist entry is in the playqueue. | |
| 1489 * | |
| 1490 * Return value: TRUE if yes, FALSE otherwise. | |
| 1491 **/ | |
| 1492 gboolean | |
| 1493 xmms_remote_playqueue_is_queued(gint session, gint pos) | |
| 1494 { | |
| 1495 gpointer data; | |
| 1496 gint fd, ret = 0; | |
| 1497 guint32 p = pos; | |
| 1498 | |
| 1499 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 1500 return ret; | |
| 1501 remote_send_packet(fd, CMD_PLAYQUEUE_IS_QUEUED, &p, sizeof(guint32)); | |
| 1502 data = remote_read_packet(fd); | |
| 1503 if (data) { | |
| 1504 ret = *((gint *) data); | |
| 1505 g_free(data); | |
| 1506 } | |
| 1507 remote_read_ack(fd); | |
| 1508 close(fd); | |
| 1509 return ret; | |
| 1510 } | |
| 1511 | |
| 1512 /** | |
| 1513 * xmms_remote_get_playqueue_position: | |
| 1514 * @session: Legacy XMMS-style session identifier. | |
| 1515 * @pos: Position to check queue for. | |
| 1516 * | |
| 1517 * Queries audacious about what the playqueue position is for a playlist entry. | |
| 1518 * | |
| 1519 * Return value: TRUE if yes, FALSE otherwise. | |
| 1520 **/ | |
| 1521 gint | |
| 1522 xmms_remote_get_playqueue_position(gint session, gint pos) | |
| 1523 { | |
| 1524 gpointer data; | |
| 1525 gint fd, ret = 0; | |
| 1526 guint32 p = pos; | |
| 1527 | |
| 1528 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 1529 return ret; | |
| 1530 remote_send_packet(fd, CMD_PLAYQUEUE_GET_POS, &p, sizeof(guint32)); | |
| 1531 data = remote_read_packet(fd); | |
| 1532 if (data) { | |
| 1533 ret = *((gint *) data); | |
| 1534 g_free(data); | |
| 1535 } | |
| 1536 remote_read_ack(fd); | |
| 1537 close(fd); | |
| 1538 return ret; | |
| 1539 } | |
| 1540 | |
| 1541 /** | |
| 1542 * xmms_remote_get_playqueue_queue_position: | |
| 1543 * @session: Legacy XMMS-style session identifier. | |
| 1544 * @pos: Position to check queue for. | |
| 1545 * | |
| 1546 * Queries audacious about what the playlist position is for a playqueue entry. | |
| 1547 * | |
| 1548 * Return value: TRUE if yes, FALSE otherwise. | |
| 1549 **/ | |
| 1550 gint | |
| 1551 xmms_remote_get_playqueue_queue_position(gint session, gint pos) | |
| 1552 { | |
| 1553 gpointer data; | |
| 1554 gint fd, ret = 0; | |
| 1555 guint32 p = pos; | |
| 1556 | |
| 1557 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 1558 return ret; | |
| 1559 remote_send_packet(fd, CMD_PLAYQUEUE_GET_QPOS, &p, sizeof(guint32)); | |
| 1560 data = remote_read_packet(fd); | |
| 1561 if (data) { | |
| 1562 ret = *((gint *) data); | |
| 1563 g_free(data); | |
| 1564 } | |
| 1565 remote_read_ack(fd); | |
| 1566 close(fd); | |
| 1567 return ret; | |
| 1568 } | |
| 1569 | |
| 1570 /** | |
| 1571 * xmms_remote_get_eq: | |
| 1572 * @session: Legacy XMMS-style session identifier. | |
| 1573 * @preamp: Pointer to value for preamp setting. | |
| 1574 * @bands: Pointer to array of band settings. | |
| 1575 * | |
| 1576 * Queries audacious about the equalizer settings. | |
| 1577 **/ | |
| 1578 void | |
| 1579 xmms_remote_get_eq(gint session, gfloat * preamp, gfloat ** bands) | |
| 1580 { | |
| 1581 gint fd; | |
| 1582 gpointer data; | |
| 1583 | |
| 1584 if (preamp) | |
| 1585 *preamp = 0.0; | |
| 1586 | |
| 1587 if (bands) | |
| 1588 *bands = NULL; | |
| 1589 | |
| 1590 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 1591 return; | |
| 1592 remote_send_packet(fd, CMD_GET_EQ, NULL, 0); | |
| 1593 data = remote_read_packet(fd); | |
| 1594 if (data) { | |
| 1595 if (preamp) | |
| 1596 *preamp = *((gfloat *) data); | |
| 1597 if (bands) | |
| 1598 *bands = | |
| 1599 (gfloat *) g_memdup((gfloat *) data + 1, | |
| 1600 10 * sizeof(gfloat)); | |
| 1601 g_free(data); | |
| 1602 } | |
| 1603 remote_read_ack(fd); | |
| 1604 close(fd); | |
| 1605 } | |
| 1606 | |
| 1607 /** | |
| 1608 * xmms_remote_get_eq_preamp: | |
| 1609 * @session: Legacy XMMS-style session identifier. | |
| 1610 * | |
| 1611 * Queries audacious about the equalizer preamp's setting. | |
| 1612 * | |
| 1613 * Return value: The equalizer preamp's setting. | |
| 1614 **/ | |
| 1615 gfloat | |
| 1616 xmms_remote_get_eq_preamp(gint session) | |
| 1617 { | |
| 1618 return remote_get_gfloat(session, CMD_GET_EQ_PREAMP); | |
| 1619 } | |
| 1620 | |
| 1621 /** | |
| 1622 * xmms_remote_get_eq_band: | |
| 1623 * @session: Legacy XMMS-style session identifier. | |
| 1624 * @band: Which band to lookup the value for. | |
| 1625 * | |
| 1626 * Queries audacious about an equalizer band's value. | |
| 1627 * | |
| 1628 * Return value: The equalizer band's value. | |
| 1629 **/ | |
| 1630 gfloat | |
| 1631 xmms_remote_get_eq_band(gint session, gint band) | |
| 1632 { | |
| 1633 gint fd; | |
| 1634 gpointer data; | |
| 1635 gfloat val = 0.0; | |
| 1636 | |
| 1637 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 1638 return val; | |
| 1639 remote_send_packet(fd, CMD_GET_EQ_BAND, &band, sizeof(band)); | |
| 1640 data = remote_read_packet(fd); | |
| 1641 if (data) { | |
| 1642 val = *((gfloat *) data); | |
| 1643 g_free(data); | |
| 1644 } | |
| 1645 remote_read_ack(fd); | |
| 1646 close(fd); | |
| 1647 return val; | |
| 1648 } | |
| 1649 | |
| 1650 /** | |
| 1651 * xmms_remote_set_eq: | |
| 1652 * @session: Legacy XMMS-style session identifier. | |
| 1653 * @preamp: Value for preamp setting. | |
| 1654 * @bands: Array of band settings. | |
| 1655 * | |
| 1656 * Tells audacious to set the equalizer up using the provided values. | |
| 1657 **/ | |
| 1658 void | |
| 1659 xmms_remote_set_eq(gint session, gfloat preamp, gfloat * bands) | |
| 1660 { | |
| 1661 gint fd, i; | |
| 1662 gfloat data[11]; | |
| 1663 | |
| 1664 g_return_if_fail(bands != NULL); | |
| 1665 | |
| 1666 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 1667 return; | |
| 1668 data[0] = preamp; | |
| 1669 for (i = 0; i < 10; i++) | |
| 1670 data[i + 1] = bands[i]; | |
| 1671 remote_send_packet(fd, CMD_SET_EQ, data, sizeof(data)); | |
| 1672 remote_read_ack(fd); | |
| 1673 close(fd); | |
| 1674 } | |
| 1675 | |
| 1676 /** | |
| 1677 * xmms_remote_set_eq_preamp: | |
| 1678 * @session: Legacy XMMS-style session identifier. | |
| 1679 * @preamp: Value for preamp setting. | |
| 1680 * | |
| 1681 * Tells audacious to set the equalizer's preamp setting. | |
| 1682 **/ | |
| 1683 void | |
| 1684 xmms_remote_set_eq_preamp(gint session, gfloat preamp) | |
| 1685 { | |
| 1686 remote_send_gfloat(session, CMD_SET_EQ_PREAMP, preamp); | |
| 1687 } | |
| 1688 | |
| 1689 /** | |
| 1690 * xmms_remote_set_eq_band: | |
| 1691 * @session: Legacy XMMS-style session identifier. | |
| 1692 * @band: The band to set the value for. | |
| 1693 * @value: The value to set that band to. | |
| 1694 * | |
| 1695 * Tells audacious to set an equalizer band's setting. | |
| 1696 **/ | |
| 1697 void | |
| 1698 xmms_remote_set_eq_band(gint session, gint band, gfloat value) | |
| 1699 { | |
| 1700 gint fd; | |
| 1701 gchar data[sizeof(gint) + sizeof(gfloat)]; | |
| 1702 | |
| 1703 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 1704 return; | |
| 1705 *((gint *) data) = band; | |
| 1706 *((gfloat *) (data + sizeof(gint))) = value; | |
| 1707 remote_send_packet(fd, CMD_SET_EQ_BAND, data, sizeof(data)); | |
| 1708 remote_read_ack(fd); | |
| 1709 close(fd); | |
| 1710 } | |
| 1711 | |
| 1712 /** | |
| 1713 * xmms_remote_quit: | |
| 1714 * @session: Legacy XMMS-style session identifier. | |
| 1715 * | |
| 1716 * Tells audacious to quit. | |
| 1717 **/ | |
| 1718 void | |
| 1719 xmms_remote_quit(gint session) | |
| 1720 { | |
| 1721 gint fd; | |
| 1722 | |
| 1723 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 1724 return; | |
| 1725 remote_send_packet(fd, CMD_QUIT, NULL, 0); | |
| 1726 remote_read_ack(fd); | |
| 1727 close(fd); | |
| 1728 } | |
| 1729 | |
| 1730 /** | |
| 1731 * xmms_remote_activate: | |
| 1732 * @session: Legacy XMMS-style session identifier. | |
| 1733 * | |
| 1734 * Tells audacious to display the main window and become the selected window. | |
| 1735 **/ | |
| 1736 void | |
| 1737 xmms_remote_activate(gint session) | |
| 1738 { | |
| 1739 gint fd; | |
| 1740 | |
| 1741 if ((fd = xmms_connect_to_session(session)) == -1) | |
| 1742 return; | |
| 1743 remote_send_packet(fd, CMD_ACTIVATE, NULL, 0); | |
| 1744 remote_read_ack(fd); | |
| 1745 close(fd); | |
| 1746 } |
