annotate src/daap/daap.c @ 3200:8da9787de69d

alsa-ng: More paranoid debugging.
author John Lindgren <john.lindgren@tds.net>
date Tue, 11 Aug 2009 10:34:26 -0400
parents 3134a0987162
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
1 /* Audacious DAAP transport plugin
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
2 * Copyright (c) 2007 Cristi Magherusan <majeru@gentoo.ro>
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
3 *
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
4 * With inspiration and code from David Hammerton's tunesbrowser
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
5 *
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
9 * (at your option) any later version.
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
10 *
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
14 * GNU General Public License for more details.
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
15 *
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
17 * along with this program; if not, write to the Free Softmcware
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
19 */
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
20
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
21 #include <glib.h>
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
22
2971
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1978
diff changeset
23 #include <audlegacy/plugin.h>
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1978
diff changeset
24 #include <audlegacy/discovery.h>
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
25
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
26 #include "xmms2-daap/daap_cmd.h"
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
27 #include "xmms2-daap/daap_util.h"
1450
69bff388b0f8 now it compiles
Cristi Magherusan <majeru@atheme-project.org>
parents: 1448
diff changeset
28 #include "xmms2-daap/daap_mdns_browse.h"
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
29 #define DEFAULT_DAAP_PORT 3689
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
30 #define DEBUG 1
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
31 typedef struct {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
32 gchar *host;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
33 guint port;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
34
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
35 GIOChannel *channel;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
36
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
37 } daap_data_t;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
38
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
39 typedef struct {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
40 gboolean logged_in;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
41 guint session_id;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
42 guint revision_id;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
43 guint request_id;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
44 } daap_login_data_t;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
45
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
46 typedef struct{
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
47 daap_data_t *daap_data;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
48 gchar *url;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
49 int fd;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
50 guint pos;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
51 gulong length;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
52 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
53 daap_handle_t;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
54
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
55
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
56
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
57 static GHashTable *login_sessions = NULL;
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
58
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
59 gboolean daap_initialized=FALSE;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
60
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
61 GMutex * mutex_init = NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
62
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
63 GMutex * mutex_discovery = NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
64
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
65 GList * daap_servers = NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
66
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
67 guint request_id=0;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
68
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
69
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
70
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
71 static gboolean
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
72 get_data_from_url (const gchar *url, gchar **host, guint *port, gchar **cmd)
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
73 {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
74 const gchar *port_ptr, *cmd_ptr, *end_ptr, *stripped;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
75
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
76 stripped = url + sizeof (gchar) * strlen ("daap://");
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
77
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
78 end_ptr = stripped + sizeof (gchar) * strlen (stripped);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
79
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
80 if (stripped == end_ptr) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
81 g_print("DAAP: Empty URL\n");
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
82 return FALSE;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
83 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
84
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
85 port_ptr = strstr (stripped, ":");
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
86 if (port && port_ptr && (port_ptr + 1) != end_ptr) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
87 *port = strtol (port_ptr + 1, (gchar **) NULL, 10);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
88 if (*port == 0) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
89 *port = DEFAULT_DAAP_PORT;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
90 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
91 } else if (port) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
92 *port = DEFAULT_DAAP_PORT;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
93 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
94
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
95 cmd_ptr = strstr (stripped, "/");
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
96 if (cmd && cmd_ptr && (cmd_ptr + 1) != end_ptr) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
97 *cmd = g_strdup (cmd_ptr);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
98 } else if (cmd) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
99 /* cmd wanted but not found */
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
100 g_print("DAAP: No file requested\n");
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
101 } else if (!cmd && cmd_ptr && (cmd_ptr + 1) != end_ptr) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
102 /* cmd not wanted but found */
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
103 g_print("DAAP: No such directory\n");
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
104 return FALSE;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
105 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
106
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
107 if (port_ptr) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
108 *host = g_strndup (stripped, port_ptr - stripped);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
109 } else if (cmd_ptr) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
110 *host = g_strndup (stripped, cmd_ptr - stripped);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
111 } else {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
112 *host = g_strdup (stripped);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
113 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
114
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
115 return TRUE;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
116 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
117
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
118
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
119
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
120 static gboolean
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
121 daap_init (daap_handle_t *handle)
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
122 {
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
123 gint dbid;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
124 GSList *dbid_list = NULL;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
125 daap_data_t *data;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
126 daap_login_data_t *login_data;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
127 guint filesize;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
128 gchar *command=NULL;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
129 gchar *hash;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
130
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
131 data = g_new0 (daap_data_t, 1);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
132
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
133 if (!get_data_from_url (handle->url, &(data->host), &(data->port), &command))
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
134 return FALSE;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
135
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
136 hash = g_strdup_printf ("%s:%u", data->host, data->port);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
137
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
138 login_data = g_hash_table_lookup (login_sessions, hash);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
139 if (!login_data)
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
140 {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
141 #if DEBUG
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
142 g_print ("creating login data for %s\n", hash);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
143 #endif
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
144 login_data = g_new0 (daap_login_data_t, 1);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
145
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
146 login_data->request_id = 1;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
147 login_data->logged_in = TRUE;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
148
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
149 login_data->session_id = daap_command_login (data->host, data->port,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
150 login_data->request_id);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
151 if(login_data->session_id==0)
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
152 return FALSE;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
153
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
154 g_hash_table_insert (login_sessions, hash, login_data);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
155 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
156
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
157 login_data->revision_id = daap_command_update (data->host, data->port,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
158 login_data->session_id,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
159 login_data->request_id);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
160 dbid_list = daap_command_db_list (data->host, data->port,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
161 login_data->session_id,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
162 login_data->revision_id,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
163 login_data->request_id);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
164 if (!dbid_list) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
165 return FALSE;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
166 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
167
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
168 /* XXX: see XXX in the browse function above */
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
169 dbid = ((cc_item_record_t *) dbid_list->data)->dbid;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
170 /* want to request a stream, but don't read the data yet */
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
171 data->channel = daap_command_init_stream (data->host, data->port,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
172 login_data->session_id,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
173 login_data->revision_id,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
174 login_data->request_id, dbid,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
175 command,&filesize);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
176 if (!data->channel) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
177 return FALSE;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
178 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
179
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
180 login_data->request_id++;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
181
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
182 handle->daap_data=data;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
183 handle->length=filesize;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
184 handle->pos=0;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
185 g_slist_foreach (dbid_list, (GFunc) cc_item_record_free, NULL);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
186 g_slist_free (dbid_list);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
187 g_free (command);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
188
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
189 return TRUE;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
190 }
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
191
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
192
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
193
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
194
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
195
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
196
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
197
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
198 GList*
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
199 daap_get_tracks_from_server (gchar *host, guint port)
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
200 {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
201 GList * output=NULL;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
202 GSList *dbid_list = NULL;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
203 GSList *song_list = NULL, *song_el;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
204 cc_item_record_t *db_data;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
205 daap_login_data_t *login_data;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
206 gchar *hash;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
207
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
208 hash = g_strdup_printf ("%s:%u", host, port);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
209
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
210 login_data = g_hash_table_lookup (login_sessions, hash);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
211
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
212 if (!login_data) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
213 login_data = g_new0 (daap_login_data_t, 1);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
214
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
215 login_data->session_id = daap_command_login (host, port, 0);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
216
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
217 login_data->revision_id = daap_command_update (host, port,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
218 login_data->session_id,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
219 0);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
220
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
221 login_data->request_id = 1;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
222 login_data->logged_in = TRUE;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
223
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
224 g_hash_table_insert (login_sessions, hash, login_data);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
225 } else {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
226 login_data->revision_id = daap_command_update (host, port,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
227 login_data->session_id,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
228 0);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
229 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
230
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
231 dbid_list = daap_command_db_list (host, port, login_data->session_id,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
232 login_data->revision_id, 0);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
233 if (!dbid_list) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
234 return NULL;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
235 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
236
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
237 /* XXX i've never seen more than one db per server out in the wild,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
238 * let's hope that never changes *wink*
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
239 * just use the first db in the list */
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
240 db_data = (cc_item_record_t *) dbid_list->data;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
241 song_list = daap_command_song_list (host, port, login_data->session_id,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
242 login_data->revision_id,
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
243 0, db_data->dbid);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
244
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
245 g_slist_foreach (dbid_list, (GFunc) cc_item_record_free, NULL);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
246 g_slist_free (dbid_list);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
247
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
248 if (!song_list) {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
249 return NULL;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
250 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
251
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
252 for (song_el = song_list; song_el; song_el = g_slist_next (song_el))
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
253 output=g_list_prepend(output, g_memdup(song_el->data,sizeof(cc_item_record_t)));
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
254
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
255
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
256 g_slist_foreach (song_list, (GFunc) cc_item_record_free, NULL);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
257 g_slist_free (song_list);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
258
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
259 return g_list_reverse(output);
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
260 }
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
261
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
262
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
263 GList * daap_discovery_get_devices_impl(void)
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
264 {
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
265 discovery_device_t * current_device=NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
266 GList * returned_devices=NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
267 GSList * daap_found_devices=NULL,
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
268 * current_server=NULL;
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
269
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
270 if(mutex_discovery==NULL)
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
271 return NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
272
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
273 g_mutex_lock(mutex_discovery);
1450
69bff388b0f8 now it compiles
Cristi Magherusan <majeru@atheme-project.org>
parents: 1448
diff changeset
274 g_print ("caut\n");
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
275 daap_found_devices = daap_mdns_get_server_list ();
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
276 current_server=daap_found_devices;
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
277
1450
69bff388b0f8 now it compiles
Cristi Magherusan <majeru@atheme-project.org>
parents: 1448
diff changeset
278 for (; current_server; current_server = g_slist_next (current_server))
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
279 {
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
280 current_device = g_new0(discovery_device_t,1);
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
281 daap_mdns_server_t *serv=current_server->data;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
282 current_device->device_name =
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
283 g_strdup_printf("%s(%s)",serv->server_name, serv->mdns_hostname);
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
284
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
285 current_device->device_address =
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
286 g_strdup_printf(
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
287 "%s:%d",
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
288 serv->address,
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
289 serv->port
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
290 );
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
291 current_device->device_playlist=
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
292 daap_get_tracks_from_server(
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
293 serv->mdns_hostname,
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
294 serv->port
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
295 );
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
296 returned_devices = g_list_prepend(returned_devices,current_device);
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
297 #if DEBUG
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
298 g_print("DAAP: Found device %s at address %s\n", current_device->device_name ,current_device->device_address );
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
299 #endif
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
300 }
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
301 g_slist_free(daap_found_devices);
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
302 g_mutex_unlock(mutex_discovery);
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
303 return g_list_reverse(returned_devices);
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
304 }
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
305
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
306
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
307
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
308
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
309 VFSFile * daap_aud_vfs_fopen_impl(const gchar * path, const gchar * mode)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
310 {
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
311 VFSFile *file=NULL;
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
312 daap_handle_t *handle = g_new0(daap_handle_t, 1);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
313 handle->url=g_strdup(path);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
314
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
315 if (!path || !mode)
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
316 return NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
317
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
318 if( !daap_init(handle) )
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
319 {
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
320 #if DEBUG /*this isn't a fatal error, we can try again later*/
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
321 g_print("Error while initializing DAAP !!!\n");
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
322 #endif
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
323 return NULL;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
324 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
325 #if DEBUG
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
326 g_print("DAAP was initialized succesfully\n");
1452
Cristi Magherusan <majeru@atheme-project.org>
parents: 1450
diff changeset
327 #endif
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
328 file=g_new0(VFSFile, 1);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
329 handle->fd=g_io_channel_unix_get_fd(handle->daap_data->channel);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
330
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
331 if (handle->fd < 0)
1452
Cristi Magherusan <majeru@atheme-project.org>
parents: 1450
diff changeset
332 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
333 g_print("aud_vfs_fopen got a negative FD \n");
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
334 g_free(file);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
335 file = NULL;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
336 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
337 else
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
338 file->handle=(void*)handle;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
339 return file;
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
340 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
341
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
342 gint daap_aud_vfs_fclose_impl(VFSFile * file)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
343 {
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
344 gint ret=0;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
345 daap_handle_t * handle = (daap_handle_t *)file->handle;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
346 if (file == NULL)
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
347 return -1;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
348
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
349 if (file->handle)
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
350 {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
351 if(g_io_channel_shutdown(handle->daap_data->channel,TRUE,NULL)!=G_IO_STATUS_NORMAL)
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
352 ret = -1;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
353 else
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
354 {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
355 g_io_channel_unref(handle->daap_data->channel);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
356 ret=0;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
357 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
358 g_free(file->handle);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
359 file->handle=NULL;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
360 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
361 return ret;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
362
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
363 return -1;
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
364 }
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
365
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
366 size_t daap_aud_vfs_fread_impl(gpointer ptr, size_t size, size_t nmemb, VFSFile * file)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
367 {
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
368 daap_handle_t *handle= (daap_handle_t *)file->handle;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
369 size_t ret=0;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
370 if (file == NULL)
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
371 return 0;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
372 if( g_io_channel_read_chars (handle->daap_data->channel,ptr,size*nmemb,&ret,NULL)==G_IO_STATUS_NORMAL)
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
373 {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
374 handle->pos+=(size*nmemb);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
375 return ret;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
376 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
377 else
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
378 return 0;
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
379 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
380
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
381 size_t daap_aud_vfs_fwrite_impl(gconstpointer ptr, size_t size, size_t nmemb, VFSFile * file)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
382 {
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
383 return -1;
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
384 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
385
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
386 gint daap_aud_vfs_getc_impl(VFSFile * file)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
387 {
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
388 guchar ret=EOF;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
389 daap_handle_t *handle = (daap_handle_t *)file->handle;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
390 int status=g_io_channel_read_chars (handle->daap_data->channel,(void*)&ret,1,NULL,NULL);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
391 if(status==G_IO_STATUS_NORMAL)
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
392 {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
393 g_print ("fgetc OK\n");
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
394 handle->pos++;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
395 return ret;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
396 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
397 else
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
398 {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
399 g_print ("fgetc failed\n");
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
400 return EOF;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
401 }
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
402 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
403
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
404 gint daap_aud_vfs_fseek_impl(VFSFile * file, glong offset, gint whence)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
405 {
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
406 return -1;
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
407 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
408
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
409 gint daap_aud_vfs_ungetc_impl(gint c, VFSFile * stream)
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
410 {
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
411 return c;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
412 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
413
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
414 void daap_aud_vfs_rewind_impl(VFSFile * stream)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
415 {
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
416 return;
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
417 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
418
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
419 glong daap_aud_vfs_ftell_impl(VFSFile * stream)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
420 {
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
421 daap_handle_t *handle=stream->handle;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
422 return handle->pos;
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
423 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
424
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
425 gboolean daap_aud_vfs_feof_impl(VFSFile * file)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
426 {
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
427 daap_handle_t *handle=file->handle;
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
428 off_t at = daap_aud_vfs_ftell_impl(file);
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
429 return (gboolean) (at >= handle->length) ? TRUE : FALSE;
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
430 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
431
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
432 gint daap_aud_vfs_truncate_impl(VFSFile * file, glong size)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
433 {
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
434 return -1;
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
435 }
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
436 off_t daap_aud_vfs_fsize_impl(VFSFile * file)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
437 {
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
438 return 0;
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
439 }
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
440
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
441 gchar *daap_aud_vfs_metadata_impl(VFSFile * file, const gchar * field)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
442 {
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
443 daap_handle_t *handle;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
444 g_print("Requested metadata: '%s' \n",field);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
445
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
446 if(file && file->handle)
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
447 handle = (daap_handle_t *)file->handle;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
448 else
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
449 return NULL;
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
450
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
451 /*if (!g_ascii_strncasecmp(field, "stream-name", 11))
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
452 return handle->url;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
453 if (!g_ascii_strncasecmp(field, "track-name",10))
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
454 return handle->url;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
455 */
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
456
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
457 if (!g_ascii_strncasecmp(field, "content-type", 12))
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
458 return g_strdup("audio/mpeg");
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
459 return NULL;
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
460
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
461 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
462
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
463 VFSConstructor daap_const = {
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
464 "daap://",
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
465 daap_aud_vfs_fopen_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
466 daap_aud_vfs_fclose_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
467 daap_aud_vfs_fread_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
468 daap_aud_vfs_fwrite_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
469 daap_aud_vfs_getc_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
470 daap_aud_vfs_ungetc_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
471 daap_aud_vfs_fseek_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
472 daap_aud_vfs_rewind_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
473 daap_aud_vfs_ftell_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
474 daap_aud_vfs_feof_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
475 daap_aud_vfs_truncate_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
476 daap_aud_vfs_fsize_impl,
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
477 daap_aud_vfs_metadata_impl
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
478 };
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
479
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
480 static void init(void)
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
481 {
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
482 mutex_init = g_mutex_new();
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
483 mutex_discovery = g_mutex_new();
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
484 aud_vfs_register_transport(&daap_const);
1496
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
485 daap_mdns_initialize ();
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
486 if (!login_sessions)
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
487 login_sessions = g_hash_table_new (g_str_hash, g_str_equal);
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
488
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
489
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
490 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
491 static void cleanup(void)
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
492 {
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
493 g_mutex_free (mutex_init);
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
494 g_mutex_free (mutex_discovery);
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
495 daap_mdns_destroy ();
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
496 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
497 DECLARE_PLUGIN(daap, init, cleanup, NULL, NULL, NULL, NULL, NULL, NULL)