banshee r4673 - in trunk/banshee: . src/Clients/Beroe/Beroe src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4673 - in trunk/banshee: . src/Clients/Beroe/Beroe src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper
- Date: Wed, 8 Oct 2008 23:38:23 +0000 (UTC)
Author: abock
Date: Wed Oct 8 23:38:23 2008
New Revision: 4673
URL: http://svn.gnome.org/viewvc/banshee?rev=4673&view=rev
Log:
* banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs:
Pulled out the implementation from the Beroe remote client example
into a further encapsulation
* banshee/src/Clients/Beroe/Beroe/RemoteClient.cs: Now extend the new
SimpleIndexerClient
Added:
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Clients/Beroe/Beroe/RemoteClient.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Services.csproj
trunk/banshee/src/Core/Banshee.Services/Makefile.am
Modified: trunk/banshee/src/Clients/Beroe/Beroe/RemoteClient.cs
==============================================================================
--- trunk/banshee/src/Clients/Beroe/Beroe/RemoteClient.cs (original)
+++ trunk/banshee/src/Clients/Beroe/Beroe/RemoteClient.cs Wed Oct 8 23:38:23 2008
@@ -27,73 +27,21 @@
//
using System;
-using System.Threading;
using System.Collections.Generic;
using Banshee.Collection.Indexer;
namespace Beroe
{
- public class RemoteClient : Banshee.Collection.Indexer.RemoteHelper.IndexerClient
+ public class RemoteClient : Banshee.Collection.Indexer.RemoteHelper.SimpleIndexerClient
{
- private object shutdown_mutex = new object ();
- private bool indexer_running;
- private bool shutdown_requested;
-
- public RemoteClient ()
+ protected override void IndexResult(IDictionary<string, object> result)
{
- ShowDebugMessages = true;
+ Console.WriteLine (result["URI"]);
}
- protected override void ResetState ()
+ protected override void OnShutdownWhileIndexing()
{
- lock (shutdown_mutex) {
- if (indexer_running) {
- shutdown_requested = true;
- }
- }
- }
-
- protected override void UpdateIndex ()
- {
- lock (shutdown_mutex) {
- indexer_running = true;
- shutdown_requested = false;
- }
-
- Sleep (5);
-
- ICollectionIndexer indexer = CreateIndexer ();
- indexer.Index ();
-
- for (int i = 0, models = indexer.GetModelCounts (); i < models; i++) {
- for (int j = 0, items = indexer.GetModelResultsCount (i); j < items && !Shutdown; j++) {
- IDictionary<string, object> result = indexer.GetResult (i, j);
- Console.WriteLine (result["URI"]);
- }
- }
-
- indexer.Dispose ();
-
- lock (shutdown_mutex) {
- indexer_running = false;
- shutdown_requested = false;
- }
- }
-
- private void Sleep (int seconds)
- {
- int i = 0;
- Console.Write ("Sleeping... ");
- while (i++ < seconds && !Shutdown) {
- Console.Write ("{0} ", i);
- System.Threading.Thread.Sleep (1000);
- }
- Console.WriteLine (": Done");
- }
-
- private bool Shutdown {
- get { lock (shutdown_mutex) { return shutdown_requested || CleanupAndShutdown; } }
}
protected override bool HasCollectionChanged {
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs Wed Oct 8 23:38:23 2008
@@ -0,0 +1,93 @@
+//
+// SimpleIndexerClient.cs
+//
+// Author:
+// Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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;
+
+namespace Banshee.Collection.Indexer.RemoteHelper
+{
+ public abstract class SimpleIndexerClient : IndexerClient
+ {
+ private object shutdown_mutex = new object ();
+ private bool indexer_running;
+ private bool shutdown_requested;
+
+ protected override void ResetState ()
+ {
+ lock (shutdown_mutex) {
+ if (indexer_running) {
+ shutdown_requested = true;
+ }
+ }
+ }
+
+ protected override void UpdateIndex ()
+ {
+ lock (shutdown_mutex) {
+ indexer_running = true;
+ shutdown_requested = false;
+ }
+
+ bool shutdown_while_indexing = false;;
+ ICollectionIndexer indexer = CreateIndexer ();
+ indexer.Index ();
+
+ for (int i = 0, models = indexer.GetModelCounts (); i < models; i++) {
+ for (int j = 0, items = indexer.GetModelResultsCount (i); j < items; j++) {
+ if (Shutdown) {
+ shutdown_while_indexing = true;
+ break;
+ }
+
+ IndexResult (indexer.GetResult (i, j));
+ }
+
+ if (shutdown_while_indexing) {
+ break;
+ }
+ }
+
+ indexer.Dispose ();
+
+ lock (shutdown_mutex) {
+ indexer_running = false;
+ shutdown_requested = false;
+ }
+
+ OnShutdownWhileIndexing ();
+ }
+
+ protected abstract void OnShutdownWhileIndexing ();
+
+ protected abstract void IndexResult (IDictionary<string, object> result);
+
+ private bool Shutdown {
+ get { lock (shutdown_mutex) { return shutdown_requested || CleanupAndShutdown; } }
+ }
+ }
+}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.csproj
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.csproj (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.csproj Wed Oct 8 23:38:23 2008
@@ -235,6 +235,7 @@
<Compile Include="Banshee.Collection.Indexer\IIndexerClient.cs" />
<Compile Include="Banshee.Collection\RescanPipeline.cs" />
<Compile Include="Banshee.Collection.Indexer.RemoteHelper\IndexerClient.cs" />
+ <Compile Include="Banshee.Collection.Indexer.RemoteHelper\SimpleIndexerClient.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Banshee.Services.addin.xml" />
Modified: trunk/banshee/src/Core/Banshee.Services/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Makefile.am (original)
+++ trunk/banshee/src/Core/Banshee.Services/Makefile.am Wed Oct 8 23:38:23 2008
@@ -23,6 +23,7 @@
Banshee.Collection.Database/IDatabaseTrackModelProvider.cs \
Banshee.Collection.Database/QueryFilterInfo.cs \
Banshee.Collection.Indexer.RemoteHelper/IndexerClient.cs \
+ Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs \
Banshee.Collection.Indexer/CollectionIndexer.cs \
Banshee.Collection.Indexer/CollectionIndexerService.cs \
Banshee.Collection.Indexer/ICollectionIndexer.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]