static void get_user_info_ready_cb (SoupSession *session, SoupMessage *msg, gpointer user_data) { FacebookService *self = user_data; GSimpleAsyncResult *result; SoupBuffer *body; DomDocument *doc = NULL; GError *error = NULL; result = facebook_connection_get_result (self->priv->conn); if (msg->status_code != 200) { g_simple_async_result_set_error (result, SOUP_HTTP_ERROR, msg->status_code, "%s", soup_status_get_phrase (msg->status_code)); g_simple_async_result_complete_in_idle (result); return; } body = soup_message_body_flatten (msg->response_body); if (facebook_utils_parse_response (body, &doc, &error)) { DomElement *node; FacebookUser *user = NULL; for (node = DOM_ELEMENT (doc)->first_child; node; node = node->next_sibling) { if (g_strcmp0 (node->tag_name, "users_getInfo_response") == 0) { DomElement *child; for (child = node->first_child; child; child = child->next_sibling) { if (g_strcmp0 (child->tag_name, "user") == 0) { user = facebook_user_new (); dom_domizable_load_from_element (DOM_DOMIZABLE (user), child); g_simple_async_result_set_op_res_gpointer (result, user, (GDestroyNotify) g_object_unref); } } } } if (user == NULL) { error = g_error_new_literal (FACEBOOK_CONNECTION_ERROR, 0, _("Unknown error")); g_simple_async_result_set_from_error (result, error); } g_object_unref (doc); } else g_simple_async_result_set_from_error (result, error); g_simple_async_result_complete_in_idle (result); soup_buffer_free (body); }
static void get_logged_in_user_ready_cb (SoupSession *session, SoupMessage *msg, gpointer user_data) { FacebookService *self = user_data; GSimpleAsyncResult *result; SoupBuffer *body; DomDocument *doc = NULL; GError *error = NULL; result = facebook_connection_get_result (self->priv->conn); if (msg->status_code != 200) { g_simple_async_result_set_error (result, SOUP_HTTP_ERROR, msg->status_code, "%s", soup_status_get_phrase (msg->status_code)); g_simple_async_result_complete_in_idle (result); return; } body = soup_message_body_flatten (msg->response_body); if (facebook_utils_parse_response (body, &doc, &error)) { DomElement *root; char *uid = NULL; root = DOM_ELEMENT (doc)->first_child; if (g_strcmp0 (root->tag_name, "users_getLoggedInUser_response") == 0) uid = g_strdup (dom_element_get_inner_text (root)); if (uid == NULL) { error = g_error_new_literal (FACEBOOK_CONNECTION_ERROR, 0, _("Unknown error")); g_simple_async_result_set_from_error (result, error); } else g_simple_async_result_set_op_res_gpointer (result, uid, g_free); g_object_unref (doc); } else g_simple_async_result_set_from_error (result, error); g_simple_async_result_complete_in_idle (result); soup_buffer_free (body); }
static void on_icon_file_located (GObject *source_object, GAsyncResult *res, gpointer user_data) { GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data); GFile *icon_file; GError *error; error = NULL; icon_file = _g_find_file_insensitive_finish (G_FILE (source_object), res, &error); if (icon_file != NULL) { g_simple_async_result_set_op_res_gpointer (simple, g_file_icon_new (icon_file), NULL); g_object_unref (icon_file); } else { g_simple_async_result_set_from_error (simple, error); g_error_free (error); } g_simple_async_result_complete (simple); g_object_unref (simple); }
static void conn_util_send_iq_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { WockyPorter *porter = WOCKY_PORTER (source_object); WockyStanza *reply; GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data); GError *error = NULL; reply = wocky_porter_send_iq_finish (porter, res, &error); if (reply != NULL) { g_simple_async_result_set_op_res_gpointer (result, reply, (GDestroyNotify) g_object_unref); } else { g_simple_async_result_set_from_error (result, error); g_clear_error (&error); } g_simple_async_result_complete (result); g_object_unref (result); }
static void on_autorun_located (GObject *source_object, GAsyncResult *res, gpointer user_data) { GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data); GFile *autorun_path; GError *error; error = NULL; autorun_path = _g_find_file_insensitive_finish (G_FILE (source_object), res, &error); if (error != NULL) { g_simple_async_result_set_from_error (simple, error); g_simple_async_result_complete_in_idle (simple); g_object_unref (simple); g_error_free (error); } else { g_file_load_contents_async (autorun_path, g_object_get_data (G_OBJECT (simple), "cancellable"), on_autorun_loaded, simple); g_object_unref (autorun_path); } }
void set_system_timezone_async (const gchar *tz, GAsyncReadyCallback callback, gpointer user_data) { GDBusConnection *system_bus; GError *error = NULL; system_bus = get_system_bus (&error); if (system_bus == NULL) { GSimpleAsyncResult *simple; simple = g_simple_async_result_new (NULL, callback, user_data, set_system_timezone_async); g_simple_async_result_set_from_error (simple, error); g_simple_async_result_complete_in_idle (simple); g_object_unref (simple); g_error_free (error); } g_dbus_connection_call (system_bus, MECHANISM_BUS_NAME, MECHANISM_OBJECT_PATH, MECHANISM_INTERFACE, "SetTimezone", g_variant_new ("(s)", tz), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, callback, user_data); }
static void install_mime_types_ready_cb (GObject *source, GAsyncResult *res, gpointer user_data) { GtkAppChooserOnlinePk *self = user_data; GDBusProxy *proxy = G_DBUS_PROXY (source); GError *error = NULL; GVariant *variant; variant = g_dbus_proxy_call_finish (proxy, res, &error); if (variant == NULL) { /* don't show errors if the user cancelled the installation explicitely * or if PK wasn't able to find any apps */ if (g_strcmp0 (g_dbus_error_get_remote_error (error), "org.freedesktop.PackageKit.Modify.Cancelled") != 0 && g_strcmp0 (g_dbus_error_get_remote_error (error), "org.freedesktop.PackageKit.Modify.NoPackagesFound") != 0) g_simple_async_result_set_from_error (self->priv->result, error); g_error_free (error); } g_simple_async_result_complete (self->priv->result); g_clear_object (&self->priv->result); }
static void uoa_identity_query_info_cb (SignonIdentity *identity, const SignonIdentityInfo *info, const GError *error, gpointer user_data) { UoaChangePasswordData *data = user_data; if (error != NULL) { g_simple_async_result_set_from_error (data->result, error); /* libaccounts-glib API does not guarantee the callback happens after * reentering mainloop */ g_simple_async_result_complete_in_idle (data->result); uoa_change_password_data_free (data); g_object_unref (identity); return; } /* const SignonIdentityInfo is a lie, cast it! - Mardy */ signon_identity_info_set_secret ((SignonIdentityInfo *) info, data->password, data->remember); signon_identity_store_credentials_with_info (identity, info, uoa_identity_store_cb, data); }
static void create_tube_complete (GSimpleAsyncResult *simple, const GError *error) { CreateTubeData *data; data = g_simple_async_result_get_op_res_gpointer (simple); if (data->op_cancellable != NULL) g_cancellable_cancel (data->op_cancellable); if (data->offer_call != NULL) tp_proxy_pending_call_cancel (data->offer_call); if (data->cancelled_id != 0) g_cancellable_disconnect (data->global_cancellable, data->cancelled_id); data->cancelled_id = 0; if (data->invalidated_id != 0) g_signal_handler_disconnect (data->channel, data->invalidated_id); data->invalidated_id = 0; if (error != NULL) g_simple_async_result_set_from_error (simple, error); g_simple_async_result_complete_in_idle (simple); }
static void read_async_done (GInputStream *stream) { SoupInputStreamPrivate *priv = SOUP_INPUT_STREAM_GET_PRIVATE (stream); GSimpleAsyncResult *result; GError *error = NULL; result = priv->result; priv->result = NULL; if (g_cancellable_set_error_if_cancelled (priv->cancellable, &error) || set_error_if_http_failed (priv->msg, &error)) { g_simple_async_result_set_from_error (result, error); g_error_free (error); } else g_simple_async_result_set_op_res_gssize (result, priv->caller_nread); priv->got_chunk_cb = NULL; priv->finished_cb = NULL; priv->cancelled_cb = NULL; soup_input_stream_done_io (stream); g_simple_async_result_complete (result); g_object_unref (result); }
static void soup_input_stream_close_async (GInputStream *stream, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *result; gboolean success; GError *error = NULL; result = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, soup_input_stream_close_async); success = soup_input_stream_close (stream, cancellable, &error); g_simple_async_result_set_op_res_gboolean (result, success); if (error) { g_simple_async_result_set_from_error (result, error); g_error_free (error); } g_simple_async_result_complete_in_idle (result); g_object_unref (result); }
static void load_async_thread (GSimpleAsyncResult *res, GObject *object, GCancellable *cancellable) { GLoadableIconIface *iface; GInputStream *stream; LoadData *data; GError *error = NULL; char *type = NULL; data = g_simple_async_result_get_op_res_gpointer (res); iface = G_LOADABLE_ICON_GET_IFACE (object); stream = iface->load (G_LOADABLE_ICON (object), data->size, &type, cancellable, &error); if (stream == NULL) { g_simple_async_result_set_from_error (res, error); g_error_free (error); } else { data->stream = stream; data->type = type; } }
static void send_async_finished (GInputStream *stream) { SoupInputStreamPrivate *priv = SOUP_INPUT_STREAM_GET_PRIVATE (stream); GSimpleAsyncResult *result; GError *error = NULL; if (!g_cancellable_set_error_if_cancelled (priv->cancellable, &error)) set_error_if_http_failed (priv->msg, &error); priv->got_headers_cb = NULL; priv->finished_cb = NULL; soup_input_stream_done_io (stream); result = priv->result; priv->result = NULL; g_simple_async_result_set_op_res_gboolean (result, error == NULL); if (error) { g_simple_async_result_set_from_error (result, error); g_error_free (error); } g_simple_async_result_complete (result); }
static void soup_output_stream_close_async (GOutputStream *stream, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { SoupOutputStreamPrivate *priv = SOUP_OUTPUT_STREAM_GET_PRIVATE (stream); GSimpleAsyncResult *result; result = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, soup_output_stream_close_async); if (priv->size > 0 && priv->offset != priv->size) { GError *error; error = g_error_new (G_IO_ERROR, G_IO_ERROR_NO_SPACE, "File is incomplete"); g_simple_async_result_set_from_error (result, error); g_error_free (error); g_simple_async_result_complete_in_idle (result); g_object_unref (result); return; } priv->result = result; priv->cancelled_cb = close_async_done; g_signal_connect (priv->msg, "finished", G_CALLBACK (soup_output_stream_finished), stream); soup_output_stream_prepare_for_io (stream, cancellable); }
static void close_async_done (GOutputStream *stream) { SoupOutputStreamPrivate *priv = SOUP_OUTPUT_STREAM_GET_PRIVATE (stream); GSimpleAsyncResult *result; GError *error = NULL; result = priv->result; priv->result = NULL; if (g_cancellable_set_error_if_cancelled (priv->cancellable, &error) || set_error_if_http_failed (priv->msg, &error)) { g_simple_async_result_set_from_error (result, error); g_error_free (error); } else g_simple_async_result_set_op_res_gboolean (result, TRUE); priv->finished_cb = NULL; priv->cancelled_cb = NULL; soup_output_stream_done_io (stream); g_simple_async_result_complete (result); g_object_unref (result); }
static void soup_output_stream_write_async (GOutputStream *stream, const void *buffer, gsize count, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { SoupOutputStreamPrivate *priv = SOUP_OUTPUT_STREAM_GET_PRIVATE (stream); GSimpleAsyncResult *result; result = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, soup_output_stream_write_async); if (priv->size > 0 && priv->offset + count > priv->size) { GError *error; error = g_error_new (G_IO_ERROR, G_IO_ERROR_NO_SPACE, "Write would exceed caller-defined file size"); g_simple_async_result_set_from_error (result, error); g_error_free (error); } else { g_byte_array_append (priv->ba, buffer, count); priv->offset += count; g_simple_async_result_set_op_res_gssize (result, count); } g_simple_async_result_complete_in_idle (result); g_object_unref (result); }
static void on_connection_future_ensure_sidecar_returned (GObject *source_object, GAsyncResult *result, gpointer user_data) { GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data); gchar *object_path; GError *error = NULL; g_return_if_fail (TP_IS_CONNECTION (source_object)); object_path = _tp_yts_connection_future_ensure_sidecar_finish ( TP_CONNECTION (source_object), result, NULL, &error); if (error != NULL) { g_simple_async_result_set_from_error (res, error); g_clear_error (&error); g_simple_async_result_complete_in_idle (res); g_object_unref (res); return; } g_async_initable_new_async (TP_TYPE_YTS_STATUS, G_PRIORITY_DEFAULT, NULL, on_status_new_returned, res, "dbus-daemon", tp_proxy_get_dbus_daemon (source_object), "dbus-connection", tp_proxy_get_dbus_connection (source_object), "bus-name", tp_proxy_get_bus_name (source_object), "object-path", object_path, NULL); g_free (object_path); }
static void on_channel_request_create_and_handle_channel_returned (GObject *source, GAsyncResult *result, gpointer user_data) { GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data); TpAccountChannelRequest *channel_request = TP_ACCOUNT_CHANNEL_REQUEST (source); TpChannel *channel; GError *error = NULL; channel = tp_account_channel_request_create_and_handle_channel_finish ( channel_request, result, NULL, &error); if (error == NULL) { g_simple_async_result_set_op_res_gpointer (res, channel, g_object_unref); } else { g_simple_async_result_set_from_error (res, error); g_clear_error (&error); } g_simple_async_result_complete (res); g_object_unref (channel_request); }
static void uoa_session_process_cb (SignonAuthSession *session, GHashTable *session_data, const GError *error, gpointer user_data) { GSimpleAsyncResult *result = user_data; const gchar *password; if (error != NULL) { g_simple_async_result_set_from_error (result, error); goto out; } password = tp_asv_get_string (session_data, "Secret"); if (tp_str_empty (password)) { g_simple_async_result_set_error (result, TP_ERROR, TP_ERROR_DOES_NOT_EXIST, "Password not found"); goto out; } g_simple_async_result_set_op_res_gpointer (result, g_strdup (password), g_free); out: /* libaccounts-glib API does not guarantee the callback happens after * reentering mainloop */ g_simple_async_result_complete_in_idle (result); g_object_unref (result); g_object_unref (session); }
static void picasa_web_service_get_user_info_ready_cb (SoupSession *session, SoupMessage *msg, gpointer user_data) { PicasaWebService *self = user_data; GSimpleAsyncResult *result; GError *error = NULL; JsonNode *node; result = _web_service_get_result (WEB_SERVICE (self)); if (picasa_web_utils_parse_json_response (msg, &node, &error)) { OAuthAccount *account; account = (OAuthAccount *) json_gobject_deserialize (OAUTH_TYPE_ACCOUNT, node); g_object_set (account, "token", self->priv->access_token, "token-secret", self->priv->refresh_token, NULL); g_simple_async_result_set_op_res_gpointer (result, g_object_ref (account), (GDestroyNotify) g_object_unref); _g_object_unref (account); json_node_free (node); } else g_simple_async_result_set_from_error (result, error); g_simple_async_result_complete_in_idle (result); }
static void uoa_initial_identity_store_cb (SignonIdentity *identity, guint32 id, const GError *error, gpointer user_data) { UoaChangePasswordData *data = user_data; AgAccount *account = ag_account_service_get_account (data->service); GValue value = G_VALUE_INIT; if (error != NULL) { g_simple_async_result_set_from_error (data->result, error); /* libaccounts-glib API does not guarantee the callback happens after * reentering mainloop */ g_simple_async_result_complete_in_idle (data->result); uoa_change_password_data_free (data); g_object_unref (identity); return; } g_value_init (&value, G_TYPE_UINT); g_value_set_uint (&value, id); ag_account_select_service (account, NULL); ag_account_set_value (account, "CredentialsId", &value); g_value_unset (&value); ag_account_store (account, uoa_initial_account_store_cb, data); g_object_unref (identity); }
static void avatar_cache_loader_finish (GiggleAvatarCacheLoader *loader, GError *error) { if (loader->cache) { g_object_remove_weak_pointer (G_OBJECT (loader->cache), (gpointer) &loader->cache); } if (loader->cancellable) { g_cancellable_cancel (loader->cancellable); g_object_unref (loader->cancellable); } if (loader->pixbuf_loader) { gdk_pixbuf_loader_close (loader->pixbuf_loader, NULL); g_object_unref (loader->pixbuf_loader); } if (loader->pixbuf) { g_simple_async_result_set_op_res_gpointer (loader->result, g_object_ref (loader->pixbuf), g_object_unref); } else { g_simple_async_result_set_from_error (loader->result, error); g_error_free (error); } g_simple_async_result_complete_in_idle (loader->result); g_object_unref (loader->result); g_slice_free (GiggleAvatarCacheLoader, loader); }
static void _picasa_web_service_get_access_token_ready_cb (SoupSession *session, SoupMessage *msg, gpointer user_data) { PicasaWebService *self = user_data; GSimpleAsyncResult *result; GError *error = NULL; JsonNode *node; result = _web_service_get_result (WEB_SERVICE (self)); if (picasa_web_utils_parse_json_response (msg, &node, &error)) { JsonObject *obj; OAuthAccount *account; obj = json_node_get_object (node); account = web_service_get_current_account (WEB_SERVICE (self)); if (account != NULL) g_object_set (account, "token", json_object_get_string_member (obj, "access_token"), NULL); else _g_strset (&self->priv->access_token, json_object_get_string_member (obj, "access_token")); } else g_simple_async_result_set_from_error (result, error); g_simple_async_result_complete_in_idle (result); }
static void upload_photos_done (FacebookService *self, GError *error) { GSimpleAsyncResult *result; result = facebook_connection_get_result (self->priv->conn); if (error == NULL) { self->priv->post_photos->ids = g_list_reverse (self->priv->post_photos->ids); g_simple_async_result_set_op_res_gpointer (result, self->priv->post_photos->ids, (GDestroyNotify) _g_string_list_free); self->priv->post_photos->ids = NULL; } else { if (self->priv->post_photos->current != NULL) { GthFileData *file_data = self->priv->post_photos->current->data; char *msg; msg = g_strdup_printf (_("Could not upload '%s': %s"), g_file_info_get_display_name (file_data->info), error->message); g_free (error->message); error->message = msg; } g_simple_async_result_set_from_error (result, error); } g_simple_async_result_complete_in_idle (result); }
static void tls_certificate_got_all_handler(TpProxy *proxy, GHashTable *properties, const GError *error, gpointer user_data, GObject *weak_object) { HevImpathyTLSCertificate *self = HEV_IMPATHY_TLS_CERTIFICATE(weak_object); HevImpathyTLSCertificatePrivate *priv = HEV_IMPATHY_TLS_CERTIFICATE_GET_PRIVATE(self); GPtrArray *cert_data = NULL; g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); if(NULL != error) { g_simple_async_result_set_from_error(priv->async_prepare_res, error); g_simple_async_result_complete(priv->async_prepare_res); tp_clear_object(&priv->async_prepare_res); return; } priv->cert_type = g_strdup(tp_asv_get_string(properties, "CertificateType")); priv->state = tp_asv_get_uint32(properties, "State", NULL); cert_data = tp_asv_get_boxed(properties, "CertificateChainData", TP_ARRAY_TYPE_UCHAR_ARRAY_LIST); g_assert(NULL != cert_data); priv->cert_data = g_boxed_copy(TP_ARRAY_TYPE_UCHAR_ARRAY_LIST, cert_data); priv->is_prepared = TRUE; g_simple_async_result_complete(priv->async_prepare_res); tp_clear_object(&priv->async_prepare_res); }
static void new_from_stream_thread (GSimpleAsyncResult *result, GInputStream *stream, GCancellable *cancellable) { GdkPixbuf *pixbuf; AtScaleData *data; GError *error = NULL; /* If data != NULL, we're scaling the pixbuf while loading it */ data = g_simple_async_result_get_op_res_gpointer (result); if (data != NULL) pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, data->width, data->height, data->preserve_aspect_ratio, cancellable, &error); else pixbuf = gdk_pixbuf_new_from_stream (stream, cancellable, &error); g_simple_async_result_set_op_res_gpointer (result, NULL, NULL); /* Set the new pixbuf as the result, or error out */ if (pixbuf == NULL) { g_simple_async_result_set_from_error (result, error); g_error_free (error); } else { g_simple_async_result_set_op_res_gpointer (result, pixbuf, g_object_unref); } }
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 at_command_parse_response (MMAtSerialPort *port, GString *response, GError *error, AtCommandContext *ctx) { /* Cancelled? */ if (g_cancellable_is_cancelled (ctx->cancellable)) g_simple_async_result_set_error (ctx->result, MM_CORE_ERROR, MM_CORE_ERROR_CANCELLED, "AT command was cancelled"); /* Error coming from the serial port? */ else if (error) g_simple_async_result_set_from_error (ctx->result, error); /* Valid string response */ else if (response && response->str) g_simple_async_result_set_op_res_gpointer (ctx->result, g_strdup (response->str), g_free); /* No response */ else g_simple_async_result_set_op_res_gpointer (ctx->result, NULL, NULL); g_simple_async_result_complete (ctx->result); at_command_context_free (ctx); }
static void gabble_auth_manager_start_fallback_cb (GObject *self_object, GAsyncResult *result, gpointer user_data) { GabbleAuthManager *self = GABBLE_AUTH_MANAGER (self_object); WockyAuthRegistryStartData *start_data = NULL; GError *error = NULL; if (WOCKY_AUTH_REGISTRY_CLASS (gabble_auth_manager_parent_class)-> start_auth_finish_func (WOCKY_AUTH_REGISTRY (self), result, &start_data, &error)) { g_simple_async_result_set_op_res_gpointer (user_data, start_data, (GDestroyNotify) wocky_auth_registry_start_data_free); } else { g_simple_async_result_set_from_error (user_data, error); g_clear_error (&error); } g_simple_async_result_complete (user_data); g_object_unref (user_data); }
static void async_got_connection_cb (GDBusConnection *connection, GError *io_error, gpointer callback_data) { AsyncPathCall *data = callback_data; if (connection == NULL) { g_dbus_error_strip_remote_error (io_error); g_simple_async_result_set_from_error (data->result, io_error); _g_simple_async_result_complete_with_cancellable (data->result, data->cancellable); async_path_call_free (data); return; } data->connection = g_object_ref (connection); gvfs_dbus_mount_proxy_new (connection, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, data->mount_info->dbus_id, data->mount_info->object_path, data->cancellable, async_proxy_new_cb, data); }