Implements user limited session bus on Windows.
authorRalf Habacker <ralf.habacker@freenet.de>
Tue, 7 Dec 2010 01:16:14 +0000 (02:16 +0100)
committerRalf Habacker <ralf.habacker@freenet.de>
Fri, 10 Dec 2010 07:43:43 +0000 (08:43 +0100)
This feature is enabled by using the session bus address
"autolaunch:scope=*user" for the client and the server.

Reviewed-by: Romain Pokrzywka
dbus/dbus-sysdeps-win.c

index cf85e09..aca5285 100644 (file)
@@ -2568,30 +2568,35 @@ _dbus_get_install_root_as_hash(DBusString *out)
     return TRUE;
 }
 
-
 static dbus_bool_t
-_dbus_get_shm_name(DBusString *out,const char *scope)
+_dbus_get_address_string (DBusString *out, const char *basestring, const char *scope)
 {
   _dbus_string_init(out);
-  _dbus_string_append(out,cDBusDaemonAddressInfo);
+  _dbus_string_append(out,basestring);
 
   if (!scope)
     {
       return TRUE;
     }
-  else if (strcmp(scope,"install-path") == 0)
+  else if (strcmp(scope,"*install-path") == 0
+        // for 1.3 compatibility
+        || strcmp(scope,"install-path") == 0)
     {
       DBusString temp;
-
       if (!_dbus_get_install_root_as_hash(&temp))
         {
           _dbus_string_free(out);
            return FALSE;
         }
+    }
+  else if (strcmp(scope,"*user") == 0)
+    {
       _dbus_string_append(out,"-");
-      _dbus_string_append(out,_dbus_string_get_const_data(&temp));
-      _dbus_string_free(&temp);
-      return TRUE;
+      if (!_dbus_append_user_from_current_process(out))
+        {
+           _dbus_string_free(out);
+           return FALSE;
+        }
     }
   else if (strlen(scope) > 0)
     {
@@ -2599,47 +2604,19 @@ _dbus_get_shm_name(DBusString *out,const char *scope)
       _dbus_string_append(out,scope);
       return TRUE;
     }
-  else
-    {
-      return TRUE;
-    }
+  return TRUE;
 }
 
 static dbus_bool_t
-_dbus_get_mutex_name(DBusString *out,const char *scope)
+_dbus_get_shm_name (DBusString *out,const char *scope)
 {
-  _dbus_string_init(out);
-  _dbus_string_append(out,cDBusDaemonMutex);
-
-  if (!scope)
-    {
-      return TRUE;
-    }
-  else if (strcmp(scope,"install-path") == 0)
-    {
-      DBusString temp;
-
-      if (!_dbus_get_install_root_as_hash(&temp))
-        {
-          _dbus_string_free(out);
-          return FALSE;
-        }
+  return _dbus_get_address_string (out,cDBusDaemonAddressInfo,scope);
+}
 
-      _dbus_string_append(out,"-");
-      _dbus_string_append(out,_dbus_string_get_const_data(&temp));
-      _dbus_string_free(&temp);
-      return TRUE;
-    }
-  else if (strlen(scope) > 0)
-    {
-      _dbus_string_append(out,"-");
-      _dbus_string_append(out,scope);
-      return TRUE;
-    }
-  else
-    {
-      return TRUE;
-    }
+static dbus_bool_t
+_dbus_get_mutex_name (DBusString *out,const char *scope)
+{
+  return _dbus_get_address_string (out,cDBusDaemonMutex,scope);
 }
 
 dbus_bool_t