banshee r4675 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Indexer src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper



Author: abock
Date: Thu Oct  9 01:49:50 2008
New Revision: 4675
URL: http://svn.gnome.org/viewvc/banshee?rev=4675&view=rev

Log:
* banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexerService.cs:
* banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexerService.cs:
  Make time a long, since it's time_t

* banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs:
  Support getting available export fields, and setting which fields you
  want exported to you; abstract the HasCollectionChanged by adding
  CollectionCount and CollectionLastModified abstract members that make
  the API a little less confusing

Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexerService.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexerService.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs	Thu Oct  9 01:49:50 2008
@@ -34,6 +34,7 @@
     public abstract class SimpleIndexerClient
     {
         private _SimpleIndexerClient client;
+        private List<string> export_fields;
         
         public SimpleIndexerClient ()
         {
@@ -44,12 +45,50 @@
         {
             client.Start ();
         }
-    
+        
+        public string [] GetAvailableExportFields ()
+        {
+            return client.GetAvailableExportFields ();
+        }
+        
+        public void AddExportField (params string [] fields)
+        {
+            if (export_fields == null) {
+                export_fields = new List<string> ();
+            }
+            
+            foreach (string field in fields) {
+                if (!export_fields.Contains (field)) {
+                    export_fields.Add (field);
+                }
+            }
+        }
+        
+        public bool RemoveExportField (string field)
+        {
+            if (export_fields != null) {
+                return export_fields.Remove (field);
+            }
+            
+            return false;
+        }
+        
+        public IEnumerable<string> ExportFields {
+            get { 
+                if (export_fields == null) {
+                    yield break;
+                }
+                
+                foreach (string field in export_fields) {
+                    yield return field;
+                }
+            }
+        }
+        
         protected abstract void IndexResult (IDictionary<string, object> result);
-    
         protected abstract void OnShutdownWhileIndexing ();
-        
-        protected abstract bool HasCollectionChanged { get; }
+        protected abstract int CollectionCount { get; }
+        protected abstract DateTime CollectionLastModified { get; }
             
         private class _SimpleIndexerClient : IndexerClient
         {
@@ -63,6 +102,11 @@
             {
                 this.parent = parent;
             }
+            
+            public string [] GetAvailableExportFields ()
+            {
+                return Service.GetAvailableExportFields ();
+            }
         
             protected override void ResetState ()
             {
@@ -82,6 +126,10 @@
                 
                 bool shutdown_while_indexing = false;
                 
+                if (parent.export_fields != null && parent.export_fields.Count > 0) {
+                    indexer.SetExportFields (parent.export_fields.ToArray ());
+                }
+                
                 for (int i = 0, models = indexer.GetModelCounts (); i < models; i++) {
                     for (int j = 0, items = indexer.GetModelResultsCount (i); j < items; j++) {
                         if (Shutdown) {
@@ -106,7 +154,8 @@
             }
             
             protected override bool HasCollectionChanged {
-                get { return parent.HasCollectionChanged; }
+                get { return Service.HasCollectionCountChanged (parent.CollectionCount) || 
+                    Service.HasCollectionLastModifiedChanged (Hyena.DateTimeUtil.ToTimeT (parent.CollectionLastModified)); }
             }
 
             private bool Shutdown {

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexerService.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexerService.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexerService.cs	Thu Oct  9 01:49:50 2008
@@ -136,7 +136,7 @@
             }
         }
         
-        public bool HasCollectionLastModifiedChanged (int time)
+        public bool HasCollectionLastModifiedChanged (long time)
         {
             lock (this) {
                 long last_updated = 0;

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexerService.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexerService.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexerService.cs	Thu Oct  9 01:49:50 2008
@@ -44,6 +44,6 @@
         ObjectPath CreateIndexer ();
         string [] GetAvailableExportFields ();
         bool HasCollectionCountChanged (int count);
-        bool HasCollectionLastModifiedChanged (int time);
+        bool HasCollectionLastModifiedChanged (long time);
     }
 }



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