static void data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *simple; AsyncContext *async_context; async_context = g_slice_new0 (AsyncContext); async_context->stream = g_object_ref (stream); simple = g_simple_async_result_new ( G_OBJECT (data_wrapper), callback, user_data, data_wrapper_construct_from_stream); g_simple_async_result_set_op_res_gpointer ( simple, async_context, (GDestroyNotify) async_context_free); g_simple_async_result_run_in_thread ( simple, data_wrapper_construct_from_stream_thread, io_priority, cancellable); g_object_unref (simple); }
void _ostree_static_delta_part_execute_async (OstreeRepo *repo, GVariant *header, GBytes *partdata, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { StaticDeltaPartExecuteAsyncData *asyncdata; asyncdata = g_new0 (StaticDeltaPartExecuteAsyncData, 1); asyncdata->repo = g_object_ref (repo); asyncdata->header = g_variant_ref (header); asyncdata->partdata = g_bytes_ref (partdata); asyncdata->cancellable = cancellable ? g_object_ref (cancellable) : NULL; asyncdata->result = g_simple_async_result_new ((GObject*) repo, callback, user_data, _ostree_static_delta_part_execute_async); g_simple_async_result_set_op_res_gpointer (asyncdata->result, asyncdata, static_delta_part_execute_async_data_free); g_simple_async_result_run_in_thread (asyncdata->result, static_delta_part_execute_thread, G_PRIORITY_DEFAULT, cancellable); g_object_unref (asyncdata->result); }
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 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 g_tls_database_real_lookup_certificates_issued_by_async (GTlsDatabase *self, GByteArray *issuer, GTlsInteraction *interaction, GTlsDatabaseLookupFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *res; AsyncLookupCertificatesIssuedBy *args; g_return_if_fail (callback); args = g_slice_new0 (AsyncLookupCertificatesIssuedBy); args->issuer = g_byte_array_ref (issuer); args->flags = flags; args->interaction = interaction ? g_object_ref (interaction) : NULL; res = g_simple_async_result_new (G_OBJECT (self), callback, user_data, g_tls_database_real_lookup_certificates_issued_by_async); g_simple_async_result_set_op_res_gpointer (res, args, async_lookup_certificates_issued_by_free); g_simple_async_result_run_in_thread (res, async_lookup_certificates_issued_by_thread, G_PRIORITY_DEFAULT, cancellable); g_object_unref (res); }
/** * g_dbus_address_get_stream: * @address: A valid D-Bus address. * @cancellable: A #GCancellable or %NULL. * @callback: A #GAsyncReadyCallback to call when the request is satisfied. * @user_data: Data to pass to @callback. * * Asynchronously connects to an endpoint specified by @address and * sets up the connection so it is in a state to run the client-side * of the D-Bus authentication conversation. * * When the operation is finished, @callback will be invoked. You can * then call g_dbus_address_get_stream_finish() to get the result of * the operation. * * This is an asynchronous failable function. See * g_dbus_address_get_stream_sync() for the synchronous version. * * Since: 2.26 */ void g_dbus_address_get_stream (const gchar *address, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *res; GetStreamData *data; g_return_if_fail (address != NULL); res = g_simple_async_result_new (NULL, callback, user_data, g_dbus_address_get_stream); data = g_new0 (GetStreamData, 1); data->address = g_strdup (address); g_simple_async_result_set_op_res_gpointer (res, data, (GDestroyNotify) get_stream_data_free); g_simple_async_result_run_in_thread (res, get_stream_thread_func, G_PRIORITY_DEFAULT, cancellable); g_object_unref (res); }
static void g_tls_database_real_lookup_certificate_for_handle_async (GTlsDatabase *self, const gchar *handle, GTlsInteraction *interaction, GTlsDatabaseLookupFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *res; AsyncLookupCertificateForHandle *args; g_return_if_fail (callback != NULL); args = g_slice_new0 (AsyncLookupCertificateForHandle); args->handle = g_strdup (handle); args->interaction = interaction ? g_object_ref (interaction) : NULL; res = g_simple_async_result_new (G_OBJECT (self), callback, user_data, g_tls_database_real_lookup_certificate_for_handle_async); g_simple_async_result_set_op_res_gpointer (res, args, async_lookup_certificate_for_handle_free); g_simple_async_result_run_in_thread (res, async_lookup_certificate_for_handle_thread, G_PRIORITY_DEFAULT, cancellable); g_object_unref (res); }
static void cockpit_fake_manager_init_async (GAsyncInitable *initable, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { CockpitFakeManager *self = COCKPIT_FAKE_MANAGER (initable); InitAsyncData *data; g_return_if_fail (self->initializing == NULL); g_debug ("fakemanager: initializing async"); self->initializing = g_simple_async_result_new (G_OBJECT (self), callback, user_data, cockpit_fake_manager_init_async); if (cancellable) { data = g_new0 (InitAsyncData, 1); data->cancellable = g_object_ref (cancellable); g_simple_async_result_set_op_res_gpointer (self->initializing, data, init_async_data_free); data->sig_cancelled = g_cancellable_connect (cancellable, G_CALLBACK (on_init_async_cancelled), self, NULL); } /* The initialization started in constructor, may already be done? */ if (self->bus_appears > 0 || self->bus_disappears > 0) maybe_complete_async_init (self); }
/** * mm_modem_voice_list_calls: * @self: A #MMModemVoice. * @cancellable: (allow-none): A #GCancellable or %NULL. * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL. * @user_data: User data to pass to @callback. * * Asynchronously lists the #MMCall objects in the modem. * * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from. * You can then call mm_modem_voice_list_calls_finish() to get the result of the operation. * * See mm_modem_voice_list_calls_sync() for the synchronous, blocking version of this method. */ void mm_modem_voice_list_calls (MMModemVoice *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { ListCallsContext *ctx; g_return_if_fail (MM_IS_MODEM_VOICE (self)); ctx = g_slice_new0 (ListCallsContext); ctx->self = g_object_ref (self); ctx->result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, mm_modem_voice_list_calls); if (cancellable) ctx->cancellable = g_object_ref (cancellable); ctx->call_paths = mm_gdbus_modem_voice_dup_calls (MM_GDBUS_MODEM_VOICE (self)); /* If no CALL, just end here. */ if (!ctx->call_paths || !ctx->call_paths[0]) { g_simple_async_result_set_op_res_gpointer (ctx->result, NULL, NULL); list_call_context_complete_and_free (ctx); return; } /* Got list of paths. If at least one found, start creating objects for each */ ctx->i = 0; create_next_call (ctx); }
static void g_tls_database_real_verify_chain_async (GTlsDatabase *self, GTlsCertificate *chain, const gchar *purpose, GSocketConnectable *identity, GTlsInteraction *interaction, GTlsDatabaseVerifyFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *res; AsyncVerifyChain *args; args = g_slice_new0 (AsyncVerifyChain); args->chain = g_object_ref (chain); args->purpose = g_strdup (purpose); args->identity = identity ? g_object_ref (identity) : NULL; args->interaction = interaction ? g_object_ref (interaction) : NULL; args->flags = flags; res = g_simple_async_result_new (G_OBJECT (self), callback, user_data, g_tls_database_real_verify_chain_async); g_simple_async_result_set_op_res_gpointer (res, args, async_verify_chain_free); g_simple_async_result_run_in_thread (res, async_verify_chain_thread, G_PRIORITY_DEFAULT, cancellable); g_object_unref (res); }
static void list_build_object_ready (GDBusConnection *connection, GAsyncResult *res, ListCallsContext *ctx) { GError *error = NULL; GObject *call; GObject *source_object; source_object = g_async_result_get_source_object (res); call = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, &error); g_object_unref (source_object); if (error) { g_simple_async_result_take_error (ctx->result, error); list_call_context_complete_and_free (ctx); return; } /* Keep the object */ ctx->call_objects = g_list_prepend (ctx->call_objects, call); /* If no more calls, just end here. */ if (!ctx->call_paths[++ctx->i]) { g_simple_async_result_set_op_res_gpointer (ctx->result, ctx->call_objects, (GDestroyNotify)call_object_list_free); ctx->call_objects = NULL; list_call_context_complete_and_free (ctx); return; } /* Keep on creating next object */ create_next_call (ctx); }
static void seahorse_ldap_source_search_async (SeahorseServerSource *source, const gchar *match, GcrSimpleCollection *results, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { SeahorseLDAPSource *self = SEAHORSE_LDAP_SOURCE (source); source_search_closure *closure; GSimpleAsyncResult *res; gchar *text; res = g_simple_async_result_new (G_OBJECT (source), callback, user_data, seahorse_ldap_source_search_async); closure = g_new0 (source_search_closure, 1); closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL; closure->results = g_object_ref (results); text = escape_ldap_value (match); closure->filter = g_strdup_printf ("(pgpuserid=*%s*)", text); g_free (text); g_simple_async_result_set_op_res_gpointer (res, closure, source_search_free); seahorse_progress_prep_and_begin (closure->cancellable, res, NULL); seahorse_ldap_source_connect_async (self, cancellable, on_search_connect_completed, g_object_ref (res)); g_object_unref (res); }
static void seahorse_ldap_source_export_async (SeahorseServerSource *source, const gchar **keyids, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { SeahorseLDAPSource *self = SEAHORSE_LDAP_SOURCE (source); ExportClosure *closure; GSimpleAsyncResult *res; gchar *fingerprint; gint i; res = g_simple_async_result_new (G_OBJECT (self), callback, user_data, seahorse_ldap_source_export_async); closure = g_new0 (ExportClosure, 1); closure->data = g_string_sized_new (1024); closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL; closure->fingerprints = g_ptr_array_new_with_free_func (g_free); for (i = 0; keyids[i] != NULL; i++) { fingerprint = g_strdup (keyids[i]); g_ptr_array_add (closure->fingerprints, fingerprint); seahorse_progress_prep (closure->cancellable, fingerprint, NULL); } closure->current_index = -1; g_simple_async_result_set_op_res_gpointer (res, closure, export_closure_free); seahorse_ldap_source_connect_async (self, cancellable, on_export_connect_completed, g_object_ref (res)); g_object_unref (res); }
static void read_all_async (GInputStream *stream, void *buffer, gsize count, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { ReadAllData *read_data; GSimpleAsyncResult *simple; read_data = g_slice_new0 (ReadAllData); read_data->buffer = buffer; read_data->count = count; read_data->io_priority = io_priority; if (cancellable) read_data->cancellable = g_object_ref (cancellable); simple = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, read_all_async); g_simple_async_result_set_op_res_gpointer (simple, read_data, (GDestroyNotify)free_read_all_data); g_input_stream_read_async (stream, buffer, count, io_priority, cancellable, read_all_cb, simple); }
static void g_tls_database_real_lookup_certificate_issuer_async (GTlsDatabase *self, GTlsCertificate *certificate, GTlsInteraction *interaction, GTlsDatabaseLookupFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *res; AsyncLookupCertificateIssuer *args; g_return_if_fail (G_IS_TLS_CERTIFICATE (certificate)); g_return_if_fail (callback != NULL); args = g_slice_new0 (AsyncLookupCertificateIssuer); args->certificate = g_object_ref (certificate); args->flags = flags; args->interaction = interaction ? g_object_ref (interaction) : NULL; res = g_simple_async_result_new (G_OBJECT (self), callback, user_data, g_tls_database_real_lookup_certificate_issuer_async); g_simple_async_result_set_op_res_gpointer (res, args, async_lookup_certificate_issuer_free); g_simple_async_result_run_in_thread (res, async_lookup_certificate_issuer_thread, G_PRIORITY_DEFAULT, cancellable); g_object_unref (res); }
static void get_protocols_cb (GObject *source, GAsyncResult *res, gpointer user_data) { GSimpleAsyncResult *outer_result = user_data; GList *protocols = NULL; GList *ret; GList *l; GError *error = NULL; GQuark facebook_quark; #if GOA_GOOGLE_ENABLED GQuark google_talk_quark; #endif if (!tpaw_protocol_get_all_finish (&protocols, res, &error)) { g_simple_async_result_take_error (outer_result, error); g_simple_async_result_complete_in_idle (outer_result); g_object_unref (outer_result); return; } facebook_quark = g_quark_from_static_string ("facebook"); #if GOA_GOOGLE_ENABLED google_talk_quark = g_quark_from_static_string ("google-talk"); #endif ret = NULL; for (l = protocols; l != NULL; l = l->next) { TpawProtocol *protocol = l->data; const gchar *service_name = tpaw_protocol_get_service_name (protocol); GQuark service_quark = g_quark_try_string (service_name); GoaTelepathyProvider *provider; /* This service does not exist anymore, so skip it. */ if (service_quark == facebook_quark) continue; /* If the service is handled natively by GOA, so we don't allow * the creation of a Telepathy-only account. */ #if GOA_GOOGLE_ENABLED if (service_quark == google_talk_quark) continue; #endif provider = goa_telepathy_provider_new_from_protocol (protocol); ret = g_list_prepend (ret, provider); } ret = g_list_reverse (ret); g_list_free_full (protocols, g_object_unref); g_simple_async_result_set_op_res_gpointer (outer_result, ret, free_list_and_unref); g_simple_async_result_complete_in_idle (outer_result); g_object_unref (outer_result); }
static void query_cb (DBusGProxy *proxy, DBusGProxyCall *call, GSimpleAsyncResult *result) { GPtrArray *strv_array; GError *error = NULL; if (dbus_g_proxy_end_call (proxy, call, &error, TYPE_STRV_ARRAY, &strv_array, G_TYPE_INVALID)) { GStrv filenames; guint i; filenames = g_new0 (char*, strv_array->len + 1); for (i = 0; i < strv_array->len; i++) { GStrv data = g_ptr_array_index (strv_array, i); filenames[i] = g_strdup (data[0]); g_strfreev (data); } g_ptr_array_free (strv_array, TRUE); g_simple_async_result_set_op_res_gpointer (result, filenames, (GDestroyNotify) g_strfreev); }
static void write_all_async (GOutputStream *stream, const void *buffer, gsize count, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *simple; WriteAllData *write_data; write_data = g_slice_new0 (WriteAllData); write_data->buffer = buffer; write_data->count = count; write_data->io_priority = io_priority; if (cancellable) write_data->cancellable = g_object_ref (cancellable); simple = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, write_all_async); g_simple_async_result_set_op_res_gpointer (simple, write_data, (GDestroyNotify)free_write_all_data); g_output_stream_write_async (stream, buffer, count, io_priority, cancellable, write_all_cb, simple); }
void evd_dbus_agent_new_proxy (GObject *object, guint connection_id, GDBusProxyFlags flags, const gchar *name, const gchar *object_path, const gchar *iface_name, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GDBusConnection *conn; GSimpleAsyncResult *res; GError *error = NULL; ProxyData *proxy_data; g_return_if_fail (G_IS_OBJECT (object)); g_return_if_fail (connection_id > 0); res = g_simple_async_result_new (object, callback, user_data, evd_dbus_agent_new_proxy); if ( (conn = evd_dbus_agent_get_connection (object, connection_id, &error)) != NULL) { ObjectData *data; data = evd_dbus_agent_get_object_data (object); g_simple_async_result_set_op_res_gpointer (res, data, NULL); proxy_data = g_slice_new (ProxyData); proxy_data->obj_data = data; proxy_data->conn_id = connection_id; proxy_data->async_res = res; proxy_data->proxy = NULL; g_dbus_proxy_new (conn, flags, NULL, name, object_path, iface_name, cancellable, evd_dbus_agent_on_new_dbus_proxy, proxy_data); } else { g_simple_async_result_set_from_error (res, error); g_error_free (error); g_simple_async_result_complete_in_idle (res); g_object_unref (res); } }
static void rygel_seekable_response_close_stream (RygelSeekableResponse* self, GAsyncReadyCallback _callback_, gpointer _user_data_) { RygelSeekableResponseCloseStreamData* _data_; _data_ = g_slice_new0 (RygelSeekableResponseCloseStreamData); _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_seekable_response_close_stream); g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_seekable_response_close_stream_data_free); _data_->self = g_object_ref (self); rygel_seekable_response_close_stream_co (_data_); }
static void pdf_load_job_complete_success (PdfLoadJob *job) { g_simple_async_result_set_op_res_gpointer (job->result, g_object_ref (job->document), NULL); g_simple_async_result_complete_in_idle (job->result); pdf_load_job_free (job); }
static void cockpit_auth_remote_login_async (CockpitAuth *self, GHashTable *headers, const gchar *remote_peer, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *task; CockpitCreds *creds = NULL; RemoteLoginData *rl; const gchar *password; GBytes *input; gchar *type = NULL; gchar *user = NULL; task = g_simple_async_result_new (G_OBJECT (self), callback, user_data, cockpit_auth_remote_login_async); input = cockpit_auth_parse_authorization (headers, &type); if (type && input && g_str_equal (type, "basic")) { password = parse_basic_auth_password (input, &user); if (password && user) { creds = cockpit_creds_new (user, COCKPIT_CRED_PASSWORD, password, COCKPIT_CRED_RHOST, remote_peer, NULL); } g_free (user); } if (creds) { rl = g_new0 (RemoteLoginData, 1); rl->creds = creds; rl->transport = g_object_new (COCKPIT_TYPE_SSH_TRANSPORT, "host", "127.0.0.1", "port", cockpit_ws_specific_ssh_port, "command", cockpit_ws_bridge_program, "creds", creds, "ignore-key", TRUE, NULL); g_simple_async_result_set_op_res_gpointer (task, rl, remote_login_data_free); g_signal_connect (rl->transport, "result", G_CALLBACK (on_remote_login_done), g_object_ref (task)); } else { g_simple_async_result_set_error (task, COCKPIT_ERROR, COCKPIT_ERROR_AUTHENTICATION_FAILED, "Basic authentication required"); g_simple_async_result_complete_in_idle (task); } g_free (type); g_object_unref (task); }
static gboolean get_metadata (TrackerExtractTask *task) { TrackerExtractInfo *info; TrackerSparqlBuilder *preupdate, *postupdate, *statements; gchar *where = NULL; preupdate = postupdate = statements = NULL; #ifdef THREAD_ENABLE_TRACE g_debug ("Thread:%p --> File:'%s' - Extracted", g_thread_self (), task->file); #endif /* THREAD_ENABLE_TRACE */ if (task->cancellable && g_cancellable_is_cancelled (task->cancellable)) { g_simple_async_result_set_error ((GSimpleAsyncResult *) task->res, TRACKER_DBUS_ERROR, 0, "Extraction of '%s' was cancelled", task->file); g_simple_async_result_complete_in_idle ((GSimpleAsyncResult *) task->res); extract_task_free (task); return FALSE; } if (!filter_module (task->extract, task->cur_module) && get_file_metadata (task, &info)) { g_simple_async_result_set_op_res_gpointer ((GSimpleAsyncResult *) task->res, info, (GDestroyNotify) tracker_extract_info_unref); g_simple_async_result_complete_in_idle ((GSimpleAsyncResult *) task->res); extract_task_free (task); } else { if (preupdate) { g_object_unref (preupdate); } if (postupdate) { g_object_unref (postupdate); } if (statements) { g_object_unref (statements); } g_free (where); /* Reinject the task into the main thread * queue, so the next module kicks in. */ g_idle_add ((GSourceFunc) dispatch_task_cb, task); } return FALSE; }
static void seahorse_hkp_source_search_async (SeahorseServerSource *source, const gchar *match, GcrSimpleCollection *results, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { SeahorseHKPSource *self = SEAHORSE_HKP_SOURCE (source); source_search_closure *closure; GSimpleAsyncResult *res; SoupMessage *message; GHashTable *form; SoupURI *uri; gchar hexfpr[11]; res = g_simple_async_result_new (G_OBJECT (source), callback, user_data, seahorse_hkp_source_search_async); closure = g_new0 (source_search_closure, 1); closure->source = g_object_ref (self); closure->cancellable = cancellable ? g_object_ref (cancellable) : NULL; closure->session = create_hkp_soup_session (); closure->results = g_object_ref (results); g_simple_async_result_set_op_res_gpointer (res, closure, source_search_free); uri = get_http_server_uri (self, "/pks/lookup"); g_return_if_fail (uri); form = g_hash_table_new (g_str_hash, g_str_equal); g_hash_table_insert (form, "op", "index"); if (is_hex_keyid (match)) { strncpy (hexfpr, "0x", 3); strncpy (hexfpr + 2, match, 9); g_hash_table_insert (form, "search", hexfpr); } else { g_hash_table_insert (form, "search", (char *)match); } g_hash_table_insert (form, "fingerprint", "on"); soup_uri_set_query_from_form (uri, form); g_hash_table_destroy (form); message = soup_message_new_from_uri ("GET", uri); soup_session_queue_message (closure->session, message, on_search_message_complete, g_object_ref (res)); seahorse_progress_prep_and_begin (cancellable, message, NULL); if (cancellable) closure->cancelled_sig = g_cancellable_connect (cancellable, G_CALLBACK (on_session_cancelled), closure->session, NULL); soup_uri_free (uri); g_object_unref (res); }
static void get_3g_band_ready (MMBroadbandModemWavecom *self, GAsyncResult *res, GSimpleAsyncResult *operation_result) { const gchar *response; const gchar *p; GError *error = NULL; GArray *bands_array = NULL; guint32 wavecom_band; response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error); if (!response) { /* Let the error be critical. */ g_simple_async_result_take_error (operation_result, error); g_simple_async_result_complete (operation_result); g_object_unref (operation_result); return; } /* Example reply: * AT+WUBS? --> * <-- +WUBS: "3",1 * <-- OK * The "3" meaning here Band I and II are selected. */ p = mm_strip_tag (response, "+WUBS:"); if (*p == '"') p++; wavecom_band = atoi (p); if (wavecom_band > 0) { guint i; for (i = 0; i < G_N_ELEMENTS (bands_3g); i++) { if (bands_3g[i].wavecom_band_flag & wavecom_band) { if (G_UNLIKELY (!bands_array)) bands_array = g_array_new (FALSE, FALSE, sizeof (MMModemBand)); g_array_append_val (bands_array, bands_3g[i].mm_band); } } } if (!bands_array) g_simple_async_result_set_error (operation_result, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Couldn't parse current bands reply: '%s'", response); else g_simple_async_result_set_op_res_gpointer (operation_result, bands_array, (GDestroyNotify)g_array_unref); g_simple_async_result_complete (operation_result); g_object_unref (operation_result); }
static void cockpit_auth_session_login_async (CockpitAuth *self, const gchar *path, GHashTable *headers, const gchar *remote_peer, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *result; SessionLoginData *sl; GBytes *input; gchar *application; gchar *type = NULL; result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, cockpit_auth_session_login_async); application = cockpit_auth_parse_application (path); input = cockpit_auth_parse_authorization (headers, &type); if (input && application) { sl = g_new0 (SessionLoginData, 1); sl->remote_peer = g_strdup (remote_peer); sl->auth_type = type; sl->authorization = g_bytes_ref (input); sl->application = application; application = NULL; g_simple_async_result_set_op_res_gpointer (result, sl, session_login_data_free); sl->session_pipe = spawn_session_process (type, input, remote_peer, &sl->auth_pipe); if (sl->session_pipe) { g_signal_connect (sl->auth_pipe, "close", G_CALLBACK (on_session_login_done), g_object_ref (result)); } else { g_simple_async_result_set_error (result, COCKPIT_ERROR, COCKPIT_ERROR_FAILED, "Internal error starting session process"); g_simple_async_result_complete_in_idle (result); } } else { g_free (type); g_simple_async_result_set_error (result, COCKPIT_ERROR, COCKPIT_ERROR_AUTHENTICATION_FAILED, "Authentication required"); g_simple_async_result_complete_in_idle (result); } g_bytes_unref (input); g_free (application); g_object_unref (result); }
static void complete_accept_operation (TpStreamTubeChannel *self, TpStreamTubeConnection *tube_conn) { g_simple_async_result_set_op_res_gpointer (self->priv->result, g_object_ref (tube_conn), g_object_unref); g_simple_async_result_complete (self->priv->result); tp_clear_object (&self->priv->result); }
static void get_albums_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; GList *albums = NULL; for (node = DOM_ELEMENT (doc)->first_child; node; node = node->next_sibling) { if (g_strcmp0 (node->tag_name, "photos_getAlbums_response") == 0) { DomElement *child; for (child = node->first_child; child; child = child->next_sibling) { if (g_strcmp0 (child->tag_name, "album") == 0) { FacebookAlbum *album; album = facebook_album_new (); dom_domizable_load_from_element (DOM_DOMIZABLE (album), child); albums = g_list_prepend (albums, album); } } } } albums = g_list_reverse (albums); g_simple_async_result_set_op_res_gpointer (result, albums, (GDestroyNotify) _g_object_list_unref); 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_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 supported_ms_classes_query_ready (MMBaseModem *self, GAsyncResult *res, GSimpleAsyncResult *simple) { const gchar *response; GError *error = NULL; MMModemMode mode; response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error); if (!response) { /* Let the error be critical. */ g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); g_object_unref (simple); return; } response = mm_strip_tag (response, "+CGCLASS:"); mode = MM_MODEM_MODE_NONE; if (strstr (response, WAVECOM_MS_CLASS_A_IDSTR)) { mm_dbg ("Modem supports Class A mobile station"); mode |= MM_MODEM_MODE_3G; } if (strstr (response, WAVECOM_MS_CLASS_B_IDSTR)) { mm_dbg ("Modem supports Class B mobile station"); mode |= (MM_MODEM_MODE_2G | MM_MODEM_MODE_CS); } if (strstr (response, WAVECOM_MS_CLASS_CG_IDSTR)) { mm_dbg ("Modem supports Class CG mobile station"); mode |= MM_MODEM_MODE_2G; } if (strstr (response, WAVECOM_MS_CLASS_CC_IDSTR)) { mm_dbg ("Modem supports Class CC mobile station"); mode |= MM_MODEM_MODE_CS; } /* If none received, error */ if (mode == MM_MODEM_MODE_NONE) g_simple_async_result_set_error (simple, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Couldn't get supported mobile station classes: '%s'", response); else g_simple_async_result_set_op_res_gpointer (simple, GUINT_TO_POINTER (mode), NULL); g_simple_async_result_complete (simple); g_object_unref (simple); }