annotate libaudacious/beepctrl.c @ 1459:705d4c089fce trunk

[svn] Fix postal code.
author chainsaw
date Wed, 02 Aug 2006 16:00:13 -0700
parents f12d7e208b43
children 188437eb996b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* XMMS - Cross-platform multimedia player
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 * Copyright (C) 1998-2003 Peter Alm, Mikael Alm, Olle Hallnas,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 * Thomas Nilsson and 4Front Technologies
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 * Copyright (C) 1999-2003 Haavard Kvaalen
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 * (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
1459
705d4c089fce [svn] Fix postal code.
chainsaw
parents: 1458
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21 #ifdef HAVE_CONFIG_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 # include "config.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 #include <glib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 #include <sys/types.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27 #include <sys/stat.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include <sys/socket.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #include <sys/un.h>
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
30 #include <arpa/inet.h>
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
31 #include <netdb.h>
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 #include <errno.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 #include <stdio.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 #include <stdlib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 #include <string.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 #include "beepctrl.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37 #include "audacious/controlsocket.h"
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
38 #include "libaudacious/configdb.h"
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
40 /* overrides audacious_get_session_uri(). */
1438
ce0285d8cede [svn] - make the remote API actually work
nenolod
parents: 1437
diff changeset
41 gchar *audacious_session_uri = NULL;
1456
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
42 gint *audacious_session_type = NULL;
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 #ifdef HAVE_UNISTD_H
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 #include <unistd.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 #endif
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 static gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 read_all(gint fd, gpointer buf, size_t count)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 size_t left = count;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 GTimer *timer;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 gulong usec;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 gint r;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56 timer = g_timer_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 do {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 if ((r = read(fd, buf, left)) < 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 count = -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 left -= r;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 buf = (gchar *) buf + r;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 g_timer_elapsed(timer, &usec);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 while (left > 0 && usec <= CTRLSOCKET_IO_TIMEOUT_USEC);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 g_timer_destroy(timer);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 return count - left;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 static gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 write_all(gint fd, gconstpointer buf, size_t count)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 size_t left = count;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 GTimer *timer;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 gulong usec;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 gint written;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 timer = g_timer_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 do {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 if ((written = write(fd, buf, left)) < 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 count = -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 left -= written;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 buf = (gchar *) buf + written;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90 g_timer_elapsed(timer, &usec);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 while (left > 0 && usec <= CTRLSOCKET_IO_TIMEOUT_USEC);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 g_timer_destroy(timer);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 return count - left;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 static gpointer
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 remote_read_packet(gint fd, ServerPktHeader * pkt_hdr)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 gpointer data = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 if (read_all(fd, pkt_hdr, sizeof(ServerPktHeader)) ==
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 sizeof(ServerPktHeader)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 if (pkt_hdr->data_length) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 size_t data_length = pkt_hdr->data_length;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 data = g_malloc0(data_length);
625
0a73d1faeb4e [svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents: 0
diff changeset
108 if ((size_t)read_all(fd, data, data_length) < data_length) {
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 data = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114 return data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 remote_read_ack(gint fd)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 if (data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 remote_send_packet(gint fd, guint32 command, gpointer data,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 guint32 data_length)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 ClientPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 pkt_hdr.version = XMMS_PROTOCOL_VERSION;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 pkt_hdr.command = command;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 pkt_hdr.data_length = data_length;
625
0a73d1faeb4e [svn] GCC 4.1 warning fixes by Diego 'Flameeyes' Petteno from Gentoo.
chainsaw
parents: 0
diff changeset
138 if ((size_t)write_all(fd, &pkt_hdr, sizeof(ClientPktHeader)) < sizeof(pkt_hdr))
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 if (data_length && data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 write_all(fd, data, data_length);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 remote_send_guint32(gint session, guint32 cmd, guint32 val)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 remote_send_packet(fd, cmd, &val, sizeof(guint32));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 remote_send_boolean(gint session, guint32 cmd, gboolean val)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 remote_send_packet(fd, cmd, &val, sizeof(gboolean));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 remote_send_gfloat(gint session, guint32 cmd, gfloat value)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 remote_send_packet(fd, cmd, &value, sizeof(gfloat));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 remote_send_string(gint session, guint32 cmd, gchar * string)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187 remote_send_packet(fd, cmd, string, string ? strlen(string) + 1 : 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
188 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
189 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
190 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
191
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
192 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
193 remote_cmd(gint session, guint32 cmd)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
194 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
195 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198 return FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199 remote_send_packet(fd, cmd, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
200 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
201 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
202
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
203 return TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
204 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
205
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
206 static gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
207 remote_get_gboolean(gint session, gint cmd)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
208 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
209 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
210 gboolean ret = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
211 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
212 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
213
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
214 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
215 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
216 remote_send_packet(fd, cmd, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
217 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
218 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
219 ret = *((gboolean *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
220 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
221 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
222 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
223 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
224
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
225 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
226 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
227
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
228 static guint32
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
229 remote_get_gint(gint session, gint cmd)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
230 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
231 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
232 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
233 gint fd, ret = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
234
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
235 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
236 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
237 remote_send_packet(fd, cmd, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
238 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
239 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
240 ret = *((gint *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
241 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
242 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
243 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
244 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
245 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
246 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
247
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
248 static gfloat
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
249 remote_get_gfloat(gint session, gint cmd)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
250 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
251 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
252 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
253 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
254 gfloat ret = 0.0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
255
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
256 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
257 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
258 remote_send_packet(fd, cmd, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
259 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
260 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
261 ret = *((gfloat *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
262 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
263 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
264 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
265 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
266 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
267 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
268
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
269 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
270 remote_get_string(gint session, gint cmd)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
271 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
272 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
273 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
274 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
275
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
276 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
277 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
278 remote_send_packet(fd, cmd, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
279 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
280 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
281 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
282 return data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
283 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
284
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
285 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
286 remote_get_string_pos(gint session, gint cmd, guint32 pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
287 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
288 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
289 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
290 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
291
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
292 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
293 return NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
294 remote_send_packet(fd, cmd, &pos, sizeof(guint32));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
295 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
296 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
297 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
298 return data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
299 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
300
1437
dd2b97f79a20 [svn] - add audacious_set_session_uri().
nenolod
parents: 1436
diff changeset
301 void
dd2b97f79a20 [svn] - add audacious_set_session_uri().
nenolod
parents: 1436
diff changeset
302 audacious_set_session_uri(gchar *uri)
dd2b97f79a20 [svn] - add audacious_set_session_uri().
nenolod
parents: 1436
diff changeset
303 {
1438
ce0285d8cede [svn] - make the remote API actually work
nenolod
parents: 1437
diff changeset
304 audacious_session_uri = uri;
1437
dd2b97f79a20 [svn] - add audacious_set_session_uri().
nenolod
parents: 1436
diff changeset
305 }
dd2b97f79a20 [svn] - add audacious_set_session_uri().
nenolod
parents: 1436
diff changeset
306
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
307 gchar *
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
308 audacious_get_session_uri(gint session)
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
309 {
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
310 ConfigDb *db;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
311 gchar *value = NULL;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
312
1438
ce0285d8cede [svn] - make the remote API actually work
nenolod
parents: 1437
diff changeset
313 if (audacious_session_uri != NULL)
ce0285d8cede [svn] - make the remote API actually work
nenolod
parents: 1437
diff changeset
314 {
ce0285d8cede [svn] - make the remote API actually work
nenolod
parents: 1437
diff changeset
315 return audacious_session_uri;
ce0285d8cede [svn] - make the remote API actually work
nenolod
parents: 1437
diff changeset
316 }
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
317
1456
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
318 if (audacious_session_type != AUDACIOUS_TYPE_UNIX)
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
319 {
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
320 db = bmp_cfg_db_open();
1444
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1442
diff changeset
321
1456
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
322 bmp_cfg_db_get_string(db, NULL, "listen_uri_base", &value);
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
323
1456
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
324 bmp_cfg_db_close(db);
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
325 }
1442
5b44358151f8 [svn] - more sanity
nenolod
parents: 1441
diff changeset
326
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
327 if (value == NULL)
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
328 return g_strdup_printf("unix://localhost/%s/%s_%s.%d", g_get_tmp_dir(),
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
329 CTRLSOCKET_NAME, g_get_user_name(), session);
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
330
1444
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1442
diff changeset
331 audacious_session_uri = value;
c04ce16b2b57 [svn] - libaudacious/beepctrl.c: optimise further and be more paranoid about leaks
nenolod
parents: 1442
diff changeset
332
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
333 return value;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
334 }
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
335
1456
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
336 void
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
337 audacious_set_session_type(gint *type)
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
338 {
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
339 audacious_session_type = type;
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
340 }
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
341
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
342 gint *
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
343 audacious_determine_session_type(gint session)
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
344 {
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
345 gchar *uri;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
346
1456
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
347 if (audacious_session_type != NULL)
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
348 {
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
349 return audacious_session_type;
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
350 }
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
351
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
352 uri = audacious_get_session_uri(session);
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
353
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
354 if (!g_strncasecmp(uri, "tcp://", 6))
1456
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
355 audacious_session_type = (gint *) AUDACIOUS_TYPE_TCP;
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
356 else
1456
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
357 audacious_session_type = (gint *) AUDACIOUS_TYPE_UNIX;
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
358
1456
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
359 if (audacious_session_type == NULL)
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
360 audacious_session_type = (gint *) AUDACIOUS_TYPE_UNIX;
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
361
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
362 return audacious_session_type;
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
363 }
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
364
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
365 /* tcp://192.168.100.1:5900/zyzychynxi389xvmfewqaxznvnw */
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
366 void
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
367 audacious_decode_tcp_uri(gint session, gchar *in, gchar **host, gint *port, gchar **key)
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
368 {
1439
bd0b46c8a70e [svn] - i believe we've got it!
nenolod
parents: 1438
diff changeset
369 static gchar *workbuf, *keybuf;
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
370 gint iport;
1439
bd0b46c8a70e [svn] - i believe we've got it!
nenolod
parents: 1438
diff changeset
371 gchar *tmp = g_strdup(in);
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
372
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
373 /* split out the host/port and key */
1439
bd0b46c8a70e [svn] - i believe we've got it!
nenolod
parents: 1438
diff changeset
374 workbuf = tmp;
1448
3b1c464cbbb0 [svn] Seems safer to me to free this way, assuming I'm not misreading.
nemo
parents: 1447
diff changeset
375 workbuf += 6;
1439
bd0b46c8a70e [svn] - i believe we've got it!
nenolod
parents: 1438
diff changeset
376
1448
3b1c464cbbb0 [svn] Seems safer to me to free this way, assuming I'm not misreading.
nemo
parents: 1447
diff changeset
377 keybuf = strchr(workbuf, '/');
1439
bd0b46c8a70e [svn] - i believe we've got it!
nenolod
parents: 1438
diff changeset
378 *keybuf++ = '\0';
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
379
1441
ed80e946f30b [svn] - ok, don't eat up all the system ram (I forgot to g_free())
nenolod
parents: 1439
diff changeset
380 *key = g_strdup(keybuf);
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
381
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
382 if (strchr(workbuf, ':') == NULL)
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
383 {
1441
ed80e946f30b [svn] - ok, don't eat up all the system ram (I forgot to g_free())
nenolod
parents: 1439
diff changeset
384 *host = g_strdup(workbuf);
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
385 *port = 37370 + session;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
386 }
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
387 else
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
388 {
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
389 gchar *hostbuf = NULL;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
390 sscanf(workbuf, "%s:%d", hostbuf, &iport);
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
391
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
392 *port = iport + session;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
393 }
1441
ed80e946f30b [svn] - ok, don't eat up all the system ram (I forgot to g_free())
nenolod
parents: 1439
diff changeset
394
1447
7ca5bef8d9ee [svn] - fix invalid frees
nenolod
parents: 1444
diff changeset
395 g_free(tmp);
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
396 }
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
397
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
398 /* unix://localhost/tmp/audacious_nenolod.0 */
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
399 void
1439
bd0b46c8a70e [svn] - i believe we've got it!
nenolod
parents: 1438
diff changeset
400 audacious_decode_unix_uri(gint session, gchar *in, gchar **key)
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
401 {
1439
bd0b46c8a70e [svn] - i believe we've got it!
nenolod
parents: 1438
diff changeset
402 static gchar *workbuf, *keybuf;
bd0b46c8a70e [svn] - i believe we've got it!
nenolod
parents: 1438
diff changeset
403 gchar *tmp = g_strdup(in);
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
404
1439
bd0b46c8a70e [svn] - i believe we've got it!
nenolod
parents: 1438
diff changeset
405 /* split out the host/port and key */
bd0b46c8a70e [svn] - i believe we've got it!
nenolod
parents: 1438
diff changeset
406 workbuf = tmp;
1448
3b1c464cbbb0 [svn] Seems safer to me to free this way, assuming I'm not misreading.
nemo
parents: 1447
diff changeset
407 workbuf += 7;
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
408
1448
3b1c464cbbb0 [svn] Seems safer to me to free this way, assuming I'm not misreading.
nemo
parents: 1447
diff changeset
409 keybuf = strchr(workbuf, '/');
1439
bd0b46c8a70e [svn] - i believe we've got it!
nenolod
parents: 1438
diff changeset
410 *keybuf++ = '\0';
bd0b46c8a70e [svn] - i believe we've got it!
nenolod
parents: 1438
diff changeset
411
1441
ed80e946f30b [svn] - ok, don't eat up all the system ram (I forgot to g_free())
nenolod
parents: 1439
diff changeset
412 *key = g_strdup(keybuf);
ed80e946f30b [svn] - ok, don't eat up all the system ram (I forgot to g_free())
nenolod
parents: 1439
diff changeset
413
1447
7ca5bef8d9ee [svn] - fix invalid frees
nenolod
parents: 1444
diff changeset
414 g_free(tmp);
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
415 }
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
416
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
417 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
418 xmms_connect_to_session(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
419 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
420 gint fd;
1456
6fe7ba6e5489 [svn] - Don't poll the config database if not using TCP sockets.
nhjm449
parents: 1450
diff changeset
421 gint *type = audacious_determine_session_type(session);
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
422 gchar *uri = audacious_get_session_uri(session);
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
423
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
424 if (type == AUDACIOUS_TYPE_UNIX)
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
425 {
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
426 if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1)
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
427 {
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
428 uid_t stored_uid, euid;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
429 struct sockaddr_un saddr;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
430 gchar *path;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
431
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
432 saddr.sun_family = AF_UNIX;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
433 stored_uid = getuid();
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
434 euid = geteuid();
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
435 setuid(euid);
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
437 audacious_decode_unix_uri(session, uri, &path);
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
438
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
439 g_strlcpy(saddr.sun_path, path, 108);
1441
ed80e946f30b [svn] - ok, don't eat up all the system ram (I forgot to g_free())
nenolod
parents: 1439
diff changeset
440 g_free(path);
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
441 setreuid(stored_uid, euid);
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
442 if (connect(fd, (struct sockaddr *) &saddr, sizeof(saddr)) != -1)
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
443 return fd;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
444 }
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
445 }
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
446 else
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
447 {
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
448 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) != -1)
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
449 {
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
450 struct hostent *hp;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
451 struct sockaddr_in saddr;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
452 gchar *host, *key;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
453 gint port;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
454
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
455 audacious_decode_tcp_uri(session, uri, &host, &port, &key);
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
456
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
457 /* resolve it */
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
458 if ((hp = gethostbyname(host)) == NULL)
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
459 {
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
460 close(fd);
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
461 return -1;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
462 }
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
463
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
464 memset(&saddr, '\0', sizeof(saddr));
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
465 saddr.sin_family = AF_INET;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
466 saddr.sin_port = htons(port);
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
467 memcpy(&saddr.sin_addr, hp->h_addr, hp->h_length);
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
468
1441
ed80e946f30b [svn] - ok, don't eat up all the system ram (I forgot to g_free())
nenolod
parents: 1439
diff changeset
469 g_free(host);
ed80e946f30b [svn] - ok, don't eat up all the system ram (I forgot to g_free())
nenolod
parents: 1439
diff changeset
470 g_free(key);
ed80e946f30b [svn] - ok, don't eat up all the system ram (I forgot to g_free())
nenolod
parents: 1439
diff changeset
471
1436
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
472 if (connect(fd, (struct sockaddr *) &saddr, sizeof(saddr)) != -1)
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
473 return fd;
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
474 }
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
475 }
c70b68bcf527 [svn] - add framework for later handling tcp:// connections
nenolod
parents: 984
diff changeset
476
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
477 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
478 return -1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
479 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
480
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
481 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
482 xmms_remote_playlist(gint session, gchar ** list, gint num, gboolean enqueue)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
483 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
484 gint fd, i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
485 gchar *data, *ptr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
486 gint data_length;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
487 guint32 len;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
488
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
489 g_return_if_fail(list != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
490 g_return_if_fail(num > 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
491
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
492 if (!enqueue)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
493 xmms_remote_playlist_clear(session);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
494
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
495 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
496 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
497
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
498 for (i = 0, data_length = 0; i < num; i++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
499 data_length += (((strlen(list[i]) + 1) + 3) / 4) * 4 + 4;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
500 if (data_length) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
501 data_length += 4;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
502 data = g_malloc(data_length);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
503 for (i = 0, ptr = data; i < num; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
504 len = strlen(list[i]) + 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
505 *((guint32 *) ptr) = len;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
506 ptr += 4;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
507 memcpy(ptr, list[i], len);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
508 ptr += ((len + 3) / 4) * 4;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
509 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
510 *((guint32 *) ptr) = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
511 remote_send_packet(fd, CMD_PLAYLIST_ADD, data, data_length);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
512 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
513 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
514 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
515 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
516
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
517 if (!enqueue)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
518 xmms_remote_play(session);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
519 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
520
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
521 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
522 xmms_remote_get_version(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
523 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
524 return remote_get_gint(session, CMD_GET_VERSION);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
525 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
526
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
527 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
528 xmms_remote_play_files(gint session, GList * list)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
529 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
530 g_return_if_fail(list != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
531
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
532 xmms_remote_playlist_clear(session);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
533 xmms_remote_add_files(session, list);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
534 xmms_remote_play(session);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
535 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
536
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
537 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
538 xmms_remote_playlist_add(gint session, GList * list)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
539 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
540 gchar **str_list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
541 GList *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
542 gint i, num;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
543
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
544 g_return_if_fail(list != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
545
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
546 num = g_list_length(list);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
547 str_list = g_malloc0(num * sizeof(gchar *));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
548 for (i = 0, node = list; i < num && node; i++, node = g_list_next(node))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
549 str_list[i] = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
550
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
551 xmms_remote_playlist(session, str_list, num, TRUE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
552 g_free(str_list);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
553 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
554
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
555 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
556 xmms_remote_playlist_delete(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
557 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
558 remote_send_guint32(session, CMD_PLAYLIST_DELETE, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
559 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
560
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
561 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
562 xmms_remote_play(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
563 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
564 remote_cmd(session, CMD_PLAY);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
565 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
566
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
567 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
568 xmms_remote_pause(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
569 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
570 remote_cmd(session, CMD_PAUSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
571 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
572
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
573 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
574 xmms_remote_stop(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
575 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
576 remote_cmd(session, CMD_STOP);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
577 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
578
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
579 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
580 xmms_remote_play_pause(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
581 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
582 remote_cmd(session, CMD_PLAY_PAUSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
583 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
584
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
585 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
586 xmms_remote_is_playing(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
587 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
588 return remote_get_gboolean(session, CMD_IS_PLAYING);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
589 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
590
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
591 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
592 xmms_remote_is_paused(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
593 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
594 return remote_get_gboolean(session, CMD_IS_PAUSED);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
595 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
596
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
597 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
598 xmms_remote_get_playlist_pos(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
599 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
600 return remote_get_gint(session, CMD_GET_PLAYLIST_POS);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
601 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
602
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
603 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
604 xmms_remote_set_playlist_pos(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
605 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
606 remote_send_guint32(session, CMD_SET_PLAYLIST_POS, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
607 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
608
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
609 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
610 xmms_remote_get_playlist_length(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
611 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
612 return remote_get_gint(session, CMD_GET_PLAYLIST_LENGTH);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
613 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
614
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
615 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
616 xmms_remote_playlist_clear(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
617 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
618 remote_cmd(session, CMD_PLAYLIST_CLEAR);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
619 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
620
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
621 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
622 xmms_remote_get_output_time(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
623 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
624 return remote_get_gint(session, CMD_GET_OUTPUT_TIME);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
625 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
626
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
627 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
628 xmms_remote_jump_to_time(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
629 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
630 remote_send_guint32(session, CMD_JUMP_TO_TIME, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
631 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
632
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
633 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
634 xmms_remote_get_volume(gint session, gint * vl, gint * vr)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
635 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
636 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
637 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
638 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
639
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
640 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
641 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
642
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
643 remote_send_packet(fd, CMD_GET_VOLUME, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
644 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
645 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
646 *vl = ((guint32 *) data)[0];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
647 *vr = ((guint32 *) data)[1];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
648 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
649 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
650 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
651 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
652 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
653
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
654 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
655 xmms_remote_get_main_volume(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
656 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
657 gint vl, vr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
658
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
659 xmms_remote_get_volume(session, &vl, &vr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
660
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
661 return (vl > vr) ? vl : vr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
662 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
663
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
664 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
665 xmms_remote_get_balance(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
666 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
667 return remote_get_gint(session, CMD_GET_BALANCE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
668 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
669
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
670 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
671 xmms_remote_set_volume(gint session, gint vl, gint vr)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
672 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
673 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
674 guint32 v[2];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
675
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
676 if (vl < 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
677 vl = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
678 if (vl > 100)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
679 vl = 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
680 if (vr < 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
681 vr = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
682 if (vr > 100)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
683 vr = 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
684
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
685 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
686 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
687 v[0] = vl;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
688 v[1] = vr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
689 remote_send_packet(fd, CMD_SET_VOLUME, v, 2 * sizeof(guint32));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
690 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
691 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
692 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
693
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
694 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
695 xmms_remote_set_main_volume(gint session, gint v)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
696 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
697 gint b, vl, vr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
698
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
699 b = xmms_remote_get_balance(session);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
700
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
701 if (b < 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
702 vl = v;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
703 vr = (v * (100 - abs(b))) / 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
704 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
705 else if (b > 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
706 vl = (v * (100 - b)) / 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
707 vr = v;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
708 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
709 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
710 vl = vr = v;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
711 xmms_remote_set_volume(session, vl, vr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
712 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
713
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
714 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
715 xmms_remote_set_balance(gint session, gint b)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
716 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
717 gint v, vl, vr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
718
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
719 if (b < -100)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
720 b = -100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
721 if (b > 100)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
722 b = 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
723
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
724 v = xmms_remote_get_main_volume(session);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
725
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
726 if (b < 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
727 vl = v;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
728 vr = (v * (100 - abs(b))) / 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
729 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
730 else if (b > 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
731 vl = (v * (100 - b)) / 100;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
732 vr = v;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
733 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
734 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
735 vl = vr = v;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
736 xmms_remote_set_volume(session, vl, vr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
737 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
738
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
739 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
740 xmms_remote_get_skin(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
741 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
742 return remote_get_string(session, CMD_GET_SKIN);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
743 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
744
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
745 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
746 xmms_remote_set_skin(gint session, gchar * skinfile)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
747 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
748 remote_send_string(session, CMD_SET_SKIN, skinfile);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
749 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
750
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
751 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
752 xmms_remote_get_playlist_file(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
753 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
754 return remote_get_string_pos(session, CMD_GET_PLAYLIST_FILE, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
755 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
756
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
757 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
758 xmms_remote_get_playlist_title(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
759 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
760 return remote_get_string_pos(session, CMD_GET_PLAYLIST_TITLE, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
761 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
762
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
763 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
764 xmms_remote_get_playlist_time(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
765 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
766 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
767 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
768 gint fd, ret = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
769 guint32 p = pos;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
770
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
771 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
772 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
773 remote_send_packet(fd, CMD_GET_PLAYLIST_TIME, &p, sizeof(guint32));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
774 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
775 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
776 ret = *((gint *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
777 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
778 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
779 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
780 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
781 return ret;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
782 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
783
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
784 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
785 xmms_remote_get_info(gint session, gint * rate, gint * freq, gint * nch)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
786 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
787 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
788 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
789 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
790
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
791 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
792 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
793 remote_send_packet(fd, CMD_GET_INFO, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
794 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
795 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
796 *rate = ((guint32 *) data)[0];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
797 *freq = ((guint32 *) data)[1];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
798 *nch = ((guint32 *) data)[2];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
799 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
800 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
801 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
802 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
803 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
804
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
805 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
806 xmms_remote_get_eq_data(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
807 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
808 /* Obsolete */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
809 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
810
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
811 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
812 xmms_remote_set_eq_data(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
813 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
814 /* Obsolete */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
815 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
816
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
817 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
818 xmms_remote_pl_win_toggle(gint session, gboolean show)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
819 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
820 remote_send_boolean(session, CMD_PL_WIN_TOGGLE, show);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
821 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
822
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
823 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
824 xmms_remote_eq_win_toggle(gint session, gboolean show)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
825 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
826 remote_send_boolean(session, CMD_EQ_WIN_TOGGLE, show);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
827 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
828
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
829 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
830 xmms_remote_main_win_toggle(gint session, gboolean show)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
831 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
832 remote_send_boolean(session, CMD_MAIN_WIN_TOGGLE, show);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
833 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
834
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
835 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
836 xmms_remote_is_main_win(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
837 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
838 return remote_get_gboolean(session, CMD_IS_MAIN_WIN);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
839 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
840
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
841 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
842 xmms_remote_is_pl_win(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
843 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
844 return remote_get_gboolean(session, CMD_IS_PL_WIN);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
845 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
846
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
847 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
848 xmms_remote_is_eq_win(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
849 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
850 return remote_get_gboolean(session, CMD_IS_EQ_WIN);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
851 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
852
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
853 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
854 xmms_remote_show_prefs_box(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
855 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
856 remote_cmd(session, CMD_SHOW_PREFS_BOX);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
857 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
858
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
859 void
984
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
860 xmms_remote_show_jtf_box(gint session)
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
861 {
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
862 remote_cmd(session, CMD_SHOW_JTF_BOX);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
863 }
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
864
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
865 void
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
866 xmms_remote_toggle_aot(gint session, gboolean ontop)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
867 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
868 remote_send_boolean(session, CMD_TOGGLE_AOT, ontop);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
869 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
870
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
871 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
872 xmms_remote_show_about_box(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
873 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
874 remote_cmd(session, CMD_SHOW_ABOUT_BOX);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
875 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
876
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
877 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
878 xmms_remote_eject(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
879 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
880 remote_cmd(session, CMD_EJECT);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
881 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
882
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
883 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
884 xmms_remote_playlist_prev(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
885 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
886 remote_cmd(session, CMD_PLAYLIST_PREV);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
887 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
888
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
889 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
890 xmms_remote_playlist_next(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
891 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
892 remote_cmd(session, CMD_PLAYLIST_NEXT);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
893 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
894
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
895 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
896 xmms_remote_playlist_add_url_string(gint session, gchar * string)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
897 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
898 g_return_if_fail(string != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
899 remote_send_string(session, CMD_PLAYLIST_ADD_URL_STRING, string);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
900 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
901
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
902 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
903 xmms_remote_playlist_ins_url_string(gint session, gchar * string, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
904 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
905 gint fd, size;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
906 gchar *packet;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
907
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
908 g_return_if_fail(string != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
909
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
910 size = strlen(string) + 1 + sizeof(gint);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
911
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
912 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
913 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
914
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
915 packet = g_malloc0(size);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
916 *((gint *) packet) = pos;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
917 strcpy(packet + sizeof(gint), string);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
918 remote_send_packet(fd, CMD_PLAYLIST_INS_URL_STRING, packet, size);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
919 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
920 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
921 g_free(packet);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
922 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
923
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
924 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
925 xmms_remote_is_running(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
926 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
927 return remote_cmd(session, CMD_PING);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
928 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
929
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
930 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
931 xmms_remote_toggle_repeat(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
932 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
933 remote_cmd(session, CMD_TOGGLE_REPEAT);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
934 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
935
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
936 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
937 xmms_remote_toggle_shuffle(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
938 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
939 remote_cmd(session, CMD_TOGGLE_SHUFFLE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
940 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
941
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
942 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
943 xmms_remote_toggle_advance(int session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
944 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
945 remote_cmd(session, CMD_TOGGLE_ADVANCE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
946 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
947
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
948 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
949 xmms_remote_is_repeat(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
950 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
951 return remote_get_gboolean(session, CMD_IS_REPEAT);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
952 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
953
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
954 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
955 xmms_remote_is_shuffle(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
956 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
957 return remote_get_gboolean(session, CMD_IS_SHUFFLE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
958 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
959
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
960 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
961 xmms_remote_is_advance(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
962 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
963 return remote_get_gboolean(session, CMD_IS_ADVANCE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
964 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
965
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
966 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
967 xmms_remote_playqueue_add(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
968 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
969 remote_send_guint32(session, CMD_PLAYQUEUE_ADD, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
970 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
971
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
972 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
973 xmms_remote_playqueue_remove(gint session, gint pos)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
974 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
975 remote_send_guint32(session, CMD_PLAYQUEUE_REMOVE, pos);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
976 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
977
984
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
978 void
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
979 xmms_remote_playqueue_clear(gint session)
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
980 {
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
981 remote_cmd(session, CMD_PLAYQUEUE_CLEAR);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
982 }
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
983
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
984 gint
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
985 xmms_remote_get_playqueue_length(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
986 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
987 return remote_get_gint(session, CMD_GET_PLAYQUEUE_LENGTH);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
988 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
989
984
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
990 gboolean
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
991 xmms_remote_playqueue_is_queued(gint session, gint pos)
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
992 {
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
993 ServerPktHeader pkt_hdr;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
994 gpointer data;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
995 gint fd, ret = 0;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
996 guint32 p = pos;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
997
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
998 if ((fd = xmms_connect_to_session(session)) == -1)
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
999 return ret;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1000 remote_send_packet(fd, CMD_PLAYQUEUE_IS_QUEUED, &p, sizeof(guint32));
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1001 data = remote_read_packet(fd, &pkt_hdr);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1002 if (data) {
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1003 ret = *((gint *) data);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1004 g_free(data);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1005 }
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1006 remote_read_ack(fd);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1007 close(fd);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1008 return ret;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1009 }
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1010
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1011 gint
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1012 xmms_remote_get_playqueue_position(gint session, gint pos)
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1013 {
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1014 ServerPktHeader pkt_hdr;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1015 gpointer data;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1016 gint fd, ret = 0;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1017 guint32 p = pos;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1018
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1019 if ((fd = xmms_connect_to_session(session)) == -1)
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1020 return ret;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1021 remote_send_packet(fd, CMD_PLAYQUEUE_GET_POS, &p, sizeof(guint32));
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1022 data = remote_read_packet(fd, &pkt_hdr);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1023 if (data) {
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1024 ret = *((gint *) data);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1025 g_free(data);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1026 }
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1027 remote_read_ack(fd);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1028 close(fd);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1029 return ret;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1030 }
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1031
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1032 gint
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1033 xmms_remote_get_playqueue_queue_position(gint session, gint pos)
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1034 {
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1035 ServerPktHeader pkt_hdr;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1036 gpointer data;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1037 gint fd, ret = 0;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1038 guint32 p = pos;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1039
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1040 if ((fd = xmms_connect_to_session(session)) == -1)
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1041 return ret;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1042 remote_send_packet(fd, CMD_PLAYQUEUE_GET_QPOS, &p, sizeof(guint32));
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1043 data = remote_read_packet(fd, &pkt_hdr);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1044 if (data) {
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1045 ret = *((gint *) data);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1046 g_free(data);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1047 }
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1048 remote_read_ack(fd);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1049 close(fd);
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1050 return ret;
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1051 }
bcd1ebd0a7c1 [svn] - jumptofile and queue support fun
nhjm449
parents: 625
diff changeset
1052
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1053 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1054 xmms_remote_get_eq(gint session, gfloat * preamp, gfloat ** bands)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1055 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1056 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1057 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1058 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1059
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1060 if (preamp)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1061 *preamp = 0.0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1062
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1063 if (bands)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1064 *bands = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1065
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1066 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1067 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1068 remote_send_packet(fd, CMD_GET_EQ, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1069 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1070 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1071 if (pkt_hdr.data_length >= 11 * sizeof(gfloat)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1072 if (preamp)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1073 *preamp = *((gfloat *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1074 if (bands)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1075 *bands =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1076 (gfloat *) g_memdup((gfloat *) data + 1,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1077 10 * sizeof(gfloat));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1078 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1079 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1080 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1081 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1082 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1083 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1084
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1085 gfloat
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1086 xmms_remote_get_eq_preamp(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1087 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1088 return remote_get_gfloat(session, CMD_GET_EQ_PREAMP);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1089 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1090
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1091 gfloat
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1092 xmms_remote_get_eq_band(gint session, gint band)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1093 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1094 ServerPktHeader pkt_hdr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1095 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1096 gpointer data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1097 gfloat val = 0.0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1098
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1099 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1100 return val;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1101 remote_send_packet(fd, CMD_GET_EQ_BAND, &band, sizeof(band));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1102 data = remote_read_packet(fd, &pkt_hdr);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1103 if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1104 val = *((gfloat *) data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1105 g_free(data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1106 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1107 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1108 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1109 return val;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1110 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1111
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1112 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1113 xmms_remote_set_eq(gint session, gfloat preamp, gfloat * bands)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1114 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1115 gint fd, i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1116 gfloat data[11];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1117
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1118 g_return_if_fail(bands != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1119
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1120 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1121 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1122 data[0] = preamp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1123 for (i = 0; i < 10; i++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1124 data[i + 1] = bands[i];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1125 remote_send_packet(fd, CMD_SET_EQ, data, sizeof(data));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1126 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1127 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1128 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1129
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1130 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1131 xmms_remote_set_eq_preamp(gint session, gfloat preamp)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1132 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1133 remote_send_gfloat(session, CMD_SET_EQ_PREAMP, preamp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1134 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1135
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1136 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1137 xmms_remote_set_eq_band(gint session, gint band, gfloat value)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1138 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1139 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1140 gchar data[sizeof(gint) + sizeof(gfloat)];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1141
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1142 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1143 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1144 *((gint *) data) = band;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1145 *((gfloat *) (data + sizeof(gint))) = value;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1146 remote_send_packet(fd, CMD_SET_EQ_BAND, data, sizeof(data));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1147 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1148 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1149 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1150
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1151 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1152 xmms_remote_quit(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1153 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1154 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1155
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1156 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1157 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1158 remote_send_packet(fd, CMD_QUIT, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1159 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1160 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1161 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1162
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1163 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1164 xmms_remote_activate(gint session)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1165 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1166 gint fd;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1167
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1168 if ((fd = xmms_connect_to_session(session)) == -1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1169 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1170 remote_send_packet(fd, CMD_ACTIVATE, NULL, 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1171 remote_read_ack(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1172 close(fd);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1173 }