banshee r4515 - in trunk/banshee: . data src/Clients src/Clients/Beroe/Beroe src/Clients/Booter src/Clients/Booter/Booter src/Clients/Halie/Halie src/Core/Banshee.Services/Banshee.Collection.Indexer src/Core/Banshee.Services/Banshee.ServiceStack
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4515 - in trunk/banshee: . data src/Clients src/Clients/Beroe/Beroe src/Clients/Booter src/Clients/Booter/Booter src/Clients/Halie/Halie src/Core/Banshee.Services/Banshee.Collection.Indexer src/Core/Banshee.Services/Banshee.ServiceStack
- Date: Thu, 11 Sep 2008 20:14:15 +0000 (UTC)
Author: abock
Date: Thu Sep 11 20:14:15 2008
New Revision: 4515
URL: http://svn.gnome.org/viewvc/banshee?rev=4515&view=rev
Log:
2008-09-11 Aaron Bockover <abock gnome org>
* src/Clients/Halie/Halie/Client.cs: Moved the indexer reboot hint to
the booter client
* src/Clients/Booter/Booter/Entry.cs: Finished implementing the new
boot sequence
* src/Clients/Beroe/Beroe/IndexerClient.cs: DBus fixes
* src/Core/Banshee.Services/Banshee.ServiceStack/DBusConnection.cs:
* src/Core/Banshee.Services/Banshee.ServiceStack/DBusServiceManager.cs:
Support registering and finding objects on multiple busses without
horribly breaking API
* src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexerService.cs:
* src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexer.cs:
* src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexerService.cs:
* src/Core/Banshee.Services/Banshee.Collection.Indexer/IIndexerClient.cs:
* src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexer.cs:
Register the indexer stuff on a new bus so it can be activated without
spawning the thick client: org.bansheeproject.CollectionIndexer
* configure.ac:
* data/Makefile.am:
* data/org.bansheeproject.CollectionIndexer.service.in: Add the new
activatable service
Added:
trunk/banshee/data/org.bansheeproject.CollectionIndexer.service.in
Modified:
trunk/banshee/ChangeLog
trunk/banshee/configure.ac
trunk/banshee/data/Makefile.am
trunk/banshee/src/Clients/ (props changed)
trunk/banshee/src/Clients/Beroe/Beroe/IndexerClient.cs
trunk/banshee/src/Clients/Booter/ (props changed)
trunk/banshee/src/Clients/Booter/Booter/Entry.cs
trunk/banshee/src/Clients/Halie/Halie/Client.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexer.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/CollectionIndexerService.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexer.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/ICollectionIndexerService.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/IIndexerClient.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/DBusConnection.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/DBusServiceManager.cs
Modified: trunk/banshee/configure.ac
==============================================================================
--- trunk/banshee/configure.ac (original)
+++ trunk/banshee/configure.ac Thu Sep 11 20:14:15 2008
@@ -116,6 +116,7 @@
data/Makefile
data/org.bansheeproject.Banshee.service
+data/org.bansheeproject.CollectionIndexer.service
data/audio-profiles/Makefile
data/icon-theme-hicolor/Makefile
Modified: trunk/banshee/data/Makefile.am
==============================================================================
--- trunk/banshee/data/Makefile.am (original)
+++ trunk/banshee/data/Makefile.am Thu Sep 11 20:14:15 2008
@@ -11,7 +11,9 @@
@INTLTOOL_DESKTOP_RULE@
-dbusservice_in_files = org.bansheeproject.Banshee.service.in
+dbusservice_in_files = \
+ org.bansheeproject.Banshee.service.in \
+ org.bansheeproject.CollectionIndexer.service.in
dbusservicedir = $(datadir)/dbus-1/services
dbusservice_DATA = $(dbusservice_in_files:.service.in=.service)
Added: trunk/banshee/data/org.bansheeproject.CollectionIndexer.service.in
==============================================================================
--- (empty file)
+++ trunk/banshee/data/org.bansheeproject.CollectionIndexer.service.in Thu Sep 11 20:14:15 2008
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name=org.bansheeproject.CollectionIndexer
+Exec= expanded_bindir@/banshee-1 --indexer
+
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 Thu Sep 11 20:14:15 2008
@@ -27,6 +27,7 @@
//
using System;
+using System.Diagnostics;
using NDesk.DBus;
using Hyena;
@@ -39,20 +40,20 @@
namespace Beroe
{
+ [DBusExportable (ServiceName = "CollectionIndexer")]
public class IndexerClient : Client, IIndexerClient
{
public static void Main ()
{
- if (!DBusConnection.ConnectTried) {
- DBusConnection.Connect ();
- }
-
if (!DBusConnection.Enabled) {
Log.Error ("All commands ignored, DBus support is disabled");
return;
} else if (DBusConnection.ApplicationInstanceAlreadyRunning) {
Log.Error ("Banshee is already running");
return;
+ } else if (DBusConnection.NameHasOwner ("CollectionIndexer")) {
+ Log.Error ("Another indexer is already running");
+ return;
}
Startup ();
@@ -94,8 +95,12 @@
builder.AppendFormat ("\"{0}\" ", arg);
}
- // FIXME: Lame
- System.Diagnostics.Process.Start ("banshee-1", builder.ToString ());
+ // FIXME: Using Process.Start sucks, but DBus doesn't let you specify
+ // extra command line arguments
+ DBusConnection.Disconnect ("CollectionIndexer");
+ Process.Start ("banshee-1", builder.ToString ());
+ // Bus.Session.StartServiceByName (DBusConnection.DefaultBusName);
+ // Bus.Session.Iterate ();
}
}
Modified: trunk/banshee/src/Clients/Booter/Booter/Entry.cs
==============================================================================
--- trunk/banshee/src/Clients/Booter/Booter/Entry.cs (original)
+++ trunk/banshee/src/Clients/Booter/Booter/Entry.cs Thu Sep 11 20:14:15 2008
@@ -26,17 +26,46 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+//
+// Crazy Banshee Boot Procedure
+//
+// [Exec or DBus Activation] <---------------------------------------------------------.
+// | |
+// v |
+// [Bootloader (Banshee.exe)] |
+// | |
+// v yes |
+// <org.bansheeproject.Banshee?> -------> [Load DBus Proxy Client (Halie.exe)] -----. |
+// |no | |
+// v yes | |
+// <org.bansheeproject.CollectionIndexer?> -------> [Tell Indexer to Reboot] -----/IPC/'
+// |no |
+// v yes |
+// <command line contains --indexer?> -------> [Load Indexer Client (Beroe.exe)] |
+// |no |
+// v yes |
+// <command line contains --client=XYZ> -------> [Load XYZ Client] |
+// |no |
+// v |
+// [Load Primary Interface Client (Nereid.exe)] <-----------------------------------'
+//
+
using System;
using System.IO;
using System.Reflection;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
using Mono.Unix;
+using NDesk.DBus;
+
+using Hyena;
using Hyena.CommandLine;
using Banshee.Base;
using Banshee.ServiceStack;
+using Banshee.Collection.Indexer;
namespace Booter
{
@@ -47,29 +76,51 @@
if (CheckHelpVersion ()) {
return;
}
-
- bool gui_notify_startup = false;
- string client_assembly_name = "Nereid";
-
- if (ApplicationContext.CommandLine.Contains ("client")) {
- client_assembly_name = ApplicationContext.CommandLine["client"];
- }
-
- DBusConnection.Connect ();
if (DBusConnection.ApplicationInstanceAlreadyRunning) {
- client_assembly_name = "Halie"; // DBus Command/Query/File Proxy Client
- gui_notify_startup = true;
+ // DBus Command/Query/File Proxy Client
+ BootClient ("Halie");
+ NotifyStartupComplete ();
+ } else if (DBusConnection.NameHasOwner ("CollectionIndexer")) {
+ // Tell the existing indexer to start Banshee when it's done
+ IIndexerClient indexer = DBusServiceManager.FindInstance<IIndexerClient> ("CollectionIndexer", "/IndexerClient");
+ try {
+ indexer.Hello ();
+ indexer.RebootWhenFinished (Environment.GetCommandLineArgs ());
+ Log.Warning ("The Banshee indexer is currently running. Banshee will be started when the indexer finishes.");
+ } catch (Exception e) {
+ Log.Exception ("CollectionIndexer found on the Bus, but doesn't say Hello", e);
+ }
} else if (ApplicationContext.CommandLine.Contains ("indexer")) {
- client_assembly_name = "Beroe"; // Indexer Client
+ // Indexer Client
+ BootClient ("Beroe");
+ } else if (ApplicationContext.CommandLine.Contains ("client")) {
+ BootClient (Path.GetFileNameWithoutExtension (ApplicationContext.CommandLine["client"]));
+ } else {
+ BootClient ("Nereid");
}
-
+ }
+
+ private static void BootClient (string clientName)
+ {
AppDomain.CurrentDomain.ExecuteAssembly (Path.Combine (Path.GetDirectoryName (
- Assembly.GetEntryAssembly ().Location), String.Format ("{0}.exe", client_assembly_name)));
-
- if (gui_notify_startup) {
- // Gdk.Global.InitCheck (ref args);
- // Gdk.Global.NotifyStartupComplete ();
+ Assembly.GetEntryAssembly ().Location), String.Format ("{0}.exe", clientName)));
+ }
+
+ [DllImport ("libgdk-x11-2.0.so.0")]
+ private static extern bool gdk_init_check (IntPtr argc, IntPtr argv);
+
+ [DllImport ("libgdk-x11-2.0.so.0")]
+ private static extern void gdk_notify_startup_complete ();
+
+ private static void NotifyStartupComplete ()
+ {
+ try {
+ if (gdk_init_check (IntPtr.Zero, IntPtr.Zero)) {
+ gdk_notify_startup_complete ();
+ }
+ } catch (Exception e) {
+ Hyena.Log.Exception ("Problem with NotifyStartupComplete", e);
}
}
Modified: trunk/banshee/src/Clients/Halie/Halie/Client.cs
==============================================================================
--- trunk/banshee/src/Clients/Halie/Halie/Client.cs (original)
+++ trunk/banshee/src/Clients/Halie/Halie/Client.cs Thu Sep 11 20:14:15 2008
@@ -70,15 +70,6 @@
return;
}
- IIndexerClient indexer = DBusServiceManager.FindInstance<IIndexerClient> ("/IndexerClient");
- try {
- indexer.Hello ();
- indexer.RebootWhenFinished (Environment.GetCommandLineArgs ());
- Log.Warning ("The Banshee indexer is currently running. Banshee will be started when the indexer finishes.");
- return;
- } catch {
- }
-
command = DBusServiceManager.FindInstance<DBusCommandService> ("/DBusCommandService");
hide_field = ApplicationContext.CommandLine.Contains ("hide-field");
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 Thu Sep 11 20:14:15 2008
@@ -42,6 +42,7 @@
namespace Banshee.Collection.Indexer
{
+ [DBusExportable (ServiceName = "CollectionIndexer")]
public class CollectionIndexer : ICollectionIndexer, IDisposable
{
private static int instance_count = 0;
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 Sep 11 20:14:15 2008
@@ -41,6 +41,7 @@
namespace Banshee.Collection.Indexer
{
+ [DBusExportable (ServiceName = "CollectionIndexer")]
public class CollectionIndexerService : ICollectionIndexerService, IDisposable
{
private List<LibrarySource> libraries = new List<LibrarySource> ();
@@ -57,6 +58,8 @@
public CollectionIndexerService ()
{
+ DBusConnection.Connect ("CollectionIndexer");
+
ServiceManager.SourceManager.SourceAdded += OnSourceAdded;
ServiceManager.SourceManager.SourceRemoved += OnSourceRemoved;
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 Thu Sep 11 20:14:15 2008
@@ -36,7 +36,7 @@
{
public delegate void SaveToXmlFinishedHandler (bool success, string path);
- [Interface ("org.bansheeproject.Banshee.CollectionIndexer")]
+ [Interface ("org.bansheeproject.CollectionIndexer.Indexer")]
public interface ICollectionIndexer : IService, IDBusExportable
{
event Action IndexingFinished;
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 Sep 11 20:14:15 2008
@@ -33,7 +33,7 @@
namespace Banshee.Collection.Indexer
{
- [Interface ("org.bansheeproject.Banshee.CollectionIndexerService")]
+ [Interface ("org.bansheeproject.CollectionIndexer.Service")]
public interface ICollectionIndexerService : IService, IDBusExportable
{
event Action CollectionChanged;
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/IIndexerClient.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/IIndexerClient.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Indexer/IIndexerClient.cs Thu Sep 11 20:14:15 2008
@@ -33,7 +33,7 @@
namespace Banshee.Collection.Indexer
{
- [Interface ("org.bansheeproject.Banshee.IndexerClient")]
+ [Interface ("org.bansheeproject.CollectionIndexer.Client")]
public interface IIndexerClient : IDBusExportable
{
void Hello ();
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/DBusConnection.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/DBusConnection.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/DBusConnection.cs Thu Sep 11 20:14:15 2008
@@ -42,7 +42,12 @@
private const string BusPrefix = "org.bansheeproject";
public const string DefaultServiceName = "Banshee";
public const string DefaultBusName= "org.bansheeproject.Banshee";
-
+
+ static DBusConnection ()
+ {
+ enabled = !ApplicationContext.CommandLine.Contains ("disable-dbus");
+ }
+
private static List<string> active_connections = new List<string> ();
public static string MakeBusName (string serviceName)
@@ -61,7 +66,7 @@
}
public static bool ApplicationInstanceAlreadyRunning {
- get { return !ServiceIsConnected (DefaultServiceName); }
+ get { return Bus.Session.NameHasOwner (DefaultBusName); }
}
public static bool ServiceIsConnected (string service)
@@ -69,28 +74,46 @@
return active_connections.Contains (service);
}
- public static void Connect ()
+ public static void Disconnect (string serviceName)
+ {
+ if (active_connections.Contains (serviceName)) {
+ active_connections.Remove (serviceName);
+ }
+
+ Bus.Session.ReleaseName (MakeBusName (serviceName));
+ }
+
+ public static bool Connect ()
{
- Connect (DefaultServiceName);
+ return Connect (DefaultServiceName);
}
- public static void Connect (string serviceName)
+ public static bool Connect (string serviceName)
{
connect_tried = true;
- enabled = !ApplicationContext.CommandLine.Contains ("disable-dbus");
if (!enabled) {
- return;
+ return false;
}
+ Console.WriteLine ("ATTEMPTING TO CONNECT: {0}", serviceName);
+
try {
if (Connect (serviceName, true) == RequestNameReply.PrimaryOwner) {
active_connections.Add (serviceName);
+ return true;
}
} catch {
Log.Warning ("DBus support could not be started. Disabling for this session.");
enabled = false;
}
+
+ return false;
+ }
+
+ public static bool NameHasOwner (string serviceName)
+ {
+ return Bus.Session.NameHasOwner (MakeBusName (serviceName));
}
private static RequestNameReply Connect (string serviceName, bool init)
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/DBusServiceManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/DBusServiceManager.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/DBusServiceManager.cs Thu Sep 11 20:14:15 2008
@@ -30,6 +30,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
+using System.Reflection;
using NDesk.DBus;
using org.freedesktop.DBus;
@@ -39,6 +40,15 @@
namespace Banshee.ServiceStack
{
+ public class DBusExportableAttribute : Attribute
+ {
+ private string service_name;
+ public string ServiceName {
+ get { return service_name; }
+ set { service_name = value; }
+ }
+ }
+
public class DBusServiceManager : IService
{
public const string ObjectRoot = "/org/bansheeproject/Banshee";
@@ -110,11 +120,24 @@
ObjectPath path = null;
if (DBusConnection.Enabled && Bus.Session != null) {
+ object [] attrs = o.GetType ().GetCustomAttributes (typeof (DBusExportableAttribute), true);
+ if (attrs != null && attrs.Length > 0) {
+ DBusExportableAttribute dbus_attr = (DBusExportableAttribute)attrs[0];
+ if (!String.IsNullOrEmpty (dbus_attr.ServiceName)) {
+ serviceName = dbus_attr.ServiceName;
+ }
+ }
+
lock (registered_objects) {
registered_objects.Add (o, path = new ObjectPath (objectName));
}
+
+ string bus_name = DBusConnection.MakeBusName (serviceName);
+
+ Log.DebugFormat ("Registering remote object {0} ({1}) on {2}", path, o.GetType (), bus_name);
+
#pragma warning disable 0618
- Bus.Session.Register (DBusConnection.MakeBusName (serviceName), path, o);
+ Bus.Session.Register (bus_name, path, o);
#pragma warning restore 0618
}
@@ -139,11 +162,17 @@
public static T FindInstance<T> (string objectPath) where T : class
{
- return FindInstance<T> (DBusConnection.DefaultBusName, objectPath);
+ return FindInstance<T> (DBusConnection.DefaultBusName, true, objectPath);
+ }
+
+ public static T FindInstance<T> (string serviceName, string objectPath) where T : class
+ {
+ return FindInstance<T> (serviceName, false, objectPath);
}
- public static T FindInstance<T> (string busName, string objectPath) where T : class
+ public static T FindInstance<T> (string serviceName, bool isFullBusName, string objectPath) where T : class
{
+ string busName = isFullBusName ? serviceName : DBusConnection.MakeBusName (serviceName);
if (!DBusConnection.Enabled || !Bus.Session.NameHasOwner (busName)) {
return null;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]