static void
discover_file_cb (GObject      *object,
                  GAsyncResult *result,
                  gpointer      user_data)
{
  IdeAutotoolsBuildSystem *self;
  g_autoptr(GTask) task = user_data;
  g_autoptr(GFile) file = NULL;
  GError *error = NULL;

  g_return_if_fail (G_IS_TASK (task));

  self = g_task_get_source_object (task);
  file = ide_autotools_build_system_discover_file_finish (self, result, &error);

  if (!file)
    {
      g_task_return_error (task, error);
      return;
    }

  g_object_set (self, "project-file", file, NULL);

  ide_autotools_build_system_parse_async (self,
                                          file,
                                          g_task_get_cancellable (task),
                                          parse_cb,
                                          g_object_ref (task));
}
static gboolean
finish_animation_in_idle (gpointer data)
{
  g_autoptr(GTask) task = data;
  IdeGitCloneWidget *self;

  IDE_ENTRY;

  g_assert (G_IS_TASK (task));
  self = g_task_get_source_object (task);
  g_assert (IDE_IS_GIT_CLONE_WIDGET (self));

  egg_object_animate_full (self->clone_progress,
                           EGG_ANIMATION_EASE_IN_OUT_QUAD,
                           ANIMATION_DURATION_MSEC,
                           NULL,
                           (GDestroyNotify)ide_widget_hide_with_fade,
                           self->clone_progress,
                           "fraction", 1.0,
                           NULL);

  /*
   * Wait for a second so animations can complete before opening
   * the project. Otherwise, it's pretty jarring to the user.
   */
  g_timeout_add (ANIMATION_DURATION_MSEC, open_after_timeout, g_object_ref (task));

  IDE_RETURN (G_SOURCE_REMOVE);
}
static gpointer
ide_git_buffer_change_monitor_worker (gpointer data)
{
  GAsyncQueue *queue = data;
  GTask *task;

  g_assert (queue);

  while ((task = g_async_queue_pop (queue)))
    {
      IdeGitBufferChangeMonitor *self;
      DiffTask *diff;
      GError *error = NULL;

      self = g_task_get_source_object (task);
      diff = g_task_get_task_data (task);

      if (!ide_git_buffer_change_monitor_calculate_threaded (self, diff, &error))
        g_task_return_error (task, error);
      else
        g_task_return_pointer (task, g_hash_table_ref (diff->state),
                               (GDestroyNotify)g_hash_table_unref);

      g_object_unref (task);
    }

  return NULL;
}
Beispiel #4
0
static void
socket_connect_complete (GObject *object, GAsyncResult *result, gpointer user_data)
{
	SoupSocket *sock = SOUP_SOCKET (object);
	GTask *task = user_data;
	SoupConnection *conn = g_task_get_source_object (task);
	SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn);
	GError *error = NULL;

	if (!soup_socket_connect_finish_internal (sock, result, &error)) {
		socket_connect_finished (task, sock, error);
		return;
	}

	priv->proxy_uri = soup_socket_get_http_proxy_uri (sock);

	if (priv->ssl && !priv->proxy_uri) {
		soup_socket_handshake_async (sock, priv->remote_uri->host,
					     g_task_get_cancellable (task),
					     socket_handshake_complete, task);
		return;
	}

	socket_connect_finished (task, sock, NULL);
}
Beispiel #5
0
static gboolean
cd_sensor_get_sample_wait_cb (GTask *task)
{
	CdSensor *sensor = CD_SENSOR (g_task_get_source_object (task));
	CdSensorDummyPrivate *priv = cd_sensor_dummy_get_private (sensor);
	CdColorXYZ *sample = NULL;
	g_autoptr(GError) error = NULL;

	/* never setup */
	if (priv->transform_fake == NULL) {
		g_task_return_new_error (task,
					 CD_SENSOR_ERROR,
					 CD_SENSOR_ERROR_NO_SUPPORT,
					 "no fake transfor set up");
		return G_SOURCE_REMOVE;
	}

	/* run the sample through the profile */
	sample = cd_color_xyz_new ();
	cmsDoTransform (priv->transform_fake, &priv->sample_fake, sample, 1);

	/* emulate */
	cd_sensor_button_pressed (sensor);

	/* just return without a problem */
	g_task_return_pointer (task, sample, (GDestroyNotify) cd_color_xyz_free);
	return G_SOURCE_REMOVE;
}
static void
on_reformatter_exited (GTask  *task,
                       GError *error)
{
  GisPage *page = GIS_PAGE (g_task_get_source_object (task));

  gis_driver_show_window (page->driver);

  if (error == NULL)
    {
      g_task_return_boolean (task, TRUE);
      return;
    }

  GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (page)));
  GtkWidget *message_dialog;

  g_critical ("Error running the reformatter: %s", error->message);

  message_dialog = gtk_message_dialog_new (toplevel,
                                           GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                           GTK_MESSAGE_ERROR,
                                           GTK_BUTTONS_CLOSE,
                                           /* Translators: this is shown when launching the
                                            * reformatter (an external program) fails. The
                                            * placeholder is an error message describing what went
                                            * wrong.
                                            */
                                           _("Error running the reformatter: %s"), error->message);
  g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, run_dialog_cb,
                   message_dialog, (GDestroyNotify) gtk_widget_destroy);

  g_task_return_error (task, g_steal_pointer (&error));
}
static void
handshake_thread_completed (GObject      *object,
			    GAsyncResult *result,
			    gpointer      user_data)
{
  GTask *caller_task = user_data;
  GTlsConnectionBase *tls = g_task_get_source_object (caller_task);
  GError *error = NULL;
  gboolean need_finish_handshake, success;

  g_mutex_lock (&tls->op_mutex);
  if (tls->need_finish_handshake)
    {
      need_finish_handshake = TRUE;
      tls->need_finish_handshake = FALSE;
    }
  else
    need_finish_handshake = FALSE;
  g_mutex_unlock (&tls->op_mutex);

  if (need_finish_handshake)
    {
      success = finish_handshake (tls, G_TASK (result), &error);
      if (success)
	g_task_return_boolean (caller_task, TRUE);
      else
	g_task_return_error (caller_task, error);
    }
  else if (tls->handshake_error)
    g_task_return_error (caller_task, g_error_copy (tls->handshake_error));
  else
    g_task_return_boolean (caller_task, TRUE);

  g_object_unref (caller_task);
}
static void
ide_thread_pool_worker (gpointer data,
                        gpointer user_data)
{
  WorkItem *work_item = data;
  gpointer source_object;
  gpointer task_data;
  GCancellable *cancellable;

  g_assert (work_item != NULL);

  EGG_COUNTER_DEC (QueuedTasks);

  if (work_item->type == TYPE_TASK)
    {
      source_object = g_task_get_source_object (work_item->task.task);
      task_data = g_task_get_task_data (work_item->task.task);
      cancellable = g_task_get_cancellable (work_item->task.task);

      work_item->task.func (work_item->task.task, source_object, task_data, cancellable);

      g_object_unref (work_item->task.task);
    }
  else if (work_item->type == TYPE_FUNC)
    {
      work_item->func.callback (work_item->func.data);
    }

  g_slice_free (WorkItem, work_item);
}
static void
photos_base_item_create_thumbnail_in_thread_func (gpointer data, gpointer user_data)
{
  GTask *task = G_TASK (data);
  PhotosBaseItem *self;
  GCancellable *cancellable;
  GError *error;
  gboolean op_res;

  self = PHOTOS_BASE_ITEM (g_task_get_source_object (task));
  cancellable = g_task_get_cancellable (task);

  error = NULL;
  op_res = PHOTOS_BASE_ITEM_GET_CLASS (self)->create_thumbnail (self, cancellable, &error);
  if (error != NULL)
    {
      g_task_return_error (task, error);
      goto out;
    }

  g_task_return_boolean (task, op_res);

 out:
  g_object_unref (task);
}
Beispiel #10
0
static void
on_get_user_id_ready (GObject      *source_object,
                      GAsyncResult *res,
                      gpointer      user_data)
{
        GTask *task = G_TASK (user_data);
        gpointer *info = g_task_get_source_object (task);
        GClueClientInfoPrivate *priv = GCLUE_CLIENT_INFO (info)->priv;
        GError *error = NULL;
        GVariant *results = NULL;

        results = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object),
                                            res,
                                            &error);
        if (results == NULL) {
                g_task_return_error (task, error);
                g_object_unref (task);

                return;
        }

        g_assert (g_variant_n_children (results) > 0);
        g_variant_get_child (results, 0, "u", &priv->user_id);
        g_variant_unref (results);

        g_dbus_proxy_call (priv->dbus_proxy,
                           "GetConnectionUnixProcessID",
                           g_variant_new ("(s)", priv->bus_name),
                           G_DBUS_CALL_FLAGS_NONE,
                           -1,
                           g_task_get_cancellable (task),
                           on_get_pid_ready,
                           task);
}
Beispiel #11
0
static void
ide_run_manager_run_cb (GObject      *object,
                        GAsyncResult *result,
                        gpointer      user_data)
{
  IdeRunner *runner = (IdeRunner *)object;
  g_autoptr(GTask) task = user_data;
  IdeRunManager *self;
  GError *error = NULL;

  IDE_ENTRY;

  g_assert (IDE_IS_RUNNER (runner));
  g_assert (G_IS_TASK (task));

  self = g_task_get_source_object (task);

  if (!ide_runner_run_finish (runner, result, &error))
    {
      g_task_return_error (task, error);
      IDE_GOTO (failure);
    }

  g_task_return_boolean (task, TRUE);

failure:

  g_signal_emit (self, signals [STOPPED], 0);

  IDE_EXIT;
}
Beispiel #12
0
static void
ide_async_helper_cb (GObject      *object,
                     GAsyncResult *result,
                     gpointer      user_data)
{
  g_autoptr(GTask) task = user_data;
  GPtrArray *funcs;
  GError *error = NULL;

  g_return_if_fail (G_IS_TASK (task));
  g_return_if_fail (G_IS_TASK (result));

  funcs = g_task_get_task_data (task);

  if (!g_task_propagate_boolean (G_TASK (result), &error))
    {
      g_task_return_error (task, error);
      return;
    }

  g_ptr_array_remove_index (funcs, 0);

  if (funcs->len)
    {
      IdeAsyncStep step;

      step = g_ptr_array_index (funcs, 0);
      step (g_task_get_source_object (task),
            g_task_get_cancellable (task),
            ide_async_helper_cb,
            g_object_ref (task));
    }
  else
    g_task_return_boolean (task, TRUE);
}
Beispiel #13
0
static void
aws_s3_client_read_got_chunk (SoupMessage *message,
                              SoupBuffer  *buffer,
                              GTask       *task)
{
  AwsS3Client *client;
  ReadState *state;

  g_assert (SOUP_IS_MESSAGE (message));
  g_assert (buffer != NULL);
  g_assert (G_IS_TASK (task));

  client = g_task_get_source_object (task);
  g_assert (AWS_IS_S3_CLIENT (client));

  state = g_task_get_task_data (task);
  g_assert (state != NULL);
  g_assert (state->handler != NULL);

  if (!state->handler (client, message, buffer, state->handler_data))
    {
      g_task_return_new_error (task,
                               G_IO_ERROR,
                               G_IO_ERROR_CANCELLED,
                               "The request was cancelled");
      soup_session_cancel_message (SOUP_SESSION (client), message, SOUP_STATUS_CANCELLED);
   }
}
Beispiel #14
0
static void
on_dbus_proxy_ready (GObject      *source_object,
                     GAsyncResult *res,
                     gpointer      user_data)
{
        GTask *task = G_TASK (user_data);
        gpointer *info = g_task_get_source_object (task);
        GClueClientInfoPrivate *priv = GCLUE_CLIENT_INFO (info)->priv;
        GError *error = NULL;

        priv->dbus_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
        if (priv->dbus_proxy == NULL) {
                g_task_return_error (task, error);
                g_object_unref (task);
                return;
        }

        g_dbus_proxy_call (priv->dbus_proxy,
                           "GetConnectionUnixUser",
                           g_variant_new ("(s)", priv->bus_name),
                           G_DBUS_CALL_FLAGS_NONE,
                           -1,
                           g_task_get_cancellable (task),
                           on_get_user_id_ready,
                           task);
}
void WebSoupRequestManager::didHandleURIRequest(const IPC::DataReference& requestData, uint64_t contentLength, const String& mimeType, uint64_t requestID)
{
    WebSoupRequestAsyncData* data = m_requestMap.get(requestID);
    ASSERT(data);
    GRefPtr<GTask> task = data->releaseTask();
    ASSERT(task.get());

    WebKitSoupRequestGeneric* request = WEBKIT_SOUP_REQUEST_GENERIC(g_task_get_source_object(task.get()));
    webkitSoupRequestGenericSetContentLength(request, contentLength ? contentLength : -1);
    webkitSoupRequestGenericSetContentType(request, !mimeType.isEmpty() ? mimeType.utf8().data() : 0);

    GInputStream* dataStream;
    if (!requestData.size()) {
        // Empty reply, just create and empty GMemoryInputStream.
        dataStream = g_memory_input_stream_new();
        m_requestMap.remove(requestID);
    } else if (requestData.size() == contentLength) {
        // We don't expect more data, so we can just create a GMemoryInputStream with all the data.
        dataStream = g_memory_input_stream_new_from_data(g_memdup(requestData.data(), requestData.size()), contentLength, g_free);
        m_requestMap.remove(requestID);
    } else {
        // We expect more data chunks from the UI process.
        dataStream = webkitSoupRequestInputStreamNew(contentLength);
        data->stream = dataStream;
        webkitSoupRequestInputStreamAddData(WEBKIT_SOUP_REQUEST_INPUT_STREAM(dataStream), requestData.data(), requestData.size());
    }
    g_task_return_pointer(task.get(), dataStream, g_object_unref);
}
Beispiel #16
0
static void
dms_uim_set_pin_protection_ready (QmiClientDms *client,
                                  GAsyncResult *res,
                                  GTask        *task)
{
    QmiMessageDmsUimSetPinProtectionOutput *output = NULL;
    GError *error = NULL;
    MMSimQmi *self;

    self = g_task_get_source_object (task);

    output = qmi_client_dms_uim_set_pin_protection_finish (client, res, &error);
    if (!output) {
        g_prefix_error (&error, "QMI operation failed: ");
        g_task_return_error (task, error);
    } else if (!qmi_message_dms_uim_set_pin_protection_output_get_result (output, &error)) {
        g_prefix_error (&error, "Couldn't enable PIN: ");
        g_task_return_error (task, pin_qmi_error_to_mobile_equipment_error (error));
    } else
        g_task_return_boolean (task, TRUE);

    if (output)
        qmi_message_dms_uim_set_pin_protection_output_unref (output);
    g_object_unref (task);
}
void CustomProtocolManagerImpl::start(GTask* task)
{
    uint64_t customProtocolID = generateCustomProtocolID();
    WebKitSoupRequestGeneric* request = WEBKIT_SOUP_REQUEST_GENERIC(g_task_get_source_object(task));
    m_customProtocolMap.set(customProtocolID, std::make_unique<WebSoupRequestAsyncData>(task, request));

    m_childProcess->send(Messages::CustomProtocolManagerProxy::StartLoading(customProtocolID, *webkitSoupRequestGenericGetRequest(request)), 0);
}
void CustomProtocolManagerImpl::didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse& response)
{
    WebSoupRequestAsyncData* data = m_customProtocolMap.get(customProtocolID);
    ASSERT(data);
    ASSERT(data->task);

    WebKitSoupRequestGeneric* request = WEBKIT_SOUP_REQUEST_GENERIC(g_task_get_source_object(data->task));
    webkitSoupRequestGenericSetContentLength(request, response.expectedContentLength() ? response.expectedContentLength() : -1);
    webkitSoupRequestGenericSetContentType(request, !response.mimeType().isEmpty() ? response.mimeType().utf8().data() : 0);
}
static gint
photos_base_item_create_thumbnail_sort_func (gconstpointer a, gconstpointer b, gpointer user_data)
{
  GTask *task_a = G_TASK (a);
  GTask *task_b = G_TASK (b);
  PhotosBaseItem *item_a;
  PhotosBaseItem *item_b;
  gint ret_val = 0;

  item_a = PHOTOS_BASE_ITEM (g_task_get_source_object (task_a));
  item_b = PHOTOS_BASE_ITEM (g_task_get_source_object (task_b));

  if (PHOTOS_IS_LOCAL_ITEM (item_a))
    ret_val = -1;
  else if (PHOTOS_IS_LOCAL_ITEM (item_b))
    ret_val = 1;

  return ret_val;
}
void WebSoupRequestManager::send(GTask* task)
{
    WebKitSoupRequestGeneric* request = WEBKIT_SOUP_REQUEST_GENERIC(g_task_get_source_object(task));
    SoupRequest* soupRequest = SOUP_REQUEST(request);
    GUniquePtr<char> uriString(soup_uri_to_string(soup_request_get_uri(soupRequest), FALSE));

    uint64_t requestID = generateSoupRequestID();
    m_requestMap.set(requestID, adoptPtr(new WebSoupRequestAsyncData(task, request)));

    uint64_t initiatingPageID = WebCore::ResourceHandle::getSoupRequestInitiatingPageID(soupRequest);
    m_process->parentProcessConnection()->send(Messages::WebPageProxy::DidReceiveURIRequest(String::fromUTF8(uriString.get()), requestID), initiatingPageID);
}
Beispiel #21
0
static void
start_ssl_completed (GObject *object, GAsyncResult *result, gpointer user_data)
{
	GTask *task = user_data;
	SoupConnection *conn = g_task_get_source_object (task);
	SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (conn);
	GError *error = NULL;

	if (soup_socket_handshake_finish (priv->socket, result, &error)) {
		soup_connection_event (conn, G_SOCKET_CLIENT_COMPLETE, NULL);
		g_task_return_boolean (task, TRUE);
	} else
		g_task_return_error (task, error);
	g_object_unref (task);
}
Beispiel #22
0
static void
got_addresses (SoupAddress *addr, guint status, gpointer user_data)
{
	GTask *task = user_data;
	GError *error;

	error = g_object_get_data (G_OBJECT (addr), "async-resolved-error");
	if (error)
		g_task_return_error (task, g_error_copy (error));
	else {
		GSocketAddress *addr;

		addr = next_address (g_task_get_source_object (task));
		g_task_return_pointer (task, addr, g_object_unref);
	}
	g_object_unref (task);
}
static void
photos_camera_cache_cursor_next (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
  GTask *task = G_TASK (user_data);
  PhotosCameraCache *self;
  PhotosCameraCachePrivate *priv;
  TrackerSparqlCursor *cursor = TRACKER_SPARQL_CURSOR (source_object);
  GError *error;
  const gchar *manufacturer;
  const gchar *model;
  gchar *camera;
  gpointer key;

  self = PHOTOS_CAMERA_CACHE (g_task_get_source_object (task));
  priv = self->priv;

  error = NULL;
  tracker_sparql_cursor_next_finish (cursor, res, &error);
  if (error != NULL)
    {
      g_task_return_error (task, error);
      goto out;
    }

  manufacturer = tracker_sparql_cursor_get_string (cursor, 0, NULL);
  model = tracker_sparql_cursor_get_string (cursor, 1, NULL);

  if (manufacturer == NULL && model == NULL)
    camera = NULL;
  else if (manufacturer == NULL || g_str_has_prefix (model, manufacturer))
    camera = g_strdup (model);
  else if (model == NULL)
    camera = g_strdup (manufacturer);
  else
    camera = g_strconcat (manufacturer, " ", model, NULL);

  key = g_task_get_task_data (task);
  g_hash_table_insert (priv->cache, key, camera);

  g_task_return_pointer (task, g_strdup (camera), g_free);

 out:
  tracker_sparql_cursor_close (cursor);
  g_object_unref (task);
}
static void
photos_fetch_ids_job_cursor_next (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
  PhotosFetchIdsJob *self;
  GCancellable *cancellable;
  g_autoptr (GTask) task = G_TASK (user_data);
  TrackerSparqlCursor *cursor = TRACKER_SPARQL_CURSOR (source_object);
  GError *error;
  gboolean success;

  self = PHOTOS_FETCH_IDS_JOB (g_task_get_source_object (task));
  cancellable = g_task_get_cancellable (task);

  error = NULL;
  /* Note that tracker_sparql_cursor_next_finish can return FALSE even
   * without an error.
   */
  success = tracker_sparql_cursor_next_finish (cursor, res, &error);
  if (error != NULL)
    {
      g_task_return_error (task, error);
      goto end;
    }

  if (success)
    {
      const gchar *id;

      id = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_URN, NULL);
      g_ptr_array_add (self->ids, g_strdup (id));

      tracker_sparql_cursor_next_async (cursor,
                                        cancellable,
                                        photos_fetch_ids_job_cursor_next,
                                        g_object_ref (task));
      return;
    }

  g_ptr_array_add (self->ids, NULL);
  g_task_return_pointer (task, self->ids->pdata, NULL);

 end:
  return;
}
Beispiel #25
0
static void
ide_run_manager_install_cb (GObject      *object,
                            GAsyncResult *result,
                            gpointer      user_data)
{
  IdeBuildManager *build_manager = (IdeBuildManager *)object;
  g_autoptr(GTask) task = user_data;
  IdeRunManager *self;
  IdeBuildTarget *build_target;
  GCancellable *cancellable;
  GError *error = NULL;

  IDE_ENTRY;

  g_assert (IDE_IS_BUILD_MANAGER (build_manager));
  g_assert (G_IS_TASK (task));

  if (!ide_build_manager_build_finish (build_manager, result, &error))
    {
      g_task_return_error (task, error);
      IDE_EXIT;
    }

  self = g_task_get_source_object (task);
  g_assert (IDE_IS_RUN_MANAGER (self));

  build_target = ide_run_manager_get_build_target (self);
  if (build_target == NULL)
    {
      cancellable = g_task_get_cancellable (task);
      g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));

      ide_run_manager_discover_default_target_async (self,
                                                     cancellable,
                                                     ide_run_manager_run_discover_cb,
                                                     g_steal_pointer (&task));
      IDE_EXIT;
    }

  g_task_set_task_data (task, g_object_ref (build_target), g_object_unref);

  do_run_async (self, g_steal_pointer (&task));
}
static void
dspy_introspection_model_introspect (GTask           *task,
                                     GDBusConnection *connection,
                                     const gchar     *path)
{
  DspyIntrospectionModel *self;
  Introspect *state;
  gint *n_active;

  g_assert (G_IS_TASK (task));
  g_assert (G_IS_DBUS_CONNECTION (connection));
  g_assert (path != NULL);

  self = g_task_get_source_object (task);
  n_active = g_task_get_task_data (task);

  g_assert (G_IS_TASK (task));
  g_assert (n_active != NULL);

  /* If we already have this path, then ignore the suplimental query */
  if (has_node_with_path (self, path))
    return;

  (*n_active)++;

  state = g_slice_new0 (Introspect);
  state->task = g_object_ref (task);
  state->connection = g_object_ref (connection);
  state->path = g_strdup (path);

  g_dbus_connection_call (connection,
                          dspy_name_get_owner (self->name),
                          path,
                          "org.freedesktop.DBus.Introspectable",
                          "Introspect",
                          NULL, /* Params */
                          G_VARIANT_TYPE ("(s)"),
                          G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION,
                          -1,
                          self->cancellable,
                          dspy_introspection_model_init_introspect_cb,
                          state);
}
static void
ide_recent_projects__miner_mine_cb (GObject      *object,
                                    GAsyncResult *result,
                                    gpointer      user_data)
{
  IdeRecentProjects *self;
  g_autoptr(GTask) task = user_data;
  IdeProjectMiner *miner = (IdeProjectMiner *)object;

  g_assert (G_IS_TASK (task));
  g_assert (IDE_IS_PROJECT_MINER (miner));
  self = g_task_get_source_object (task);
  g_assert (IDE_IS_RECENT_PROJECTS (self));

  ide_project_miner_mine_finish (miner, result, NULL);

  if (--self->active == 0)
    g_task_return_boolean (task, TRUE);
}
Beispiel #28
0
static void
aws_s3_client_read_got_headers (SoupMessage *message,
                                GTask       *task)
{
  AwsS3Client *client;

  g_assert (SOUP_IS_MESSAGE(message));
  g_assert (G_IS_TASK (task));

  client = g_task_get_source_object (task);
  g_assert (AWS_IS_S3_CLIENT (client));

  if (!SOUP_STATUS_IS_SUCCESSFUL (message->status_code))
    {
      /*
       * Extract the given error type.
       */
      if (message->status_code == SOUP_STATUS_NOT_FOUND)
        {
          g_task_return_new_error (task,
                                   AWS_S3_CLIENT_ERROR,
                                   AWS_S3_CLIENT_ERROR_NOT_FOUND,
                                   "The requested object was not found.");
         soup_session_cancel_message (SOUP_SESSION (client), message, message->status_code);
        }
      else if (SOUP_STATUS_IS_CLIENT_ERROR (message->status_code))
        {
          g_task_return_new_error (task,
                                   AWS_S3_CLIENT_ERROR,
                                   AWS_S3_CLIENT_ERROR_BAD_REQUEST,
                                   "The request was invalid.");
          soup_session_cancel_message (SOUP_SESSION (client), message, message->status_code);
        }
      else
        {
          g_task_return_new_error (task,
                                   AWS_S3_CLIENT_ERROR,
                                   AWS_S3_CLIENT_ERROR_UNKNOWN,
                                   "An unknown error occurred.");
          soup_session_cancel_message (SOUP_SESSION (client), message, SOUP_STATUS_CANCELLED);
        }
    }
}
void CustomProtocolManagerImpl::didLoadData(uint64_t customProtocolID, const IPC::DataReference& dataReference)
{
    WebSoupRequestAsyncData* data = m_customProtocolMap.get(customProtocolID);
    // The data might have been removed from the request map if a previous chunk failed
    // and a new message was sent by the UI process before being notified about the failure.
    if (!data)
        return;

    if (!data->stream) {
        GRefPtr<GTask> task = data->releaseTask();
        ASSERT(task.get());

        goffset soupContentLength = soup_request_get_content_length(SOUP_REQUEST(g_task_get_source_object(task.get())));
        uint64_t contentLength = soupContentLength == -1 ? 0 : static_cast<uint64_t>(soupContentLength);
        if (!dataReference.size()) {
            // Empty reply, just create and empty GMemoryInputStream.
            data->stream = g_memory_input_stream_new();
        } else if (dataReference.size() == contentLength) {
            // We don't expect more data, so we can just create a GMemoryInputStream with all the data.
            data->stream = g_memory_input_stream_new_from_data(g_memdup(dataReference.data(), dataReference.size()), contentLength, g_free);
        } else {
            // We expect more data chunks from the UI process.
            data->stream = webkitSoupRequestInputStreamNew(contentLength);
            webkitSoupRequestInputStreamAddData(WEBKIT_SOUP_REQUEST_INPUT_STREAM(data->stream.get()), dataReference.data(), dataReference.size());
        }
        g_task_return_pointer(task.get(), data->stream.get(), g_object_unref);
        return;
    }

    if (data->requestFailed()) {
        // ResourceRequest failed or it was cancelled. It doesn't matter here the error or if it was cancelled,
        // because that's already handled by the resource handle client, we just want to notify the UI process
        // to stop reading data from the user input stream. If UI process already sent all the data we simply
        // finish silently.
        if (!webkitSoupRequestInputStreamFinished(WEBKIT_SOUP_REQUEST_INPUT_STREAM(data->stream.get())))
            m_childProcess->send(Messages::CustomProtocolManagerProxy::StopLoading(customProtocolID), 0);

        return;
    }

    webkitSoupRequestInputStreamAddData(WEBKIT_SOUP_REQUEST_INPUT_STREAM(data->stream.get()), dataReference.data(), dataReference.size());
}
static void
photos_fetch_metas_job_create_collection_icon_executed (GIcon *icon, gpointer user_data)
{
  GTask *task = G_TASK (user_data);
  PhotosFetchMetasJob *self;
  PhotosFetchMeta *meta;

  self = PHOTOS_FETCH_METAS_JOB (g_task_get_source_object (task));
  meta = (PhotosFetchMeta *) g_task_get_task_data (task);

  if (icon != NULL)
    {
      g_clear_object (&meta->icon);
      meta->icon = g_object_ref (icon);
    }

  self->metas = g_list_prepend (self->metas, meta);
  photos_fetch_metas_job_collector (self);
  g_object_unref (task);
}