static void get_volumes_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { GVfsAfpServer *server = G_VFS_AFP_SERVER (source_object); GSimpleAsyncResult *simple = user_data; GVfsBackendAfpBrowse *afp_backend; GPtrArray *volumes; GError *err = NULL; afp_backend = G_VFS_BACKEND_AFP_BROWSE (g_async_result_get_source_object (G_ASYNC_RESULT (simple))); volumes = g_vfs_afp_server_get_volumes_finish (server, res, &err); if (!volumes) { g_simple_async_result_take_error (simple, err); goto done; } if (afp_backend->volumes) g_ptr_array_unref (afp_backend->volumes); afp_backend->volumes = volumes; done: g_simple_async_result_complete (simple); g_object_unref (simple); }
static void gom_resource_save_cb (GomAdapter *adapter, gpointer user_data) { GSimpleAsyncResult *simple = user_data; GomResource *resource; gboolean ret; GError *error = NULL; GAsyncQueue *queue; g_return_if_fail(GOM_IS_ADAPTER(adapter)); g_return_if_fail(G_IS_SIMPLE_ASYNC_RESULT(simple)); resource = GOM_RESOURCE(g_async_result_get_source_object(G_ASYNC_RESULT(simple))); g_assert(GOM_IS_RESOURCE(resource)); queue = g_object_get_data(G_OBJECT(simple), "queue"); if (!(ret = gom_resource_do_save(resource, adapter, &error))) { g_simple_async_result_take_error(simple, error); } g_simple_async_result_set_op_res_gboolean(simple, ret); if (!queue) g_simple_async_result_complete_in_idle(simple); else g_async_queue_push(queue, GINT_TO_POINTER(TRUE)); g_object_unref(resource); }
static void process_result (GckCall *call, gpointer unused) { gboolean stop = FALSE; /* Double check a few things */ g_assert (GCK_IS_CALL (call)); if (call->cancellable) { /* Don't call the callback when cancelled */ if (g_cancellable_is_cancelled (call->cancellable)) { call->rv = CKR_FUNCTION_CANCELED; stop = TRUE; } } /* * Hmmm, does the function want to actually be done? * If not, then queue this call again. */ if (!stop && !complete_call (call->complete, call->args, call->rv)) { g_object_ref (call); g_thread_pool_push (GCK_CALL_GET_CLASS (call)->thread_pool, call, NULL); /* All done, finish processing */ } else if (call->callback) { g_assert (G_IS_OBJECT (call->object)); (call->callback) (G_OBJECT (call->object), G_ASYNC_RESULT (call), call->user_data); } }
static void bluez_connect_cb (GDBusConnection *dbus_connection, GAsyncResult *res, gpointer user_data) { GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data); GObject *result_object = g_async_result_get_source_object (G_ASYNC_RESULT (result)); NMBluezDevice *self = NM_BLUEZ_DEVICE (result_object); NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self); GError *error = NULL; char *device; GVariant *variant; variant = g_dbus_connection_call_finish (dbus_connection, res, &error); if (!variant) { g_simple_async_result_take_error (result, error); } else { g_variant_get (variant, "(s)", &device); g_simple_async_result_set_op_res_gpointer (result, g_strdup (device), g_free); priv->bt_iface = device; g_variant_unref (variant); } g_simple_async_result_complete (result); g_object_unref (result); g_object_unref (result_object); }
static void load_pixbuf_thread (GSimpleAsyncResult *result, GObject *object, GCancellable *cancellable) { GdkPixbuf *pixbuf; AsyncTextureLoadData *data; GError *error = NULL; data = g_async_result_get_user_data (G_ASYNC_RESULT (result)); g_assert (data != NULL); g_assert (data->file != NULL); pixbuf = impl_load_pixbuf_file (data->file, data->width, data->height, data->scale, &error); if (error != NULL) { g_simple_async_result_set_from_error (result, error); return; } if (pixbuf) g_simple_async_result_set_op_res_gpointer (result, g_object_ref (pixbuf), g_object_unref); }
static void news_sync_task_save_cb (GObject *object, GAsyncResult *result, gpointer user_data) { NewsSyncTaskPrivate *priv; GSimpleAsyncResult *simple = user_data; NewsSyncTask *task; GomResource *resource = (GomResource *)object; GError *error = NULL; g_assert(NEWS_IS_FEED(resource)); g_assert(G_IS_SIMPLE_ASYNC_RESULT(simple)); task = (NewsSyncTask *)g_async_result_get_source_object(G_ASYNC_RESULT(simple)); g_assert(NEWS_IS_SYNC_TASK(task)); priv = task->priv; if (!gom_resource_save_finish(resource, result, &error)) { g_simple_async_result_take_error(simple, error); gom_adapter_sqlite_rollback(GOM_ADAPTER_SQLITE(priv->adapter)); } else if (!gom_adapter_sqlite_commit(GOM_ADAPTER_SQLITE(priv->adapter), &error)) { g_simple_async_result_take_error(simple, error); gom_adapter_sqlite_rollback(GOM_ADAPTER_SQLITE(priv->adapter)); } g_simple_async_result_complete_in_idle(simple); g_object_unref(simple); }
static void state_complete (GcrImporter *self, gboolean async) { if (async && self->pv->callback != NULL) (self->pv->callback) (G_OBJECT (self), G_ASYNC_RESULT (self), self->pv->user_data); cleanup_state_data (self); self->pv->processing = FALSE; }
static gboolean create_thumbnail (GIOSchedulerJob *job, GCancellable *cancellable, gpointer user_data) { GSimpleAsyncResult *result = user_data; GFile *file = G_FILE (g_async_result_get_source_object (G_ASYNC_RESULT (result))); GnomeDesktopThumbnailFactory *factory; GFileInfo *info; gchar *uri; GdkPixbuf *pixbuf; guint64 mtime; uri = g_file_get_uri (file); info = g_file_query_info (file, ATTRIBUTES_FOR_THUMBNAIL, G_FILE_QUERY_INFO_NONE, NULL, NULL); /* we don't care about reporting errors here, just fail the * thumbnail. */ if (info == NULL) { g_simple_async_result_set_op_res_gboolean (result, FALSE); goto out; } mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED); factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL); pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (factory, uri, g_file_info_get_content_type (info)); if (pixbuf != NULL) { gnome_desktop_thumbnail_factory_save_thumbnail (factory, pixbuf, uri, (time_t) mtime); g_simple_async_result_set_op_res_gboolean (result, TRUE); } else { g_simple_async_result_set_op_res_gboolean (result, FALSE); } g_object_unref (info); g_object_unref (file); g_object_unref (factory); g_clear_object (&pixbuf); out: g_simple_async_result_complete_in_idle (result); g_object_unref (result); return FALSE; }
static void catch_task_real_completed (CatchTask *task) { g_return_if_fail(CATCH_IS_TASK(task)); if (task->priv->callback) { task->priv->callback(task->priv->source_object, G_ASYNC_RESULT(task), task->priv->callback_data); } }
static void gabble_server_sasl_channel_respond ( TpSvcChannelInterfaceSASLAuthentication *channel, const GArray *in_Response_Data, DBusGMethodInvocation *context) { GabbleServerSaslChannel *self = GABBLE_SERVER_SASL_CHANNEL (channel); GString *response_data; GSimpleAsyncResult *r = self->priv->result; if (self->priv->sasl_status != TP_SASL_STATUS_IN_PROGRESS) { gabble_server_sasl_channel_raise (context, TP_ERROR_NOT_AVAILABLE, "You can only respond to challenges in state In_Progress, not %u", self->priv->sasl_status); DEBUG ("cannot respond: state %u != In_Progress", self->priv->sasl_status); return; } if (r == NULL) { gabble_server_sasl_channel_raise (context, TP_ERROR_NOT_AVAILABLE, "You already responded to the most recent challenge"); DEBUG ("cannot respond: already responded"); return; } g_assert (g_simple_async_result_is_valid (G_ASYNC_RESULT (r), G_OBJECT (self), gabble_server_sasl_channel_challenge_async)); /* The response might be secret (for PLAIN etc.), and also might * not be UTF-8 or even text, so we just output the length */ DEBUG ("responding with %u bytes", in_Response_Data->len); self->priv->result = NULL; if (in_Response_Data->len > 0) response_data = g_string_new_len (in_Response_Data->data, in_Response_Data->len); else response_data = NULL; g_simple_async_result_set_op_res_gpointer (r, response_data, (GDestroyNotify) wocky_g_string_free); g_simple_async_result_complete_in_idle (r); g_object_unref (r); tp_svc_channel_interface_sasl_authentication_return_from_respond ( context); }
static gboolean gum_script_task_complete (GumScriptTask * self) { GumScriptTaskPrivate * priv = self->priv; if (priv->callback != NULL) { priv->callback (priv->source_object, G_ASYNC_RESULT (self), priv->callback_data); } return FALSE; }
static void complete_async_result (GcrCertificateExporter *self) { g_assert (self->pv->callback); g_assert (!self->pv->completed); if (self->pv->chooser_dialog) gtk_widget_hide (GTK_WIDGET (self->pv->chooser_dialog)); self->pv->completed = TRUE; (self->pv->callback) (G_OBJECT (self), G_ASYNC_RESULT (self), self->pv->user_data); }
static void cloud_spy_dispatcher_invocation_perform (CloudSpyDispatcherInvocation * self) { CloudSpyDispatcher * dispatcher; dispatcher = CLOUD_SPY_DISPATCHER (g_async_result_get_source_object (G_ASYNC_RESULT (self->res))); cloud_spy_dispatcher_invocation_ref (self); dispatcher->dispatch_func (NULL, NULL, NULL, NULL, self->method->name, self->parameters, (GDBusMethodInvocation *) self, &dispatcher->target_object); g_object_unref (dispatcher); }
static void nm_connectivity_check_cb (SoupSession *session, SoupMessage *msg, gpointer user_data) { GSimpleAsyncResult *simple = user_data; NMConnectivity *self; NMConnectivityPrivate *priv; NMConnectivityState new_state; const char *nm_header; self = NM_CONNECTIVITY (g_async_result_get_source_object (G_ASYNC_RESULT (simple))); g_object_unref (self); priv = NM_CONNECTIVITY_GET_PRIVATE (self); if (SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code)) { nm_log_info (LOGD_CONCHECK, "Connectivity check for uri '%s' failed with '%s'.", priv->uri, msg->reason_phrase); new_state = NM_CONNECTIVITY_LIMITED; goto done; } /* Check headers; if we find the NM-specific one we're done */ nm_header = soup_message_headers_get_one (msg->response_headers, "X-NetworkManager-Status"); if (g_strcmp0 (nm_header, "online") == 0) { nm_log_dbg (LOGD_CONCHECK, "Connectivity check for uri '%s' with Status header successful.", priv->uri); new_state = NM_CONNECTIVITY_FULL; } else if (msg->status_code == SOUP_STATUS_OK) { /* check response */ if (msg->response_body->data && (g_str_has_prefix (msg->response_body->data, priv->response))) { nm_log_dbg (LOGD_CONCHECK, "Connectivity check for uri '%s' successful.", priv->uri); new_state = NM_CONNECTIVITY_FULL; } else { nm_log_info (LOGD_CONCHECK, "Connectivity check for uri '%s' did not match expected response '%s'; assuming captive portal.", priv->uri, priv->response); new_state = NM_CONNECTIVITY_PORTAL; } } else { nm_log_info (LOGD_CONCHECK, "Connectivity check for uri '%s' returned status '%d %s'; assuming captive portal.", priv->uri, msg->status_code, msg->reason_phrase); new_state = NM_CONNECTIVITY_PORTAL; } done: g_simple_async_result_set_op_res_gssize (simple, new_state); g_simple_async_result_complete (simple); update_state (self, new_state); }
/* This function can be called in any thread */ void tracker_extract_file (TrackerExtract *extract, const gchar *file, const gchar *mimetype, const gchar *graph, GCancellable *cancellable, GAsyncReadyCallback cb, gpointer user_data) { GSimpleAsyncResult *res; GError *error = NULL; TrackerExtractTask *task; g_return_if_fail (TRACKER_IS_EXTRACT (extract)); g_return_if_fail (file != NULL); g_return_if_fail (cb != NULL); #ifdef THREAD_ENABLE_TRACE g_debug ("Thread:%p <-- '%s': Processing file\n", g_thread_self (), file); #endif /* THREAD_ENABLE_TRACE */ res = g_simple_async_result_new (G_OBJECT (extract), cb, user_data, NULL); task = extract_task_new (extract, file, mimetype, graph, cancellable, G_ASYNC_RESULT (res), &error); if (error) { g_warning ("Could not get mimetype, %s", error->message); g_simple_async_result_set_from_error (res, error); g_simple_async_result_complete_in_idle (res); g_error_free (error); } else { TrackerExtractPrivate *priv; priv = TRACKER_EXTRACT_GET_PRIVATE (task->extract); g_mutex_lock (&priv->task_mutex); priv->running_tasks = g_list_prepend (priv->running_tasks, task); g_mutex_unlock (&priv->task_mutex); g_idle_add ((GSourceFunc) dispatch_task_cb, task); } /* Task takes a ref and if this fails, we want to unref anyway */ g_object_unref (res); }
static gboolean after_power_up_wait_cb (GSimpleAsyncResult *result) { MMBroadbandModemOption *option; option = MM_BROADBAND_MODEM_OPTION (g_async_result_get_source_object (G_ASYNC_RESULT (result))); g_simple_async_result_set_op_res_gboolean (result, TRUE); g_simple_async_result_complete (result); g_object_unref (result); option->priv->after_power_up_wait_id = 0; g_object_unref (option); return FALSE; }
static gboolean after_atz_sleep_cb (GSimpleAsyncResult *simple) { MMBaseModem *self; self = MM_BASE_MODEM (g_async_result_get_source_object (G_ASYNC_RESULT (simple))); /* Now, run the remaining sequence */ mm_base_modem_at_sequence (self, modem_init_sequence, NULL, /* response_processor_context */ NULL, /* response_processor_context_free */ (GAsyncReadyCallback)init_sequence_ready, simple); g_object_unref (self); return FALSE; }
static void news_sync_task_fetch_cb (GObject *object, GAsyncResult *result, gpointer user_data) { NewsSyncTaskPrivate *priv; GSimpleAsyncResult *simple = (GSimpleAsyncResult *)user_data; GInputStream *stream; NewsSyncTask *task; NewsSource *source = (NewsSource *)object; NewsParser *parser; GError *error = NULL; g_assert(NEWS_IS_SOURCE(source)); g_assert(G_IS_SIMPLE_ASYNC_RESULT(simple)); task = (NewsSyncTask *)g_async_result_get_source_object(G_ASYNC_RESULT(simple)); g_assert(NEWS_IS_SYNC_TASK(task)); priv = task->priv; priv->fraction = 0.333; g_object_notify_by_pspec(G_OBJECT(task), gParamSpecs[PROP_FRACTION]); if (!(stream = news_source_fetch_finish(source, result, &error))) { g_simple_async_result_take_error(simple, error); g_simple_async_result_complete_in_idle(simple); g_object_unref(simple); return; } if (g_cancellable_is_cancelled(priv->cancellable)) { g_simple_async_result_set_error(simple, NEWS_SYNC_TASK_ERROR, NEWS_SYNC_TASK_ERROR_CANCELLED, _("The task was cancelled.")); g_simple_async_result_complete_in_idle(simple); g_object_unref(simple); return; } parser = g_object_new(NEWS_TYPE_PARSER, "adapter", priv->adapter, "source", priv->source, NULL); news_parser_parse_async(parser, stream, priv->cancellable, news_sync_task_parse_cb, simple); g_object_unref(parser); }
/** * grl_net_wc_request_with_headers_hash_async: * @self: a #GrlNetWc instance * @uri: The URI of the resource to request * @headers: (allow-none) (element-type utf8 utf8): a set of additional HTTP * headers for this request or %NULL to ignore * @cancellable: (allow-none): a #GCancellable instance or %NULL to ignore * @callback: The callback when the result is ready * @user_data: User data set for the @callback * * Request the fetching of a web resource given the @uri. This request is * asynchronous, thus the result will be returned within the @callback. * * Since: 0.2.2 * Rename to: grl_net_wc_request_with_headers_async */ void grl_net_wc_request_with_headers_hash_async (GrlNetWc *self, const char *uri, GHashTable *headers, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *result; result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, grl_net_wc_request_async); get_url (self, uri, headers, G_ASYNC_RESULT (result), cancellable); }
static void run_async_ready_callback (GcrGnupgProcess *self) { GAsyncReadyCallback callback; gpointer user_data; g_debug ("running async callback"); /* Remove these before completing */ callback = self->pv->async_callback; user_data = self->pv->user_data; self->pv->async_callback = NULL; self->pv->user_data = NULL; if (callback != NULL) (callback) (G_OBJECT (self), G_ASYNC_RESULT (self), user_data); }
UmUser * um_account_dialog_finish (UmAccountDialog *self, GAsyncResult *result) { UmUser *user; g_return_val_if_fail (UM_IS_ACCOUNT_DIALOG (self), NULL); g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (self), um_account_dialog_show), NULL); g_return_val_if_fail (result == G_ASYNC_RESULT (self->async), NULL); user = g_simple_async_result_get_op_res_gpointer (self->async); if (user != NULL) g_object_ref (user); g_clear_object (&self->async); return user; }
static void news_sync_task_parse_cb (GObject *object, GAsyncResult *result, gpointer user_data) { NewsSyncTaskPrivate *priv; GSimpleAsyncResult *simple = user_data; NewsSyncTask *task; NewsParser *parser = (NewsParser *)object; GError *error = NULL; g_assert(NEWS_IS_PARSER(parser)); g_assert(G_IS_SIMPLE_ASYNC_RESULT(simple)); task = (NewsSyncTask *)g_async_result_get_source_object(G_ASYNC_RESULT(simple)); g_assert(NEWS_IS_SYNC_TASK(task)); priv = task->priv; priv->fraction = 0.666; g_object_notify_by_pspec(G_OBJECT(task), gParamSpecs[PROP_FRACTION]); if (!(priv->feed = news_parser_parse_finish(parser, result, &error))) { g_simple_async_result_take_error(simple, error); g_simple_async_result_complete_in_idle(simple); g_object_unref(simple); return; } if (g_cancellable_is_cancelled(priv->cancellable)) { g_simple_async_result_set_error(simple, NEWS_SYNC_TASK_ERROR, NEWS_SYNC_TASK_ERROR_CANCELLED, _("The task was cancelled.")); g_simple_async_result_complete_in_idle(simple); g_object_unref(simple); return; } news_sync_task_prepare_save(task); gom_adapter_sqlite_begin(GOM_ADAPTER_SQLITE(priv->adapter)); gom_resource_save_async(GOM_RESOURCE(priv->feed), priv->cancellable, news_sync_task_save_cb, simple); }
static void delete_user_done (GObject *proxy, GAsyncResult *r, gpointer user_data) { AsyncUserOpData *data = user_data; GSimpleAsyncResult *res; GVariant *result; GError *error = NULL; res = g_simple_async_result_new (G_OBJECT (data->manager), data->callback, data->data, um_user_manager_delete_user); result = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), r, &error); if (!result) { if (g_dbus_error_is_remote_error (error) && strcmp (g_dbus_error_get_remote_error(error), "org.freedesktop.Accounts.Error.PermissionDenied") == 0) { g_simple_async_result_set_error (res, UM_USER_MANAGER_ERROR, UM_USER_MANAGER_ERROR_PERMISSION_DENIED, "Not authorized"); } else if (g_dbus_error_is_remote_error (error) && strcmp (g_dbus_error_get_remote_error(error), "org.freedesktop.Accounts.Error.UserExists") == 0) { g_simple_async_result_set_error (res, UM_USER_MANAGER_ERROR, UM_USER_MANAGER_ERROR_USER_DOES_NOT_EXIST, _("This user does not exist.")); } else { g_simple_async_result_set_from_error (res, error); g_error_free (error); } } else g_variant_unref (result); data->callback (G_OBJECT (data->manager), G_ASYNC_RESULT (res), data->data); async_user_op_data_free (data); g_object_unref (res); }
static void channel_prepared (GObject *proxy, GAsyncResult *prepare_res, gpointer user_data) { GSimpleAsyncResult *res = user_data; TfCallChannel *self = TF_CALL_CHANNEL (g_async_result_get_source_object (G_ASYNC_RESULT (res))); GError *error = NULL; GPtrArray *contents; guint i; if (!tp_proxy_prepare_finish (proxy, prepare_res, &error)) { g_warning ("Preparing the channel: %s", error->message); g_simple_async_result_take_error (res, error); goto out; } if (tp_call_channel_has_hardware_streaming (TP_CALL_CHANNEL (proxy))) { g_warning ("Hardware streaming property is TRUE, ignoring"); g_simple_async_result_set_error (res, TP_ERROR, TP_ERROR_NOT_CAPABLE, "This channel does hardware streaming, not handled here"); goto out; } contents = tp_call_channel_get_contents (TP_CALL_CHANNEL (proxy)); self->contents = g_ptr_array_new_with_free_func (free_content); for (i = 0; i < contents->len; i++) if (!add_content (self, g_ptr_array_index (contents, i))) break; g_simple_async_result_set_op_res_gboolean (res, TRUE); out: g_simple_async_result_complete (res); g_object_unref (res); g_object_unref (self); }
static gboolean g_tls_output_stream_gnutls_write_ready (GIOStreamAdapter *adapter, gpointer user_data) { GTlsOutputStreamGnutls *tls_stream; GSimpleAsyncResult *simple = user_data; gssize nwrote; GError *error = NULL; tls_stream = G_TLS_OUTPUT_STREAM_GNUTLS (g_async_result_get_source_object (G_ASYNC_RESULT (simple))); g_object_unref (tls_stream); nwrote = g_tls_connection_gnutls_write (tls_stream->priv->conn, tls_stream->priv->buffer, tls_stream->priv->count, FALSE, tls_stream->priv->cancellable, &error); if (nwrote == -1 && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) { g_error_free (error); return TRUE; } if (error) { g_simple_async_result_set_from_error (simple, error); g_error_free (error); } else g_simple_async_result_set_op_res_gssize (simple, nwrote); if (tls_stream->priv->cancellable) g_object_unref (tls_stream->priv->cancellable); g_simple_async_result_complete (simple); g_object_unref (simple); return FALSE; }
static void write_screenshot_thread (GSimpleAsyncResult *result, GObject *object, GCancellable *cancellable) { cairo_status_t status; GOutputStream *stream; _screenshot_data *screenshot_data = g_async_result_get_user_data (G_ASYNC_RESULT (result)); g_assert (screenshot_data != NULL); stream = prepare_write_stream (screenshot_data->filename, &screenshot_data->filename_used); if (stream == NULL) status = CAIRO_STATUS_FILE_NOT_FOUND; else { GdkPixbuf *pixbuf; pixbuf = gdk_pixbuf_get_from_surface (screenshot_data->image, 0, 0, cairo_image_surface_get_width (screenshot_data->image), cairo_image_surface_get_height (screenshot_data->image)); if (gdk_pixbuf_save_to_stream (pixbuf, stream, "png", NULL, NULL, "tEXt::Software", "gnome-screenshot", NULL)) status = CAIRO_STATUS_SUCCESS; else status = CAIRO_STATUS_WRITE_ERROR; g_object_unref (pixbuf); } g_simple_async_result_set_op_res_gboolean (result, status == CAIRO_STATUS_SUCCESS); g_clear_object (&stream); }
gboolean _gcr_certificate_exporter_export_finish (GcrCertificateExporter *self, GAsyncResult *result, GError **error) { gboolean ret = TRUE; g_return_val_if_fail (G_ASYNC_RESULT (self) == result, FALSE); g_return_val_if_fail (!error || !*error, FALSE); g_return_val_if_fail (self->pv->completed, FALSE); /* Cleanup all the operation stuff */ self->pv->callback = NULL; if (self->pv->chooser_dialog) g_object_unref (self->pv->chooser_dialog); self->pv->chooser_dialog = NULL; if (self->pv->output_file) g_object_unref (self->pv->output_file); self->pv->output_file = NULL; if (self->pv->buffer) g_byte_array_free (self->pv->buffer, TRUE); self->pv->buffer = NULL; self->pv->buffer_at = 0; self->pv->completed = FALSE; if (self->pv->error) { g_propagate_error (error, self->pv->error); ret = FALSE; } /* Matches in export_async */ g_object_unref (self); return ret; }
static void save_snapshot_replace_cb (GFile *snapshot_file, GAsyncResult *result, GSimpleAsyncResult *simple) { GObject *object; SaveContext *context; GFileOutputStream *output_stream; GError *local_error = NULL; context = g_simple_async_result_get_op_res_gpointer (simple); /* Output stream might be NULL, so don't use cast macro. */ output_stream = g_file_replace_finish ( snapshot_file, result, &local_error); context->output_stream = (GOutputStream *) output_stream; if (local_error != NULL) { g_warn_if_fail (output_stream == NULL); g_simple_async_result_take_error (simple, local_error); g_simple_async_result_complete (simple); g_object_unref (simple); return; } g_return_if_fail (G_IS_OUTPUT_STREAM (output_stream)); /* g_async_result_get_source_object() returns a new reference. */ object = g_async_result_get_source_object (G_ASYNC_RESULT (simple)); /* Extract a MIME message from the composer. */ e_msg_composer_get_message_draft ( E_MSG_COMPOSER (object), G_PRIORITY_DEFAULT, context->cancellable, (GAsyncReadyCallback) save_snapshot_get_message_cb, simple); g_object_unref (object); }
/** * _gcr_gnupg_process_run_finish: * @self: The process * @result: The result passed to the callback * @error: Location to raise an error on failure. * * Get the result of running a gnupg process. * * Return value: Whether the Gnupg process was run or not. */ gboolean _gcr_gnupg_process_run_finish (GcrGnupgProcess *self, GAsyncResult *result, GError **error) { g_return_val_if_fail (GCR_IS_GNUPG_PROCESS (self), FALSE); g_return_val_if_fail (!error || !*error, FALSE); g_return_val_if_fail (G_ASYNC_RESULT (self) == result, FALSE); g_return_val_if_fail (self->pv->complete, FALSE); /* This allows the process to run again... */ self->pv->complete = FALSE; g_assert (!self->pv->running); g_assert (!self->pv->async_callback); g_assert (!self->pv->user_data); if (self->pv->error) { g_propagate_error (error, self->pv->error); self->pv->error = NULL; return FALSE; } return TRUE; }
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); }