static GList* g_tls_database_real_lookup_certificates_issued_by_finish (GTlsDatabase *self, GAsyncResult *result, GError **error) { AsyncLookupCertificatesIssuedBy *args; GList *results; g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL); g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self), g_tls_database_real_lookup_certificates_issued_by_async), FALSE); if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error)) return NULL; args = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result)); results = args->results; args->results = NULL; return results; }
static GTlsCertificate* g_tls_database_real_lookup_certificate_for_handle_finish (GTlsDatabase *self, GAsyncResult *result, GError **error) { AsyncLookupCertificateForHandle *args; GTlsCertificate *certificate; g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), NULL); g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self), g_tls_database_real_lookup_certificate_for_handle_async), FALSE); if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error)) return NULL; args = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result)); certificate = args->result; args->result = NULL; return certificate; }
static gssize data_wrapper_decode_to_stream_finish (CamelDataWrapper *data_wrapper, GAsyncResult *result, GError **error) { GSimpleAsyncResult *simple; AsyncContext *async_context; g_return_val_if_fail ( g_simple_async_result_is_valid ( result, G_OBJECT (data_wrapper), data_wrapper_decode_to_stream), -1); simple = G_SIMPLE_ASYNC_RESULT (result); async_context = g_simple_async_result_get_op_res_gpointer (simple); if (g_simple_async_result_propagate_error (simple, error)) return -1; return async_context->bytes_written; }
static GList * lookup_service_finish (GResolver *resolver, GAsyncResult *result, GError **error) { GSimpleAsyncResult *simple; GUnixResolverRequest *req; GList *targets; g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (resolver), lookup_service_async), FALSE); simple = G_SIMPLE_ASYNC_RESULT (result); if (g_simple_async_result_propagate_error (simple, error)) return NULL; req = g_simple_async_result_get_op_res_gpointer (simple); targets = req->u.service.targets; req->u.service.targets = NULL; return targets; }
const char * nm_bluez_device_connect_finish (NMBluezDevice *self, GAsyncResult *result, GError **error) { GSimpleAsyncResult *simple; const char *device; g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self), nm_bluez_device_connect_async), NULL); simple = (GSimpleAsyncResult *) result; if (g_simple_async_result_propagate_error (simple, error)) return NULL; device = (const char *) g_simple_async_result_get_op_res_gpointer (simple); return device; }
static gchar * lookup_by_address_finish (GResolver *resolver, GAsyncResult *result, GError **error) { GSimpleAsyncResult *simple; GUnixResolverRequest *req; gchar *name; g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (resolver), lookup_by_address_async), FALSE); simple = G_SIMPLE_ASYNC_RESULT (result); if (g_simple_async_result_propagate_error (simple, error)) return NULL; req = g_simple_async_result_get_op_res_gpointer (simple); name = req->u.address.hostname; req->u.address.hostname = NULL; return name; }
gboolean fr_process_execute_finish (FrProcess *process, GAsyncResult *result, FrError **error) { ExecuteData *exec_data; g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (process), fr_process_execute), FALSE); exec_data = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result)); if (exec_data->error == NULL) return TRUE; if (error != NULL) { if (exec_data->error->gerror == NULL) exec_data->error->gerror = g_error_new_literal (FR_ERROR, exec_data->error->type, ""); *error = fr_error_copy (exec_data->error); } return FALSE; }
/** * e_webdav_discover_content_refresh_finish: * @content: a WebDAV discovery content, created by e_webdav_discover_content_new() * @result: a #GAsyncResult * @error: (allow-none): return location for a #GError, or %NULL * * Finishes the operation started with e_webdav_discover_content_refresh(). If an * error occurred, the function will set @error and return %FALSE. There is * available e_webdav_discover_content_show_error() for convenience, which * shows the error within @content and takes care of it when refreshing * the content. * * Returns: %TRUE on success, %FALSE on failure * * Since: 3.18 **/ gboolean e_webdav_discover_content_refresh_finish (GtkWidget *content, GAsyncResult *result, GError **error) { EWebDAVDiscoverContentData *data; GSimpleAsyncResult *simple; g_return_val_if_fail (GTK_IS_GRID (content), FALSE); data = g_object_get_data (G_OBJECT (content), WEBDAV_DISCOVER_CONTENT_DATA_KEY); g_return_val_if_fail (data != NULL, FALSE); g_return_val_if_fail (g_simple_async_result_is_valid ( result, G_OBJECT (content), e_webdav_discover_content_refresh), FALSE); simple = G_SIMPLE_ASYNC_RESULT (result); if (g_simple_async_result_propagate_error (simple, error)) return FALSE; return g_simple_async_result_get_op_res_gboolean (simple); }
static GList * lookup_by_name_finish (GResolver *resolver, GAsyncResult *result, GError **error) { GSimpleAsyncResult *simple; GUnixResolverRequest *req; GList *addresses; g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (resolver), lookup_by_name_async), NULL); simple = G_SIMPLE_ASYNC_RESULT (result); if (g_simple_async_result_propagate_error (simple, error)) return NULL; req = g_simple_async_result_get_op_res_gpointer (simple); addresses = req->u.name.addresses; req->u.name.addresses = NULL; return addresses; }
static CockpitCreds * cockpit_auth_remote_login_finish (CockpitAuth *self, GAsyncResult *result, GHashTable *headers, CockpitTransport **transport, GError **error) { RemoteLoginData *rl; g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self), cockpit_auth_remote_login_async), NULL); if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error)) return NULL; rl = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result)); if (transport) *transport = g_object_ref (rl->transport); return cockpit_creds_ref (rl->creds); }
gboolean _sw_client_service_upload_finish (SwClientService *service, GAsyncResult *res, GError **error) { GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res); gboolean ret; g_return_val_if_fail (g_simple_async_result_is_valid (res, G_OBJECT (service), NULL), FALSE); ret = FALSE; if (g_simple_async_result_propagate_error (simple, error)) goto out; ret = g_simple_async_result_get_op_res_gboolean (simple); out: return ret; }
static gpointer seahorse_hkp_source_export_finish (SeahorseServerSource *source, GAsyncResult *result, gsize *size, GError **error) { ExportClosure *closure; gpointer output; g_return_val_if_fail (size != NULL, NULL); g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (source), seahorse_hkp_source_export_async), NULL); if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error)) return NULL; closure = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result)); *size = closure->data->len; output = g_string_free (closure->data, FALSE); closure->data = NULL; return output; }
/** * e_mail_session_get_fcc_for_message_finish: * @session: an #EMailSession * @result: a #GAsyncResult * @error: return location for a #GError, or %NULL * * Finishes the operation started with e_mail_session_get_fcc_for_message(). * * The returned #CamelFolder is referenced for thread-safety and must be * unreferenced with g_object_unref() when finished with it. * * If a non-recoverable error occurred, the function sets @error and * returns %NULL. * * Returns: a #CamelFolder, or %NULL **/ CamelFolder * e_mail_session_get_fcc_for_message_finish (EMailSession *session, GAsyncResult *result, GError **error) { GSimpleAsyncResult *simple; AsyncContext *async_context; g_return_val_if_fail ( g_simple_async_result_is_valid ( result, G_OBJECT (session), e_mail_session_get_fcc_for_message), NULL); simple = G_SIMPLE_ASYNC_RESULT (result); async_context = g_simple_async_result_get_op_res_gpointer (simple); if (g_simple_async_result_propagate_error (simple, error)) return NULL; g_return_val_if_fail (async_context->folder != NULL, NULL); return g_object_ref (async_context->folder); }
EMsgComposer * e_composer_load_snapshot_finish (EShell *shell, GAsyncResult *result, GError **error) { GSimpleAsyncResult *simple; LoadContext *context; g_return_val_if_fail ( g_simple_async_result_is_valid ( result, G_OBJECT (shell), e_composer_load_snapshot), NULL); simple = G_SIMPLE_ASYNC_RESULT (result); context = g_simple_async_result_get_op_res_gpointer (simple); if (g_simple_async_result_propagate_error (simple, error)) return NULL; g_return_val_if_fail (E_IS_MSG_COMPOSER (context->composer), NULL); return g_object_ref (context->composer); }
/** * folks_tp_lowlevel_connection_get_alias_flags_finish: * @result: a #GAsyncResult * @error: return location for a #GError, or %NULL * * Determine the alias-related capabilities of the #TpConnection. * * Returns: the #TpConnectionAliasFlags */ TpConnectionAliasFlags folks_tp_lowlevel_connection_get_alias_flags_finish ( GAsyncResult *result, GError **error) { GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); TpConnection *conn; g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (simple), FALSE); conn = TP_CONNECTION (g_async_result_get_source_object (result)); g_return_val_if_fail (TP_IS_CONNECTION (conn), FALSE); if (g_simple_async_result_propagate_error (simple, error)) return 0; g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (conn), folks_tp_lowlevel_connection_get_alias_flags_finish), 0); return (TpConnectionAliasFlags) (g_simple_async_result_get_op_res_gpointer ( G_SIMPLE_ASYNC_RESULT (result))); }
GByteArray * hev_serial_port_queue_command_finish(HevSerialPort *self, GAsyncResult *res, GError **error) { HevSerialPortPrivate *priv = NULL; g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); g_return_val_if_fail(HEV_IS_SERIAL_PORT(self), NULL); priv = HEV_SERIAL_PORT_GET_PRIVATE(self); /* Pop tail */ g_queue_pop_tail(priv->queue); if(!g_queue_is_empty(priv->queue)) hev_serial_port_queue_command_handler(self); g_return_val_if_fail(g_simple_async_result_is_valid(res, G_OBJECT(self), hev_serial_port_queue_command_async), NULL); if(g_simple_async_result_propagate_error(G_SIMPLE_ASYNC_RESULT(res), error)) return NULL; return g_simple_async_result_get_op_res_gpointer(G_SIMPLE_ASYNC_RESULT(res)); }
gboolean set_system_timezone_finish (GAsyncResult *result, GError **error) { GDBusConnection *system_bus = get_system_bus (NULL); GVariant *reply; /* detect if we set an error due to being unable to get the system bus */ if (g_simple_async_result_is_valid (result, NULL, set_system_timezone_async)) { g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error); return FALSE; } g_assert (system_bus != NULL); reply = g_dbus_connection_call_finish (system_bus, result, error); if (reply != NULL) g_variant_unref (reply); return reply != NULL; }
gboolean idle_server_connection_send_finish(IdleServerConnection *conn, GAsyncResult *result, GError **error) { /* we can't check the source tag here because we use * report_error_in_idle which never sets a source tag */ g_return_val_if_fail(g_simple_async_result_is_valid(result, G_OBJECT(conn), NULL), FALSE); return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT(result), error); }
/* When called from start_mechanism, initial_data can be NULL. When called * from D-Bus as StartMechanismWithData, it can't. */ static void gabble_server_sasl_channel_start_mechanism_with_data ( TpSvcChannelInterfaceSASLAuthentication *iface, const gchar *in_Mechanism, const GArray *in_InitialData, DBusGMethodInvocation *context) { GabbleServerSaslChannel *self = GABBLE_SERVER_SASL_CHANNEL (iface); GabbleServerSaslChannelPrivate *priv = self->priv; WockyAuthRegistryStartData *start_data; GSimpleAsyncResult *r = priv->result; GString *initial_data = NULL; if (self->priv->sasl_status != TP_SASL_STATUS_NOT_STARTED) { gabble_server_sasl_channel_raise (context, TP_ERROR_NOT_AVAILABLE, "Mechanisms can only be started in state Not_Started, not %u", self->priv->sasl_status); DEBUG ("cannot start: state %u != Not_Started", self->priv->sasl_status); return; } /* NotStarted state is entered by creating the channel: the caller must * call start_auth_async immediately */ g_assert (r != NULL); g_assert (g_simple_async_result_is_valid (G_ASYNC_RESULT (r), G_OBJECT (self), gabble_server_sasl_channel_start_auth_async)); if (tp_strv_contains ((const gchar * const *) priv->available_mechanisms, in_Mechanism)) { priv->result = NULL; if (in_InitialData != NULL) { /* The initial data might be secret (for PLAIN etc.), and also might * not be UTF-8 or even text, so we just output the length */ DEBUG ("Starting %s authentication with %u bytes of initial data", in_Mechanism, in_InitialData->len); initial_data = g_string_new_len (in_InitialData->data, in_InitialData->len); } else { DEBUG ("Starting %s authentication without initial data", in_Mechanism); } change_current_state (self, TP_SASL_STATUS_IN_PROGRESS, NULL, NULL); dbus_g_method_return (context); start_data = wocky_auth_registry_start_data_new (in_Mechanism, initial_data); g_simple_async_result_set_op_res_gpointer (r, start_data, (GDestroyNotify) wocky_auth_registry_start_data_free); g_simple_async_result_complete_in_idle (r); g_object_unref (r); if (initial_data != NULL) g_string_free (initial_data, TRUE); } else { DEBUG ("cannot start: %s is not a supported mechanism", in_Mechanism); gabble_server_sasl_channel_raise (context, TP_ERROR_NOT_IMPLEMENTED, "Selected mechanism is not available."); } }
static void gabble_server_sasl_channel_accept_sasl ( TpSvcChannelInterfaceSASLAuthentication *channel, DBusGMethodInvocation *context) { GabbleServerSaslChannel *self = GABBLE_SERVER_SASL_CHANNEL (channel); GSimpleAsyncResult *r = self->priv->result; const gchar *message = NULL; switch (self->priv->sasl_status) { case TP_SASL_STATUS_NOT_STARTED: message = "Authentication has not yet begun (Not_Started)"; break; case TP_SASL_STATUS_IN_PROGRESS: /* In this state, the only valid time to call this method is in response * to a challenge, to indicate that, actually, that challenge was * additional data for a successful authentication. */ if (r == NULL) { message = "In_Progress, but you already responded to the last " "challenge"; } else { DEBUG ("client says the last challenge was actually final data " "and has accepted it"); g_assert (g_simple_async_result_is_valid (G_ASYNC_RESULT (r), G_OBJECT (self), gabble_server_sasl_channel_challenge_async)); change_current_state (self, TP_SASL_STATUS_CLIENT_ACCEPTED, NULL, NULL); } break; case TP_SASL_STATUS_SERVER_SUCCEEDED: /* The server has already said yes, and the caller is waiting for * success_async(), i.e. waiting for the UI to check whether it's * happy too. AcceptSASL means that it is. */ DEBUG ("client has accepted server's success"); g_assert (g_simple_async_result_is_valid (G_ASYNC_RESULT (r), G_OBJECT (self), gabble_server_sasl_channel_success_async)); change_current_state (self, TP_SASL_STATUS_SUCCEEDED, NULL, NULL); break; case TP_SASL_STATUS_CLIENT_ACCEPTED: message = "Client already accepted authentication (Client_Accepted)"; break; case TP_SASL_STATUS_SUCCEEDED: message = "Authentication already succeeded (Succeeded)"; break; case TP_SASL_STATUS_SERVER_FAILED: message = "Authentication has already failed (Server_Failed)"; break; case TP_SASL_STATUS_CLIENT_FAILED: message = "Authentication has already been aborted (Client_Failed)"; break; default: g_assert_not_reached (); } if (message != NULL) { DEBUG ("cannot accept SASL: %s", message); gabble_server_sasl_channel_raise (context, TP_ERROR_NOT_AVAILABLE, "%s", message); return; } if (r != NULL) { /* This is a bit weird - this code is run for two different async * results. In the In_Progress case, this code results in * success with the GSimpleAsyncResult's op_res left as NULL, which * is what Wocky wants for an empty response. In the Server_Succeeded * response, the async result is just success or error - we succeed. */ self->priv->result = NULL; /* We want want to complete not in an idle because if we do we * will hit fd.o#32278. This is safe because we're being called * from dbus-glib in the main loop. */ g_simple_async_result_complete (r); g_object_unref (r); } tp_svc_channel_interface_sasl_authentication_return_from_accept_sasl ( context); }
gboolean idle_server_connection_disconnect_finish(IdleServerConnection *conn, GAsyncResult *result, GError **error) { g_return_val_if_fail(g_simple_async_result_is_valid(result, G_OBJECT(conn), idle_server_connection_disconnect_full_async), FALSE); return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT(result), error); }