Author: abock
Date: 2007-08-27 23:25:36 -0400 (Mon, 27 Aug 2007)
New Revision: 84929

Removed:
   trunk/daap-sharp/ext/
Modified:
   trunk/daap-sharp/
   trunk/daap-sharp/ChangeLog
   trunk/daap-sharp/autogen.sh
   trunk/daap-sharp/configure.ac
   trunk/daap-sharp/sample/
   trunk/daap-sharp/sample/Makefile.am
   trunk/daap-sharp/sample/SampleServer.cs
   trunk/daap-sharp/src/
   trunk/daap-sharp/src/Client.cs
   trunk/daap-sharp/src/Database.cs
   trunk/daap-sharp/src/Makefile.am
   trunk/daap-sharp/src/Server.cs
   trunk/daap-sharp/src/ServiceLocator.cs
Log:
2007-08-27  Aaron Bockover  <[EMAIL PROTECTED]>

    * autogen.sh: A fresh, hip, autogen

    * src/ServiceLocator.cs:
    * src/Server.cs: Removed old Mono.Zeroconf and Avahi support, replaced
    with new Mono.Zeroconf support (which is a frontend to either
    mDNSResponder or Avahi support, abstracted from applications or other
    libraries)

    * src/Client.cs:
    * src/Database.cs: Fix some compiler warnings
    
    * configure.ac: Require Mono.Zeroconf instead of either Avahi or
    mDNSResponder; check for TagLib#; bump version to 0.4.0

    * sample/SampleServer.cs: Use TagLib instead of Entagged to build the
    sample server

    * sample/Makefile.am: Fixed up to link against TagLib




Property changes on: trunk/daap-sharp
___________________________________________________________________
Name: svn:ignore
   + configure
daap-sharp.pc
Makefile
Makefile.in
config.*
autom4te.cache
INSTALL
missing
aclocal.m4
install-sh



Modified: trunk/daap-sharp/ChangeLog
===================================================================
--- trunk/daap-sharp/ChangeLog  2007-08-28 00:05:21 UTC (rev 84928)
+++ trunk/daap-sharp/ChangeLog  2007-08-28 03:25:36 UTC (rev 84929)
@@ -1,3 +1,24 @@
+2007-08-27  Aaron Bockover  <[EMAIL PROTECTED]>
+
+       * autogen.sh: A fresh, hip, autogen
+
+       * src/ServiceLocator.cs:
+       * src/Server.cs: Removed old Mono.Zeroconf and Avahi support, replaced
+       with new Mono.Zeroconf support (which is a frontend to either 
+       mDNSResponder or Avahi support, abstracted from applications or other
+       libraries)
+
+       * src/Client.cs: 
+       * src/Database.cs: Fix some compiler warnings
+       
+       * configure.ac: Require Mono.Zeroconf instead of either Avahi or 
+       mDNSResponder; check for TagLib#; bump version to 0.4.0
+
+       * sample/SampleServer.cs: Use TagLib instead of Entagged to build the
+       sample server
+
+       * sample/Makefile.am: Fixed up to link against TagLib
+
 2007-01-29  James Willcox  <[EMAIL PROTECTED]>
 
        * src/Database.cs: fix a regression caused by s/Song/Track/ a while

Modified: trunk/daap-sharp/autogen.sh
===================================================================
--- trunk/daap-sharp/autogen.sh 2007-08-28 00:05:21 UTC (rev 84928)
+++ trunk/daap-sharp/autogen.sh 2007-08-28 03:25:36 UTC (rev 84929)
@@ -1,85 +1,62 @@
-#! /bin/sh
+#!/bin/bash
 
-# Ok, simple script to do this.
+PROJECT=daap-sharp
 
-: ${AUTOCONF=autoconf}
-: ${AUTOHEADER=autoheader}
-: ${AUTOMAKE=automake}
-: ${LIBTOOLIZE=libtoolize}
-: ${ACLOCAL=aclocal}
-: ${LIBTOOL=libtool}
+function error () {
+       echo "Error: $1" 1>&2
+       exit 1
+}
 
