Mercurial > audlegacy-plugins
changeset 1455:68c9906e0ac4
Automated merge with ssh://majeru@hg.atheme.org//hg/audacious-plugins
author | Cristi Magherusan <majeru@atheme-project.org> |
---|---|
date | Fri, 10 Aug 2007 23:06:50 +0300 |
parents | f57f3af1f722 (diff) 195b5657303e (current diff) |
children | 475eac76a8ba |
files | |
diffstat | 8 files changed, 136 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/daap/Makefile Fri Aug 10 22:00:07 2007 +0200 +++ b/src/daap/Makefile Fri Aug 10 23:06:50 2007 +0300 @@ -7,7 +7,15 @@ LIBDIR = $(plugindir)/$(TRANSPORT_PLUGIN_DIR) -LIBADD += ./xmms2-daap/xmms2-daap.a $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) +#For the moment i'm hardcoding it but it will be configurable +#MDNS_LIBS=-ldns_sd +MDNS_LIBS=-lavahi-glib -lavahi-common -lavahi-client +#MDNS_LIBS= + + + + +LIBADD += ./xmms2-daap/xmms2-daap.a $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) $(MDNS_LIBS) SOURCES = daap.c
--- a/src/daap/daap.c Fri Aug 10 22:00:07 2007 +0200 +++ b/src/daap/daap.c Fri Aug 10 23:06:50 2007 +0300 @@ -20,30 +20,127 @@ #include <audacious/vfs.h> #include <audacious/plugin.h> +#include <audacious/discovery.h> /* #include <audacious/configdb.h> #include <libmowgli/mowgli.h> #include <curl/curl.h> */ #include <glib.h> -#include <daap/client.h> +#include "xmms2-daap/daap_mdns_browse.h" +#include "xmms2-daap/daap_cmd.h" + +gboolean daap_initialized=FALSE; + +GMutex * mutex_init = NULL; + +GMutex * mutex_discovery = NULL; + +GList * daap_servers = NULL; + +guint request_id=0; + +GList * daap_get_server_playlist(gchar * host, gint port ) +{ +return NULL; + +} +GList * daap_discovery_get_devices_impl(void) +{ + discovery_device_t * current_device=NULL; + GList * returned_devices=NULL; + GSList * daap_found_devices=NULL, + * current_server=NULL; + + if(mutex_discovery==NULL) + return NULL; + + g_mutex_lock(mutex_discovery); + g_print ("caut\n"); + daap_found_devices = daap_mdns_get_server_list (); + current_server=daap_found_devices; + g_print ("entering for\n"); + if(current_server!=NULL) + g_print("!=NULL\n"); + else + g_print("==NULL\n"); + + for (; current_server; current_server = g_slist_next (current_server)) + { + g_print ("in for\n"); + + current_device = g_new0(discovery_device_t,1); + daap_mdns_server_t *serv=current_server->data; + current_device->device_name = + g_strdup_printf("%s(%s)", + serv->server_name, + serv->mdns_hostname + ); + + current_device->device_address = + g_strdup_printf( + "%s:%d", + serv->address, + serv->port + ); + current_device->device_playlist= + daap_get_server_playlist( + serv->mdns_hostname, + serv->port + ); + returned_devices = g_list_prepend(returned_devices,current_device); +#if 1 + g_print("DAAP: Found device %s at address %s\n", current_device->device_name ,current_device->device_address ); +#endif + } + g_print("am iesit\n"); + g_slist_free(daap_found_devices); + g_mutex_unlock(mutex_discovery); + return g_list_reverse(returned_devices); +} -DAAP_SClientHost *libopendaap_host; - - VFSFile * daap_vfs_fopen_impl(const gchar * path, const gchar * mode) { - VFSFile *file; + VFSFile *file=NULL; + if(!mutex_init) + return NULL; + + g_mutex_lock(mutex_init); /* locking for init */ + if(!daap_initialized) + { + if( !daap_mdns_initialize ()) + { +#if 1 /*this isn't a fatal error, we can try again later*/ + g_print("Error while initializing DAAP !!!\n"); +#endif + g_mutex_unlock(mutex_init); + return NULL; + } + else + { +#if 1 + g_print("DAAP was initialized succesfully\n"); +#endif + daap_initialized=TRUE; + } + + if(daap_initialized) + { + sleep(1); + daap_discovery_get_devices_impl(); + } + } + g_mutex_unlock(mutex_init); /*init ended*/ + file = g_new0(VFSFile, 1); - /* connectiong daap*/ +// GList * l = - - return file; + return file; } gint daap_vfs_fclose_impl(VFSFile * file) @@ -120,10 +217,15 @@ }; static void init(void) -{ +{ + mutex_init = g_mutex_new(); + mutex_discovery = g_mutex_new(); vfs_register_transport(&daap_const); } static void cleanup(void) { + g_mutex_free (mutex_init); + g_mutex_free (mutex_discovery); + daap_mdns_destroy (); } DECLARE_PLUGIN(daap, init, cleanup, NULL, NULL, NULL, NULL, NULL, NULL)
--- a/src/daap/xmms2-daap/Makefile Fri Aug 10 22:00:07 2007 +0200 +++ b/src/daap/xmms2-daap/Makefile Fri Aug 10 23:06:50 2007 +0300 @@ -14,11 +14,14 @@ # daap_xform.c LIBADD = $(GLIB_LIBS) - -CFLAGS = $(GLIB_CFLAGS) -I/usr/include -std=c99 -Wall # -H -v +#For the moment i'm hardcoding it but it will be configurable +#MDNS_IMPL=DAAP_MDNS_DNSSD +MDNS_IMPL=DAAP_MDNS_AVAHI +#MDNS_IMPL=DAAP_MDNS_DUMMY -#CFLAGS += $(PICFLAGS) $(ARCH_DEFINES) $(CURL_CFLAGS) -c -I../../../intl -I../../.. -I/usr/include -Wall -std=c99 -H -v +CFLAGS = $(GLIB_CFLAGS) $(PICFLAGS) -std=c99 -Wall -D_POSIX_SOURCE -D$(MDNS_IMPL) + OBJECTS=${SOURCES:.c=.o} include ../../../mk/objective.mk
--- a/src/daap/xmms2-daap/daap_conn.c Fri Aug 10 22:00:07 2007 +0200 +++ b/src/daap/xmms2-daap/daap_conn.c Fri Aug 10 23:06:50 2007 +0300 @@ -121,7 +121,7 @@ FD_SET (sockfd, &fds); sret = select (sockfd + 1, NULL, &fds, NULL, &tmout); - if (sret == 0 || sret == SOCKET_ERROR) { + if (sret <= 0 ) { g_io_channel_unref (sock_chan); return NULL; }
--- a/src/daap/xmms2-daap/daap_conn.h Fri Aug 10 22:00:07 2007 +0200 +++ b/src/daap/xmms2-daap/daap_conn.h Fri Aug 10 23:06:50 2007 +0300 @@ -35,7 +35,7 @@ #define CONTENT_LENGTH "Content-Length: " #define CONTENT_TYPE "Content-Type: " /* TODO does this work ok? */ -#define USER_AGENT VERSION +#define USER_AGENT "Audacious" /*#define USER_AGENT "iTunes/4.6 (Windows; N)"*/ GIOChannel *
--- a/src/daap/xmms2-daap/daap_mdns_avahi.c Fri Aug 10 22:00:07 2007 +0200 +++ b/src/daap/xmms2-daap/daap_mdns_avahi.c Fri Aug 10 23:06:50 2007 +0300 @@ -13,7 +13,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ - +#ifdef DAAP_MDNS_AVAHI #include "daap_mdns_browse.h" #include <string.h> @@ -264,4 +264,5 @@ { /* FIXME: deinit avahi */ } +#endif
--- a/src/daap/xmms2-daap/daap_mdns_dnssd.c Fri Aug 10 22:00:07 2007 +0200 +++ b/src/daap/xmms2-daap/daap_mdns_dnssd.c Fri Aug 10 23:06:50 2007 +0300 @@ -12,6 +12,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ +#ifdef DAAP_MDNS_DNSSD #include <glib.h> #include <dns_sd.h> @@ -182,7 +183,7 @@ err = DNSServiceResolve (&ud2->client, 0, kDNSServiceInterfaceIndexAny, server->mdnsname, "_daap._tcp", "local", - resolve_reply, ud2); + (DNSServiceResolveReply)resolve_reply, ud2); if (err != kDNSServiceErr_NoError) { g_warning ("Couldn't do ServiceResolv"); @@ -332,7 +333,7 @@ service, 0, browse_reply, ud); if (err != kDNSServiceErr_NoError) { - g_warning ("Couldn't setup mDNS poller"); + g_warning ("Couldn't setup mDNS poller, error = %d",err); return FALSE; } @@ -415,4 +416,4 @@ g_mdns->mutex = g_mutex_new (); return g_mdns_browse (g_mdns, "_daap._tcp", NULL, NULL); } - +#endif
--- a/src/daap/xmms2-daap/daap_mdns_dummy.c Fri Aug 10 22:00:07 2007 +0200 +++ b/src/daap/xmms2-daap/daap_mdns_dummy.c Fri Aug 10 23:06:50 2007 +0300 @@ -12,7 +12,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ - +#ifdef AVAHI_MDNS_DUMMY #include <glib.h> #include "daap_mdns_browse.h" @@ -33,4 +33,4 @@ daap_mdns_destroy () { } - +#endif