annotate libaudacious/beepctrl.c @ 1821:bbd774554ae7 trunk

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