-srcdir=`dirname $0`
-test -z "$srcdir" && srcdir=.
+function check_autotool_version () {
+       which $1 &>/dev/null || {
+               error "$1 is not installed, and is required to configure 
$PACKAGE"
+       }
 
-ORIGDIR=`pwd`
-cd $srcdir
-PROJECT=daap-sharp
-TEST_TYPE=-f
-FILE=src/Client.cs
-CONFIGURE=configure.ac
-aclocalinclude="-I . $ACLOCAL_FLAGS"
+       version=$($1 --version | head -n 1 | cut -f4 -d' ')
+       major=$(echo $version | cut -f1 -d.)
+       minor=$(echo $version | cut -f2 -d.)
+       major_check=$(echo $2 | cut -f1 -d.)
+       minor_check=$(echo $2 | cut -f2 -d.)
 
-DIE=0
+       if [ $major -lt $major_check ]; then
+               do_bail=yes
+       elif [[ $minor -lt $minor_check && $major = $major_check ]]; then
+               do_bail=yes
+       fi
 
-($AUTOCONF --version) < /dev/null > /dev/null 2>&1 || {
-        echo
-        echo "You must have autoconf installed to compile $PROJECT."
-        echo "Download the appropriate package for your distribution,"
-        echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/";
-        DIE=1
+       if [ x"$do_bail" = x"yes" ]; then
+               error "$1 version $2 or better is required to configure 
$PROJECT"
+       fi
 }
 
-($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
-        echo
-        echo "You must have automake installed to compile $PROJECT."
-        echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.4.tar.gz";
-        echo "(or a newer version if it is available)"
-        DIE=1
+function run () {
+       echo "Running $@ ..."
+       $@ 2>.autogen.log || {
+               cat .autogen.log 1>&2
+               rm .autogen.log
+               error "Could not run $1, which is required to configure 
$PROJECT"
+       }
+       rm .autogen.log
 }
 
-(grep "^AM_PROG_LIBTOOL" configure.ac >/dev/null) && {
-  ($LIBTOOL --version) < /dev/null > /dev/null 2>&1 || {
-    echo
-    echo "**Error**: You must have \`libtool' installed to compile $PROJECT."
-    echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz";
-    echo "(or a newer version if it is available)"
-    DIE=1
-  }
-}
+srcdir=$(dirname $0)
+test -z "$srcdir" && srcdir=.
 
-if test "$DIE" -eq 1; then
-        exit 1
-fi
-                                                                               
 
-test $TEST_TYPE $FILE || {
-        echo "You must run this script in the top-level $PROJECT directory"
-        exit 1
+(test -f $srcdir/configure.ac) || {
+       error "Directory \"$srcdir\" does not look like the top-level $PROJECT 
directory"
 }
 
-if test -z "$*"; then
-        echo "I am going to run ./configure with no arguments - if you wish "
-        echo "to pass any to it, please specify them on the $0 command line."
-fi
+check_autotool_version aclocal 1.9
+check_autotool_version automake 1.9
+check_autotool_version autoconf 2.13
 
-case $CC in
-*xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;;
-esac
+run aclocal -I .
+run autoconf
+run automake -a --gnu
 
-(grep "^AM_PROG_LIBTOOL" configure.ac >/dev/null) && {
-    echo "Running $LIBTOOLIZE ..."
-    $LIBTOOLIZE --force --copy
-}
+if [ $# = 0 ]; then
+       echo "WARNING: I am going to run configure without any arguments."
+fi
 
-echo "Running $ACLOCAL $aclocalinclude ..."
-$ACLOCAL $aclocalinclude
+run ./configure --enable-maintainer-mode $@
 
-echo "Running $AUTOMAKE --gnu $am_opt ..."
-$AUTOMAKE --add-missing --gnu $am_opt
-
-echo "Running $AUTOCONF ..."
-$AUTOCONF
-
-echo Running $srcdir/configure $conf_flags "$@" ...
-$srcdir/configure --enable-maintainer-mode $conf_flags "$@" \
-

Modified: trunk/daap-sharp/configure.ac
===================================================================
--- trunk/daap-sharp/configure.ac       2007-08-28 00:05:21 UTC (rev 84928)
+++ trunk/daap-sharp/configure.ac       2007-08-28 03:25:36 UTC (rev 84929)
@@ -2,8 +2,8 @@
 AC_CANONICAL_SYSTEM
 
 MAJOR_VERSION=0
-MINOR_VERSION=3
-MICRO_VERSION=5
+MINOR_VERSION=4
+MICRO_VERSION=0
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
                                                                                
 
 AM_INIT_AUTOMAKE(daap-sharp, $VERSION)
@@ -24,18 +24,10 @@
        AC_MSG_ERROR([You need to install pkg-config])
 fi
 
-AC_ARG_ENABLE(mdnsd, AC_HELP_STRING([--enable-mdnsd], [Use mDNSResponder 
instead of Avahi]), enable_mdnsd="yes", enable_mdnsd="no")
-AM_CONDITIONAL(ENABLE_MDNSD, test "x$enable_mdnsd" = "xyes")
+PKG_CHECK_MODULES(MZC, mono-zeroconf >= 0.7.1)
+MCS_FLAGS=$MZC_LIBS
+AC_SUBST(MCS_FLAGS)
 
-if test "x$enable_mdnsd" = "xyes"; then
-       MCS_FLAGS="-define:ENABLE_MDNSD"
-       AC_SUBST(MCS_FLAGS)
-else
-       PKG_CHECK_MODULES(AVAHI, avahi-sharp >= 0.6.11)
-       MCS_FLAGS=$AVAHI_LIBS
-       AC_SUBST(MCS_FLAGS)
-fi
-
 dnl Mono          
 AC_PATH_PROG(MONO, mono)
 if test "x$MONO" = "x" ; then
@@ -48,10 +40,10 @@
    AC_MSG_ERROR([Can not find "gmcs" in your PATH])
 fi
 
-PKG_CHECK_MODULES(ENTAGGED, entagged-sharp, have_entagged=yes, 
have_entagged=no)
+PKG_CHECK_MODULES(TAGLIB, taglib-sharp >= 2.0.2, have_taglib=yes, 
have_taglib=no)
 PKG_CHECK_MODULES(MONODOC, monodoc >= 1.1.9, have_monodoc=yes, have_monodoc=no)
 
-AM_CONDITIONAL(HAVE_ENTAGGED, test "x$have_entagged" = "xyes")
+AM_CONDITIONAL(HAVE_TAGLIB, test "x$have_taglib" = "xyes")
 
 if test "x$have_monodoc" = "xyes"; then
     AC_PATH_PROG(MONODOCER, monodocer)
@@ -76,13 +68,9 @@
 sample/Makefile
 ])
 
-zeroconf_lib="Avahi"
-if test "x$enable_mdnsd" = "xyes"; then
-       zeroconf_lib="mDNSResponder"
-fi
+echo "
+    Installation Prefix:     $prefix
+    C# Compiler:             $MCS
 
-echo
-echo "daap-sharp prefix:    $prefix"
-echo "build documentation:  $have_monodoc"
-echo "Zeroconf Client:      $zeroconf_lib"
-echo
+    Developer Documentation: $have_monodoc
+"


Property changes on: trunk/daap-sharp/sample
___________________________________________________________________
Name: svn:external
   + 

Name: svn:ignore
   + *.exe
*.mdb
*.dll
Makefile
Makefile.in



Modified: trunk/daap-sharp/sample/Makefile.am
===================================================================
--- trunk/daap-sharp/sample/Makefile.am 2007-08-28 00:05:21 UTC (rev 84928)
+++ trunk/daap-sharp/sample/Makefile.am 2007-08-28 03:25:36 UTC (rev 84929)
@@ -8,19 +8,16 @@
 MIRRORSOURCES = $(srcdir)/Mirror.cs
 UPDATETESTSOURCES = $(srcdir)/UpdateTest.cs
 
-if HAVE_ENTAGGED
+if HAVE_TAGLIB
 ASSEMBLIES += server.exe
 endif
 
 client.exe: $(CLIENTSOURCES) $(top_builddir)/src/daap-sharp.dll
        $(MCS) -debug -out:$@ $(CLIENTSOURCES) 
-r:$(top_builddir)/src/daap-sharp.dll
 
-entagged-sharp.dll:
-       cp `pkg-config --variable=Libraries entagged-sharp` .
+server.exe: $(SERVERSOURCES) $(top_builddir)/src/daap-sharp.dll
+       $(MCS) -debug -out:$@ $(TAGLIB_LIBS) $(SERVERSOURCES) 
-r:$(top_builddir)/src/daap-sharp.dll
 
-server.exe: $(SERVERSOURCES) $(top_builddir)/src/daap-sharp.dll 
entagged-sharp.dll
-       $(MCS) -debug -out:$@ $(SERVERSOURCES) 
-r:$(top_builddir)/src/daap-sharp.dll -r:entagged-sharp.dll
-
 mirror.exe: $(MIRRORSOURCES) $(top_builddir)/src/daap-sharp.dll
        $(MCS) -debug -out:$@ $(MIRRORSOURCES) 
-r:$(top_builddir)/src/daap-sharp.dll
 

Modified: trunk/daap-sharp/sample/SampleServer.cs
===================================================================
--- trunk/daap-sharp/sample/SampleServer.cs     2007-08-28 00:05:21 UTC (rev 
84928)
+++ trunk/daap-sharp/sample/SampleServer.cs     2007-08-28 03:25:36 UTC (rev 
84929)
@@ -21,7 +21,7 @@
 using System.Net;
 using System.IO;
 using DAAP;
-using Entagged;
+using TagLib;
 
 public class SampleServer
 {
@@ -89,24 +89,24 @@
     private static void AddDirectory (Database db, string dir) {
         Console.WriteLine ("Adding files in: " + dir);
         foreach (string file in Directory.GetFiles (dir)) {
-            AudioFile afw = null;
+            TagLib.File afw = null;
 
             try {
-                afw = new AudioFile (file);
-            } catch (Exception e) {
+                afw = TagLib.File.Create(file);
+            } catch (Exception) {
                 continue;
             }
 
             Track track = new Track ();
-            track.Artist = afw.Artist;
-            track.Album = afw.Album;
-            track.Title = afw.Title;
-            track.Year = afw.Year;
+            track.Artist = afw.Tag.FirstAlbumArtist;
+            track.Album = afw.Tag.Album;
+            track.Title = afw.Tag.Title;
+            track.Year = (int)afw.Tag.Year;
             track.Format = Path.GetExtension (file).Substring (1);
-            track.Duration = afw.Duration;
-            track.Genre = afw.Genre;
-            track.TrackNumber = afw.TrackNumber;
-            track.TrackCount = afw.TrackCount;
+            track.Duration = afw.Properties.Duration;
+            track.Genre = afw.Tag.JoinedGenres;
+            track.TrackNumber = (int)afw.Tag.Track;
+            track.TrackCount = (int)afw.Tag.TrackCount;
             track.DateAdded = DateTime.Now;
             track.DateModified = DateTime.Now;
             track.FileName = file;


Property changes on: trunk/daap-sharp/src
___________________________________________________________________
Name: svn:ignore
   + Makefile.in
Makefile
*.exe
*.dll
*.mdb
*.tree
*.zip
*.config


Modified: trunk/daap-sharp/src/Client.cs
===================================================================
--- trunk/daap-sharp/src/Client.cs      2007-08-28 00:05:21 UTC (rev 84928)
+++ trunk/daap-sharp/src/Client.cs      2007-08-28 03:25:36 UTC (rev 84929)
@@ -79,7 +79,7 @@
         public Client (Service service) : this (service.Address, service.Port) 
{
         }
 
-        public Client (string host, UInt16 port) : this (Dns.Resolve 
(host).AddressList[0], port) {
+        public Client (string host, UInt16 port) : this (Dns.GetHostEntry 
(host).AddressList[0], port) {
         }
 
         public Client (IPAddress address, UInt16 port) {
@@ -151,7 +151,7 @@
                 updateRunning = false;
                 fetcher.KillAll ();
                 fetcher.Fetch ("/logout");
-            } catch (WebException e) {
+            } catch (WebException) {
                 // some servers don't implement this, etc.
             }
             
@@ -214,7 +214,7 @@
                         break;
                     
                     Refresh ();
-                } catch (WebException e) {
+                } catch (WebException) {
                     if (!updateRunning)
                         break;
                     

Modified: trunk/daap-sharp/src/Database.cs
===================================================================
--- trunk/daap-sharp/src/Database.cs    2007-08-28 00:05:21 UTC (rev 84928)
+++ trunk/daap-sharp/src/Database.cs    2007-08-28 03:25:36 UTC (rev 84929)
@@ -266,7 +266,7 @@
 
             try {
                 playlistsData = client.Fetcher.Fetch (String.Format 
("/databases/{0}/containers", id, revquery));
-            } catch (WebException e) {
+            } catch (WebException) {
                 return;
             }
             

Modified: trunk/daap-sharp/src/Makefile.am
===================================================================
--- trunk/daap-sharp/src/Makefile.am    2007-08-28 00:05:21 UTC (rev 84928)
+++ trunk/daap-sharp/src/Makefile.am    2007-08-28 03:25:36 UTC (rev 84929)
@@ -23,8 +23,7 @@
        $(srcdir)/ServiceLocator.cs     \
        $(srcdir)/Track.cs              \
        $(srcdir)/User.cs               \
-       $(srcdir)/Utility.cs            \
-       $(srcdir)/Mono.Zeroconf/*.cs
+       $(srcdir)/Utility.cs
 
 if HAVE_MONODOC
 docdir = $(MONODOC_DIR)

Modified: trunk/daap-sharp/src/Server.cs
===================================================================
--- trunk/daap-sharp/src/Server.cs      2007-08-28 00:05:21 UTC (rev 84928)
+++ trunk/daap-sharp/src/Server.cs      2007-08-28 03:25:36 UTC (rev 84929)
@@ -30,11 +30,7 @@
 using System.Net.Sockets;
 using System.Web;
 
-#if ENABLE_MDNSD
 using Mono.Zeroconf;
-#else
-using Avahi;
-#endif
 
 namespace DAAP {
 
@@ -297,7 +293,7 @@
                         }
 
                         return handler (client, user, uri.AbsolutePath, query, 
range);
-                    } catch (IOException e) {
+                    } catch (IOException) {
                         ret = false;
                     } catch (Exception e) {
                         ret = false;
@@ -314,7 +310,7 @@
 
             try {
                 while (HandleRequest (client)) { }
-            } catch (IOException e) {
+            } catch (IOException) {
                 // ignore
             } catch (Exception e) {
                 Console.Error.WriteLine ("Error handling request: " + e);
@@ -333,7 +329,7 @@
                     Socket client = server.Accept ();
                     clients.Add (client);
                     ThreadPool.QueueUserWorkItem (HandleConnection, client);
-                } catch (SocketException e) {
+                } catch (SocketException) {
                     break;
                 }
             }
@@ -451,12 +447,7 @@
         private bool running;
         private string machineId;
 
-#if !ENABLE_MDNSD
-        private Avahi.Client client;
-        private EntryGroup eg;
-#else
         private RegisterService zc_service;
-#endif
 
         private object eglock = new object ();
         private RevisionManager revmgr = new RevisionManager ();
@@ -541,11 +532,6 @@
             running = true;
             ws.Start ();
 
-#if !ENABLE_MDNSD
-            client = new Avahi.Client ();
-            client.StateChanged += OnClientStateChanged;
-#endif
-
             if (publish)
                 RegisterService ();
         }
@@ -560,13 +546,6 @@
             lock (revmgr) {
                 Monitor.PulseAll (revmgr);
             }
-
-#if !ENABLE_MDNSD
-            if (client != null) {
-                client.Dispose ();
-                client = null;
-            }
-#endif
         }
 
         public void AddDatabase (Database db) {
@@ -597,7 +576,6 @@
             }
         }
 
-#if ENABLE_MDNSD
         private void RegisterService () {
             lock (eglock) {
                 if (zc_service != null) {
@@ -606,7 +584,9 @@
                 
                 string auth = serverInfo.AuthenticationMethod == 
AuthenticationMethod.None ? "false" : "true";
                 
-                zc_service = new RegisterService (serverInfo.Name, null, 
"_daap._tcp");
+                zc_service = new RegisterService ();
+                zc_service.Name = serverInfo.Name;
+                zc_service.RegType = "_daap._tcp";
                 zc_service.Port = (short)ws.BoundPort;
                 zc_service.TxtRecord = new TxtRecord ();
                 zc_service.TxtRecord.Add ("Password", auth);
@@ -618,8 +598,7 @@
                 
                 zc_service.TxtRecord.Add ("txtvers", "1");
                 zc_service.Response += OnRegisterServiceResponse;
-                zc_service.AutoRename = false;
-                zc_service.RegisterAsync ();
+                zc_service.Register ();
             }
         }
         
@@ -638,70 +617,11 @@
         }
         
         private void OnRegisterServiceResponse (object o, 
RegisterServiceEventArgs args) {
-            if (args.NameConflict && Collision != null) {
+            if (args.ServiceError == ServiceErrorCode.AlreadyRegistered && 
Collision != null) {
                 Collision (this, new EventArgs ());
             }
         }
-#else
-        private void OnClientStateChanged (object o, ClientStateArgs args) {
-            if (publish && args.State == ClientState.Running) {
-                RegisterService ();
-            }
-        }
-        
-        private void RegisterService () {
-            lock (eglock) {
-                
-                if (eg != null) {
-                    eg.Reset ();
-                } else {
-                    eg = new EntryGroup (client);
-                    eg.StateChanged += OnEntryGroupStateChanged;
-                }
 
-                try {
-                    string auth = serverInfo.AuthenticationMethod == 
AuthenticationMethod.None ? "false" : "true";
-
-                    List<string> txtdata = new List<string> ();
-                    txtdata.Add ("Password=" + auth);
-                    txtdata.Add ("Machine Name=" + serverInfo.Name);
-
-                    if (machineId != null) {
-                        txtdata.Add ("Machine ID=" + machineId);
-                    }
-                    
-                    txtdata.Add ("txtvers=1");
-                    
-                    eg.AddService (serverInfo.Name, "_daap._tcp", "", 
ws.BoundPort, txtdata.ToArray ());
-                    eg.Commit ();
-                } catch (ClientException e) {
-                    if (e.ErrorCode == ErrorCode.Collision && Collision != 
null) {
-                        Collision (this, new EventArgs ());
-                    } else {
-                        throw e;
-                    }
-                }
-            }
-        }
-
-        private void UnregisterService () {
-            lock (eglock) {
-                if (eg == null)
-                    return;
-
-                eg.Reset ();
-                eg.Dispose ();
-                eg = null;
-            }
-        }
-
-        private void OnEntryGroupStateChanged (object o, EntryGroupStateArgs 
args) {
-            if (args.State == EntryGroupState.Collision && Collision != null) {
-                Collision (this, new EventArgs ());
-            }
-        }
-#endif
-
         private void ExpireSessions () {
             lock (sessions) {
                 foreach (int s in new List<int> (sessions.Keys)) {
@@ -857,7 +777,7 @@
                         
                         try {
                             ws.WriteResponseStream (client, trackStream, 
trackLength);
-                        } catch (IOException e) {
+                        } catch (IOException) {
                         }
                     } else {
                         ws.WriteResponse (client, 
HttpStatusCode.InternalServerError, "no file");

Modified: trunk/daap-sharp/src/ServiceLocator.cs
===================================================================
--- trunk/daap-sharp/src/ServiceLocator.cs      2007-08-28 00:05:21 UTC (rev 
84928)
+++ trunk/daap-sharp/src/ServiceLocator.cs      2007-08-28 03:25:36 UTC (rev 
84929)
@@ -22,11 +22,7 @@
 using System.Text;
 using System.Collections;
 
-#if ENABLE_MDNSD
 using Mono.Zeroconf;
-#else
-using Avahi;
-#endif
 
 namespace DAAP {
 
@@ -86,8 +82,6 @@
         }
     }
     
-    
-#if ENABLE_MDNSD
     public class ServiceLocator {
         
         private ServiceBrowser browser;
@@ -111,10 +105,10 @@
                 Stop ();
             }
         
-            browser = new ServiceBrowser ("_daap._tcp");
+            browser = new ServiceBrowser ();
             browser.ServiceAdded += OnServiceAdded;
             browser.ServiceRemoved += OnServiceRemoved;
-            browser.StartAsync ();
+            browser.Browse ("_daap._tcp", "local");
         }
         
         public void Stop () {
@@ -128,9 +122,9 @@
             args.Service.Resolve ();
         }
         
-        private void OnServiceResolved (object o, EventArgs args) {
-            BrowseService zc_service = o as BrowseService;
-
+        private void OnServiceResolved (object o, ServiceResolvedEventArgs 
args) {
+            IResolvableService zc_service = args.Service;
+            
             string name = zc_service.Name;
             string machineId = null;
             
@@ -175,118 +169,4 @@
             }
         }
     }
-#else
-    public class ServiceLocator {
-
-        private Avahi.Client client;
-        private ServiceBrowser browser;
-        private Hashtable services = new Hashtable ();
-        private ArrayList resolvers = new ArrayList ();
-        private bool showLocals = false;
-
-        public event ServiceHandler Found;
-        public event ServiceHandler Removed;
-
-        public bool ShowLocalServices {
-            get { return showLocals; }
-            set { showLocals = value; }
-        }
-        
-        public IEnumerable Services {
-            get { return services; }
-        }
-        
-        public ServiceLocator () {
-        }
-
-        public void Start () {
-            if (client == null) {
-                client = new Avahi.Client ();
-                browser = new ServiceBrowser (client, "_daap._tcp");
-                browser.ServiceAdded += OnServiceAdded;
-                browser.ServiceRemoved += OnServiceRemoved;
-            }
-        }
-
-        public void Stop () {
-            if (client != null) {
-                services.Clear ();
-                browser.Dispose ();
-                client.Dispose ();
-                client = null;
-                browser = null;
-            }
-        }
-
-        private void OnServiceAdded (object o, ServiceInfoArgs args) {
-            if ((args.Service.Flags & LookupResultFlags.Local) > 0 && 
!showLocals)
-                return;
-            
-            ServiceResolver resolver = new ServiceResolver (client, 
args.Service);
-            resolvers.Add (resolver);
-            resolver.Found += OnServiceResolved;
-            resolver.Timeout += OnServiceTimeout;
-        }
-
-        private void OnServiceResolved (object o, ServiceInfoArgs args) {
-
-            resolvers.Remove (o);
-            (o as ServiceResolver).Dispose ();
-
-            string name = args.Service.Name;
-            string machineId = null;
-
-            if (services[args.Service.Name] != null) {
-                return; // we already have it somehow
-            }
-            
-            bool pwRequired = false;
-
-            // iTunes tacks this on to indicate a passsword protected share.  
Ugh.
-            if (name.EndsWith ("_PW")) {
-                name = name.Substring (0, name.Length - 3);
-                pwRequired = true;
-            }
-            
-            foreach (byte[] txt in args.Service.Text) {
-                string txtstr = Encoding.UTF8.GetString (txt);
-
-                string[] splitstr = txtstr.Split('=');
-
-                if (splitstr.Length < 2)
-                    continue;
-
-                if (splitstr[0].ToLower () == "password") {
-                    pwRequired = splitstr[1].ToLower () == "true";
-                } else if (splitstr[0].ToLower () == "machine name") {
-                    name = splitstr[1];
-                } else if (splitstr[0].ToLower () == "machine id") {
-                    machineId = splitstr[1];
-                }
-            }
-
-            Service svc = new Service (args.Service.Address, args.Service.Port,
-                                       name, pwRequired, machineId);
-
-            services[svc.Name] = svc;
-
-            if (Found != null)
-                Found (this, new ServiceArgs (svc));
-        }
-
-        private void OnServiceTimeout (object o, EventArgs args) {
-            Console.Error.WriteLine ("Failed to resolve");
-        }
-
-        private void OnServiceRemoved (object o, ServiceInfoArgs args) {
-            Service svc = (Service) services[args.Service.Name];
-            if (svc != null) {
-                services.Remove (svc.Name);
-
-                if (Removed != null)
-                    Removed (this, new ServiceArgs (svc));
-            }
-        }
-    }
-#endif
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to