static DBusMessage* service_method_open_session (GkdSecretService *self, DBusMessage *message) { GkdSecretSession *session; ServiceClient *client; DBusMessage *reply = NULL; const gchar *caller; const gchar *path; if (!dbus_message_has_signature (message, "sv")) return NULL; caller = dbus_message_get_sender (message); /* Now we can create a session with this information */ session = gkd_secret_session_new (self, caller); reply = gkd_secret_session_handle_open (session, message); if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_METHOD_RETURN) { /* Take ownership of the session */ client = g_hash_table_lookup (self->clients, caller); g_return_val_if_fail (client, NULL); path = gkd_secret_dispatch_get_object_path (GKD_SECRET_DISPATCH (session)); g_return_val_if_fail (!g_hash_table_lookup (client->sessions, path), NULL); g_hash_table_replace (client->sessions, (gpointer)path, session); } else { g_object_unref (session); } return reply; }
static DBusMessage* service_method_open_session (GkdSecretService *self, DBusMessage *message) { GkdSecretSession *session; DBusMessage *reply = NULL; const gchar *caller; if (!dbus_message_has_signature (message, "sv")) return NULL; caller = dbus_message_get_sender (message); /* Now we can create a session with this information */ session = gkd_secret_session_new (self, caller); reply = gkd_secret_session_handle_open (session, message); if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_METHOD_RETURN) gkd_secret_service_publish_dispatch (self, caller, GKD_SECRET_DISPATCH (session)); g_object_unref (session); return reply; }
static gboolean service_method_open_session (GkdExportedService *skeleton, GDBusMethodInvocation *invocation, gchar *algorithm, GVariant *input, GkdSecretService *self) { GkdSecretSession *session; GVariant *output = NULL; gchar *result = NULL; GError *error = NULL; const gchar *caller; GVariant *input_payload; caller = g_dbus_method_invocation_get_sender (invocation); /* Now we can create a session with this information */ session = gkd_secret_session_new (self, caller); input_payload = g_variant_get_variant (input); gkd_secret_session_handle_open (session, algorithm, input_payload, &output, &result, &error); g_variant_unref (input_payload); if (error != NULL) { g_dbus_method_invocation_take_error (invocation, error); } else { gkd_secret_service_publish_dispatch (self, caller, GKD_SECRET_DISPATCH (session)); gkd_exported_service_complete_open_session (skeleton, invocation, output, result); g_free (result); } g_object_unref (session); return TRUE; }