static void identity_registered (SignonIdentity *identity, char *object_path, GVariant *identity_data, GError *error) { g_return_if_fail (SIGNON_IS_IDENTITY (identity)); SignonIdentityPrivate *priv; priv = identity->priv; g_return_if_fail (priv != NULL); if (!error) { GDBusConnection *connection; GDBusProxy *auth_service_proxy; const gchar *bus_name; GError *proxy_error = NULL; DEBUG("%s: %s", G_STRFUNC, object_path); /* * TODO: as Aurel will finalize the code polishing so we will * need to implement the refresh of the proxy to SignonIdentity * */ g_return_if_fail (priv->proxy == NULL); auth_service_proxy = (GDBusProxy *)priv->auth_service_proxy; connection = g_dbus_proxy_get_connection (auth_service_proxy); bus_name = g_dbus_proxy_get_name (auth_service_proxy); priv->proxy = sso_identity_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, bus_name, object_path, priv->cancellable, &proxy_error); if (G_UNLIKELY (proxy_error != NULL)) { g_warning ("Failed to initialize Identity proxy: %s", proxy_error->message); g_clear_error (&proxy_error); } priv->signal_info_updated = g_signal_connect (priv->proxy, "info-updated", G_CALLBACK (identity_state_changed_cb), identity); priv->signal_unregistered = g_signal_connect (priv->proxy, "unregistered", G_CALLBACK (identity_remote_object_destroyed_cb), identity); if (identity_data) { DEBUG("%s: ", G_STRFUNC); priv->identity_info = signon_identity_info_new_from_variant (identity_data); g_variant_unref (identity_data); } priv->updated = TRUE; } else g_warning ("%s: %s", G_STRFUNC, error->message); /* * execute queued operations or emit errors on each of them * */ priv->registration_state = REGISTERED; /* * TODO: if we will add a new state for identity: "INVALID" * consider emission of another error, like "invalid" * */ _signon_object_ready (identity, identity_object_quark (), error); /* * as the registration failed we do not * request for new registration, but emit * same error again and again * */ }
static void auth_session_get_object_path_reply (GObject *object, GAsyncResult *res, gpointer userdata) { SsoAuthService *proxy = SSO_AUTH_SERVICE (object); gchar *object_path = NULL; GError *error = NULL; sso_auth_service_call_get_auth_session_object_path_finish (proxy, &object_path, res, &error); SIGNON_RETURN_IF_CANCELLED (error); g_return_if_fail (SIGNON_IS_AUTH_SESSION (userdata)); SignonAuthSession *self = SIGNON_AUTH_SESSION (userdata); SignonAuthSessionPrivate *priv = self->priv; g_return_if_fail (priv != NULL); priv->registering = FALSE; if (!g_strcmp0(object_path, "") || error) { if (error) DEBUG ("Error message is %s", error->message); else error = g_error_new (signon_error_quark(), SIGNON_ERROR_RUNTIME, "Cannot create remote AuthSession object"); } else { GDBusConnection *connection; const gchar *bus_name; GError *proxy_error = NULL; connection = g_dbus_proxy_get_connection ((GDBusProxy *)proxy); bus_name = g_dbus_proxy_get_name ((GDBusProxy *)proxy); priv->proxy = sso_auth_session_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, bus_name, object_path, priv->cancellable, &proxy_error); if (G_UNLIKELY (proxy_error != NULL)) { g_warning ("Failed to initialize AuthSession proxy: %s", proxy_error->message); g_clear_error (&proxy_error); } g_dbus_proxy_set_default_timeout ((GDBusProxy *)priv->proxy, G_MAXINT); priv->signal_state_changed = g_signal_connect (priv->proxy, "state-changed", G_CALLBACK (auth_session_state_changed_cb), self); priv->signal_unregistered = g_signal_connect (priv->proxy, "unregistered", G_CALLBACK (auth_session_remote_object_destroyed_cb), self); } DEBUG ("Object path received: %s", object_path); _signon_object_ready (self, auth_session_object_quark (), error); g_clear_error (&error); }
static void auth_session_get_object_path_reply (DBusGProxy *proxy, char *object_path, GError *error, gpointer userdata) { g_return_if_fail (SIGNON_IS_AUTH_SESSION (userdata)); SignonAuthSession *self = SIGNON_AUTH_SESSION (userdata); SignonAuthSessionPrivate *priv = self->priv; g_return_if_fail (priv != NULL); priv->pending_call_get_path = NULL; if (!g_strcmp0(object_path, "") || error) { if (error) DEBUG ("Error message is %s", error->message); else { error = g_error_new (auth_session_errors_quark(), 1, SSO_AUTH_SESSION_CONNECTION_PROBLEM_G); g_free (object_path); } } else { priv->proxy = dbus_g_proxy_new_from_proxy (DBUS_G_PROXY (priv->signon_proxy), SIGNOND_AUTH_SESSION_INTERFACE, object_path); dbus_g_object_register_marshaller (_signon_marshal_VOID__INT_STRING, G_TYPE_NONE, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_add_signal (priv->proxy, "stateChanged", G_TYPE_INT, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->proxy, "stateChanged", G_CALLBACK (auth_session_state_changed_cb), self, NULL); dbus_g_object_register_marshaller (g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, G_TYPE_INVALID); dbus_g_proxy_add_signal (priv->proxy, "unregistered", G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->proxy, "unregistered", G_CALLBACK (auth_session_remote_object_destroyed_cb), self, NULL); g_free (object_path); } DEBUG ("Object path received: %s", object_path); _signon_object_ready (self, auth_session_object_quark (), error); g_clear_error (&error); }