[banshee] DBusConnection: improve slightly initialization API
- From: Andrés Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] DBusConnection: improve slightly initialization API
- Date: Mon, 24 Feb 2014 16:49:41 +0000 (UTC)
commit bb228791703d38484f7234e5d152ba2f199cf4ba
Author: Andrés G. Aragoneses <knocte gmail com>
Date: Mon Feb 24 17:45:12 2014 +0100
DBusConnection: improve slightly initialization API
The property ConnectTried had a poor name and exposed internal
state which was only ever used to avoid initializing the
DBusConnection more than once. We can therefore improve this
exposing an Init() method that checks under the hood if it
has already been called in the past or not, before connecting.
Another option could have been checking the connect_tried field
inside the Connect() method, but this approach would have other
issues:
- It would mean a change of behaviour of the Connect() method.
- It would raise questions about what should be the return value
of the method in the case connect_tried was true.
- It would make you wonder if it should avoid connecting to a
non-default serviceName in the case connect_tried==true.
So by encapsulating this into a new Init() method with no return
value, this is a lot simpler to reason about, and will make this
easier to port to a higher-level IPC abstraction (which includes
Remoting besides DBus) in the very near future (see bgo#630110).
src/Clients/Halie/Halie/Client.cs | 4 +---
.../Banshee.ServiceStack/Application.cs | 4 +---
.../Banshee.ServiceStack/DBusConnection.cs | 10 +++++++---
3 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/src/Clients/Halie/Halie/Client.cs b/src/Clients/Halie/Halie/Client.cs
index 2ff9796..12d2ef5 100644
--- a/src/Clients/Halie/Halie/Client.cs
+++ b/src/Clients/Halie/Halie/Client.cs
@@ -68,9 +68,7 @@ namespace Halie
public static void Main ()
{
- if (!DBusConnection.ConnectTried) {
- DBusConnection.Connect ();
- }
+ DBusConnection.Init ();
if (!DBusConnection.Enabled) {
Error ("All commands ignored, DBus support is disabled");
diff --git a/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
b/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
index 5108fbe..74542a1 100644
--- a/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
+++ b/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs
@@ -99,9 +99,7 @@ namespace Banshee.ServiceStack
Catalog.Init (Application.InternalName, System.IO.Path.Combine (
Hyena.Paths.InstalledApplicationDataRoot, "locale"));
- if (!DBusConnection.ConnectTried) {
- DBusConnection.Connect ();
- }
+ DBusConnection.Init ();
ServiceManager.Run ();
diff --git a/src/Core/Banshee.Services/Banshee.ServiceStack/DBusConnection.cs
b/src/Core/Banshee.Services/Banshee.ServiceStack/DBusConnection.cs
index ae2760d..a5331bb 100644
--- a/src/Core/Banshee.Services/Banshee.ServiceStack/DBusConnection.cs
+++ b/src/Core/Banshee.Services/Banshee.ServiceStack/DBusConnection.cs
@@ -64,9 +64,6 @@ namespace Banshee.ServiceStack
}
private static bool connect_tried;
- public static bool ConnectTried {
- get { return connect_tried; }
- }
public static bool ApplicationInstanceAlreadyRunning {
get {
@@ -92,6 +89,13 @@ namespace Banshee.ServiceStack
Bus.Session.ReleaseName (MakeBusName (serviceName));
}
+ public static void Init ()
+ {
+ if (!connect_tried) {
+ Connect ();
+ }
+ }
+
public static bool Connect ()
{
return Connect (DefaultServiceName);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]