annotate src/daap/daap.c @ 1496:ee1b4e1cf7ce

it can play manually added DAAP URI's like daap://localhost:3689/1.mp3 avahi discovery works but it isn't yet integrated.
author Cristi Magherusan <majeru@atheme-project.org>
date Thu, 16 Aug 2007 03:45:58 +0300
parents d43075afd1db
children e8ea3a76a84e
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
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
23 #include <audacious/vfs.h>
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
24 #include <audacious/plugin.h>
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
25 #include <audacious/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
26
ee1b4e1cf7ce 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_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
28 #include "xmms2-daap/daap_util.h"
1450
69bff388b0f8 now it compiles
Cristi Magherusan <majeru@atheme-project.org>
parents: 1448
diff changeset
29 #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
30 #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
31 #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
32 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
33 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
34 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
35
ee1b4e1cf7ce 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 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
37
ee1b4e1cf7ce 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 } 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
39
ee1b4e1cf7ce 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 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
41 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
42 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
43 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
44 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
45 } 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
46
ee1b4e1cf7ce 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 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
48 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
49 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
50 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
51 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
52 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
53 }
ee1b4e1cf7ce 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 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
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
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
58 static GHashTable *login_sessions = NULL;
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
59
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
60 gboolean daap_initialized=FALSE;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
61
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
62 GMutex * mutex_init = NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
63
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
64 GMutex * mutex_discovery = NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
65
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
66 GList * daap_servers = NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
67
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
68 guint request_id=0;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
69
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
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
ee1b4e1cf7ce 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 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
73 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
74 {
ee1b4e1cf7ce 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 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
76
ee1b4e1cf7ce 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 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
78
ee1b4e1cf7ce 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 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
80
ee1b4e1cf7ce 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 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
82 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
83 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
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
ee1b4e1cf7ce 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 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
87 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
88 *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
89 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
90 *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
91 }
ee1b4e1cf7ce 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 } 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
93 *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
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
ee1b4e1cf7ce 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 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
97 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
98 *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
99 } 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
100 /* 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
101 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
102 } 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
103 /* 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
104 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
105 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
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
ee1b4e1cf7ce 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 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
109 *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
110 } 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
111 *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
112 } 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
113 *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
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
ee1b4e1cf7ce 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 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
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
ee1b4e1cf7ce 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 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
122 daap_init (daap_handle_t *handle)
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
123 {
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
124 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
125 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
126 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
127 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
128 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
129 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
130 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
131
ee1b4e1cf7ce 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 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
133
ee1b4e1cf7ce 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 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
135 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
136
ee1b4e1cf7ce 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 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
138
ee1b4e1cf7ce 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 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
140 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
141 {
ee1b4e1cf7ce 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 #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
143 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
144 #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
145 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
146
ee1b4e1cf7ce 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->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
148 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
149
ee1b4e1cf7ce 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->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
151 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
152 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
153 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
154
ee1b4e1cf7ce 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 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
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
ee1b4e1cf7ce 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->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
159 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
160 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
161 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
162 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
163 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
164 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
165 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
166 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
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
ee1b4e1cf7ce 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 /* 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
170 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
171 /* 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
172 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
173 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
174 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
175 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
176 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
177 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
178 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
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
ee1b4e1cf7ce 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 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
182
ee1b4e1cf7ce 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->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
184 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
185 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
186 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
187 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
188 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
189
ee1b4e1cf7ce 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 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
191 }
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
192
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
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
ee1b4e1cf7ce 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 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
200 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
201 {
ee1b4e1cf7ce 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 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
203 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
204 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
205 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
206 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
207 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
208
ee1b4e1cf7ce 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 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
210
ee1b4e1cf7ce 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 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
212
ee1b4e1cf7ce 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 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
214 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
215
ee1b4e1cf7ce 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 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
217
ee1b4e1cf7ce 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->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
219 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
220 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
221
ee1b4e1cf7ce 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->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
223 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
224
ee1b4e1cf7ce 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 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
226 } 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
227 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
228 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
229 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
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
ee1b4e1cf7ce 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 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
233 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
234 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
235 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
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
ee1b4e1cf7ce 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 /* 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
239 * 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
240 * 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
241 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
242 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
243 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
244 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
245
ee1b4e1cf7ce 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_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
247 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
248
ee1b4e1cf7ce 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 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
250 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
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
ee1b4e1cf7ce 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 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
254 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
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
ee1b4e1cf7ce 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_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
258 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
259
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
260 return g_list_reverse(output);
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
261 }
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
262
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
263
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
264 GList * daap_discovery_get_devices_impl(void)
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
265 {
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
266 discovery_device_t * current_device=NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
267 GList * returned_devices=NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
268 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
269 * current_server=NULL;
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
270
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
271 if(mutex_discovery==NULL)
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
272 return NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
273
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
274 g_mutex_lock(mutex_discovery);
1450
69bff388b0f8 now it compiles
Cristi Magherusan <majeru@atheme-project.org>
parents: 1448
diff changeset
275 g_print ("caut\n");
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
276 daap_found_devices = daap_mdns_get_server_list ();
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
277 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
278
1450
69bff388b0f8 now it compiles
Cristi Magherusan <majeru@atheme-project.org>
parents: 1448
diff changeset
279 for (; current_server; current_server = g_slist_next (current_server))
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
280 {
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
281 current_device = g_new0(discovery_device_t,1);
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
282 daap_mdns_server_t *serv=current_server->data;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
283 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
284 g_strdup_printf("%s(%s)",serv->server_name, serv->mdns_hostname);
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
285
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
286 current_device->device_address =
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
287 g_strdup_printf(
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
288 "%s:%d",
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
289 serv->address,
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
290 serv->port
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
291 );
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
292 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
293 daap_get_tracks_from_server(
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
294 serv->mdns_hostname,
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
295 serv->port
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
296 );
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
297 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
298 #if DEBUG
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
299 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
300 #endif
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
301 }
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
302 g_slist_free(daap_found_devices);
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
303 g_mutex_unlock(mutex_discovery);
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
304 return g_list_reverse(returned_devices);
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
305 }
1407
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
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
309
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
310 VFSFile * daap_vfs_fopen_impl(const gchar * path, const gchar * mode)
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
311 {
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
312 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
313 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
314 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
315
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
316 if (!path || !mode)
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
317 return NULL;
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
318
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
319 if( !daap_init(handle) )
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
320 {
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
321 #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
322 g_print("Error while initializing DAAP !!!\n");
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
323 #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
324 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
325 }
ee1b4e1cf7ce 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 #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
327 g_print("DAAP was initialized succesfully\n");
1452
Cristi Magherusan <majeru@atheme-project.org>
parents: 1450
diff changeset
328 #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
329 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
330 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
331
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
332 if (handle->fd < 0)
1452
Cristi Magherusan <majeru@atheme-project.org>
parents: 1450
diff changeset
333 {
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_print("vfs_fopen got a negative FD \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
335 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
336 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
337 }
ee1b4e1cf7ce 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 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
339 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
340 return file;
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
341 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
342
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
343 gint daap_vfs_fclose_impl(VFSFile * file)
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
344 {
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
345 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
346 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
347 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
348 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
349
ee1b4e1cf7ce 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 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
351 {
ee1b4e1cf7ce 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 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
353 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
354 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
355 {
ee1b4e1cf7ce 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 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
357 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
358 }
ee1b4e1cf7ce 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 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
360 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
361 }
ee1b4e1cf7ce 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 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
363
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
364 return -1;
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
365 }
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
366
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
367 size_t daap_vfs_fread_impl(gpointer ptr, size_t size, size_t nmemb, VFSFile * file)
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
368 {
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
369 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
370 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
371 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
372 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
373 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
374 {
ee1b4e1cf7ce 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 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
376 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
377 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
378 else
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
379 return 0;
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
380 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
381
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
382 size_t daap_vfs_fwrite_impl(gconstpointer ptr, size_t size, size_t nmemb, VFSFile * file)
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
383 {
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
384 return -1;
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
385 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
386
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
387 gint daap_vfs_getc_impl(VFSFile * file)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
388 {
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
389 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
390 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
391 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
392 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
393 {
ee1b4e1cf7ce 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 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
395 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
396 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
397 }
ee1b4e1cf7ce 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 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
399 {
ee1b4e1cf7ce 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 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
401 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
402 }
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
403 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
404
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
405 gint daap_vfs_fseek_impl(VFSFile * file, glong offset, gint whence)
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
406 {
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
407 return -1;
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
408 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
409
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 gint daap_vfs_ungetc_impl(gint c, VFSFile * stream)
ee1b4e1cf7ce 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 {
ee1b4e1cf7ce 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 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
413 }
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
414
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
415 void daap_vfs_rewind_impl(VFSFile * stream)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
416 {
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
417 return;
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
418 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
419
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
420 glong daap_vfs_ftell_impl(VFSFile * stream)
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
421 {
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
422 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
423 return handle->pos;
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
424 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
425
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
426 gboolean daap_vfs_feof_impl(VFSFile * file)
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
427 {
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
428 daap_handle_t *handle=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
429 off_t at = daap_vfs_ftell_impl(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
430 return (gboolean) (at >= handle->length) ? TRUE : FALSE;
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
431 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
432
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
433 gint daap_vfs_truncate_impl(VFSFile * file, glong size)
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
434 {
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
435 return -1;
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
436 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
437 off_t daap_vfs_fsize_impl(VFSFile * file)
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
438 {
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
439 return 0;
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
440 }
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
441
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
442 gchar *daap_vfs_metadata_impl(VFSFile * file, const gchar * field)
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
443 {
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
444 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
445 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
446
ee1b4e1cf7ce 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 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
448 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
449 else
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
450 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
451
ee1b4e1cf7ce 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 /*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
453 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
454 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
455 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
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
ee1b4e1cf7ce 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 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
459 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
460 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
461
1407
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
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
464 VFSConstructor daap_const = {
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
465 "daap://",
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
466 daap_vfs_fopen_impl,
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
467 daap_vfs_fclose_impl,
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
468 daap_vfs_fread_impl,
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
469 daap_vfs_fwrite_impl,
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
470 daap_vfs_getc_impl,
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
471 daap_vfs_ungetc_impl,
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
472 daap_vfs_fseek_impl,
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
473 daap_vfs_rewind_impl,
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
474 daap_vfs_ftell_impl,
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
475 daap_vfs_feof_impl,
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
476 daap_vfs_truncate_impl,
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
477 daap_vfs_fsize_impl,
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
478 daap_vfs_metadata_impl
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
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
481 static void init(void)
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
482 {
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
483 mutex_init = g_mutex_new();
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
484 mutex_discovery = g_mutex_new();
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
485 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
486 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
487 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
488 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
489
ee1b4e1cf7ce it can play manually added DAAP URI's like daap://localhost:3689/1.mp3
Cristi Magherusan <majeru@atheme-project.org>
parents: 1452
diff changeset
490
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
491 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
492 static void cleanup(void)
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
493 {
1448
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
494 g_mutex_free (mutex_init);
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
495 g_mutex_free (mutex_discovery);
Cristi Magherusan <majeru@atheme-project.org>
parents: 1407
diff changeset
496 daap_mdns_destroy ();
1407
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
497 }
776dd8fc2b38 DAAP plugin (work in progress)
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
498 DECLARE_PLUGIN(daap, init, cleanup, NULL, NULL, NULL, NULL, NULL, NULL)