banshee r4683 - in trunk/banshee: . build build/m4/banshee src/Clients/Beroe src/Clients/Beroe/Beroe src/Core/Banshee.CollectionIndexer src/Core/Banshee.CollectionIndexer/Banshee.Collection.Indexer src/Core/Banshee.CollectionIndexer/Demo src/Core/Banshee.CollectionIndexer/Hyena src/Core/Banshee.Core/Resources src/Core/Banshee.Services/Banshee.Collection.Indexer
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4683 - in trunk/banshee: . build build/m4/banshee src/Clients/Beroe src/Clients/Beroe/Beroe src/Core/Banshee.CollectionIndexer src/Core/Banshee.CollectionIndexer/Banshee.Collection.Indexer src/Core/Banshee.CollectionIndexer/Demo src/Core/Banshee.CollectionIndexer/Hyena src/Core/Banshee.Core/Resources src/Core/Banshee.Services/Banshee.Collection.Indexer
- Date: Fri, 10 Oct 2008 00:58:48 +0000 (UTC)
Author: abock
Date: Fri Oct 10 00:58:48 2008
New Revision: 4683
URL: http://svn.gnome.org/viewvc/banshee?rev=4683&view=rev
Log:
2008-10-09 Aaron Bockover <abock gnome org>
* src/Clients/Beroe/Beroe/IndexerClient.cs:
* src/Clients/Beroe/Beroe/RemoteClient.cs: Remove the client from the
indexer server
* src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexer.cs:
* src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexer.cs:
Fix standalone API issues
* src/Core/Banshee.CollectionIndexer/Hyena/ConsoleCrayon.cs:
* src/Core/Banshee.CollectionIndexer/Hyena/Log.cs:
* src/Core/Banshee.CollectionIndexer/Hyena/DateTimeUtil.cs: Synced from
Hyena
* src/Core/Banshee.CollectionIndexer/Demo/RemoteClient.cs: Moved the
demo indexer client into its own assembly with simple build
* src/Core/Banshee.CollectionIndexer/update-includes: Script to sync
the stuff from hyena and the indexer dbus interfaces that we need
Added:
trunk/banshee/src/Core/Banshee.CollectionIndexer/Banshee.Collection.Indexer/
trunk/banshee/src/Core/Banshee.CollectionIndexer/Banshee.Collection.Indexer/ICollectionIndexer.cs
trunk/banshee/src/Core/Banshee.CollectionIndexer/Banshee.Collection.Indexer/ICollectionIndexerService.cs
trunk/banshee/src/Core/Banshee.CollectionIndexer/Demo/ (props changed)
trunk/banshee/src/Core/Banshee.CollectionIndexer/Demo/RemoteClient.cs
trunk/banshee/src/Core/Banshee.CollectionIndexer/Hyena/
trunk/banshee/src/Core/Banshee.CollectionIndexer/Hyena/ConsoleCrayon.cs
trunk/banshee/src/Core/Banshee.CollectionIndexer/Hyena/DateTimeUtil.cs
trunk/banshee/src/Core/Banshee.CollectionIndexer/Hyena/Log.cs
trunk/banshee/src/Core/Banshee.CollectionIndexer/update-includes (contents, props changed)
Removed:
trunk/banshee/src/Clients/Beroe/Beroe/RemoteClient.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/build/build.environment.mk
trunk/banshee/build/m4/banshee/dbus.m4
trunk/banshee/src/Clients/Beroe/Beroe.csproj
trunk/banshee/src/Clients/Beroe/Beroe/IndexerClient.cs
trunk/banshee/src/Clients/Beroe/Makefile.am
trunk/banshee/src/Core/Banshee.CollectionIndexer/Banshee.CollectionIndexer.csproj
trunk/banshee/src/Core/Banshee.CollectionIndexer/Makefile.am
trunk/banshee/src/Core/Banshee.Core/Resources/translators.xml
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexer.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexer.cs
Modified: trunk/banshee/build/build.environment.mk
==============================================================================
--- trunk/banshee/build/build.environment.mk (original)
+++ trunk/banshee/build/build.environment.mk Fri Oct 10 00:58:48 2008
@@ -19,7 +19,8 @@
LINK_GTK = $(GTKSHARP_LIBS)
LINK_GCONF = $(GCONFSHARP_LIBS)
LINK_GNOME = $(GNOMESHARP_LIBS)
-LINK_DBUS = $(NDESK_DBUS_LIBS)
+LINK_DBUS = $(NDESK_DBUS_LIBS) $(NDESK_DBUS_GLIB_LIBS)
+LINK_DBUS_NO_GLIB = $(NDESK_DBUS_LIBS)
LINK_TAGLIB = $(TAGLIB_SHARP_LIBS)
LINK_IPOD = $(IPODSHARP_LIBS)
LINK_BOO = $(BOO_LIBS)
@@ -100,7 +101,7 @@
REF_HALIE = $(LINK_BANSHEE_SERVICES_DEPS)
REF_BEROE = $(LINK_BANSHEE_SERVICES_DEPS)
REF_BOOTER = $(LINK_BANSHEE_SERVICES_DEPS)
-REF_BANSHEE_COLLECTIONINDEXER = $(LINK_SYSTEM) $(LINK_DBUS)
+REF_BANSHEE_COLLECTIONINDEXER = $(LINK_SYSTEM) $(LINK_DBUS_NO_GLIB) $(LINK_MONO_POSIX)
# Dap
REF_DAP = $(LINK_BANSHEE_SERVICES_DEPS) $(LINK_BANSHEE_THICKCLIENT_DEPS)
Modified: trunk/banshee/build/m4/banshee/dbus.m4
==============================================================================
--- trunk/banshee/build/m4/banshee/dbus.m4 (original)
+++ trunk/banshee/build/m4/banshee/dbus.m4 Fri Oct 10 00:58:48 2008
@@ -1,8 +1,9 @@
AC_DEFUN([BANSHEE_CHECK_NDESK_DBUS],
[
- PKG_CHECK_MODULES(NDESK_DBUS,
- ndesk-dbus-1.0 >= 0.5 \
- ndesk-dbus-glib-1.0 >= 0.3)
+ PKG_CHECK_MODULES(NDESK_DBUS_GLIB, ndesk-dbus-glib-1.0 >= 0.3)
+ AC_SUBST(NDESK_DBUS_GLIB_LIBS)
+
+ PKG_CHECK_MODULES(NDESK_DBUS, ndesk-dbus-1.0 >= 0.5)
AC_SUBST(NDESK_DBUS_LIBS)
])
Modified: trunk/banshee/src/Clients/Beroe/Beroe.csproj
==============================================================================
--- trunk/banshee/src/Clients/Beroe/Beroe.csproj (original)
+++ trunk/banshee/src/Clients/Beroe/Beroe.csproj Fri Oct 10 00:58:48 2008
@@ -46,7 +46,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Beroe\IndexerClient.cs" />
- <Compile Include="Beroe\RemoteClient.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
Modified: trunk/banshee/src/Clients/Beroe/Beroe/IndexerClient.cs
==============================================================================
--- trunk/banshee/src/Clients/Beroe/Beroe/IndexerClient.cs (original)
+++ trunk/banshee/src/Clients/Beroe/Beroe/IndexerClient.cs Fri Oct 10 00:58:48 2008
@@ -27,6 +27,8 @@
//
using System;
+using System.IO;
+using System.Reflection;
using System.Diagnostics;
using NDesk.DBus;
@@ -41,7 +43,7 @@
namespace Beroe
{
[DBusExportable (ServiceName = "CollectionIndexer")]
- public class IndexerClient : Client, IIndexerClient
+ public class IndexerClient : Client, IIndexerClient, IDBusExportable
{
public static void Main ()
{
@@ -66,12 +68,6 @@
private static void ActAsRemoteClient ()
{
- BusG.Init ();
-
- RemoteClient remote_client = new RemoteClient ();
- remote_client.Start ();
-
- DBusConnection.RunMainLoop ();
}
private static void Startup ()
Modified: trunk/banshee/src/Clients/Beroe/Makefile.am
==============================================================================
--- trunk/banshee/src/Clients/Beroe/Makefile.am (original)
+++ trunk/banshee/src/Clients/Beroe/Makefile.am Fri Oct 10 00:58:48 2008
@@ -1,9 +1,7 @@
ASSEMBLY = Beroe
TARGET = exe
LINK = $(REF_BEROE)
-SOURCES = \
- Beroe/IndexerClient.cs \
- Beroe/RemoteClient.cs
+SOURCES = Beroe/IndexerClient.cs
include $(top_srcdir)/build/build.mk
Added: trunk/banshee/src/Core/Banshee.CollectionIndexer/Banshee.Collection.Indexer/ICollectionIndexer.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.CollectionIndexer/Banshee.Collection.Indexer/ICollectionIndexer.cs Fri Oct 10 00:58:48 2008
@@ -0,0 +1,54 @@
+//
+// ICollectionIndexer.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;
+using NDesk.DBus;
+
+namespace Banshee.Collection.Indexer
+{
+ public delegate void SaveToXmlFinishedHandler (bool success, string path);
+
+ [Interface ("org.bansheeproject.CollectionIndexer.Indexer")]
+ public interface ICollectionIndexer
+ {
+ event ActionHandler IndexingFinished;
+ event SaveToXmlFinishedHandler SaveToXmlFinished;
+
+ void Index ();
+ void Dispose ();
+
+ void SetExportFields (string [] fields);
+
+ int GetModelCounts ();
+ int GetModelResultsCount (int modelIndex);
+ IDictionary<string, object> GetResult (int modelIndex, int itemIndex);
+
+ void SaveToXml (string path);
+ }
+}
Added: trunk/banshee/src/Core/Banshee.CollectionIndexer/Banshee.Collection.Indexer/ICollectionIndexerService.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.CollectionIndexer/Banshee.Collection.Indexer/ICollectionIndexerService.cs Fri Oct 10 00:58:48 2008
@@ -0,0 +1,49 @@
+//
+// ICollectionIndexer.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 NDesk.DBus;
+
+namespace Banshee.Collection.Indexer
+{
+ public delegate void ActionHandler ();
+
+ [Interface ("org.bansheeproject.CollectionIndexer.Service")]
+ public interface ICollectionIndexerService
+ {
+ event ActionHandler CollectionChanged;
+ event ActionHandler CleanupAndShutdown;
+
+ void Hello ();
+ void Shutdown ();
+ ObjectPath CreateIndexer ();
+ string [] GetAvailableExportFields ();
+ bool HasCollectionCountChanged (int count);
+ bool HasCollectionLastModifiedChanged (long time);
+ }
+}
Modified: trunk/banshee/src/Core/Banshee.CollectionIndexer/Banshee.CollectionIndexer.csproj
==============================================================================
--- trunk/banshee/src/Core/Banshee.CollectionIndexer/Banshee.CollectionIndexer.csproj (original)
+++ trunk/banshee/src/Core/Banshee.CollectionIndexer/Banshee.CollectionIndexer.csproj Fri Oct 10 00:58:48 2008
@@ -18,6 +18,10 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
+ <StartupObject />
+ <EnvironmentVariables>
+ <EnvironmentVariables />
+ </EnvironmentVariables>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -46,5 +50,13 @@
<ItemGroup>
<Compile Include="Banshee.Collection.Indexer.RemoteHelper\IndexerClient.cs" />
<Compile Include="Banshee.Collection.Indexer.RemoteHelper\SimpleIndexerClient.cs" />
+ <Compile Include="Banshee.Collection.Indexer\ICollectionIndexer.cs" />
+ <Compile Include="Banshee.Collection.Indexer\ICollectionIndexerService.cs" />
+ <Compile Include="Hyena\ConsoleCrayon.cs" />
+ <Compile Include="Hyena\Log.cs" />
+ <Compile Include="Hyena\DateTimeUtil.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Demo\RemoteClient.cs" />
</ItemGroup>
</Project>
\ No newline at end of file
Added: trunk/banshee/src/Core/Banshee.CollectionIndexer/Demo/RemoteClient.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.CollectionIndexer/Demo/RemoteClient.cs Fri Oct 10 00:58:48 2008
@@ -0,0 +1,65 @@
+//
+// RemoteClient.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;
+
+using Banshee.Collection.Indexer.RemoteHelper;
+
+namespace RemoteClient
+{
+ public class RemoteClientExample : SimpleIndexerClient
+ {
+ public static void Main ()
+ {
+ RemoteClientExample client = new RemoteClientExample ();
+ client.Start ();
+
+ while (true) {
+ NDesk.DBus.Bus.Session.Iterate ();
+ }
+ }
+
+ protected override void IndexResult (IDictionary<string, object> result)
+ {
+ Console.WriteLine (result["URI"]);
+ }
+
+ protected override void OnShutdownWhileIndexing ()
+ {
+ }
+
+ protected override int CollectionCount {
+ get { return 0; }
+ }
+
+ protected override DateTime CollectionLastModified {
+ get { return DateTime.MinValue; }
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.CollectionIndexer/Hyena/ConsoleCrayon.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.CollectionIndexer/Hyena/ConsoleCrayon.cs Fri Oct 10 00:58:48 2008
@@ -0,0 +1,251 @@
+//
+// ConsoleCrayon.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;
+
+namespace Hyena
+{
+ internal static class ConsoleCrayon
+ {
+
+#region Public API
+
+ private static ConsoleColor foreground_color;
+ internal static ConsoleColor ForegroundColor {
+ get { return foreground_color; }
+ set {
+ foreground_color = value;
+ SetColor (foreground_color, true);
+ }
+ }
+
+ private static ConsoleColor background_color;
+ internal static ConsoleColor BackgroundColor {
+ get { return background_color; }
+ set {
+ background_color = value;
+ SetColor (background_color, false);
+ }
+ }
+
+ internal static void ResetColor ()
+ {
+ if (XtermColors) {
+ Console.Write (GetAnsiResetControlCode ());
+ } else if (Environment.OSVersion.Platform != PlatformID.Unix && !RuntimeIsMono) {
+ Console.ResetColor ();
+ }
+ }
+
+ private static void SetColor (ConsoleColor color, bool isForeground)
+ {
+ if (color < ConsoleColor.Black || color > ConsoleColor.White) {
+ throw new ArgumentOutOfRangeException ("color", "Not a ConsoleColor value.");
+ }
+
+ if (XtermColors) {
+ Console.Write (GetAnsiColorControlCode (color, isForeground));
+ } else if (Environment.OSVersion.Platform != PlatformID.Unix && !RuntimeIsMono) {
+ if (isForeground) {
+ Console.ForegroundColor = color;
+ } else {
+ Console.BackgroundColor = color;
+ }
+ }
+ }
+
+#endregion
+
+#region Ansi/VT Code Calculation
+
+ // Modified from Mono's System.TermInfoDriver
+ // License: MIT/X11
+ // Authors: Gonzalo Paniagua Javier <gonzalo ximian com>
+ // (C) 2005-2006 Novell, Inc <http://www.novell.com>
+
+ private static int TranslateColor (ConsoleColor desired, out bool light)
+ {
+ light = false;
+ switch (desired) {
+ // Dark colors
+ case ConsoleColor.Black: return 0;
+ case ConsoleColor.DarkRed: return 1;
+ case ConsoleColor.DarkGreen: return 2;
+ case ConsoleColor.DarkYellow: return 3;
+ case ConsoleColor.DarkBlue: return 4;
+ case ConsoleColor.DarkMagenta: return 5;
+ case ConsoleColor.DarkCyan: return 6;
+ case ConsoleColor.Gray: return 7;
+
+ // Light colors
+ case ConsoleColor.DarkGray: light = true; return 0;
+ case ConsoleColor.Red: light = true; return 1;
+ case ConsoleColor.Green: light = true; return 2;
+ case ConsoleColor.Yellow: light = true; return 3;
+ case ConsoleColor.Blue: light = true; return 4;
+ case ConsoleColor.Magenta: light = true; return 5;
+ case ConsoleColor.Cyan: light = true; return 6;
+ case ConsoleColor.White: default: light = true; return 7;
+ }
+ }
+
+ private static string GetAnsiColorControlCode (ConsoleColor color, bool isForeground)
+ {
+ // lighter fg colours are 90 -> 97 rather than 30 -> 37
+ // lighter bg colours are 100 -> 107 rather than 40 -> 47
+ bool light;
+ int code = TranslateColor (color, out light) + (isForeground ? 30 : 40) + (light ? 60 : 0);
+ return String.Format ("\x001b[{0}m", code);
+ }
+
+ private static string GetAnsiResetControlCode ()
+ {
+ return "\x001b[0m";
+ }
+
+#endregion
+
+#region xterm Detection
+
+ private static bool? xterm_colors = null;
+ internal static bool XtermColors {
+ get {
+ if (xterm_colors == null) {
+ DetectXtermColors ();
+ }
+
+ return xterm_colors.Value;
+ }
+ }
+
+ [System.Runtime.InteropServices.DllImport ("libc", EntryPoint="isatty")]
+ private extern static int _isatty (int fd);
+
+ private static bool isatty (int fd)
+ {
+ try {
+ return _isatty (fd) == 1;
+ } catch {
+ return false;
+ }
+ }
+
+ private static void DetectXtermColors ()
+ {
+ bool _xterm_colors = false;
+
+ switch (Environment.GetEnvironmentVariable ("TERM")) {
+ case "xterm":
+ case "rxvt":
+ case "rxvt-unicode":
+ if (Environment.GetEnvironmentVariable ("COLORTERM") != null) {
+ _xterm_colors = true;
+ }
+ break;
+ case "xterm-color":
+ _xterm_colors = true;
+ break;
+ }
+
+ xterm_colors = _xterm_colors && isatty (1) && isatty (2);
+ }
+
+#endregion
+
+#region Runtime Detection
+
+ private static bool? runtime_is_mono;
+ internal static bool RuntimeIsMono {
+ get {
+ if (runtime_is_mono == null) {
+ runtime_is_mono = Type.GetType ("System.MonoType") != null;
+ }
+
+ return runtime_is_mono.Value;
+ }
+ }
+
+#endregion
+
+#region Tests
+
+ internal static void Test ()
+ {
+ TestSelf ();
+ Console.WriteLine ();
+ TestAnsi ();
+ Console.WriteLine ();
+ TestRuntime ();
+ }
+
+ private static void TestSelf ()
+ {
+ Console.WriteLine ("==SELF TEST==");
+ foreach (ConsoleColor color in Enum.GetValues (typeof (ConsoleColor))) {
+ ForegroundColor = color;
+ Console.Write (color);
+ ResetColor ();
+ Console.Write (" :: ");
+ BackgroundColor = color;
+ Console.Write (color);
+ ResetColor ();
+ Console.WriteLine ();
+ }
+ }
+
+ private static void TestAnsi ()
+ {
+ Console.WriteLine ("==ANSI TEST==");
+ foreach (ConsoleColor color in Enum.GetValues (typeof (ConsoleColor))) {
+ string color_code_fg = GetAnsiColorControlCode (color, true);
+ string color_code_bg = GetAnsiColorControlCode (color, false);
+ Console.Write ("{0}{1}: {2}{3} :: {4}{1}: {5}{3}", color_code_fg, color, color_code_fg.Substring (2),
+ GetAnsiResetControlCode (), color_code_bg, color_code_bg.Substring (2));
+ Console.WriteLine ();
+ }
+ }
+
+ private static void TestRuntime ()
+ {
+ Console.WriteLine ("==RUNTIME TEST==");
+ foreach (ConsoleColor color in Enum.GetValues (typeof (ConsoleColor))) {
+ Console.ForegroundColor = color;
+ Console.Write (color);
+ Console.ResetColor ();
+ Console.Write (" :: ");
+ Console.BackgroundColor = color;
+ Console.Write (color);
+ Console.ResetColor ();
+ Console.WriteLine ();
+ }
+ }
+
+#endregion
+
+ }
+}
Added: trunk/banshee/src/Core/Banshee.CollectionIndexer/Hyena/DateTimeUtil.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.CollectionIndexer/Hyena/DateTimeUtil.cs Fri Oct 10 00:58:48 2008
@@ -0,0 +1,75 @@
+//
+// Utilities.cs
+//
+// Author:
+// Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2007 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;
+
+namespace Hyena
+{
+ internal class DateTimeUtil
+ {
+ // FIXME I don't think having a local-unix-epoch makes any sense, I think we should be using
+ // all UTC values. Depending on the time of year in daylight savings timezones, the
+ // local-seconds-since-epoch value will differ, which will cause errors, no?
+ internal static readonly DateTime LocalUnixEpoch = new DateTime (1970, 1, 1).ToLocalTime ();
+
+ internal static DateTime ToDateTime (long time)
+ {
+ return FromTimeT (time);
+ }
+
+ internal static long FromDateTime (DateTime time)
+ {
+ return ToTimeT (time);
+ }
+
+ private static long super_ugly_min_hack = -15768000000; // 500 yrs before epoch...ewww
+ internal static DateTime FromTimeT (long time)
+ {
+ return (time <= super_ugly_min_hack) ? DateTime.MinValue : LocalUnixEpoch.AddSeconds (time);
+ }
+
+ internal static long ToTimeT (DateTime time)
+ {
+ return (long)time.Subtract (LocalUnixEpoch).TotalSeconds;
+ }
+
+ internal static string FormatDuration (long time) {
+ return FormatDuration (TimeSpan.FromSeconds (time));
+ }
+
+ internal static string FormatDuration (TimeSpan time) {
+ return FormatDuration (time.Hours, time.Minutes, time.Seconds);
+ }
+
+ internal static string FormatDuration (int hours, int minutes, int seconds) {
+ return (hours > 0 ?
+ String.Format ("{0}:{1:00}:{2:00}", hours, minutes, seconds) :
+ String.Format ("{0}:{1:00}", minutes, seconds));
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.CollectionIndexer/Hyena/Log.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.CollectionIndexer/Hyena/Log.cs Fri Oct 10 00:58:48 2008
@@ -0,0 +1,403 @@
+//
+// Log.cs
+//
+// Author:
+// Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2005-2007 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.Text;
+using System.Collections.Generic;
+
+namespace Hyena
+{
+ internal delegate void LogNotifyHandler (LogNotifyArgs args);
+
+ internal class LogNotifyArgs : EventArgs
+ {
+ private LogEntry entry;
+
+ internal LogNotifyArgs (LogEntry entry)
+ {
+ this.entry = entry;
+ }
+
+ internal LogEntry Entry {
+ get { return entry; }
+ }
+ }
+
+ internal enum LogEntryType
+ {
+ Debug,
+ Warning,
+ Error,
+ Information
+ }
+
+ internal class LogEntry
+ {
+ private LogEntryType type;
+ private string message;
+ private string details;
+ private DateTime timestamp;
+
+ internal LogEntry (LogEntryType type, string message, string details)
+ {
+ this.type = type;
+ this.message = message;
+ this.details = details;
+ this.timestamp = DateTime.Now;
+ }
+
+ internal LogEntryType Type {
+ get { return type; }
+ }
+
+ internal string Message {
+ get { return message; }
+ }
+
+ internal string Details {
+ get { return details; }
+ }
+
+ internal DateTime TimeStamp {
+ get { return timestamp; }
+ }
+ }
+
+ internal static class Log
+ {
+ internal static event LogNotifyHandler Notify;
+
+ private static Dictionary<uint, DateTime> timers = new Dictionary<uint, DateTime> ();
+ private static uint next_timer_id = 1;
+
+ private static bool debugging = false;
+ internal static bool Debugging {
+ get { return debugging; }
+ set { debugging = value; }
+ }
+
+ internal static void Commit (LogEntryType type, string message, string details, bool showUser)
+ {
+ if (type == LogEntryType.Debug && !Debugging) {
+ return;
+ }
+
+ if (type != LogEntryType.Information || (type == LogEntryType.Information && !showUser)) {
+ switch (type) {
+ case LogEntryType.Error: ConsoleCrayon.ForegroundColor = ConsoleColor.Red; break;
+ case LogEntryType.Warning: ConsoleCrayon.ForegroundColor = ConsoleColor.Yellow; break;
+ case LogEntryType.Information: ConsoleCrayon.ForegroundColor = ConsoleColor.Green; break;
+ case LogEntryType.Debug: ConsoleCrayon.ForegroundColor = ConsoleColor.Blue; break;
+ }
+
+ Console.Write ("[{0} {1:00}:{2:00}:{3:00}.{4:000}]", TypeString (type), DateTime.Now.Hour,
+ DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond);
+
+ ConsoleCrayon.ResetColor ();
+
+ if (details != null) {
+ Console.WriteLine (" {0} - {1}", message, details);
+ } else {
+ Console.WriteLine (" {0}", message);
+ }
+ }
+
+ if (showUser) {
+ OnNotify (new LogEntry (type, message, details));
+ }
+ }
+
+ private static string TypeString (LogEntryType type)
+ {
+ switch (type) {
+ case LogEntryType.Debug: return "Debug";
+ case LogEntryType.Warning: return "Warn ";
+ case LogEntryType.Error: return "Error";
+ case LogEntryType.Information: return "Info ";
+ }
+ return null;
+ }
+
+ private static void OnNotify (LogEntry entry)
+ {
+ LogNotifyHandler handler = Notify;
+ if (handler != null) {
+ handler (new LogNotifyArgs (entry));
+ }
+ }
+
+ #region Timer Methods
+
+ internal static uint DebugTimerStart (string message)
+ {
+ return TimerStart (message, false);
+ }
+
+ internal static uint InformationTimerStart (string message)
+ {
+ return TimerStart (message, true);
+ }
+
+ private static uint TimerStart (string message, bool isInfo)
+ {
+ if (!Debugging && !isInfo) {
+ return 0;
+ }
+
+ if (isInfo) {
+ Information (message);
+ } else {
+ Debug (message);
+ }
+
+ return TimerStart (isInfo);
+ }
+
+ internal static uint DebugTimerStart ()
+ {
+ return TimerStart (false);
+ }
+
+ internal static uint InformationTimerStart ()
+ {
+ return TimerStart (true);
+ }
+
+ private static uint TimerStart (bool isInfo)
+ {
+ if (!Debugging && !isInfo) {
+ return 0;
+ }
+
+ uint timer_id = next_timer_id++;
+ timers.Add (timer_id, DateTime.Now);
+ return timer_id;
+ }
+
+ internal static void DebugTimerPrint (uint id)
+ {
+ if (!Debugging) {
+ return;
+ }
+
+ TimerPrint (id, "Operation duration: {0}", false);
+ }
+
+ internal static void DebugTimerPrint (uint id, string message)
+ {
+ if (!Debugging) {
+ return;
+ }
+
+ TimerPrint (id, message, false);
+ }
+
+ internal static void InformationTimerPrint (uint id)
+ {
+ TimerPrint (id, "Operation duration: {0}", true);
+ }
+
+ internal static void InformationTimerPrint (uint id, string message)
+ {
+ TimerPrint (id, message, true);
+ }
+
+ private static void TimerPrint (uint id, string message, bool isInfo)
+ {
+ if (!Debugging && !isInfo) {
+ return;
+ }
+
+ DateTime finish = DateTime.Now;
+
+ if (!timers.ContainsKey (id)) {
+ return;
+ }
+
+ TimeSpan duration = finish - timers[id];
+ string d_message;
+ if (duration.TotalSeconds < 60) {
+ d_message = String.Format ("{0}s", duration.TotalSeconds);
+ } else {
+ d_message = duration.ToString ();
+ }
+
+ if (isInfo) {
+ InformationFormat (message, d_message);
+ } else {
+ DebugFormat (message, d_message);
+ }
+ }
+
+ #endregion
+
+ #region Public Debug Methods
+
+ internal static void Debug (string message, string details)
+ {
+ if (Debugging) {
+ Commit (LogEntryType.Debug, message, details, false);
+ }
+ }
+
+ internal static void Debug (string message)
+ {
+ if (Debugging) {
+ Debug (message, null);
+ }
+ }
+
+ internal static void DebugFormat (string format, params object [] args)
+ {
+ if (Debugging) {
+ Debug (String.Format (format, args));
+ }
+ }
+
+ #endregion
+
+ #region Public Information Methods
+
+ internal static void Information (string message)
+ {
+ Information (message, null);
+ }
+
+ internal static void Information (string message, string details)
+ {
+ Information (message, details, false);
+ }
+
+ internal static void Information (string message, string details, bool showUser)
+ {
+ Commit (LogEntryType.Information, message, details, showUser);
+ }
+
+ internal static void Information (string message, bool showUser)
+ {
+ Information (message, null, showUser);
+ }
+
+ internal static void InformationFormat (string format, params object [] args)
+ {
+ Information (String.Format (format, args));
+ }
+
+ #endregion
+
+ #region Public Warning Methods
+
+ internal static void Warning (string message)
+ {
+ Warning (message, null);
+ }
+
+ internal static void Warning (string message, string details)
+ {
+ Warning (message, details, false);
+ }
+
+ internal static void Warning (string message, string details, bool showUser)
+ {
+ Commit (LogEntryType.Warning, message, details, showUser);
+ }
+
+ internal static void Warning (string message, bool showUser)
+ {
+ Warning (message, null, showUser);
+ }
+
+ internal static void WarningFormat (string format, params object [] args)
+ {
+ Warning (String.Format (format, args));
+ }
+
+ #endregion
+
+ #region Public Error Methods
+
+ internal static void Error (string message)
+ {
+ Error (message, null);
+ }
+
+ internal static void Error (string message, string details)
+ {
+ Error (message, details, false);
+ }
+
+ internal static void Error (string message, string details, bool showUser)
+ {
+ Commit (LogEntryType.Error, message, details, showUser);
+ }
+
+ internal static void Error (string message, bool showUser)
+ {
+ Error (message, null, showUser);
+ }
+
+ internal static void ErrorFormat (string format, params object [] args)
+ {
+ Error (String.Format (format, args));
+ }
+
+ #endregion
+
+ #region Public Exception Methods
+
+ internal static void Exception (Exception e)
+ {
+ Exception (null, e);
+ }
+
+ internal static void Exception (string message, Exception e)
+ {
+ Stack<Exception> exception_chain = new Stack<Exception> ();
+ StringBuilder builder = new StringBuilder ();
+
+ while (e != null) {
+ exception_chain.Push (e);
+ e = e.InnerException;
+ }
+
+ while (exception_chain.Count > 0) {
+ e = exception_chain.Pop ();
+ builder.AppendFormat ("{0} (in `{1}')", e.Message, e.Source).AppendLine ();
+ builder.Append (e.StackTrace);
+ if (exception_chain.Count > 0) {
+ builder.AppendLine ();
+ }
+ }
+
+ // FIXME: We should save these to an actual log file
+ Log.Warning (message ?? "Caught an exception", builder.ToString (), false);
+ }
+
+ #endregion
+ }
+}
Modified: trunk/banshee/src/Core/Banshee.CollectionIndexer/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.CollectionIndexer/Makefile.am (original)
+++ trunk/banshee/src/Core/Banshee.CollectionIndexer/Makefile.am Fri Oct 10 00:58:48 2008
@@ -1,8 +1,17 @@
ASSEMBLY = Banshee.CollectionIndexer
+#ASSEMBLY_BUILD_FLAGS = -main:RemoteClient.RemoteClientExample
TARGET = library
LINK = $(REF_BANSHEE_COLLECTIONINDEXER)
SOURCES = \
Banshee.Collection.Indexer.RemoteHelper/IndexerClient.cs \
- Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs
+ Banshee.Collection.Indexer.RemoteHelper/SimpleIndexerClient.cs \
+ Banshee.Collection.Indexer/ICollectionIndexer.cs \
+ Banshee.Collection.Indexer/ICollectionIndexerService.cs \
+ Hyena/ConsoleCrayon.cs \
+ Hyena/DateTimeUtil.cs \
+ Hyena/Log.cs
+
include $(top_srcdir)/build/build.mk
+#ASSEMBLY_FILE_TMP=$(ASSEMBLY_FILE)
+#ASSEMBLY_FILE=$(strip $(patsubst .exe, .dll, $(ASSEMBLY_FILE_TMP)))
Added: trunk/banshee/src/Core/Banshee.CollectionIndexer/update-includes
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.CollectionIndexer/update-includes Fri Oct 10 00:58:48 2008
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+rm -f Hyena/* Banshee.Collection.Indexer/*
+
+INTERNALIZE_FILES="
+ ../../Libraries/Hyena/Hyena/Log.cs
+ ../../Libraries/Hyena/Hyena/ConsoleCrayon.cs
+ ../../Libraries/Hyena/Hyena/DateTimeUtil.cs
+"
+
+for file in $INTERNALIZE_FILES; do
+ dest=Hyena/$(basename $file)
+ cp -a $file $dest.pub
+ sed 's,public ,internal ,g' < $dest.pub > $dest
+ rm $dest.pub
+done
+
+grep -l "\[Interface.*org\.bansheeproject.CollectionIndexer" $(find ../Banshee.Services/Banshee.Collection.Indexer/ -maxdepth 1 -name *.cs | grep -v IIndexerClient | xargs) | xargs -i% cp -a % Banshee.Collection.Indexer
+
+for dir in Hyena Banshee.Collection.Indexer; do
+ svn status $dir | grep ^? | sed s,^?,, | xargs --no-run-if-empty svn add
+ svn status $dir | grep ^\\! | sed s,^\\!,, | xargs --no-run-if-empty svn remove
+done
+
Modified: trunk/banshee/src/Core/Banshee.Core/Resources/translators.xml
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Resources/translators.xml (original)
+++ trunk/banshee/src/Core/Banshee.Core/Resources/translators.xml Fri Oct 10 00:58:48 2008
@@ -52,6 +52,7 @@
<language code="fr" name="French">
<person>Jonathan Ernst</person>
<person>StÃphane Raimbault</person>
+ <person>Yannick Tailliez</person>
<person>Claude Paroz</person>
<person>Florent Le Coz</person>
<person>Alexandre Franke</person>
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexer.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexer.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexer.cs Fri Oct 10 00:58:48 2008
@@ -51,8 +51,8 @@
private List<CachedList<DatabaseTrackInfo>> model_caches = new List<CachedList<DatabaseTrackInfo>> ();
private string [] export_fields;
- private event Hyena.Action indexing_finished;
- event Hyena.Action ICollectionIndexer.IndexingFinished {
+ private event ActionHandler indexing_finished;
+ event ActionHandler ICollectionIndexer.IndexingFinished {
add { indexing_finished += value; }
remove { indexing_finished -= value; }
}
@@ -242,7 +242,7 @@
handler (this, EventArgs.Empty);
}
- Hyena.Action dbus_handler = indexing_finished;
+ ActionHandler dbus_handler = indexing_finished;
if (dbus_handler != null) {
dbus_handler ();
}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexer.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexer.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexer.cs Fri Oct 10 00:58:48 2008
@@ -37,7 +37,7 @@
[Interface ("org.bansheeproject.CollectionIndexer.Indexer")]
public interface ICollectionIndexer
{
- event Hyena.Action IndexingFinished;
+ event ActionHandler IndexingFinished;
event SaveToXmlFinishedHandler SaveToXmlFinished;
void Index ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]