[blam] Use dbus-sharp if available



commit 73926443f5d40a31f0e5163f918f1bf05790a33b
Author: Carlos MartÃn Nieto <carlos cmartin tk>
Date:   Sun Jul 31 13:17:40 2011 +0200

    Use dbus-sharp if available
    
    Signed-off-by: Carlos MartÃn Nieto <carlos cmartin tk>

 configure.in       |   33 +++++++++++++++++++++++++++++----
 src/Application.cs |   13 ++++++++-----
 src/Makefile.am    |    9 +++++++--
 3 files changed, 44 insertions(+), 11 deletions(-)
---
diff --git a/configure.in b/configure.in
index 6a1f4f3..e31c458 100644
--- a/configure.in
+++ b/configure.in
@@ -54,11 +54,36 @@ PKG_CHECK_MODULES(BLAM,
 AC_SUBST(BLAM_LIBS)
 
 #
-# Use DBus# to export our remote control if available.
+# Use DBus# to export our remote control if available and the user wants it
 #
-PKG_CHECK_MODULES(DBUS, ndesk-dbus-glib-1.0, ENABLE_DBUS="yes", ENABLE_DBUS="no")
-AM_CONDITIONAL(ENABLE_DBUS, test "$ENABLE_DBUS" = "yes")
-AC_SUBST(DBUS_LIBS)
+AC_ARG_WITH([dbus],
+	AC_HELP_STRING([--with-dbus], [Support D-Bus @<:@default=auto:>@]),
+	[],
+	with_dbus=auto
+)
+# In auto mode, prefer dbus-sharp
+PKG_CHECK_EXISTS([dbus-sharp-1.0], DBUS_SHARP_SUPPORT=yes, DBUS_SHARP_SUPPORT=no)
+PKG_CHECK_EXISTS([ndesk-dbus-1.0], NDESK_DBUS_SUPPORT=yes, NDESK_DBUS_SUPPORT=no)
+if test "x$with_dbus" = "xauto"; then
+   if test "$DBUS_SHARP_SUPPORT" = "xyes"; then
+      ENABLE_DBUS=$DBUS_SHARP_SUPPORT
+   else
+      ENABLE_DBUS=$NDESK_DBUS_SUPPORT
+   fi
+fi
+# If we found a package or the user told us
+if test "x$with_dbus" = "xyes"; then
+   if test "x$DBUS_SHARP_SUPPORT" = "xyes"; then
+      PKG_CHECK_MODULES(DBUS_SHARP, dbus-sharp-glib-1.0, ENABLE_NDESK_DBUS="yes", ENABLE_NDESK_DBUS="no")
+      AC_SUBST(DBUS_LIBS, "$DBUS_SHARP_LIBS")
+   else
+      PKG_CHECK_MODULES(DBUS_NDESK, ndesk-dbus-glib-1.0, ENABLE_DBUS_SHARP="yes", ENABLE_DBUS_SHARP="no")
+      AC_SUBST(DBUS_LIBS, "$DBUS_NDESK_LIBS")
+   fi
+fi
+# Tell the code what we're using
+AM_CONDITIONAL(NDESK_DBUS, test "x$ENABLE_NDESK_DBUS" = "xyes")
+AM_CONDITIONAL(DBUS_SHARP, test "x$ENABLE_DBUS_SHARP" = "xyes")
 
 #
 # Use libnotify is available
diff --git a/src/Application.cs b/src/Application.cs
index 9ec9064..4b52e95 100644
--- a/src/Application.cs
+++ b/src/Application.cs
@@ -19,7 +19,10 @@ using System.IO;
 using System.Text;
 using System.Runtime.InteropServices;
 using WebKit;
-#if ENABLE_DBUS
+#if DBUS_SHARP
+using DBus;
+using org.freedesktop.DBus;
+#elif NDESK_DBUS
 using NDesk.DBus;
 using org.freedesktop.DBus;
 #endif
@@ -32,16 +35,16 @@ namespace Imendio.Blam {
 		Channel
 	};
 
-#if ENABLE_DBUS
-    [NDesk.DBus.Interface("org.gnome.feed.Reader")]
+#if NDESK_DBUS || DBUS_SHARP
+    [Interface("org.gnome.feed.Reader")]
 #endif
     public interface IFeedReader {
         bool Subscribe(string url);
         void SetOnline(bool value);
     }
 
-#if ENABLE_DBUS
-    [NDesk.DBus.Interface("org.gnome.Blam.Reader")]
+#if NDESK_DBUS || DBUS_SHARP
+    [Interface("org.gnome.Blam.Reader")]
 #endif
     public interface IBlamReader {
         void ShowWindow();
diff --git a/src/Makefile.am b/src/Makefile.am
index a2cd0f7..3e9aa1e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -41,8 +41,13 @@ BLAM_CSFILES = Application.cs \
 GENERATED_CSFILES = \
 	       Defines.cs
 
-if ENABLE_DBUS
-FLAGS += -define:ENABLE_DBUS
+if NDESK_DBUS
+FLAGS += -define:NDESK_DBUS
+ASSEMBLIES += $(DBUS_LIBS)
+endif
+
+if DBUS_SHARP
+FLAGS += -define:DBUS_SHARP
 ASSEMBLIES += $(DBUS_LIBS)
 endif
 



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