0);
}
-void
-polkit_backend_authority_system_bus_name_owner_changed (PolkitBackendAuthority *authority,
- const gchar *name,
- const gchar *old_owner,
- const gchar *new_owner)
-{
- PolkitBackendAuthorityClass *klass;
-
- klass = POLKIT_BACKEND_AUTHORITY_GET_CLASS (authority);
-
- if (klass->system_bus_name_owner_changed != NULL)
- klass->system_bus_name_owner_changed (authority, name, old_owner, new_owner);
-}
-
/**
* polkit_backend_authority_get_name:
* @authority: A #PolkitBackendAuthority.
typedef struct
{
guint authority_registration_id;
- guint name_owner_changed_signal_id;
GDBusNodeInfo *introspection_info;
{
g_free (server->object_path);
- //g_signal_handler_disconnect (server->bus, server->name_owner_changed_id);
-
if (server->authority_registration_id > 0)
g_dbus_connection_unregister_object (server->connection, server->authority_registration_id);
- if (server->name_owner_changed_signal_id > 0)
- g_dbus_connection_signal_unsubscribe (server->connection, server->name_owner_changed_signal_id);
-
if (server->connection != NULL)
g_object_unref (server->connection);
/* ---------------------------------------------------------------------------------------------------- */
-static void
-server_on_name_owner_changed_signal (GDBusConnection *connection,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data)
-{
- Server *server = user_data;
- const gchar *name;
- const gchar *old_owner;
- const gchar *new_owner;
-
- g_variant_get (parameters,
- "(&s&s&s)",
- &name,
- &old_owner,
- &new_owner);
-
- polkit_backend_authority_system_bus_name_owner_changed (server->authority,
- name,
- old_owner,
- new_owner);
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
static const GDBusInterfaceVTable server_vtable =
{
server_handle_method_call,
goto error;
}
- server->name_owner_changed_signal_id =
- g_dbus_connection_signal_subscribe (server->connection,
- "org.freedesktop.DBus", /* sender */
- "org.freedesktop.DBus", /* interface */
- "NameOwnerChanged", /* member */
- "/org/freedesktop/DBus", /* path */
- NULL, /* arg0 */
- G_DBUS_SIGNAL_FLAGS_NONE,
- server_on_name_owner_changed_signal,
- server,
- NULL); /* GDestroyNotify */
-
server->authority = g_object_ref (authority);
server->authority_changed_id = g_signal_connect (server->authority,
* authorization identified by id or %NULL if the backend doesn't support
* the operation. See polkit_backend_authority_revoke_temporary_authorization_by_id()
* for details.
- * @system_bus_name_owner_changed: temporary VFunc, to be removed before API is declared stable.
*
* VFuncs that authority backends need to implement.
*/
const gchar *id,
GError **error);
- /* TODO: need something more efficient such that we don't watch all name changes */
- void (*system_bus_name_owner_changed) (PolkitBackendAuthority *authority,
- const gchar *name,
- const gchar *old_owner,
- const gchar *new_owner);
-
/*< private >*/
/* Padding for future expansion */
void (*_polkit_reserved1) (void);
const gchar *format,
...);
-void polkit_backend_authority_system_bus_name_owner_changed (PolkitBackendAuthority *authority,
- const gchar *name,
- const gchar *old_owner,
- const gchar *new_owner);
-
GList *polkit_backend_authority_enumerate_actions (PolkitBackendAuthority *authority,
PolkitSubject *caller,
const gchar *locale,
/* ---------------------------------------------------------------------------------------------------- */
-static void polkit_backend_interactive_authority_system_bus_name_owner_changed (PolkitBackendAuthority *authority,
- const gchar *name,
- const gchar *old_owner,
- const gchar *new_owner);
+static void polkit_backend_interactive_authority_system_bus_name_owner_changed (PolkitBackendInteractiveAuthority *authority,
+ const gchar *name,
+ const gchar *old_owner,
+ const gchar *new_owner);
static GList *polkit_backend_interactive_authority_enumerate_actions (PolkitBackendAuthority *authority,
PolkitSubject *caller,
GHashTable *hash_session_to_authentication_agent;
+ GDBusConnection *system_bus_connection;
+ guint name_owner_changed_signal_id;
} PolkitBackendInteractiveAuthorityPrivate;
/* ---------------------------------------------------------------------------------------------------- */
g_signal_emit_by_name (authority, "changed");
}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+on_name_owner_changed_signal (GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ PolkitBackendInteractiveAuthority *authority = POLKIT_BACKEND_INTERACTIVE_AUTHORITY (user_data);
+ const gchar *name;
+ const gchar *old_owner;
+ const gchar *new_owner;
+
+ g_variant_get (parameters,
+ "(&s&s&s)",
+ &name,
+ &old_owner,
+ &new_owner);
+
+ polkit_backend_interactive_authority_system_bus_name_owner_changed (authority,
+ name,
+ old_owner,
+ new_owner);
+}
+
/* ---------------------------------------------------------------------------------------------------- */
static void
{
PolkitBackendInteractiveAuthorityPrivate *priv;
GFile *directory;
+ GError *error;
priv = POLKIT_BACKEND_INTERACTIVE_AUTHORITY_GET_PRIVATE (authority);
"changed",
G_CALLBACK (on_session_monitor_changed),
authority);
+
+ error = NULL;
+ priv->system_bus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (priv->system_bus_connection == NULL)
+ {
+ g_warning ("Error getting system bus: %s", error->message);
+ g_error_free (error);
+ }
+ else
+ {
+ /* TODO: this is a bit inefficient */
+ priv->name_owner_changed_signal_id =
+ g_dbus_connection_signal_subscribe (priv->system_bus_connection,
+ "org.freedesktop.DBus", /* sender */
+ "org.freedesktop.DBus", /* interface */
+ "NameOwnerChanged", /* member */
+ "/org/freedesktop/DBus", /* path */
+ NULL, /* arg0 */
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ on_name_owner_changed_signal,
+ authority,
+ NULL); /* GDestroyNotify */
+ }
}
static void
interactive_authority = POLKIT_BACKEND_INTERACTIVE_AUTHORITY (object);
priv = POLKIT_BACKEND_INTERACTIVE_AUTHORITY_GET_PRIVATE (interactive_authority);
+ if (priv->name_owner_changed_signal_id > 0)
+ g_dbus_connection_signal_unsubscribe (priv->system_bus_connection, priv->name_owner_changed_signal_id);
+
+ if (priv->system_bus_connection != NULL)
+ g_object_unref (priv->system_bus_connection);
+
if (priv->action_pool != NULL)
g_object_unref (priv->action_pool);
authority_class->get_name = polkit_backend_interactive_authority_get_name;
authority_class->get_version = polkit_backend_interactive_authority_get_version;
authority_class->get_features = polkit_backend_interactive_authority_get_features;
- authority_class->system_bus_name_owner_changed = polkit_backend_interactive_authority_system_bus_name_owner_changed;
authority_class->enumerate_actions = polkit_backend_interactive_authority_enumerate_actions;
authority_class->check_authorization = polkit_backend_interactive_authority_check_authorization;
authority_class->check_authorization_finish = polkit_backend_interactive_authority_check_authorization_finish;
/* ---------------------------------------------------------------------------------------------------- */
static void
-polkit_backend_interactive_authority_system_bus_name_owner_changed (PolkitBackendAuthority *authority,
- const gchar *name,
- const gchar *old_owner,
- const gchar *new_owner)
+polkit_backend_interactive_authority_system_bus_name_owner_changed (PolkitBackendInteractiveAuthority *authority,
+ const gchar *name,
+ const gchar *old_owner,
+ const gchar *new_owner)
{
PolkitBackendInteractiveAuthority *interactive_authority;
PolkitBackendInteractiveAuthorityPrivate *priv;