/* Default implementation just calls the synchronous method; this can * be used if the implementation already knows all of its addresses, * and so the synchronous method will never block. */ static void g_socket_address_enumerator_real_next_async (GSocketAddressEnumerator *enumerator, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; GSocketAddress *address; GError *error = NULL; task = g_task_new (enumerator, NULL, callback, user_data); g_task_set_source_tag (task, g_socket_address_enumerator_real_next_async); address = g_socket_address_enumerator_next (enumerator, cancellable, &error); if (error) g_task_return_error (task, error); else g_task_return_pointer (task, address, g_object_unref); g_object_unref (task); }
static void remove_account (GoaProvider *provider, GoaObject *object, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GoaTelepathyProvider *self = GOA_TELEPATHY_PROVIDER (provider); GTask *task; task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, remove_account); goa_tp_account_linker_remove_tp_account (tp_linker, object, cancellable, remove_account_remove_tp_account_cb, g_object_ref (task)); g_object_unref (task); }
static void ide_builder_real_build_async (IdeBuilder *self, IdeBuilderBuildFlags flags, IdeBuildResult **result, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; g_assert (IDE_IS_BUILDER (self)); g_assert (!cancellable || G_IS_CANCELLABLE (cancellable)); g_assert (!result || *result == NULL); task = g_task_new (self, cancellable, callback, user_data); g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, _("%s does not support building"), G_OBJECT_TYPE_NAME (self)); }
static void load_imsi (MMBaseSim *self, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; QmiClient *client = NULL; task = g_task_new (self, NULL, callback, user_data); if (!ensure_qmi_client (task, MM_SIM_QMI (self), QMI_SERVICE_DMS, &client)) return; mm_dbg ("loading IMSI..."); qmi_client_dms_uim_get_imsi (QMI_CLIENT_DMS (client), NULL, 5, NULL, (GAsyncReadyCallback)dms_uim_get_imsi_ready, task); }
static void load_texture_async (StTextureCache *cache, AsyncTextureLoadData *data) { if (data->file) { GTask *task = g_task_new (cache, NULL, on_pixbuf_loaded, data); g_task_set_task_data (task, data, NULL); g_task_run_in_thread (task, load_pixbuf_thread); g_object_unref (task); } else if (data->icon_info) { StIconColors *colors = data->colors; if (colors) { GdkRGBA foreground_color; GdkRGBA success_color; GdkRGBA warning_color; GdkRGBA error_color; rgba_from_clutter (&foreground_color, &colors->foreground); rgba_from_clutter (&success_color, &colors->success); rgba_from_clutter (&warning_color, &colors->warning); rgba_from_clutter (&error_color, &colors->error); gtk_icon_info_load_symbolic_async (data->icon_info, &foreground_color, &success_color, &warning_color, &error_color, NULL, on_symbolic_icon_loaded, data); } else { gtk_icon_info_load_icon_async (data->icon_info, NULL, on_icon_loaded, data); } } else g_assert_not_reached (); }
void photos_glib_file_create_async (GFile *file, GFileCreateFlags flags, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr (GTask) task = NULL; g_autoptr (PhotosGLibFileCreateData) data = NULL; g_return_if_fail (G_IS_FILE (file)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); task = g_task_new (file, cancellable, callback, user_data); g_task_set_source_tag (task, photos_glib_file_create_async); data = photos_glib_file_create_data_new (file, flags, io_priority); g_task_set_task_data (task, g_steal_pointer (&data), (GDestroyNotify) photos_glib_file_create_data_free); g_file_create_async (file, flags, io_priority, cancellable, photos_glib_file_create_create, g_object_ref (task)); }
static void lookup_records_async (GResolver *resolver, const char *rrname, GResolverRecordType record_type, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; LookupRecordsData *lrd; task = g_task_new (resolver, cancellable, callback, user_data); lrd = g_slice_new (LookupRecordsData); lrd->rrname = g_strdup (rrname); lrd->record_type = record_type; g_task_set_task_data (task, lrd, (GDestroyNotify) free_lookup_records_data); g_task_set_return_on_cancel (task, TRUE); g_task_run_in_thread (task, do_lookup_records); g_object_unref (task); }
static void load_operator_name (MMBaseSim *self, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; QmiClient *client = NULL; task = g_task_new (self, NULL, callback, user_data); if (!ensure_qmi_client (task, MM_SIM_QMI (self), QMI_SERVICE_NAS, &client)) return; mm_dbg ("loading SIM operator name..."); qmi_client_nas_get_home_network (QMI_CLIENT_NAS (client), NULL, 5, NULL, (GAsyncReadyCallback)load_operator_name_ready, task); }
void cd_sensor_get_sample_async (CdSensor *sensor, CdSensorCap cap, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; g_return_if_fail (CD_IS_SENSOR (sensor)); task = g_task_new (sensor, cancellable, callback, user_data); /* set state */ cd_sensor_set_state (sensor, CD_SENSOR_STATE_MEASURING); /* just complete in idle */ if (cap != CD_SENSOR_CAP_AMBIENT) g_timeout_add_seconds (2, (GSourceFunc) cd_sensor_get_sample_wait_cb, task); else g_timeout_add_seconds (2, (GSourceFunc) cd_sensor_get_ambient_wait_cb, task); }
static void mock_interaction_request_certificate_async (GTlsInteraction *interaction, GTlsConnection *connection, GTlsCertificateRequestFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { MockInteraction *self = MOCK_INTERACTION (interaction); GTask *task; task = g_task_new (interaction, cancellable, callback, user_data); if (self->static_error) g_task_return_error (task, g_error_copy (self->static_error)); else { g_tls_connection_set_certificate (connection, self->static_certificate); g_task_return_boolean (task, TRUE); } g_object_unref (task); }
/** * gdata_calendar_service_query_events_async: * @self: a #GDataCalendarService * @calendar: a #GDataCalendarCalendar * @query: (allow-none): a #GDataQuery with the query parameters, or %NULL * @cancellable: (allow-none): optional #GCancellable object, or %NULL * @progress_callback: (allow-none) (closure progress_user_data): a #GDataQueryProgressCallback to call when an entry is loaded, or %NULL * @progress_user_data: (closure): data to pass to the @progress_callback function * @destroy_progress_user_data: (allow-none): the function to call when @progress_callback will not be called any more, or %NULL. This function will be * called with @progress_user_data as a parameter and can be used to free any memory allocated for it. * @callback: a #GAsyncReadyCallback to call when the query is finished * @user_data: (closure): data to pass to the @callback function * * Queries the service to return a list of events in the given @calendar, which match @query. @self, @calendar and @query are all reffed when this * function is called, so can safely be unreffed after this function returns. * * Get the results of the query using gdata_service_query_finish() in the @callback. * * For more details, see gdata_calendar_service_query_events(), which is the synchronous version of this function, and gdata_service_query_async(), * which is the base asynchronous query function. * * Since: 0.9.1 */ void gdata_calendar_service_query_events_async (GDataCalendarService *self, GDataCalendarCalendar *calendar, GDataQuery *query, GCancellable *cancellable, GDataQueryProgressCallback progress_callback, gpointer progress_user_data, GDestroyNotify destroy_progress_user_data, GAsyncReadyCallback callback, gpointer user_data) { gchar *request_uri; g_return_if_fail (GDATA_IS_CALENDAR_SERVICE (self)); g_return_if_fail (GDATA_IS_CALENDAR_CALENDAR (calendar)); g_return_if_fail (query == NULL || GDATA_IS_QUERY (query)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (callback != NULL); /* Ensure we're authenticated first */ if (gdata_authorizer_is_authorized_for_domain (gdata_service_get_authorizer (GDATA_SERVICE (self)), get_calendar_authorization_domain ()) == FALSE) { g_autoptr(GTask) task = NULL; task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, gdata_service_query_async); g_task_return_new_error (task, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED, "%s", _("You must be authenticated to query your own calendars.")); return; } /* Execute the query. */ request_uri = build_events_uri (calendar); gdata_service_query_async (GDATA_SERVICE (self), get_calendar_authorization_domain (), request_uri, query, GDATA_TYPE_CALENDAR_EVENT, cancellable, progress_callback, progress_user_data, destroy_progress_user_data, callback, user_data); g_free (request_uri); }
void ide_run_manager_run_async (IdeRunManager *self, IdeBuildTarget *build_target, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; g_autoptr(GCancellable) local_cancellable = NULL; GError *error = NULL; IDE_ENTRY; g_return_if_fail (IDE_IS_RUN_MANAGER (self)); g_return_if_fail (!build_target || IDE_IS_BUILD_TARGET (build_target)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); if (cancellable == NULL) cancellable = local_cancellable = g_cancellable_new (); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, ide_run_manager_run_async); g_set_object (&self->cancellable, cancellable); if (ide_run_manager_check_busy (self, &error)) { g_task_return_error (task, error); IDE_EXIT; } if (build_target != NULL) ide_run_manager_set_build_target (self, build_target); ide_run_manager_do_install_before_run (self, task); IDE_EXIT; }
/** * cd_profile_install_system_wide: * @profile: a #CdProfile instance. * @cancellable: a #GCancellable, or %NULL * @callback: the function to run on completion * @user_data: the data to pass to @callback * * Sets the profile system wide. * * Since: 0.1.8 **/ void cd_profile_install_system_wide (CdProfile *profile, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { CdProfilePrivate *priv = GET_PRIVATE (profile); GTask *task = NULL; g_return_if_fail (CD_IS_PROFILE (profile)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (priv->proxy != NULL); task = g_task_new (profile, cancellable, callback, user_data); g_dbus_proxy_call (priv->proxy, "InstallSystemWide", NULL, G_DBUS_CALL_FLAGS_NONE, -1, cancellable, cd_profile_install_system_wide_cb, task); }
void ide_subprocess_wait_check_async (IdeSubprocess *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; IDE_ENTRY; g_return_if_fail (IDE_IS_SUBPROCESS (self)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, ide_subprocess_wait_check_async); ide_subprocess_wait_async (self, cancellable, ide_subprocess_wait_check_cb, g_steal_pointer (&task)); IDE_EXIT; }
static gboolean g_tls_connection_base_handshake (GTlsConnection *conn, GCancellable *cancellable, GError **error) { GTlsConnectionBase *tls = G_TLS_CONNECTION_BASE (conn); GTask *task; gboolean success; GError *my_error = NULL; task = g_task_new (conn, cancellable, NULL, NULL); g_task_set_source_tag (task, g_tls_connection_base_handshake); g_task_run_in_thread_sync (task, handshake_thread); success = finish_handshake (tls, task, &my_error); g_object_unref (task); yield_op (tls, G_TLS_CONNECTION_BASE_OP_HANDSHAKE, G_TLS_CONNECTION_BASE_OK); if (my_error) g_propagate_error (error, my_error); return success; }
void tracker_db_backup_save (GFile *destination, TrackerDBBackupFinished callback, gpointer user_data, GDestroyNotify destroy) { GTask *task; BackupInfo *info; info = g_slice_new0 (BackupInfo); info->destination = g_object_ref (destination); info->callback = callback; info->user_data = user_data; info->destroy = destroy; task = g_task_new (NULL, NULL, NULL, NULL); g_task_set_task_data (task, info, NULL); g_task_run_in_thread (task, backup_job); g_object_unref (task); }
void pp_cups_renew_subscription_async (PpCups *cups, gint subscription_id, gchar **events, gint lease_duration, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { CRSData *subscription_data; GTask *task; subscription_data = g_slice_new (CRSData); subscription_data->id = subscription_id; subscription_data->events = g_strdupv (events); subscription_data->lease_duration = lease_duration; task = g_task_new (cups, cancellable, callback, user_data); g_task_set_task_data (task, subscription_data, (GDestroyNotify) crs_data_free); g_task_run_in_thread (task, renew_subscription_thread); g_object_unref (task); }
void nul_sparql_query_util_query_async (gchar const *const sparql, GCancellable *const cancellable, GAsyncReadyCallback const callback, gpointer const user_data) { nul_debug ("scheduling query %s", sparql); GTask *const task = g_task_new (NULL, cancellable, callback, user_data); SparqlQueryWork *const work = g_new0 (SparqlQueryWork, 1); work->sparql = g_strdup (sparql); g_task_set_task_data (task, work, (GDestroyNotify) sparql_query_work_free); tracker_sparql_connection_get_async ( cancellable, (GAsyncReadyCallback) do_sparql_query_async_connection_cb, task ); }
static void ide_gettext_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provider, IdeFile *file, IdeBuffer *buffer, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { IdeGettextDiagnosticProvider *self = (IdeGettextDiagnosticProvider *)provider; g_autoptr(IdeUnsavedFile) unsaved_file = NULL; IdeGettextDiagnostics *cached; g_autoptr(GTask) task = NULL; g_return_if_fail (IDE_IS_GETTEXT_DIAGNOSTIC_PROVIDER (self)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, ide_gettext_diagnostic_provider_diagnose_async); if (NULL != (cached = dzl_task_cache_peek (self->diagnostics_cache, file))) { unsaved_file = get_unsaved_file (self, file); if (unsaved_file == NULL || (cached->sequence >= ide_unsaved_file_get_sequence (unsaved_file))) { g_task_return_pointer (task, g_object_ref (cached), g_object_unref); return; } } dzl_task_cache_get_async (self->diagnostics_cache, file, TRUE, cancellable, get_diagnostics_cb, g_steal_pointer (&task)); }
void aws_s3_client_write_async (AwsS3Client *client, const gchar *bucket, const gchar *path, GInputStream *stream, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; g_return_if_fail (AWS_IS_S3_CLIENT (client)); g_return_if_fail (bucket); g_return_if_fail (path); g_return_if_fail (G_IS_INPUT_STREAM (stream)); task = g_task_new (client, cancellable, callback, user_data); g_task_set_source_tag (task, aws_s3_client_write_async); g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "Writing support has not been implemented"); }
void ide_git_clone_widget_clone_async (IdeGitCloneWidget *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; g_autoptr(GFile) location = NULL; g_autoptr(GFile) child = NULL; CloneRequest *req; const gchar *uri; const gchar *child_name; g_return_if_fail (IDE_IS_GIT_CLONE_WIDGET (self)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); gtk_label_set_label (self->clone_error_label, NULL); uri = gtk_entry_get_text (self->clone_uri_entry); child_name = gtk_entry_get_text (self->clone_location_entry); location = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (self->clone_location_button)); if (child_name != NULL) { child = g_file_get_child (location, child_name); req = clone_request_new (uri, child); } else { req = clone_request_new (uri, location); } task = g_task_new (self, cancellable, callback, user_data); g_task_set_task_data (task, req, clone_request_free); g_task_run_in_thread (task, ide_git_clone_widget_worker); }
/** * g_io_scheduler_push_job: * @job_func: a #GIOSchedulerJobFunc. * @user_data: data to pass to @job_func * @notify: (nullable): a #GDestroyNotify for @user_data, or %NULL * @io_priority: the [I/O priority][io-priority] * of the request. * @cancellable: optional #GCancellable object, %NULL to ignore. * * Schedules the I/O job to run in another thread. * * @notify will be called on @user_data after @job_func has returned, * regardless whether the job was cancelled or has run to completion. * * If @cancellable is not %NULL, it can be used to cancel the I/O job * by calling g_cancellable_cancel() or by calling * g_io_scheduler_cancel_all_jobs(). * * Deprecated: use #GThreadPool or g_task_run_in_thread() **/ void g_io_scheduler_push_job (GIOSchedulerJobFunc job_func, gpointer user_data, GDestroyNotify notify, gint io_priority, GCancellable *cancellable) { GIOSchedulerJob *job; GTask *task; g_return_if_fail (job_func != NULL); job = g_slice_new0 (GIOSchedulerJob); job->job_func = job_func; job->data = user_data; job->destroy_notify = notify; if (cancellable) job->cancellable = g_object_ref (cancellable); job->context = g_main_context_ref_thread_default (); G_LOCK (active_jobs); active_jobs = g_list_prepend (active_jobs, job); job->active_link = active_jobs; G_UNLOCK (active_jobs); task = g_task_new (NULL, cancellable, NULL, NULL); G_GNUC_BEGIN_IGNORE_DEPRECATIONS g_task_set_source_tag (task, g_io_scheduler_push_job); G_GNUC_END_IGNORE_DEPRECATIONS g_task_set_task_data (task, job, (GDestroyNotify)g_io_job_free); g_task_set_priority (task, io_priority); g_task_run_in_thread (task, io_job_thread); g_object_unref (task); }
static void watch_smartcards_from_driver_async (GsdSmartcardManager *self, SECMODModule *driver, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GsdSmartcardManagerPrivate *priv = self->priv; GTask *task; WatchSmartcardsOperation *operation; operation = g_new0 (WatchSmartcardsOperation, 1); operation->driver = SECMOD_ReferenceModule (driver); operation->smartcards = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) PK11_FreeSlot); task = g_task_new (self, cancellable, callback, user_data); g_task_set_task_data (task, operation, (GDestroyNotify) destroy_watch_smartcards_operation); G_LOCK (gsd_smartcards_watch_tasks); priv->smartcards_watch_tasks = g_list_prepend (priv->smartcards_watch_tasks, task); g_object_weak_ref (G_OBJECT (task), (GWeakNotify) on_smartcards_watch_task_destroyed, self); G_UNLOCK (gsd_smartcards_watch_tasks); sync_initial_tokens_from_driver (self, driver, operation->smartcards, cancellable); g_task_run_in_thread (task, (GTaskThreadFunc) watch_smartcards_from_driver); }
void um_realm_login (UmRealmObject *realm, const gchar *user, const gchar *password, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; LoginClosure *login; UmRealmKerberos *kerberos; g_return_if_fail (UM_REALM_IS_OBJECT (realm)); g_return_if_fail (user != NULL); g_return_if_fail (password != NULL); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); kerberos = um_realm_object_get_kerberos (realm); g_return_if_fail (kerberos != NULL); task = g_task_new (realm, cancellable, callback, user_data); login = g_slice_new0 (LoginClosure); login->domain = g_strdup (um_realm_kerberos_get_domain_name (kerberos)); login->realm = g_strdup (um_realm_kerberos_get_realm_name (kerberos)); login->user = g_strdup (user); login->password = g_strdup (password); g_task_set_task_data (task, login, login_closure_free); g_task_set_check_cancellable (task, TRUE); g_task_set_return_on_cancel (task, TRUE); g_task_run_in_thread (task, kinit_thread_func); g_object_unref (task); g_object_unref (kerberos); }
static void activate_driver (GsdSmartcardManager *self, SECMODModule *driver, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GTask *task; g_debug ("Activating driver '%s'", driver->commonName); task = g_task_new (self, cancellable, callback, user_data); register_driver (self, driver, cancellable, (GAsyncReadyCallback) on_driver_registered, task); watch_smartcards_from_driver_async (self, driver, cancellable, (GAsyncReadyCallback) on_smartcards_from_driver_watched, task); }
static void ide_autotools_build_system_get_local_makefile_async (IdeAutotoolsBuildSystem *self, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { IdeContext *context; g_autoptr(IdeConfiguration) configuration = NULL; g_autoptr(GTask) task = NULL; g_autoptr(IdeBuilder) builder = NULL; g_autoptr(GFile) build_directory = NULL; g_autoptr(GFile) makefile = NULL; GError *error = NULL; g_return_if_fail (IDE_IS_AUTOTOOLS_BUILD_SYSTEM (self)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); context = ide_object_get_context (IDE_OBJECT (self)); configuration = ide_configuration_new (context, "autotools-bootstrap", "local", "host"); builder = ide_autotools_build_system_get_builder (IDE_BUILD_SYSTEM (self), configuration, &error); if (builder == NULL) { g_task_return_error (task, error); return; } build_directory = ide_autotools_builder_get_build_directory (IDE_AUTOTOOLS_BUILDER (builder)); makefile = g_file_get_child (build_directory, "Makefile"); g_task_return_pointer (task, g_object_ref (makefile), g_object_unref); }
static void ide_rename_provider_real_rename_async (IdeRenameProvider *self, IdeSourceLocation *location, const gchar *new_name, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; g_assert (IDE_IS_RENAME_PROVIDER (self)); g_assert (location != NULL); g_assert (new_name != NULL); g_assert (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); g_task_set_source_tag (task, ide_rename_provider_real_rename_async); g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "%s has not implemented rename_async", G_OBJECT_TYPE_NAME (self)); }
/** * e_trust_prompt_run_for_source: * @parent: A #GtkWindow to use as a parent for the trust prompt dialog * @source: an #ESource, with %E_SOURCE_EXTENSION_AUTHENTICATION * @certificate_pem: a PEM-encoded certificate for which to show the trust prompt * @certificate_errors: errors of the @certificate_pem * @error_text: (allow-none): an optional error text to show in the dialog; can be %NULL * @allow_source_save: whether can also save any @source changes * @cancellable: (allow-none): a #GCancellable, or %NULL * @callback: a callback to call, when the prompt (an @source save) is done * @user_data: user data passed into @callback * * Similar to e_trust_prompt_run_modal(), except it also manages all the necessary things * around the @source<!-- -->'s SSL/TLS trust properties when it also contains %E_SOURCE_EXTENSION_WEBDAV, * thus the SSL/TLS trust on the WebDAV @source is properly updated based on the user's choice. * The call is finished with e_trust_prompt_run_for_source_finish(), * which also returns the user's choice. The finish happens in the @callback. * This is necessary, because the @source can be also saved. * * The function fails, if the @source doesn't contain the %E_SOURCE_EXTENSION_AUTHENTICATION. * * Note: The dialog is not shown when the stored certificate trust in the WebDAV @source * matches the @certificate_pem and the stored result is #E_TRUST_PROMPT_RESPONSE_REJECT. * * Since: 3.16 **/ void e_trust_prompt_run_for_source (GtkWindow *parent, ESource *source, const gchar *certificate_pem, GTlsCertificateFlags certificate_errors, const gchar *error_text, gboolean allow_source_save, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { ESourceAuthentication *extension_authentication = NULL; ESourceWebdav *extension_webdav = NULL; SaveSourceData *save_data; GTlsCertificate *certificate; gchar *host; GTask *task; if (parent) g_return_if_fail (GTK_IS_WINDOW (parent)); g_return_if_fail (E_IS_SOURCE (source)); g_return_if_fail (certificate_pem != NULL); if (e_source_has_extension (source, E_SOURCE_EXTENSION_GOA) || e_source_has_extension (source, E_SOURCE_EXTENSION_UOA)) { /* Make sure that GOA/UOA collection sources contain these extensions too */ g_warn_if_fail (e_source_get_extension (source, E_SOURCE_EXTENSION_AUTHENTICATION)); g_warn_if_fail (e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND)); } if (e_source_has_extension (source, E_SOURCE_EXTENSION_AUTHENTICATION)) extension_authentication = e_source_get_extension (source, E_SOURCE_EXTENSION_AUTHENTICATION); if (e_source_has_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND)) extension_webdav = e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND); save_data = g_new0 (SaveSourceData, 1); save_data->response = E_TRUST_PROMPT_RESPONSE_UNKNOWN; save_data->call_save = FALSE; /* Lookup used host name */ if (extension_authentication) host = e_source_authentication_dup_host (extension_authentication); else host = NULL; if (!host || !*host) { g_free (host); host = NULL; if (e_source_has_extension (source, E_SOURCE_EXTENSION_GOA)) { ESourceGoa *goa_extension; gchar *url; goa_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_GOA); url = e_source_goa_dup_calendar_url (goa_extension); host = trust_prompt_get_host_from_url (url); g_free (url); if (!host) { url = e_source_goa_dup_contacts_url (goa_extension); host = trust_prompt_get_host_from_url (url); g_free (url); } } } certificate = g_tls_certificate_new_from_pem (certificate_pem, -1, &save_data->error); if (certificate) { if (extension_webdav && host) save_data->response = e_source_webdav_verify_ssl_trust (extension_webdav, host, certificate, 0); else save_data->response = E_TRUST_PROMPT_RESPONSE_REJECT_TEMPORARILY; if (save_data->response != E_TRUST_PROMPT_RESPONSE_REJECT) { const gchar *source_extension = NULL; if (e_source_has_extension (source, E_SOURCE_EXTENSION_ADDRESS_BOOK)) source_extension = E_SOURCE_EXTENSION_ADDRESS_BOOK; if (e_source_has_extension (source, E_SOURCE_EXTENSION_CALENDAR)) { if (!source_extension) source_extension = E_SOURCE_EXTENSION_CALENDAR; else source_extension = E_SOURCE_EXTENSION_COLLECTION; } if (e_source_has_extension (source, E_SOURCE_EXTENSION_MEMO_LIST)) { if (!source_extension) source_extension = E_SOURCE_EXTENSION_MEMO_LIST; else source_extension = E_SOURCE_EXTENSION_COLLECTION; } if (e_source_has_extension (source, E_SOURCE_EXTENSION_TASK_LIST)) { if (!source_extension) source_extension = E_SOURCE_EXTENSION_TASK_LIST; else source_extension = E_SOURCE_EXTENSION_COLLECTION; } if (e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_ACCOUNT)) { if (!source_extension) source_extension = E_SOURCE_EXTENSION_MAIL_ACCOUNT; else source_extension = E_SOURCE_EXTENSION_COLLECTION; } if (e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_TRANSPORT)) { if (!source_extension) source_extension = E_SOURCE_EXTENSION_MAIL_TRANSPORT; else source_extension = E_SOURCE_EXTENSION_COLLECTION; } save_data->response = e_trust_prompt_run_with_dialog_ready_callback (parent, source_extension, e_source_get_display_name (source), host, certificate_pem, certificate_errors, error_text, trust_prompt_listen_for_source_changes_cb, source); } } g_signal_handlers_disconnect_matched (source, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, source_connection_status_changed_cb, NULL); if (save_data->response != E_TRUST_PROMPT_RESPONSE_UNKNOWN) { if (certificate && extension_webdav) { e_source_webdav_update_ssl_trust (extension_webdav, host, certificate, save_data->response); save_data->call_save = allow_source_save; } } g_clear_object (&certificate); g_free (host); task = g_task_new (source, cancellable, callback, user_data); g_task_set_source_tag (task, e_trust_prompt_run_for_source); g_task_set_task_data (task, save_data, save_source_data_free); g_task_run_in_thread (task, save_source_thread); g_object_unref (task); }
void egg_task_cache_get_async (EggTaskCache *self, gconstpointer key, gboolean force_update, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_autoptr(GTask) task = NULL; GPtrArray *queued; gpointer ret; g_return_if_fail (EGG_IS_TASK_CACHE (self)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); task = g_task_new (self, cancellable, callback, user_data); /* * If we have the answer, return it now. */ if (!force_update && (ret = egg_task_cache_peek (self, key))) { g_task_return_pointer (task, self->value_copy_func (ret), self->value_destroy_func); return; } EGG_COUNTER_INC (misses); /* * Always queue the request. If we need to dispatch the worker to * fetch the result, that will happen with another task. */ if (!(queued = g_hash_table_lookup (self->queued, key))) { queued = g_ptr_array_new_with_free_func (g_object_unref); g_hash_table_insert (self->queued, self->key_copy_func ((gpointer)key), queued); } g_ptr_array_add (queued, g_object_ref (task)); EGG_COUNTER_INC (queued); /* * The in_flight hashtable will have a bit set if we have queued * an operation for this key. */ if (!g_hash_table_contains (self->in_flight, key)) { g_autoptr(GTask) fetch_task = NULL; fetch_task = g_task_new (self, cancellable, egg_task_cache_fetch_cb, self->key_copy_func ((gpointer)key)); g_hash_table_insert (self->in_flight, self->key_copy_func ((gpointer)key), GINT_TO_POINTER (TRUE)); self->populate_callback (self, key, g_object_ref (fetch_task), self->populate_callback_data); EGG_COUNTER_INC (in_flight); } }
static void handle_method_call_perform_writeback (TrackerController *controller, GDBusMethodInvocation *invocation, GVariant *parameters) { TrackerControllerPrivate *priv; TrackerDBusRequest *request; const gchar *subject; GPtrArray *results = NULL; GHashTableIter iter; gpointer key, value; GVariantIter *iter1, *iter2, *iter3; GArray *rdf_types_array; GStrv rdf_types; gchar *rdf_type = NULL; GList *writeback_handlers = NULL; priv = controller->priv; results = g_ptr_array_new_with_free_func ((GDestroyNotify) g_strfreev); g_variant_get (parameters, "(&sasaas)", &subject, &iter1, &iter2); rdf_types_array = g_array_new (TRUE, TRUE, sizeof (gchar *)); while (g_variant_iter_loop (iter1, "&s", &rdf_type)) { g_array_append_val (rdf_types_array, rdf_type); } rdf_types = (GStrv) rdf_types_array->data; g_array_free (rdf_types_array, FALSE); while (g_variant_iter_loop (iter2, "as", &iter3)) { GArray *row_array = g_array_new (TRUE, TRUE, sizeof (gchar *)); gchar *cell = NULL; while (g_variant_iter_loop (iter3, "&s", &cell)) { g_array_append_val (row_array, cell); } g_ptr_array_add (results, row_array->data); g_array_free (row_array, FALSE); } g_variant_iter_free (iter1); g_variant_iter_free (iter2); reset_shutdown_timeout (controller); request = tracker_dbus_request_begin (NULL, "%s (%s)", __FUNCTION__, subject); g_hash_table_iter_init (&iter, priv->modules); while (g_hash_table_iter_next (&iter, &key, &value)) { TrackerWritebackModule *module; const gchar * const *module_types; module = value; module_types = tracker_writeback_module_get_rdf_types (module); if (sparql_rdf_types_match (module_types, (const gchar * const *) rdf_types)) { TrackerWriteback *writeback; g_message (" Updating metadata for subject:'%s' using module:'%s'", subject, module->name); writeback = tracker_writeback_module_create (module); writeback_handlers = g_list_prepend (writeback_handlers, writeback); } } if (writeback_handlers != NULL) { WritebackData *data; GTask *task; data = writeback_data_new (controller, writeback_handlers, priv->connection, subject, results, invocation, request); task = g_task_new (controller, data->cancellable, NULL, NULL); /* No need to free data here, it's done in the callback. */ g_task_set_task_data (task, data, NULL); g_task_run_in_thread (task, io_writeback_job); g_object_unref (task); } else { g_dbus_method_invocation_return_error (invocation, TRACKER_DBUS_ERROR, TRACKER_DBUS_ERROR_UNSUPPORTED, "No module for rdf types"); } g_free (rdf_types); }