static void on_import_message_complete (SoupSession *session, SoupMessage *message, gpointer user_data) { GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data); source_import_closure *closure = g_simple_async_result_get_op_res_gpointer (res); GError *error = NULL; gchar *errmsg; g_assert (closure->requests > 0); seahorse_progress_end (closure->cancellable, GUINT_TO_POINTER (closure->requests)); closure->requests--; if (hkp_message_propagate_error (closure->source, message, &error)) { g_simple_async_result_take_error (res, error); g_simple_async_result_complete_in_idle (res); } else if ((errmsg = get_send_result (message->response_body->data)) != NULL) { g_set_error (&error, HKP_ERROR_DOMAIN, message->status_code, "%s", errmsg); g_simple_async_result_take_error (res, error); g_simple_async_result_complete_in_idle (res); g_free (errmsg); /* A successful status from the server is all we want in this case */ } else { if (closure->requests == 0) g_simple_async_result_complete_in_idle (res); } g_object_unref (res); }
static void on_import_message_complete (SoupSession *session, SoupMessage *message, gpointer user_data) { g_autoptr(GTask) task = G_TASK (user_data); source_import_closure *closure = g_task_get_task_data (task); g_autoptr(GError) error = NULL; g_autofree gchar *errmsg = NULL; g_assert (closure->requests > 0); seahorse_progress_end (closure->cancellable, GUINT_TO_POINTER (closure->requests)); closure->requests--; if (hkp_message_propagate_error (closure->source, message, &error)) { g_task_return_error (task, g_steal_pointer (&error)); return; } if ((errmsg = get_send_result (message->response_body->data)) != NULL) { g_task_return_new_error (task, HKP_ERROR_DOMAIN, message->status_code, "%s", errmsg); return; } /* A successful status from the server is all we want in this case */ if (closure->requests == 0) { /* We don't know which keys got imported, so just return NULL */ g_task_return_pointer (task, NULL, NULL); } }
static void send_callback (SoupSession *session, SoupMessage *msg, SeahorseHKPOperation *hop) { gchar *errmsg; if (hop->cancelling) return; if (SOUP_MESSAGE_IS_ERROR (msg)) { fail_hkp_operation (hop, msg, NULL); return; } errmsg = get_send_result (msg->response_body->data); if (errmsg) { fail_hkp_operation (hop, NULL, errmsg); g_free (errmsg); return; } /* A successful status from the server is all we want in this case */ if (--hop->requests <= 0) seahorse_operation_mark_done (SEAHORSE_OPERATION (hop), FALSE, NULL); else seahorse_operation_mark_progress_full (SEAHORSE_OPERATION (hop), _("Uploading keys..."), hop->requests, hop->total); }