banshee r3599 - in trunk/banshee: . src/Extensions/Banshee.Daap src/Extensions/Banshee.Daap/Banshee.Daap src/Extensions/Banshee.Daap/Resources src/Extensions/Banshee.Daap/daap-sharp



Author: ahixon
Date: Sun Mar 30 07:43:20 2008
New Revision: 3599
URL: http://svn.gnome.org/viewvc/banshee?rev=3599&view=rev

Log:
2008-03-30  Alexander Hixon  <hixon alexander mediati org>

	* src/Extensions/Banshee.Daap/daap-sharp: Copy across daap-sharp from
	old-code.

	* src/Extensions/Banshee.Daap/Banshee.Daap.mdp:
	* src/Extensions/Banshee.Daap/Makefile.am:
	* src/Extensions/Banshee.Daap/Banshee.Daap:
	* src/Extensions/Banshee.Daap/Banshee.Daap/DaapSource.cs:
	* src/Extensions/Banshee.Daap/Banshee.Daap/DaapService.cs:
	* src/Extensions/Banshee.Daap/Banshee.Daap/DaapContainerSource.cs:
	* src/Extensions/Banshee.Daap/Resources/Banshee.Daap.addin.xml: Import
	Daap extension that I've completed so far. Isn't hooked up to the 
	the Extensions Makefile yet, so this doesn't build. Also, if you did
	hook it up, my autotools foo isn't up to scratch so you'd probably have
	to modify something. :)


Added:
   trunk/banshee/src/Extensions/Banshee.Daap/
   trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/
   trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap.mdp
   trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapContainerSource.cs
   trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapService.cs
   trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapSource.cs
   trunk/banshee/src/Extensions/Banshee.Daap/Makefile.am
   trunk/banshee/src/Extensions/Banshee.Daap/Resources/
   trunk/banshee/src/Extensions/Banshee.Daap/Resources/Banshee.Daap.addin.xml
   trunk/banshee/src/Extensions/Banshee.Daap/daap-sharp/
      - copied from r3598, /trunk/banshee/old-code/Plugins/Banshee.Plugins.Daap/daap-sharp/
Modified:
   trunk/banshee/ChangeLog

Added: trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap.mdp
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap.mdp	Sun Mar 30 07:43:20 2008
@@ -0,0 +1,28 @@
+<Project name="Banshee.Daap" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
+  <Configurations active="Debug">
+    <Configuration name="Debug" ctype="DotNetProjectConfiguration">
+      <Output directory="../../../bin" assemblyKeyFile="." assembly="Banshee.Daap" />
+      <Build debugmode="True" target="Library" />
+      <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
+      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+    </Configuration>
+  </Configurations>
+  <Contents>
+    <File name="Banshee.Daap.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
+  </Contents>
+  <References>
+    <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />
+    <ProjectReference type="Project" localcopy="True" refto="Banshee.Services" />
+    <ProjectReference type="Project" localcopy="True" refto="Hyena" />
+    <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+  </References>
+  <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am">
+    <BuildFilesVar Sync="True" Name="SOURCES" />
+    <DeployFilesVar />
+    <ResourcesVar Sync="True" Name="RESOURCES" />
+    <OthersVar />
+    <GacRefVar />
+    <AsmRefVar />
+    <ProjectRefVar />
+  </MonoDevelop.Autotools.MakefileInfo>
+</Project>

