Add GDBusDAaemon, an implementation of a message bus

This is mostly complete, sans support for activation. However, its
not as picky as the libdbus implementation in terms like validation
and limits checking, nor is it as tested.

Its can be useful to test gdbus if dbus-daemon is not availible, but
its main reason for existance is to implement a default session bus
on win32 so that e.g. GApplication is guaranteed to work.
This commit is contained in:
Alexander Larsson 2012-04-16 10:16:04 +02:00
parent b38f1c7aff
commit 25581738a8
5 changed files with 1864 additions and 1 deletions

1
gio/.gitignore vendored
View File

@ -3,6 +3,7 @@ gdbus
gdbus-example-objectmanager-generated-org.gtk.GDBus.Example.ObjectManager.Animal.xml
gdbus-example-objectmanager-generated-org.gtk.GDBus.Example.ObjectManager.Cat.xml
gdbus-example-objectmanager-generated.[ch]
gdbus-daemon-generated.[ch]
gio-marshal.[ch]
gio-public-headers.txt
gio-querymodules

View File

@ -98,6 +98,19 @@ gdbus_sources = \
gtestdbus.h gtestdbus.c \
$(NULL)
# These are not built into the library yet
EXTRA_DIST += gdbusdaemon.c gdbusdaemon.h
gdbus-daemon-generated.h gdbus-daemon-generated.c : dbus-daemon.xml Makefile $(top_builddir)/gio/gdbus-2.0/codegen/gdbus-codegen
$(AM_V_GEN) UNINSTALLED_GLIB_SRCDIR=$(top_srcdir) \
UNINSTALLED_GLIB_BUILDDIR=$(top_builddir) \
$(PYTHON) $(top_builddir)/gio/gdbus-2.0/codegen/gdbus-codegen \
--interface-prefix org. \
--generate-c-code gdbus-daemon-generated \
--c-namespace _G \
$(srcdir)/dbus-daemon.xml \
$(NULL)
settings_headers = \
gsettingsbackend.h \
gsettingsschema.h \
@ -613,6 +626,8 @@ BUILT_SOURCES = \
gconstructor_as_data.h \
gioenumtypes.h \
gioenumtypes.c \
gdbus-daemon-generated.c \
gdbus-daemon-generated.h \
$(NULL)
EXTRA_DIST += \
@ -634,7 +649,7 @@ BUILT_EXTRA_DIST = \
gio-public-headers.txt: Makefile
echo $(gioinclude_HEADERS) $(giowin32include_HEADERS) $(giounixinclude_HEADERS) > $@.tmp && mv $@.tmp $@
CLEANFILES = gio-public-headers.txt gconstructor_as_data.h
CLEANFILES = gdbus-daemon-generated.c gdbus-daemon-generated.h gio-public-headers.txt gconstructor_as_data.h
all-local: gio-public-headers.txt

76
gio/dbus-daemon.xml Normal file
View File

@ -0,0 +1,76 @@
<node>
<interface name="org.freedesktop.DBus">
<method name="Hello">
<arg direction="out" type="s" name="assigned_name"/>
</method>
<method name="RequestName">
<arg direction="in" type="s" name="name"/>
<arg direction="in" type="u" name="flags"/>
<arg direction="out" type="u" name="value"/>
</method>
<method name="ReleaseName">
<arg direction="in" type="s" name="name"/>
<arg direction="out" type="u" name="value"/>
</method>
<method name="StartServiceByName">
<arg direction="in" type="s" name="name"/>
<arg direction="in" type="u" name="flags"/>
<arg direction="out" type="u" name="value"/>
</method>
<method name="NameHasOwner">
<arg direction="in" type="s" name="name"/>
<arg direction="out" type="b" name="has_owner"/>
</method>
<method name="ListNames">
<arg direction="out" type="as" name="names"/>
</method>
<method name="ListActivatableNames">
<arg direction="out" type="as" name="activatable_names"/>
</method>
<method name="AddMatch">
<arg direction="in" type="s" name="rule"/>
</method>
<method name="RemoveMatch">
<arg direction="in" type="s" name="rule"/>
</method>
<method name="GetNameOwner">
<arg direction="in" type="s" name="name"/>
<arg direction="out" type="s" name="unique_name"/>
</method>
<method name="ListQueuedOwners">
<arg direction="in" type="s" name="name"/>
<arg direction="out" type="as" name="queued_owners"/>
</method>
<method name="GetConnectionUnixUser">
<arg direction="in" type="s" name="name"/>
<arg direction="out" type="u" name="uid"/>
</method>
<method name="GetConnectionUnixProcessID">
<arg direction="in" type="s" name="name"/>
<arg direction="out" type="u" name="pid"/>
</method>
<method name="GetConnectionSELinuxSecurityContext">
<arg direction="in" type="s" name="name"/>
<arg direction="out" type="ay" name="security_context"/>
</method>
<method name="UpdateActivationEnvironment">
<arg direction="in" type="a{ss}" name="environment"/>
</method>
<method name="ReloadConfig">
</method>
<method name="GetId">
<arg direction="out" type="s" name="unique_id"/>
</method>
<signal name="NameOwnerChanged">
<arg type="s" name="name"/>
<arg type="s" name="old_owner"/>
<arg type="s" name="new_owner"/>
</signal>
<signal name="NameLost">
<arg type="s" name="name"/>
</signal>
<signal name="NameAcquired">
<arg type="s" name="name"/>
</signal>
</interface>
</node>

1752
gio/gdbusdaemon.c Normal file

File diff suppressed because it is too large Load Diff

19
gio/gdbusdaemon.h Normal file
View File

@ -0,0 +1,19 @@
#include <gio/gio.h>
#define G_TYPE_DBUS_DAEMON (_g_dbus_daemon_get_type ())
#define G_DBUS_DAEMON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_DAEMON, GDBusDaemon))
#define G_DBUS_DAEMON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), G_TYPE_DBUS_DAEMON, GDBusDaemonClass))
#define G_DBUS_DAEMON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_DAEMON, GDBusDaemonClass))
#define G_IS_DBUS_DAEMON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_DAEMON))
#define G_IS_DBUS_DAEMON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_DAEMON))
typedef struct _GDBusDaemon GDBusDaemon;
typedef struct _GDBusDaemonClass GDBusDaemonClass;
GType _g_dbus_daemon_get_type (void) G_GNUC_CONST;
GDBusDaemon *_g_dbus_daemon_new (const char *address,
GCancellable *cancellable,
GError **error);
const char *_g_dbus_daemon_get_address (GDBusDaemon *daemon);