peer to peer dbus support added
authorAmarnath Valluri <amarnath.valluri@linux.intel.com>
Mon, 8 Apr 2013 14:00:32 +0000 (17:00 +0300)
committerJussi Laako <jussi.laako@linux.intel.com>
Fri, 31 May 2013 09:27:44 +0000 (12:27 +0300)
configure.ac
libsignon-glib/sso-auth-service.c

index 8e66dac..ae4dc21 100644 (file)
@@ -33,6 +33,25 @@ PKG_CHECK_MODULES(
 AC_SUBST(DEPS_CFLAGS)
 AC_SUBST(DEPS_LIBS)
 
+AC_ARG_ENABLE(dbus-type,
+              [--enable-dbus-type=dbus-type specify daemon dbus type:
+                                  p2p(default): uses peer to peer dbus
+                                  session: uses session message bus
+                                  system: uses system message bus],
+              [enable_dbus_type=$enableval], [enable_dbus_type=p2p])
+
+echo "----------------------"
+echo " DBUS TYPE : '$enable_dbus_type'"
+echo "-----------------------"
+if test "x$enable_dbus_type" = "xp2p" ; then
+    AC_DEFINE(USE_P2P, [1], [Use peer to peer dbus])
+    AC_DEFINE(SIGNOND_BUS_ADDRESS, ["unix:abstract=gsignond"], [signond daemon server socket address])
+elif test "x$enable_dbus_type" = "xsession" ; then
+    AC_DEFINE(SIGNOND_BUS_TYPE, [G_BUS_TYPE_SESSION], [Use session bus])
+elif test "x$enable_dbus_type" = "xsystem" ; then
+    AC_DEFINE(SIGNOND_BUS_TYPE, [G_BUS_TYPE_SYSTEM], [Use system bus])
+fi
+
 # Build tests.
 
 CHECK_REQUIRED="check >= 0.9.4"
index bda4861..e3375ea 100644 (file)
@@ -22,6 +22,7 @@
  * 02110-1301 USA
  */
 
+#include <config.h>
 #include "signon-errors.h"
 #include "signon-internals.h"
 #include "sso-auth-service.h"
@@ -75,20 +76,34 @@ set_singleton (SsoAuthService *object)
 SsoAuthService *
 sso_auth_service_get_instance ()
 {
-    SsoAuthService *sso_auth_service;
+    SsoAuthService *sso_auth_service = NULL;
+    GDBusConnection *connection = NULL;
     GError *error = NULL;
 
     sso_auth_service = get_singleton ();
     if (sso_auth_service != NULL) return sso_auth_service;
 
+#ifdef USE_P2P
+    connection = g_dbus_connection_new_for_address_sync (SIGNOND_BUS_ADDRESS,
+                                                         G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
+                                                         NULL,
+                                                         NULL,
+                                                         &error);
+#else
+    connection = g_bus_get_sync (SIGNOND_BUS_TYPE, NULL, &error);
+#endif
     /* Create the object */
     sso_auth_service =
-        sso_auth_service_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
-                                                 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
-                                                 SIGNOND_SERVICE,
-                                                 SIGNOND_DAEMON_OBJECTPATH,
-                                                 NULL,
-                                                 &error);
+        sso_auth_service_proxy_new_sync (connection,
+                                         G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+#ifdef USE_P2P
+                                         NULL,
+#else
+                                         SIGNOND_SERVICE,
+#endif
+                                         SIGNOND_DAEMON_OBJECTPATH,
+                                         NULL,
+                                         &error);
     if (G_LIKELY (error == NULL)) {
         set_singleton (sso_auth_service);
     }