Added: trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapContainerSource.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapContainerSource.cs	Sun Mar 30 07:43:20 2008
@@ -0,0 +1,79 @@
+//
+// DaapContainerSource.cs
+//
+// Authors:
+//   Alexander Hixon <hixon alexander mediati org>
+//
+// Copyright (C) 2008 Alexander Hixon
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using Mono.Unix;
+
+using Banshee.Base;
+using Banshee.Collection;
+using Banshee.Sources;
+using Banshee.ServiceStack;
+
+namespace Banshee.Daap
+{
+    public class DaapContainerSource : Source
+    {
+        public DaapContainerSource () :  base (Catalog.GetString ("Shared Music"), Catalog.GetString ("Shared Music"), 300)
+        {
+            Properties.SetString ("Icon.Name", "applications-internet");
+        }
+        
+        public override bool CanRename {
+            get { return false; }
+        }
+        
+        public override bool? AutoExpand {
+            get { return true; }
+        }
+        
+        public override bool CanActivate {
+            get { return false; }
+        }
+        
+        /*private int count;
+        public override int Count {
+            get { return count; }
+        }
+        
+        public override void AddChildSource (Source child)
+        {
+            count++;
+            base.AddChildSource (child);
+        }
+        
+        public override void RemoveChildSource (Source child)
+        {
+            count--;
+            base.RemoveChildSource (child);
+        }*/
+        
+        protected override string TypeUniqueId {
+            get { return "daap-container"; }
+        }
+    }
+}

Added: trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapService.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapService.cs	Sun Mar 30 07:43:20 2008
@@ -0,0 +1,101 @@
+//
+// DaapService.cs
+//
+// Authors:
+//   Alexander Hixon <hixon alexander mediati org>
+//
+// Copyright (C) 2008 Alexander Hixon
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using Mono.Unix;
+using DAAP;
+
+using Banshee.Base;
+using Banshee.Collection;
+using Banshee.Sources;
+using Banshee.ServiceStack;
+
+namespace Banshee.Daap
+{
+    public class DaapService : IExtensionService, IDisposable
+    {
+        private ServiceLocator locator;
+        
+        private DaapContainerSource container;
+        private Dictionary<string, DaapSource> source_map;
+        
+        void IExtensionService.Initialize ()
+        {
+            // Add the source, even though its empty, so that the user sees the
+            // plugin is enabled, just no child sources yet.
+            source_map = new Dictionary<string, DaapSource> ();
+            container = new DaapContainerSource ();
+            ServiceManager.SourceManager.AddSource (container);
+            
+            // Now start looking for services.
+            // We do this after creating the source because if we do it before
+            // there's a race condition where we get a service before the source
+            // is added.
+            locator = new ServiceLocator ();
+            locator.Found += OnServiceFound;
+            locator.Removed += OnServiceRemoved;
+            locator.ShowLocalServices = true;
+            locator.Start ();
+            
+            proxy_server = new DaapProxyWebServer ();
+            proxy_server.Start ();
+        }
+        
+        public void Dispose ()
+        {
+            if (locator != null) {
+                locator.Stop ();
+                locator.Found -= OnServiceFound;
+                locator.Removed -= OnServiceRemoved;
+                locator = null;
+            }
+        }
+        
+        private void OnServiceFound (object o, ServiceArgs args)
+        {
+            DaapSource source = new DaapSource (args.Service);
+            source_map.Add (String.Format ("{0}:{1}", args.Service.Address, args.Service.Port), source);
+            container.AddChildSource (source);
+        }
+        
+        private void OnServiceRemoved (object o, ServiceArgs args)
+        {
+            string key = String.Format ("{0}:{1}", args.Service.Address, args.Service.Port);
+            DaapSource source = source_map [key];
+            
+            source.Disconnect (true);
+            container.RemoveChildSource (source);
+            source_map.Remove (key);
+        }
+        
+        string IService.ServiceName {
+            get { return "DaapService"; }
+        }
+    }
+}

