Commit 2d0ef52d authored by David Zeuthen's avatar David Zeuthen

Nuke eggdbus usage

Signed-off-by: default avatarDavid Zeuthen <davidz@redhat.com>
parent d04cd425
...@@ -120,14 +120,10 @@ if test "x$GCC" = "xyes"; then ...@@ -120,14 +120,10 @@ if test "x$GCC" = "xyes"; then
changequote([,])dnl changequote([,])dnl
fi fi
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.21.4 gio-2.0 >= 2.21.4]) PKG_CHECK_MODULES(GLIB, [gio-2.0 >= 2.25.11])
AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS) AC_SUBST(GLIB_LIBS)
PKG_CHECK_MODULES(EGG_DBUS, [eggdbus-1 >= 0.6])
AC_SUBST(EGG_DBUS_CFLAGS)
AC_SUBST(EGG_DBUS_LIBS)
EXPAT_LIB="" EXPAT_LIB=""
AC_ARG_WITH(expat, [ --with-expat=<dir> Use expat from here], AC_ARG_WITH(expat, [ --with-expat=<dir> Use expat from here],
[ [
......
...@@ -12,11 +12,9 @@ INCLUDES = \ ...@@ -12,11 +12,9 @@ INCLUDES = \
-DPACKAGE_LIB_DIR=\""$(libdir)"\" \ -DPACKAGE_LIB_DIR=\""$(libdir)"\" \
-D_POSIX_PTHREAD_SEMANTICS \ -D_POSIX_PTHREAD_SEMANTICS \
-D_REENTRANT \ -D_REENTRANT \
-DEGG_DBUS_I_KNOW_API_IS_SUBJECT_TO_CHANGE \
$(NULL) $(NULL)
BUILT_SOURCES = \ BUILT_SOURCES = \
polkit-built-sources.stamp \
polkitenumtypes.c polkitenumtypes.h \ polkitenumtypes.c polkitenumtypes.h \
$(NULL) $(NULL)
...@@ -32,37 +30,6 @@ polkitenumtypes.c: $(enum_headers) polkitenumtypes.c.template ...@@ -32,37 +30,6 @@ polkitenumtypes.c: $(enum_headers) polkitenumtypes.c.template
cd $(srcdir) && glib-mkenums --template polkitenumtypes.c.template $(enum_headers)) > \ cd $(srcdir) && glib-mkenums --template polkitenumtypes.c.template $(enum_headers)) > \
polkitenumtypes.c.tmp && mv polkitenumtypes.c.tmp polkitenumtypes.c polkitenumtypes.c.tmp && mv polkitenumtypes.c.tmp polkitenumtypes.c
# Build all the PolicyKit D-Bus code here, even the code we
# only in the daemon for agent interaction
#
polkit-built-sources.stamp : Makefile.am $(top_srcdir)/data/org.freedesktop.PolicyKit1.Authority.xml $(top_srcdir)/data/org.freedesktop.PolicyKit1.AuthenticationAgent.xml
eggdbus-binding-tool \
--namespace "_Polkit" \
--dbus-namespace "org.freedesktop.PolicyKit1" \
--introspection-xml $(top_srcdir)/data/org.freedesktop.PolicyKit1.Authority.xml \
--introspection-xml $(top_srcdir)/data/org.freedesktop.PolicyKit1.AuthenticationAgent.xml \
--stamp-file polkit-built-sources.stamp \
$(NULL)
# keep in sync with contents of polkit-built-sources.stamp (Thanks autotools)
#
polkit_built_sources = _polkitactiondescription.c _polkitactiondescription.h _polkitauthenticationagent.c _polkitauthenticationagent.h _polkitauthority.c _polkitauthority.h _polkitauthorizationresult.c _polkitauthorizationresult.h _polkitbindings.c _polkitbindings.h _polkitbindingsmarshal.c _polkitbindingsmarshal.h _polkitbindingstypes.h _polkitcheckauthorizationflags.c _polkitcheckauthorizationflags.h _polkiterror.c _polkiterror.h _polkitidentity.c _polkitidentity.h _polkitimplicitauthorization.c _polkitimplicitauthorization.h _polkitsubject.c _polkitsubject.h _polkittemporaryauthorization.c _polkittemporaryauthorization.h docbook-interface-org.freedesktop.PolicyKit1.AuthenticationAgent.xml docbook-interface-org.freedesktop.PolicyKit1.Authority.xml _polkitbindingsmarshal.list _polkitauthorityfeatures.h _polkitauthorityfeatures.c
noinst_LTLIBRARIES = libpolkit-private.la
libpolkit_private_la_SOURCES = $(polkit_built_sources)
libpolkit_private_la_CFLAGS = \
-D_POLKIT_COMPILATION \
$(GLIB_CFLAGS) \
$(EGG_DBUS_CFLAGS) \
$(NULL)
libpolkit_private_la_LIBADD = \
$(GLIB_LIBS) \
$(EGG_DBUS_LIBS) \
$(NULL)
lib_LTLIBRARIES=libpolkit-gobject-1.la lib_LTLIBRARIES=libpolkit-gobject-1.la
libpolkit_gobject_1includedir=$(includedir)/polkit-1/polkit libpolkit_gobject_1includedir=$(includedir)/polkit-1/polkit
...@@ -114,13 +81,10 @@ libpolkit_gobject_1_la_SOURCES = \ ...@@ -114,13 +81,10 @@ libpolkit_gobject_1_la_SOURCES = \
libpolkit_gobject_1_la_CFLAGS = \ libpolkit_gobject_1_la_CFLAGS = \
-D_POLKIT_COMPILATION \ -D_POLKIT_COMPILATION \
$(GLIB_CFLAGS) \ $(GLIB_CFLAGS) \
$(EGG_DBUS_CFLAGS) \
$(NULL) $(NULL)
libpolkit_gobject_1_la_LIBADD = \ libpolkit_gobject_1_la_LIBADD = \
$(GLIB_LIBS) \ $(GLIB_LIBS) \
$(EGG_DBUS_LIBS) \
libpolkit-private.la \
$(NULL) $(NULL)
libpolkit_gobject_1_la_LDFLAGS = -export-symbols-regex '(^polkit_.*)' libpolkit_gobject_1_la_LDFLAGS = -export-symbols-regex '(^polkit_.*)'
...@@ -143,10 +107,8 @@ Polkit-1.0.gir: libpolkit-gobject-1.la $(G_IR_SCANNER) Makefile.am ...@@ -143,10 +107,8 @@ Polkit-1.0.gir: libpolkit-gobject-1.la $(G_IR_SCANNER) Makefile.am
--pkg=gobject-2.0 \ --pkg=gobject-2.0 \
--pkg=gio-2.0 \ --pkg=gio-2.0 \
--libtool=$(top_builddir)/libtool \ --libtool=$(top_builddir)/libtool \
$(EGG_DBUS_CFLAGS) \
-I$(top_srcdir)/src \ -I$(top_srcdir)/src \
-D_POLKIT_COMPILATION \ -D_POLKIT_COMPILATION \
-DEGG_DBUS_I_KNOW_API_IS_SUBJECT_TO_CHANGE \
$(srcdir)/polkit.h \ $(srcdir)/polkit.h \
$(srcdir)/polkittypes.h \ $(srcdir)/polkittypes.h \
$(srcdir)/polkitactiondescription.h \ $(srcdir)/polkitactiondescription.h \
......
This diff is collapsed.
...@@ -45,7 +45,8 @@ struct _PolkitAuthorizationResult ...@@ -45,7 +45,8 @@ struct _PolkitAuthorizationResult
{ {
GObject parent_instance; GObject parent_instance;
_PolkitAuthorizationResult *real; gboolean is_authorized;
gboolean is_challenge;
PolkitDetails *details; PolkitDetails *details;
}; };
...@@ -69,7 +70,6 @@ polkit_authorization_result_finalize (GObject *object) ...@@ -69,7 +70,6 @@ polkit_authorization_result_finalize (GObject *object)
authorization_result = POLKIT_AUTHORIZATION_RESULT (object); authorization_result = POLKIT_AUTHORIZATION_RESULT (object);
g_object_unref (authorization_result->real);
if (authorization_result->details != NULL) if (authorization_result->details != NULL)
g_object_unref (authorization_result->details); g_object_unref (authorization_result->details);
...@@ -85,24 +85,6 @@ polkit_authorization_result_class_init (PolkitAuthorizationResultClass *klass) ...@@ -85,24 +85,6 @@ polkit_authorization_result_class_init (PolkitAuthorizationResultClass *klass)
gobject_class->finalize = polkit_authorization_result_finalize; gobject_class->finalize = polkit_authorization_result_finalize;
} }
PolkitAuthorizationResult *
polkit_authorization_result_new_for_real (_PolkitAuthorizationResult *real)
{
PolkitAuthorizationResult *authorization_result;
authorization_result = POLKIT_AUTHORIZATION_RESULT (g_object_new (POLKIT_TYPE_AUTHORIZATION_RESULT, NULL));
authorization_result->real = g_object_ref (real);
return authorization_result;
}
_PolkitAuthorizationResult *
polkit_authorization_result_get_real (PolkitAuthorizationResult *authorization_result)
{
return g_object_ref (authorization_result->real);
}
/* ---------------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------------- */
/** /**
...@@ -123,33 +105,11 @@ polkit_authorization_result_new (gboolean is_authorized, ...@@ -123,33 +105,11 @@ polkit_authorization_result_new (gboolean is_authorized,
PolkitDetails *details) PolkitDetails *details)
{ {
PolkitAuthorizationResult *authorization_result; PolkitAuthorizationResult *authorization_result;
_PolkitAuthorizationResult *real;
EggDBusHashMap *real_details;
real_details = egg_dbus_hash_map_new (G_TYPE_STRING, g_free, G_TYPE_STRING, g_free);
if (details != NULL)
{
GHashTable *hash;
GHashTableIter iter;
gpointer key, value;
hash = polkit_details_get_hash (details);
if (hash != NULL)
{
g_hash_table_iter_init (&iter, hash);
while (g_hash_table_iter_next (&iter, &key, &value))
{
egg_dbus_hash_map_insert (real_details, g_strdup (key), g_strdup (value));
}
}
}
real = _polkit_authorization_result_new (is_authorized, is_challenge, real_details);
g_object_unref (real_details);
authorization_result = polkit_authorization_result_new_for_real (real); authorization_result = POLKIT_AUTHORIZATION_RESULT (g_object_new (POLKIT_TYPE_AUTHORIZATION_RESULT, NULL));
authorization_result->is_authorized = is_authorized;
g_object_unref (real); authorization_result->is_challenge = is_challenge;
authorization_result->details = g_object_ref (details);
return authorization_result; return authorization_result;
} }
...@@ -168,7 +128,7 @@ polkit_authorization_result_new (gboolean is_authorized, ...@@ -168,7 +128,7 @@ polkit_authorization_result_new (gboolean is_authorized,
gboolean gboolean
polkit_authorization_result_get_is_authorized (PolkitAuthorizationResult *result) polkit_authorization_result_get_is_authorized (PolkitAuthorizationResult *result)
{ {
return _polkit_authorization_result_get_is_authorized (result->real); return result->is_authorized;
} }
/** /**
...@@ -182,7 +142,7 @@ polkit_authorization_result_get_is_authorized (PolkitAuthorizationResult *result ...@@ -182,7 +142,7 @@ polkit_authorization_result_get_is_authorized (PolkitAuthorizationResult *result
gboolean gboolean
polkit_authorization_result_get_is_challenge (PolkitAuthorizationResult *result) polkit_authorization_result_get_is_challenge (PolkitAuthorizationResult *result)
{ {
return _polkit_authorization_result_get_is_challenge (result->real); return result->is_challenge;
} }
/** /**
...@@ -197,16 +157,6 @@ polkit_authorization_result_get_is_challenge (PolkitAuthorizationResult *result) ...@@ -197,16 +157,6 @@ polkit_authorization_result_get_is_challenge (PolkitAuthorizationResult *result)
PolkitDetails * PolkitDetails *
polkit_authorization_result_get_details (PolkitAuthorizationResult *result) polkit_authorization_result_get_details (PolkitAuthorizationResult *result)
{ {
EggDBusHashMap *real_details;
if (result->details != NULL)
goto out;
real_details = _polkit_authorization_result_get_details (result->real);
if (real_details != NULL)
result->details = result->details = polkit_details_new_for_hash (real_details->data);
out:
return result->details; return result->details;
} }
......
...@@ -102,7 +102,7 @@ polkit_details_new (void) ...@@ -102,7 +102,7 @@ polkit_details_new (void)
} }
/* private */ /* private */
PolkitDetails * static PolkitDetails *
polkit_details_new_for_hash (GHashTable *hash) polkit_details_new_for_hash (GHashTable *hash)
{ {
PolkitDetails *details; PolkitDetails *details;
...@@ -114,13 +114,6 @@ polkit_details_new_for_hash (GHashTable *hash) ...@@ -114,13 +114,6 @@ polkit_details_new_for_hash (GHashTable *hash)
return details; return details;
} }
/* private */
GHashTable *
polkit_details_get_hash (PolkitDetails *details)
{
return details->hash;
}
/** /**
* polkit_details_lookup: * polkit_details_lookup:
* @details: A #PolkitDetails. * @details: A #PolkitDetails.
......
...@@ -185,80 +185,6 @@ polkit_identity_from_string (const gchar *str, ...@@ -185,80 +185,6 @@ polkit_identity_from_string (const gchar *str,
return identity; return identity;
} }
PolkitIdentity *
polkit_identity_new_for_real (_PolkitIdentity *real)
{
PolkitIdentity *s;
const gchar *kind;
EggDBusHashMap *details;
EggDBusVariant *variant;
s = NULL;
kind = _polkit_identity_get_identity_kind (real);
details = _polkit_identity_get_identity_details (real);
if (strcmp (kind, "unix-user") == 0)
{
variant = egg_dbus_hash_map_lookup (details, "uid");
if (variant != NULL)
s = polkit_unix_user_new (egg_dbus_variant_get_uint (variant));
}
else if (strcmp (kind, "unix-group") == 0)
{
variant = egg_dbus_hash_map_lookup (details, "gid");
if (variant != NULL)
s = polkit_unix_group_new (egg_dbus_variant_get_uint (variant));
}
else
{
g_warning ("Unknown identity kind %s:", kind);
}
return s;
}
_PolkitIdentity *
polkit_identity_get_real (PolkitIdentity *identity)
{
_PolkitIdentity *real;
const gchar *kind;
EggDBusHashMap *details;
real = NULL;
kind = NULL;
details = egg_dbus_hash_map_new (G_TYPE_STRING, NULL, EGG_DBUS_TYPE_VARIANT, (GDestroyNotify) g_object_unref);
if (POLKIT_IS_UNIX_USER (identity))
{
kind = "unix-user";
egg_dbus_hash_map_insert (details,
"uid",
egg_dbus_variant_new_for_uint (polkit_unix_user_get_uid (POLKIT_UNIX_USER (identity))));
}
else if (POLKIT_IS_UNIX_GROUP (identity))
{
kind = "unix-group";
egg_dbus_hash_map_insert (details,
"gid",
egg_dbus_variant_new_for_uint (polkit_unix_group_get_gid (POLKIT_UNIX_GROUP (identity))));
}
else
{
g_warning ("Unknown class %s implementing PolkitIdentity", g_type_name (G_TYPE_FROM_INSTANCE (identity)));
}
if (kind != NULL)
{
real = _polkit_identity_new (kind, details);
}
if (details != NULL)
g_object_unref (details);
return real;
}
GVariant * GVariant *
polkit_identity_to_gvariant (PolkitIdentity *identity) polkit_identity_to_gvariant (PolkitIdentity *identity)
{ {
......
...@@ -27,17 +27,7 @@ ...@@ -27,17 +27,7 @@
#include "polkitsubject.h" #include "polkitsubject.h"
#include "polkitauthorizationresult.h" #include "polkitauthorizationresult.h"
#include "polkittemporaryauthorization.h" #include "polkittemporaryauthorization.h"
#include "_polkitbindings.h"
/* notes:
*
* - the _new_for_real() functions will ref the passed arg (you will still own the ref)
* - the _get_real() functions will return a ref (you will own the ref)
*
*/
PolkitActionDescription *polkit_action_description_new_for_real (_PolkitActionDescription *real);
_PolkitActionDescription *polkit_action_description_get_real (PolkitActionDescription *action_description);
PolkitActionDescription *polkit_action_description_new_for_gvariant (GVariant *value); PolkitActionDescription *polkit_action_description_new_for_gvariant (GVariant *value);
GVariant *polkit_action_description_to_gvariant (PolkitActionDescription *action_description); GVariant *polkit_action_description_to_gvariant (PolkitActionDescription *action_description);
...@@ -47,25 +37,25 @@ GVariant *polkit_identity_to_gvariant (PolkitIdentity *identity); ...@@ -47,25 +37,25 @@ GVariant *polkit_identity_to_gvariant (PolkitIdentity *identity);
PolkitSubject *polkit_subject_new_for_gvariant (GVariant *variant, GError **error); PolkitSubject *polkit_subject_new_for_gvariant (GVariant *variant, GError **error);
PolkitIdentity *polkit_identity_new_for_gvariant (GVariant *variant, GError **error); PolkitIdentity *polkit_identity_new_for_gvariant (GVariant *variant, GError **error);
PolkitSubject *polkit_subject_new_for_real (_PolkitSubject *real);
_PolkitSubject *polkit_subject_get_real (PolkitSubject *subject);
PolkitIdentity *polkit_identity_new_for_real (_PolkitIdentity *real);
_PolkitIdentity *polkit_identity_get_real (PolkitIdentity *identity);
PolkitAuthorizationResult *polkit_authorization_result_new_for_real (_PolkitAuthorizationResult *real);
_PolkitAuthorizationResult *polkit_authorization_result_get_real (PolkitAuthorizationResult *authorization_result);
PolkitAuthorizationResult *polkit_authorization_result_new_for_gvariant (GVariant *value); PolkitAuthorizationResult *polkit_authorization_result_new_for_gvariant (GVariant *value);
GVariant *polkit_authorization_result_to_gvariant (PolkitAuthorizationResult *authorization_result); GVariant *polkit_authorization_result_to_gvariant (PolkitAuthorizationResult *authorization_result);
_PolkitTemporaryAuthorization *polkit_temporary_authorization_get_real (PolkitTemporaryAuthorization *authorization);
PolkitTemporaryAuthorization *polkit_temporary_authorization_new_for_real (_PolkitTemporaryAuthorization *real);
PolkitTemporaryAuthorization *polkit_temporary_authorization_new_for_gvariant (GVariant *value); PolkitTemporaryAuthorization *polkit_temporary_authorization_new_for_gvariant (GVariant *value);
GVariant *polkit_temporary_authorization_to_gvariant (PolkitTemporaryAuthorization *authorization); GVariant *polkit_temporary_authorization_to_gvariant (PolkitTemporaryAuthorization *authorization);
PolkitDetails *polkit_details_new_for_hash (GHashTable *hash);
GHashTable *polkit_details_get_hash (PolkitDetails *details);
GVariant *polkit_details_to_gvariant (PolkitDetails *details); GVariant *polkit_details_to_gvariant (PolkitDetails *details);
PolkitDetails *polkit_details_new_for_gvariant (GVariant *value); PolkitDetails *polkit_details_new_for_gvariant (GVariant *value);
PolkitActionDescription *
polkit_action_description_new (const gchar *action_id,
const gchar *description,
const gchar *message,
const gchar *vendor_name,
const gchar *vendor_url,
const gchar *icon_name,
PolkitImplicitAuthorization implicit_any,
PolkitImplicitAuthorization implicit_inactive,
PolkitImplicitAuthorization implicit_active,
GHashTable *annotations);
#endif /* __POLKIT_PRIVATE_H */ #endif /* __POLKIT_PRIVATE_H */
...@@ -260,107 +260,6 @@ polkit_subject_from_string (const gchar *str, ...@@ -260,107 +260,6 @@ polkit_subject_from_string (const gchar *str,
return subject; return subject;
} }
PolkitSubject *
polkit_subject_new_for_real (_PolkitSubject *real)
{
PolkitSubject *s;
const gchar *kind;
EggDBusHashMap *details;
EggDBusVariant *variant;
EggDBusVariant *variant2;
s = NULL;
kind = _polkit_subject_get_subject_kind (real);
details = _polkit_subject_get_subject_details (real);
if (strcmp (kind, "") == 0)
{
/* explicitly left blank (for subjects that are NULL) */
}
else if (strcmp (kind, "unix-process") == 0)
{
variant = egg_dbus_hash_map_lookup (details, "pid");
variant2 = egg_dbus_hash_map_lookup (details, "start-time");
if (variant != NULL && variant2 != NULL)
s = polkit_unix_process_new_full (egg_dbus_variant_get_uint (variant),
egg_dbus_variant_get_uint64 (variant2));
}
else if (strcmp (kind, "unix-session") == 0)
{
variant = egg_dbus_hash_map_lookup (details, "session-id");
if (variant != NULL)
s = polkit_unix_session_new (egg_dbus_variant_get_string (variant));
}
else if (strcmp (kind, "system-bus-name") == 0)
{
variant = egg_dbus_hash_map_lookup (details, "name");
if (variant != NULL)
s = polkit_system_bus_name_new (egg_dbus_variant_get_string (variant));
}
else
{
g_warning ("Unknown subject kind %s:", kind);
}
return s;
}
_PolkitSubject *
polkit_subject_get_real (PolkitSubject *subject)
{
_PolkitSubject *real;
const gchar *kind;
EggDBusHashMap *details;
real = NULL;
kind = NULL;
details = egg_dbus_hash_map_new (G_TYPE_STRING, NULL, EGG_DBUS_TYPE_VARIANT, (GDestroyNotify) g_object_unref);
if (subject == NULL)
{
kind = "";
}
else if (POLKIT_IS_UNIX_PROCESS (subject))
{
kind = "unix-process";
egg_dbus_hash_map_insert (details,
"pid",
egg_dbus_variant_new_for_uint (polkit_unix_process_get_pid (POLKIT_UNIX_PROCESS (subject))));
egg_dbus_hash_map_insert (details,
"start-time",
egg_dbus_variant_new_for_uint64 (polkit_unix_process_get_start_time (POLKIT_UNIX_PROCESS (subject))));
}
else if (POLKIT_IS_UNIX_SESSION (subject))
{
kind = "unix-session";
egg_dbus_hash_map_insert (details,
"session-id",
egg_dbus_variant_new_for_string (polkit_unix_session_get_session_id (POLKIT_UNIX_SESSION (subject))));
}
else if (POLKIT_IS_SYSTEM_BUS_NAME (subject))
{
kind = "system-bus-name";
egg_dbus_hash_map_insert (details,
"name",
egg_dbus_variant_new_for_string (polkit_system_bus_name_get_name (POLKIT_SYSTEM_BUS_NAME (subject))));
}
else
{
g_warning ("Unknown class %s implementing PolkitSubject", g_type_name (G_TYPE_FROM_INSTANCE (subject)));
}
if (kind != NULL)
{
real = _polkit_subject_new (kind, details);
}
if (details != NULL)
g_object_unref (details);
return real;
}
GVariant * GVariant *
polkit_subject_to_gvariant (PolkitSubject *subject) polkit_subject_to_gvariant (PolkitSubject *subject)
{ {
......
...@@ -226,38 +226,59 @@ polkit_system_bus_name_to_string (PolkitSubject *subject) ...@@ -226,38 +226,59 @@ polkit_system_bus_name_to_string (PolkitSubject *subject)
return g_strdup_printf ("system-bus-name:%s", system_bus_name->name); return g_strdup_printf ("system-bus-name:%s", system_bus_name->name);
} }
static gboolean
polkit_system_bus_name_exists_sync (PolkitSubject *subject,
GCancellable *cancellable,
GError **error)
{
PolkitSystemBusName *name = POLKIT_SYSTEM_BUS_NAME (subject);
GDBusConnection *connection;
GVariant *result;
gboolean ret;
ret = FALSE;
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, cancellable, error);
if (connection == NULL)
goto out;
result = g_dbus_connection_call_sync (connection,
"org.freedesktop.DBus", /* name */
"/org/freedesktop/DBus", /* object path */
"org.freedesktop.DBus", /* interface name */
"NameHasOwner", /* method */
g_variant_new ("(s)", name->name),
G_VARIANT_TYPE ("(b)"),
G_DBUS_CALL_FLAGS_NONE,
-1,
cancellable,
error);
if (result == NULL)
goto out;
g_variant_get (result, "(b)", &ret);
g_variant_unref (result);
out:
if (connection != NULL)
g_object_unref (connection);
return ret;
}
static void static void
name_exists_cb (GObject *source_object, exists_in_thread_func (GSimpleAsyncResult *res,
GAsyncResult *res, GObject *object,
gpointer user_data) GCancellable *cancellable)
{ {
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data);
EggDBusMessage *reply;
GError *error; GError *error;
error = NULL; error = NULL;
reply = egg_dbus_connection_send_message_with_reply_finish (EGG_DBUS_CONNECTION (source_object), if (!polkit_system_bus_name_exists_sync (POLKIT_SUBJECT (object),
res, cancellable,
&error); &error))
if (reply != NULL)
{
gboolean has_owner;
if (egg_dbus_message_extract_boolean (reply, &has_owner, &error))
{
g_simple_async_result_set_op_res_gboolean (simple, has_owner);
}
g_object_unref (reply);
}
if (error != NULL)
{ {
g_simple_async_result_set_from_error (simple, error); g_simple_async_result_set_from_error (res, error);
g_error_free (error); g_error_free (error);
} }
g_simple_async_result_complete (simple);
g_object_unref (simple);
} }
static void static void
...@@ -266,88 +287,19 @@ polkit_system_bus_name_exists (PolkitSubject *subject, ...@@ -266,88 +287,19 @@ polkit_system_bus_name_exists (PolkitSubject *subject,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
PolkitSystemBusName *name = POLKIT_SYSTEM_BUS_NAME (subject);
EggDBusMessage *message;
EggDBusConnection *connection;
GSimpleAsyncResult *simple; GSimpleAsyncResult *simple;
message = NULL; g_return_if_fail (POLKIT_IS_SYSTEM_BUS_NAME (subject));
connection = NULL;
connection = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SYSTEM);
message = egg_dbus_connection_new_message_for_method_call (connection, simple = g_simple_async_result_new (G_OBJECT (subject),
NULL,
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"NameHasOwner");
egg_dbus_message_append_string (message, name->name, NULL);
simple = g_simple_async_result_new (G_OBJECT (name),
callback, callback,
user_data, user_data,
polkit_system_bus_name_exists); polkit_system_bus_name_exists);
g_simple_async_result_run_in_thread (simple,
egg_dbus_connection_send_message_with_reply (connection, exists_in_thread_func,
EGG_DBUS_CALL_FLAGS_NONE, G_PRIORITY_DEFAULT,
message, cancellable);
NULL, g_object_unref (simple);
cancellable,
name_exists_cb,
simple);
g_object_unref (message);
g_object_unref (connection);
}
static gboolean
polkit_system_bus_name_exists_sync (PolkitSubject *subject,
GCancellable *cancellable,
GError **error)
{
PolkitSystemBusName *name = POLKIT_SYSTEM_BUS_NAME (subject);
EggDBusMessage *message;
EggDBusMessage *reply;
EggDBusConnection *connection;
gboolean ret;
message = NULL;
reply = NULL;
connection = NULL;
ret = FALSE;
connection = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SYSTEM);
message = egg_dbus_connection_new_message_for_method_call (connection,
NULL,
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",