Added: trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapSource.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapSource.cs	Sun Mar 30 07:43:20 2008
@@ -0,0 +1,242 @@
+//
+// DaapSource.cs
+//
+// Authors:
+//   Alexander Hixon <hixon alexander mediati org>
+//
+// Copyright (C) 2008 Alexander Hixon
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using Mono.Unix;
+using DAAP;
+
+using Banshee.Base;
+using Banshee.Collection;
+using Banshee.Collection.Database;
+using Banshee.Sources;
+using Banshee.ServiceStack;
+
+namespace Banshee.Daap
+{
+    public class DaapSource : PrimarySource, IDurationAggregator, IDisposable
+    {
+        private Service service;
+        private DAAP.Client client;
+        private DAAP.Database database;
+        
+        private bool is_activating;
+        private SourceMessage status_message;
+        
+        public DaapSource (Service service) : base (Catalog.GetString ("Music Share"), service.Name, (service.Address.ToString () + service.Port).Replace (":", "").Replace (".", ""), 300)
+        {
+            this.service = service;
+            Properties.SetString ("Icon.Name", "computer");
+            
+            AfterInitialized ();
+        }
+        
+        public override void Activate ()
+        {
+            if (client != null || is_activating) {
+            	return;
+            }
+            
+            is_activating = true;
+            base.Activate ();
+            
+            SetMessage (String.Format (Catalog.GetString ("Connecting to {0}"), service.Name), true);
+            
+            Console.WriteLine ("Connecting to {0}:{1}", service.Address, service.Port);
+            
+            ThreadAssist.Spawn (delegate {
+                try {
+                    // XXX: We get connect failures if we try with IPv6 address - what's up with that?!
+                    // Investigate.
+                    
+                    //client = new Client (service);
+                    client = new Client (System.Net.IPAddress.Parse ("127.0.0.1"), service.Port);
+                    client.Updated += OnClientUpdated;
+                    
+                    if (client.AuthenticationMethod == AuthenticationMethod.None) {
+                        client.Login ();
+                    }/* else {
+                        ThreadAssist.ProxyToMain (PromptLogin);
+                    }*/
+                } catch(Exception e) {
+                    /*ThreadAssist.ProxyToMain(delegate {
+                        DaapErrorView error_view = new DaapErrorView(this, DaapErrorType.BrokenAuthentication);
+                        while(box.Children.Length > 0) {
+                            box.Remove(box.Children[0]);
+                        }
+                        box.PackStart(error_view, true, true, 0);
+                        error_view.Show();
+                    });*/
+                    Console.WriteLine ("Error while connecting to remote: {0}", e);
+                }
+               
+                is_activating = false;
+            });
+            
+            Reload ();
+        }
+        
+        internal bool Disconnect (bool logout)
+        {
+            if (client != null) {
+                if (logout) {
+                    client.Logout ();
+                }
+                
+                client.Dispose ();
+                client = null;
+                database = null;
+            }
+            
+            if (database != null) {
+                database.TrackAdded -= OnDatabaseTrackAdded;
+                // TODO
+                //database.TrackRemoved -= OnDatabaseTrackRemoved;
+                database = null;
+            }
+
+            ClearChildSources();
+            
+            return true;
+        }
+        
+        public void Dispose ()
+        {
+            Disconnect (true);
+        }
+        
+        private void SetMessage (string message, bool spinner)
+        {
+            if (status_message == null) {
+                status_message = new SourceMessage (this);
+                PushMessage (status_message);
+                
+                // Nice hack here.
+                status_message.FreezeNotify ();
+                status_message.Text = message;
+                status_message.CanClose = !spinner;
+                status_message.IsSpinning = spinner;
+                status_message.SetIconName (null);
+                
+                status_message.ThawNotify ();
+            }
+            
+            //string status_name = String.Format ("<i>{0}</i>", GLib.Markup.EscapeText (Name));
+            
+            status_message.FreezeNotify ();
+            status_message.Text = message;
+            status_message.CanClose = !spinner;
+            status_message.IsSpinning = spinner;
+            status_message.SetIconName (null);
+            
+            status_message.ThawNotify ();
+        }
+        
+        private void HideMessage ()
+        {
+            if (status_message != null) {
+                RemoveMessage (status_message);
+                status_message = null;
+            }
+        }
+        
+        private void OnClientUpdated (object o, EventArgs args)
+        {
+            if (database == null && client.Databases.Count > 0) {
+                database = client.Databases[0];
+                database.TrackAdded += OnDatabaseTrackAdded;
+                //database.TrackRemoved += OnDatabaseTrackRemoved;
+                //database_proxy.Database = database;
+                //DaapCore.ProxyServer.RegisterDatabase (database);
+                //AddPlaylistSources ();
+                
+                foreach (Track track in database.Tracks) {
+                    //track_model.Add (track);
+                    DatabaseTrackInfo r = new DatabaseTrackInfo ();
+                    r.TrackTitle = track.Title;
+                    r.AlbumTitle = track.Album;
+                    r.ArtistName = track.Artist;
+                    
+                    r.TrackNumber = track.TrackNumber;
+                    r.Year = track.Year;
+                    r.Duration = track.Duration;
+                    r.PrimarySource = this;
+                    
+                    r.Save ();
+                }
+                
+                Reload ();
+                
+                ThreadAssist.ProxyToMain(delegate {
+                    HideMessage ();
+                });
+            }
+            
+            Name = client.Name;
+            
+            OnUpdated ();
+        }
+        
+        public void OnDatabaseTrackAdded (object o, TrackArgs args)
+        {
+            Console.WriteLine ("Added: {0}", args.Track);
+        }
+        
+        public override bool CanRename {
+            get { return false; }
+        }
+        
+        public override bool CanRemoveTracks {
+            get { return false; }
+        }
+
+        public override bool CanDeleteTracks {
+            get { return false; }
+        }
+
+        public override bool ConfirmRemoveTracks {
+            get { return false; }
+        }
+
+        public override void RemoveSelectedTracks ()
+        {
+        }
+
+        public override void DeleteSelectedTracks ()
+        {
+            throw new Exception ("Should not call DeleteSelectedTracks on DaapSource");
+        }
+        
+        public override bool HasDependencies {
+            get { return false; }
+        }
+        
+        protected override string TypeUniqueId {
+            get { return "daap"; }
+        }
+    }
+}

Added: trunk/banshee/src/Extensions/Banshee.Daap/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Makefile.am	Sun Mar 30 07:43:20 2008
@@ -0,0 +1,15 @@
+ASSEMBLY = Banshee.Daap
+TARGET = library
+LINK = $(REF_EXTENSION_PLAYQUEUE) $(LINK_MONOZEROCONF) $(LINK_ICSHARP_ZIP_LIB) $(LINK_SYSTEM_WEB) -r:/home/alex/Desktop/Downloads/mono-zeroconf-0.7.5/src/Mono.Zeroconf/Mono.Zeroconf.dll
+INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
+
+SOURCES = Banshee.Daap/DaapService.cs \
+    Banshee.Daap/DaapContainerSource.cs \
+    Banshee.Daap/DaapSource.cs \
+    daap-sharp/*.cs
+
+RESOURCES = daap-sharp/content-codes \
+    Resources/Banshee.Daap.addin.xml
+
+include $(top_srcdir)/build/build.mk
+

Added: trunk/banshee/src/Extensions/Banshee.Daap/Resources/Banshee.Daap.addin.xml
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Resources/Banshee.Daap.addin.xml	Sun Mar 30 07:43:20 2008
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Addin 
+    id="Banshee.Daap"
+    version="1.0"
+    compatVersion="1.0"
+    copyright="Â 2008 Alexander Hixon. Licensed under the MIT X11 license."
+    name="DAAP"
+    category=""
+    description=""
+    author="Alexander Hixon"
+    url="http://banshee-project.org/";
+    defaultEnabled="true">
+
+  <Dependencies>
+    <Addin id="Banshee.Services" version="1.0"/>
+    <Addin id="Banshee.ThickClient" version="1.0"/>
+  </Dependencies>
+
+  <!--<Extension path="/Banshee/SourceManager/Source">
+    <Source class="Banshee.Daap.DaapSource"/>
+  </Extension>-->
+
+  <Extension path="/Banshee/ServiceManager/Service">
+    <Service class="Banshee.Daap.DaapService"/>
+  </Extension>
+
+</Addin>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]