static void
resolve_album_art_cb (GObject       *source_object,
                      GAsyncResult  *result,
                      gpointer       user_data)
{
  GFile *cache_file;
  ResolveData *resolve_data;
  GFileInfo *info = NULL;
  GError *error = NULL;

  cache_file = G_FILE (source_object);
  resolve_data = user_data;

  info = g_file_query_info_finish (cache_file, result, &error);

  if (info != NULL) {
    /* Success, the album art exists. */
    gchar *cache_uri = g_file_get_uri (cache_file);
    grl_media_set_thumbnail (resolve_data->rs->media, cache_uri);
    g_free (cache_uri);
  } else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
    /* Ignore G_IO_ERROR_NOT_FOUND. */
    g_clear_error (&error);
  }

  resolve_data_finish_operation (resolve_data, "album-art", error);

  g_clear_object (&info);
  g_clear_error (&error);
}
static void
exists_query_info_ready_cb (GObject *source,
			    GAsyncResult *res,
			    gpointer user_data)
{
	GFileInfo *info;
	NautilusBookmark *bookmark;
	GError *error = NULL;
	gboolean exists = FALSE;

	info = g_file_query_info_finish (G_FILE (source), res, &error);
	if (!info && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
		g_clear_error (&error);
		return;
	}

	g_clear_error (&error);
	bookmark = user_data;

	if (info) {
		exists = TRUE;

		g_object_unref (info);
		g_clear_object (&bookmark->details->cancellable);
	}

	nautilus_bookmark_set_exists (bookmark, exists);
}
static void
ft_handler_gfile_ready_cb (GObject *source,
    GAsyncResult *res,
    CallbacksData *cb_data)
{
  GFileInfo *info;
  GError *error = NULL;
  GTimeVal mtime;
  EmpathyFTHandlerPriv *priv = GET_PRIV (cb_data->handler);

  DEBUG ("Got GFileInfo.");

  info = g_file_query_info_finish (priv->gfile, res, &error);

  if (error != NULL)
    goto out;

  if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
    {
      error = g_error_new_literal (EMPATHY_FT_ERROR_QUARK,
          EMPATHY_FT_ERROR_INVALID_SOURCE_FILE,
          _("The selected file is not a regular file"));
      goto out;
    }

  priv->total_bytes = g_file_info_get_size (info);
  if (priv->total_bytes == 0)
    {
      error = g_error_new_literal (EMPATHY_FT_ERROR_QUARK,
          EMPATHY_FT_ERROR_EMPTY_SOURCE_FILE,
          _("The selected file is empty"));
      goto out;
    }

  priv->content_type = g_strdup (g_file_info_get_content_type (info));
  priv->filename = g_strdup (g_file_info_get_display_name (info));
  g_file_info_get_modification_time (info, &mtime);
  priv->mtime = mtime.tv_sec;
  priv->transferred_bytes = 0;
  priv->description = NULL;

  g_object_unref (info);

out:
  if (error != NULL)
    {
      if (!g_cancellable_is_cancelled (priv->cancellable))
        g_cancellable_cancel (priv->cancellable);

      cb_data->callback (cb_data->handler, error, cb_data->user_data);
      g_error_free (error);

      callbacks_data_free (cb_data);
    }
  else
    {
      /* see if FT/hashing are allowed */
      check_hashing (cb_data);
    }
}
Example #4
0
static void
set_metadata_get_info_callback (GObject      *source_object,
                                GAsyncResult *res,
                                gpointer      callback_data)
{
    NautilusFile *file;
    GFileInfo *new_info;
    GError *error;

    file = callback_data;

    error = NULL;
    new_info = g_file_query_info_finish (G_FILE (source_object), res, &error);
    if (new_info != NULL)
    {
        if (nautilus_file_update_info (file, new_info))
        {
            nautilus_file_changed (file);
        }
        g_object_unref (new_info);
    }
    nautilus_file_unref (file);
    if (error)
    {
        g_error_free (error);
    }
}
static void
query_info_ready_cb (GObject *obj,
                     GAsyncResult *res,
                     gpointer user_data)
{
  NemoPreviewPdfLoader *self = user_data;
  GError *error = NULL;
  GFileInfo *info;
  const gchar *content_type;

  info = g_file_query_info_finish (G_FILE (obj),
                                   res, &error);

  if (error != NULL) {
    g_warning ("Unable to query the mimetype of %s: %s",
               self->priv->uri, error->message);
    g_error_free (error);

    return;
  }

  content_type = g_file_info_get_content_type (info);

  if (content_type_is_native (content_type))
    load_pdf (self, self->priv->uri);
  else
    load_libreoffice (self);

  g_object_unref (info);
}
static void
file_info_ready (GObject      *object,
                 GAsyncResult *res,
                 gpointer      user_data)
{
  GFileInfo *info;
  GError *error = NULL;
  GFile *file = G_FILE (object);

  info = g_file_query_info_finish (file, res, &error);

  if (!info)
    {
      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
        g_warning ("Problem looking up file info: %s", error->message);
      g_clear_error (&error);
      return;
    }

  /* Up the ref count so we can re-use the add_single_item code path which
   * reduces the ref count.
   */
  g_object_ref (file);
  add_single_file_from_info (BG_PICTURES_SOURCE (user_data), file, info, NULL);
}
Example #7
0
static void
photos_base_item_file_query_info (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
  PhotosBaseItem *self = PHOTOS_BASE_ITEM (user_data);
  PhotosBaseItemPrivate *priv = self->priv;
  GError *error = NULL;
  GFile *file = G_FILE (source_object);
  GFileInfo *info;

  info = g_file_query_info_finish (file, res, &error);
  if (error != NULL)
    {
      g_warning ("Unable to query info for file at %s: %s", priv->uri, error->message);
      priv->failed_thumbnailing = TRUE;
      photos_base_item_set_failed_icon (self);
      g_error_free (error);
      goto out;
    }

  priv->thumb_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
  if (priv->thumb_path != NULL)
    photos_base_item_refresh_thumb_path (self);
  else
    {
      photos_base_item_create_thumbnail_async (self,
                                               NULL,
                                               photos_base_item_create_thumbnail_cb,
                                               g_object_ref (file));
    }

 out:
  g_object_unref (self);
}
static void
cache_file_query_info_cb (GObject *source,
                          GAsyncResult *res,
                          gpointer user_data)
{
  GFileInfo *cache_info = NULL;
  NemoPreviewCoverArtFetcher *self = user_data;
  GError *error = NULL;
  GFile *file;

  cache_info = g_file_query_info_finish (G_FILE (source),
                                         res, &error);

  if (error != NULL) {
    self->priv->tried_cache = TRUE;
    file = get_gfile_for_amazon (self);
    g_error_free (error);
  } else {
    file = g_object_ref (source);
  }

  try_read_from_file (self, file);

  g_clear_object (&cache_info);
  g_object_unref (file);
}
static void
query_info_ready_cb (GObject *obj,
                     GAsyncResult *res,
                     gpointer user_data)
{
  PdfLoadJob *job = user_data;
  GError *error = NULL;
  GFileInfo *info;
  const gchar *content_type;

  info = g_file_query_info_finish (G_FILE (obj),
                                   res, &error);

  if (error != NULL) {
    pdf_load_job_complete_error (job, error);
    return;
  }

  content_type = g_file_info_get_content_type (info);

  if (content_type_is_native (content_type))
    pdf_load_job_from_pdf (job);
  else
    pdf_load_job_from_openoffice (job);

  g_object_unref (info);
}
static void
on_recent_file_query_result (GObject       *source,
                             GAsyncResult  *result,
                             gpointer       user_data)
{
  ShellDocSystemRecentQueryData *data = user_data;
  ShellDocSystem *self = data->self;
  GError *error = NULL;
  GFileInfo *fileinfo;

  fileinfo = g_file_query_info_finish (G_FILE (source), result, &error);
  if (fileinfo)
    g_object_unref (fileinfo);
  /* This is a strict error check; we don't want to cause recent files to
   * vanish for anything potentially transient.
   */
  if (error != NULL && error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_FOUND)
    {
      self->priv->infos_by_timestamp = g_slist_remove (self->priv->infos_by_timestamp, data->info);
      g_hash_table_remove (self->priv->infos_by_uri, gtk_recent_info_get_uri (data->info));

      g_hash_table_insert (self->priv->deleted_infos, gtk_recent_info_ref (data->info), NULL);

      if (self->priv->idle_emit_deleted_id == 0)
        self->priv->idle_emit_deleted_id = g_timeout_add (0, shell_doc_system_idle_emit_deleted, self);
    }
  g_clear_error (&error);

  gtk_recent_info_unref (data->info);
  g_free (data);
}
static void
openoffice_cache_query_info_ready_cb (GObject *source,
                                      GAsyncResult *res,
                                      gpointer user_data)
{
  PdfLoadJob *job = user_data;
  GError *error = NULL;
  GFileInfo *info;

  info = g_file_query_info_finish (G_FILE (source), res, &error);

  if (error != NULL) {
    /* create/invalidate cache */
    pdf_load_job_openoffice_refresh_cache (job);

    g_error_free (error);
    return;
  }

  job->pdf_cache_mtime = 
    g_file_info_get_attribute_uint64 (info, 
                                      G_FILE_ATTRIBUTE_TIME_MODIFIED);

  if (job->original_file_mtime != job->pdf_cache_mtime) {
    pdf_load_job_openoffice_refresh_cache (job);
  } else {
    job->from_old_cache = TRUE;

    /* load the cached file */
    pdf_load_job_from_pdf (job);
  }

  g_object_unref (info);
}
static void
place_query_info_ready (GObject *source,
                        GAsyncResult *res,
                        gpointer user_data)
{
  GtkWidget *row, *box, *w;
  Place *place;
  GFileInfo *info;
  const gchar *desktop_path;
  gchar *path;

  info = g_file_query_info_finish (G_FILE (source), res, NULL);
  if (!info)
    return;

  row = user_data;
  place = g_object_get_data (G_OBJECT (row), "place");
  g_clear_object (&place->cancellable);

  box = gtk_bin_get_child (GTK_BIN (row));

  /* FIXME: GLib is currently buggy and returns a non-existent icon name
   * when asked for the desktop symbolic icon.
   */
  desktop_path = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
  path = g_file_get_path (G_FILE (source));

  if (g_strcmp0 (path, desktop_path) == 0)
    place->icon = g_themed_icon_new ("folder-symbolic");
  else
    place->icon = g_object_ref (g_file_info_get_symbolic_icon (info));

  if (g_strcmp0 (path, g_get_home_dir ()) == 0)
    place->settings_key = TRACKER_KEY_SINGLE_DIRECTORIES;
  else
    place->settings_key = TRACKER_KEY_RECURSIVE_DIRECTORIES;

  g_free (path);

  w = gtk_image_new_from_gicon (place->icon, GTK_ICON_SIZE_MENU);
  gtk_container_add (GTK_CONTAINER (box), w);

  w = gtk_label_new (place->display_name);
  gtk_container_add (GTK_CONTAINER (box), w);

  w = gtk_switch_new ();
  gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);
  g_settings_bind_with_mapping (tracker_preferences, place->settings_key,
                                w, "active",
                                G_SETTINGS_BIND_DEFAULT,
                                switch_tracker_get_mapping,
                                switch_tracker_set_mapping,
                                place, NULL);

  gtk_widget_show_all (row);
  g_object_unref (info);
}
Example #13
0
static void
saved_query_info_cb (GFile         *location,
		     GAsyncResult  *result,
		     GeditDocument *doc)
{
	GFileInfo *info;
	const gchar *content_type = NULL;
	GError *error = NULL;

	info = g_file_query_info_finish (location, result, &error);

	if (error != NULL)
	{
		g_warning ("Document saving: query info error: %s", error->message);
		g_error_free (error);
		error = NULL;
	}

	doc->priv->mtime_set = FALSE;

	if (info != NULL)
	{
		if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE))
		{
			content_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
		}

		if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
		{
			g_file_info_get_modification_time (info, &doc->priv->mtime);
			doc->priv->mtime_set = TRUE;
		}
	}

	gedit_document_set_content_type (doc, content_type);

	if (info != NULL)
	{
		/* content_type (owned by info) is no longer needed. */
		g_object_unref (info);
	}

	g_get_current_time (&doc->priv->time_of_last_save_or_load);

	doc->priv->externally_modified = FALSE;
	doc->priv->deleted = FALSE;
	doc->priv->create = FALSE;

	set_readonly (doc, FALSE);

	gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (doc), FALSE);

	save_encoding_metadata (doc);

	/* Async operation finished. */
	g_object_unref (doc);
}
Example #14
0
static void
loaded_query_info_cb (GFile         *location,
		      GAsyncResult  *result,
		      GeditDocument *doc)
{
	GFileInfo *info;
	GError *error = NULL;

	info = g_file_query_info_finish (location, result, &error);

	if (error != NULL)
	{
		/* Ignore not found error as it can happen when opening a
		 * non-existent file from the command line.
		 */
		if (error->domain != G_IO_ERROR ||
		    error->code != G_IO_ERROR_NOT_FOUND)
		{
			g_warning ("Document loading: query info error: %s", error->message);
		}

		g_error_free (error);
		error = NULL;
	}

	if (info != NULL)
	{
		if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE))
		{
			const gchar *content_type;

			content_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);

			gedit_document_set_content_type (doc, content_type);
		}

		if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
		{
			gboolean read_only;

			read_only = !g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);

			set_readonly (doc, read_only);
		}

		if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
		{
			g_file_info_get_modification_time (info, &doc->priv->mtime);
			doc->priv->mtime_set = TRUE;
		}

		g_object_unref (info);
	}

	/* Async operation finished. */
	g_object_unref (doc);
}
static void
got_file_size_cb (GObject *source_object,
                   GAsyncResult *res,
                   gpointer userdata)
{
  SwClientServiceCallClosure *closure = (SwClientServiceCallClosure *) userdata;
  SwClientServicePrivate *priv = GET_PRIVATE (closure->service);
  GFileInfo *info;
  char *filename;
  const char *signal;

  info = g_file_query_info_finish (G_FILE (source_object), res, NULL);
  if (info == NULL ||
      g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_STANDARD_TYPE) != G_FILE_TYPE_REGULAR) {
    g_simple_async_report_error_in_idle (G_OBJECT (closure->service),
                                         (GAsyncReadyCallback) closure->cb,
                                         closure->userdata,
                                         SW_CLIENT_SERVICE_ERROR,
                                         0,
                                         info ? "File to upload is not a regular file" :
                                         "Could not get file size information for file");
    if (info)
      g_object_unref (info);
    g_object_unref (closure->service);
    g_hash_table_unref (closure->fields);
    g_slice_free (SwClientServiceCallClosure, closure);
    return;
  }

  closure->filesize = g_file_info_get_attribute_uint64 (info,
                                                        G_FILE_ATTRIBUTE_STANDARD_SIZE);
  g_object_unref (info);

  signal = (closure->iface == PHOTO_UPLOAD_IFACE ? "PhotoUploadProgress" : "VideoUploadProgress");
  dbus_g_proxy_connect_signal (priv->proxies[closure->iface], signal,
                               G_CALLBACK (_upload_file_progress_cb), closure, NULL);

  filename = g_file_get_path (G_FILE (source_object));
  if (closure->iface == PHOTO_UPLOAD_IFACE) {
    org_gnome_libsocialweb_PhotoUpload_upload_photo_async (priv->proxies[PHOTO_UPLOAD_IFACE],
                                                           filename,
                                                           closure->fields,
                                                           _upload_file_cb,
                                                           closure);
  } else {
    org_gnome_libsocialweb_VideoUpload_upload_video_async (priv->proxies[VIDEO_UPLOAD_IFACE],
                                                           filename,
                                                           closure->fields,
                                                           _upload_file_cb,
                                                           closure);
  }
  g_hash_table_unref (closure->fields);
  closure->fields = NULL;

  g_free (filename);
}
static void
process_file_cb (GObject      *object,
                 GAsyncResult *result,
                 gpointer      user_data)
{
	ProcessApplicationData *data;
	GFileInfo *file_info;
	GError *error = NULL;
	GFile *file;

	data = user_data;
	file = G_FILE (object);
	file_info = g_file_query_info_finish (file, result, &error);

	if (error) {
		tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), file, error);
		process_application_data_free (data);
		g_error_free (error);
		return;
	}

	if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY) {
		process_directory (data, file_info, &error);
	} else {
		data->key_file = get_desktop_key_file (file, &data->type, &error);
		if (!data->key_file) {
			gchar *uri;

			uri = g_file_get_uri (file);
			g_warning ("Couldn't properly parse desktop file '%s': '%s'",
			           uri,
			           error ? error->message : "unknown error");
			g_free (uri);
			g_clear_error (&error);

			error = g_error_new_literal (miner_applications_error_quark, 0, "File is not a key file");
		} else if (g_key_file_get_boolean (data->key_file, GROUP_DESKTOP_ENTRY, "Hidden", NULL)) {
			error = g_error_new_literal (miner_applications_error_quark, 0, "Desktop file is 'hidden', not gathering metadata for it");
		} else {
			process_desktop_file (data, file_info, &error);
		}
	}

	tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, error);
	process_application_data_free (data);

	if (error) {
		g_error_free (error);
	}

	if (file_info) {
		g_object_unref (file_info);
	}
}
Example #17
0
static void on_size_query_ready (GObject * object, GAsyncResult * result, gpointer data)
{
	GError *error = NULL;
	GFileInfo *info = g_file_query_info_finish (G_FILE(object), result, &error);
	GDownloadable *download = G_DOWNLOADABLE(data);
	g_assert (download != NULL);
	
	if (error) {
		handle_error (error);
		g_downloadable_set_status (download, G_DOWNLOADABLE_NETWORK_ERROR);
		
	} else {
		download->priv->size = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE);
		g_object_unref (info);
	}
}
Example #18
0
void TrashLauncherIcon::UpdateTrashIconCb(GObject* source, GAsyncResult* res, gpointer data)
{
  auto self = static_cast<TrashLauncherIcon*>(data);

  // FIXME: should use the generic LoadIcon function (not taking from the unity theme)
  glib::Object<GFileInfo> info(g_file_query_info_finish(G_FILE(source), res, nullptr));

  if (info)
  {
    glib::Object<GIcon> icon(g_file_info_get_icon(info), glib::AddRef());
    glib::String icon_string(g_icon_to_string(icon));

    self->icon_name = icon_string.Str();
    self->empty_ = (self->icon_name == "user-trash");
  }
}
Example #19
0
static void
find_file_insensitive_exists_callback (GObject *source_object,
                                       GAsyncResult *res,
                                       gpointer user_data)
{
  GFileInfo *info;
  InsensitiveFileSearchData *data = (InsensitiveFileSearchData *) (user_data);

  /* The file exists and can be found with the given path, no need to search. */
  if ((info = g_file_query_info_finish (G_FILE (source_object), res, NULL)))
    {
      GSimpleAsyncResult *simple;

      simple = g_simple_async_result_new (G_OBJECT (data->root),
                                          data->callback,
                                          data->user_data,
                                          _g_find_file_insensitive_async);

      g_simple_async_result_set_op_res_gpointer (simple, g_object_ref (source_object), g_object_unref);
      g_simple_async_result_complete_in_idle (simple);
      g_object_unref (simple);
      clear_find_file_insensitive_state (data);
      g_object_unref (info);
    }

  else
    {
      data->split_path = g_strsplit (data->original_path, G_DIR_SEPARATOR_S, -1);
      data->index = 0;
      data->enumerator = NULL;
      data->current_file = g_object_ref (data->root);

      /* Skip any empty components due to multiple slashes */
      while (data->split_path[data->index] != NULL &&
             *data->split_path[data->index] == 0)
        data->index++;

      g_file_enumerate_children_async (data->current_file,
                                       G_FILE_ATTRIBUTE_STANDARD_NAME,
                                       0, G_PRIORITY_DEFAULT,
                                       data->cancellable,
                                       enumerated_children_callback, data);
    }

  g_object_unref (source_object);
}
static void
gb_rename_file_popover__file_query_info (GObject      *object,
                                         GAsyncResult *result,
                                         gpointer      user_data)
{
  GFile *file = (GFile *)object;
  g_autoptr(GFileInfo) file_info = NULL;
  g_autoptr(GbRenameFilePopover) self = user_data;
  g_autoptr(GError) error = NULL;
  GFileType file_type;

  file_info = g_file_query_info_finish (file, result, &error);

  if (file_info == NULL &&
      g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
    return;

  if ((file_info == NULL) &&
      g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
    {
      gtk_label_set_label (self->message, NULL);
      gtk_widget_set_sensitive (GTK_WIDGET (self->button), TRUE);
      return;
    }

  if (file_info == NULL)
    {
      gtk_label_set_label (self->message, error->message);
      return;
    }

  file_type = g_file_info_get_file_type (file_info);

  if (file_type == G_FILE_TYPE_DIRECTORY)
    gtk_label_set_label (self->message,
                         _("A folder with that name already exists."));
  else
    gtk_label_set_label (self->message,
                         _("A file with that name already exists."));

  gtk_widget_set_sensitive (GTK_WIDGET (self->button), FALSE);
}
Example #21
0
static void
loaded_query_info_cb (GFile         *location,
		      GAsyncResult  *result,
		      GeditDocument *doc)
{
	GFileInfo *info;
	GError *error = NULL;

	info = g_file_query_info_finish (location, result, &error);

	if (error != NULL)
	{
		/* Ignore not found error as it can happen when opening a
		 * non-existent file from the command line.
		 */
		if (error->domain != G_IO_ERROR ||
		    error->code != G_IO_ERROR_NOT_FOUND)
		{
			g_warning ("Document loading: query info error: %s", error->message);
		}

		g_error_free (error);
		error = NULL;
	}

	if (info != NULL &&
	    g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE))
	{
		const gchar *content_type;

		content_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);

		set_content_type (doc, content_type);
	}

	g_clear_object (&info);

	/* Async operation finished. */
	g_object_unref (doc);
}
static void
process_file_cb (GObject      *object,
                 GAsyncResult *result,
                 gpointer      user_data)
{
	ProcessUserguideData *data;
	GFileInfo *file_info;
	GError *error = NULL;
	GFile *file;
	gboolean is_dir;

	data = user_data;
	file = G_FILE (object);
	file_info = g_file_query_info_finish (file, result, &error);

	if (error) {
		tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), file, error);
		process_userguide_data_free (data);
		g_error_free (error);
		return;
	}

	is_dir = g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY;
	process_item (data, file_info, is_dir, &error);

	tracker_miner_fs_file_notify (TRACKER_MINER_FS (data->miner), data->file, error);
	process_userguide_data_free (data);

	if (error) {
		g_error_free (error);
	}

	if (file_info) {
		g_object_unref (file_info);
	}
}
static void
remote_query_info_ready_cb (GObject *obj,
                            GAsyncResult *res,
                            gpointer user_data)
{
  PdfLoadJob *job = user_data;
  GError *error = NULL;
  GFile *pdf_file;
  GFileInfo *info;
  const gchar *content_type;
  gchar *tmp_name;
  gchar *tmp_path;

  info = g_file_query_info_finish (G_FILE (obj),
                                   res, &error);

  if (error != NULL) {
    pdf_load_job_complete_error (job, error);
    return;
  }

  job->original_file_mtime =
    g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);

  tmp_name = g_strdup_printf ("gnome-documents-%u.pdf", g_str_hash (job->uri));
  tmp_path = g_build_filename (g_get_user_cache_dir (), "gnome-documents", NULL);
  job->pdf_path =
    g_build_filename (tmp_path, tmp_name, NULL);
  g_mkdir_with_parents (tmp_path, 0700);

  content_type = g_file_info_get_content_type (info);

  if (!content_type_is_native (content_type)) {
    GFileIOStream *iostream;

    job->download_file = g_file_new_tmp (NULL, &iostream, &error);
    if (error != NULL) {
      pdf_load_job_complete_error (job, error);
      return;
    }

    /* We don't need the iostream. */
    g_io_stream_close (G_IO_STREAM (iostream), NULL, NULL);
  } else {
    job->download_file = g_file_new_for_path (job->pdf_path);
  }

  pdf_file = g_file_new_for_path (job->pdf_path);

  g_file_query_info_async (pdf_file,
                           G_FILE_ATTRIBUTE_TIME_MODIFIED,
                           G_FILE_QUERY_INFO_NONE,
                           G_PRIORITY_DEFAULT,
                           job->cancellable,
                           remote_cache_query_info_ready_cb,
                           job);

  g_free (tmp_name);
  g_free (tmp_path);
  g_object_unref (pdf_file);
  g_object_unref (info);
}
static void
openoffice_cache_query_info_original_ready_cb (GObject *source,
                                               GAsyncResult *res,
                                               gpointer user_data)
{
  PdfLoadJob *job = user_data;
  GError *error = NULL;
  GFileInfo *info;
  guint64 mtime;
  gchar *pdf_path, *tmp_name, *tmp_path;
  GFile *cache_file;

  info = g_file_query_info_finish (G_FILE (source), res, &error);

  if (error != NULL) {
    /* try to create the cache anyway - if the source file
     * is really not readable we'll fail again soon.
     */
    pdf_load_job_openoffice_refresh_cache (job);

    g_error_free (error);
    return;
  }

  /* If we are converting a downloaded file then we already know its
   * mtime. Moreover, we we don't want to find the mtime of the
   * temporary file.
   */
  if (job->original_file_mtime == 0)
    job->original_file_mtime = mtime =
      g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);

  g_object_unref (info);

  tmp_path = g_build_filename (g_get_user_cache_dir (), "gnome-documents", NULL);
  g_mkdir_with_parents (tmp_path, 0700);

  /* If we are converting a downloaded file then we already know its
   * location in the cache. Moreover, we we don't want to hash the
   * temporary file.
   */
  if (job->pdf_path == NULL)
    {
      tmp_name = g_strdup_printf ("gnome-documents-%u.pdf", g_str_hash (job->uri));
      job->pdf_path = pdf_path =
        g_build_filename (tmp_path, tmp_name, NULL);
      g_free (tmp_name);
    }

  g_free (tmp_path);

  cache_file = g_file_new_for_path (pdf_path);
  g_file_query_info_async (cache_file,
                           G_FILE_ATTRIBUTE_TIME_MODIFIED,
                           G_FILE_QUERY_INFO_NONE,
                           G_PRIORITY_DEFAULT,
                           job->cancellable,
                           openoffice_cache_query_info_ready_cb,
                           job);

  g_object_unref (cache_file);
}
static void queryInfoCallback(GObject* source, GAsyncResult* res, gpointer data)
{
    ResourceHandle* handle = static_cast<ResourceHandle*>(data);
    ResourceHandleInternal* d = handle->getInternal();
    ResourceHandleClient* client = handle->client();

    if (d->m_cancelled) {
        cleanupGioOperation(handle);
        return;
    }

    ResourceResponse response;

    char* uri = g_file_get_uri(d->m_gfile);
    response.setUrl(KURL(uri));
    g_free(uri);

    GError *error = NULL;
    GFileInfo* info = g_file_query_info_finish(d->m_gfile, res, &error);

    if (error) {
        // FIXME: to be able to handle ftp URIs properly, we must
        // check if the error is G_IO_ERROR_NOT_MOUNTED, and if so,
        // call g_file_mount_enclosing_volume() to mount the ftp
        // server (and then keep track of the fact that we mounted it,
        // and set a timeout to unmount it later after it's been idle
        // for a while).

        cleanupGioOperation(handle);

        if (error->domain == G_IO_ERROR &&
                error->code == G_IO_ERROR_NOT_FOUND)
            response.setHTTPStatusCode(SOUP_STATUS_NOT_FOUND);
        else if (error->domain == G_IO_ERROR &&
                 error->code == G_IO_ERROR_PERMISSION_DENIED)
            response.setHTTPStatusCode(SOUP_STATUS_FORBIDDEN);
        else
            response.setHTTPStatusCode(SOUP_STATUS_BAD_REQUEST); // ?
        g_error_free(error);

        // FIXME: do we need to fake up a response body containing the
        // error message?

        client->didReceiveResponse(handle, response);
        client->didFinishLoading(handle);
        return;
    }

    if (g_file_info_get_file_type(info) != G_FILE_TYPE_REGULAR) {
        // FIXME: what if the URI points to a directory? Should we
        // generate a listing? How? What do other backends do here?

        cleanupGioOperation(handle);
        response.setHTTPStatusCode(SOUP_STATUS_FORBIDDEN); // ?
        client->didReceiveResponse(handle, response);
        client->didFinishLoading(handle);
        return;
    }

    response.setMimeType(g_file_info_get_content_type(info));
    response.setExpectedContentLength(g_file_info_get_size(info));
    response.setHTTPStatusCode(SOUP_STATUS_OK);

    GTimeVal tv;
    g_file_info_get_modification_time(info, &tv);
    response.setLastModifiedDate(tv.tv_sec);

    client->didReceiveResponse(handle, response);

    g_file_read_async(d->m_gfile, G_PRIORITY_DEFAULT, d->m_cancellable,
                      openCallback, handle);
}
static void
got_file_info (GFile *file,
               GAsyncResult *result,
               gpointer user_data)
{
  GCancellable *cancellable;
  GFileInfo *info;
  GError *error = NULL;
  const gchar *thumbnail_path;
  gboolean thumbnail_is_valid;
  GrlLocalMetadataSourcePriv *priv;
  ResolveData *resolve_data = user_data;
  GrlSourceResolveSpec *rs = resolve_data->rs;
  resolution_flags_t flags;

  GRL_DEBUG ("got_file_info");

  priv = GRL_LOCAL_METADATA_SOURCE_GET_PRIVATE (resolve_data->source);

  cancellable = resolve_data_ensure_cancellable (resolve_data);

  info = g_file_query_info_finish (file, result, &error);
  if (error)
    goto error;

  thumbnail_path =
      g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
#if GLIB_CHECK_VERSION (2, 39, 0)
  thumbnail_is_valid =
      g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID);
#else
  thumbnail_is_valid = TRUE;
#endif


  if (thumbnail_path && thumbnail_is_valid) {
    gchar *thumbnail_uri = g_filename_to_uri (thumbnail_path, NULL, &error);
    if (error)
      goto error;

    GRL_INFO ("Got thumbnail %s for media: %s", thumbnail_uri,
              grl_media_get_url (rs->media));
    grl_media_set_thumbnail (rs->media, thumbnail_uri);
    g_free (thumbnail_uri);
  } else if (thumbnail_path && !thumbnail_is_valid) {
    GRL_INFO ("Found outdated thumbnail %s for media: %s", thumbnail_path,
              grl_media_get_url (rs->media));
  } else {
    GRL_INFO ("Could not find thumbnail for media: %s",
              grl_media_get_url (rs->media));
  }

  flags = get_resolution_flags (rs->keys, priv);

  if (GRL_IS_MEDIA_AUDIO (rs->media) &&
      !(thumbnail_path && thumbnail_is_valid)) {
    /* We couldn't get a per-track thumbnail; try for a per-album one,
     * using libmediaart */
    resolve_album_art (resolve_data, flags);
  }

  if (flags & FLAG_GIBEST_HASH) {
    extract_gibest_hash_async (resolve_data, file, cancellable);
  } else {
    resolve_data_finish_operation (resolve_data, "image", NULL);
  }

  goto exit;

error:
    {
      GError *new_error = g_error_new (GRL_CORE_ERROR,
                                       GRL_CORE_ERROR_RESOLVE_FAILED,
                                       _("Failed to resolve: %s"),
                                       error->message);
      resolve_data_finish_operation (resolve_data, "image", new_error);

      g_error_free (error);
      g_error_free (new_error);
    }

exit:
    g_clear_object (&info);
}
static gboolean rotation_plugin_store_state_co (RotationPluginStoreStateData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	g_object_get ((PeasActivatable*) _data_->self, "object", &_data_->_tmp0_, NULL);
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->t = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp1_, totem_object_get_type (), TotemObject);
	_data_->_tmp2_ = NULL;
	_data_->_tmp2_ = _data_->t;
	_data_->_tmp3_ = NULL;
	_data_->_tmp3_ = totem_object_get_current_mrl (_data_->_tmp2_);
	_data_->mrl = _data_->_tmp3_;
	_data_->_tmp4_ = NULL;
	_data_->_tmp4_ = _data_->mrl;
	if (_data_->_tmp4_ == NULL) {
		_g_free0 (_data_->mrl);
		_g_object_unref0 (_data_->t);
		if (_data_->_state_ == 0) {
			g_simple_async_result_complete_in_idle (_data_->_async_result);
		} else {
			g_simple_async_result_complete (_data_->_async_result);
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp5_ = NULL;
	_data_->_tmp5_ = _data_->mrl;
	_data_->_tmp6_ = NULL;
	_data_->_tmp6_ = g_file_new_for_uri (_data_->_tmp5_);
	_data_->file = _data_->_tmp6_;
	{
		_data_->_tmp7_ = NULL;
		_data_->_tmp7_ = _data_->file;
		_data_->_state_ = 1;
		g_file_query_info_async (_data_->_tmp7_, GIO_ROTATION_FILE_ATTRIBUTE, G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, NULL, rotation_plugin_store_state_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp8_ = NULL;
		_data_->_tmp8_ = g_file_query_info_finish (_data_->_tmp7_, _data_->_res_, &_data_->_inner_error_);
		_data_->file_info = _data_->_tmp8_;
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			if (g_error_matches (_data_->_inner_error_, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) {
				goto __catch0_g_io_error_not_supported;
			}
			goto __catch0_g_error;
		}
		_data_->_tmp9_ = NULL;
		_data_->_tmp9_ = g_strdup ("");
		_data_->state_str = _data_->_tmp9_;
		_data_->_tmp10_ = NULL;
		_data_->_tmp10_ = _data_->self->priv->bvw;
		_data_->_tmp11_ = 0;
		_data_->_tmp11_ = bacon_video_widget_get_rotation (_data_->_tmp10_);
		_data_->rotation = _data_->_tmp11_;
		_data_->_tmp12_ = 0;
		_data_->_tmp12_ = _data_->rotation;
		if (_data_->_tmp12_ != BVW_ROTATION_R_ZERO) {
			_data_->_tmp13_ = 0;
			_data_->_tmp13_ = _data_->rotation;
			_data_->_tmp14_ = NULL;
			_data_->_tmp14_ = g_strdup_printf ("%u", (guint) _data_->_tmp13_);
			_g_free0 (_data_->state_str);
			_data_->state_str = _data_->_tmp14_;
		}
		_data_->_tmp15_ = NULL;
		_data_->_tmp15_ = _data_->file_info;
		_data_->_tmp16_ = NULL;
		_data_->_tmp16_ = _data_->state_str;
		g_file_info_set_attribute_string (_data_->_tmp15_, GIO_ROTATION_FILE_ATTRIBUTE, _data_->_tmp16_);
		_data_->_tmp17_ = NULL;
		_data_->_tmp17_ = _data_->file;
		_data_->_tmp18_ = NULL;
		_data_->_tmp18_ = _data_->file_info;
		_data_->_state_ = 2;
		g_file_set_attributes_async (_data_->_tmp17_, _data_->_tmp18_, G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, NULL, rotation_plugin_store_state_ready, _data_);
		return FALSE;
		_state_2:
		g_file_set_attributes_finish (_data_->_tmp17_, _data_->_res_, NULL, &_data_->_inner_error_);
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			_g_free0 (_data_->state_str);
			_g_object_unref0 (_data_->file_info);
			if (g_error_matches (_data_->_inner_error_, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) {
				goto __catch0_g_io_error_not_supported;
			}
			goto __catch0_g_error;
		}
		_g_free0 (_data_->state_str);
		_g_object_unref0 (_data_->file_info);
	}
	goto __finally0;
	__catch0_g_io_error_not_supported:
	{
		_data_->e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_g_error_free0 (_data_->e);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->_vala1_e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp19_ = NULL;
		_data_->_tmp19_ = _data_->_vala1_e;
		_data_->_tmp20_ = NULL;
		_data_->_tmp20_ = _data_->_tmp19_->message;
		g_warning ("totem-rotation-plugin.vala:156: Could not store file attribute: %s", _data_->_tmp20_);
		_g_error_free0 (_data_->_vala1_e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
		_g_object_unref0 (_data_->file);
		_g_free0 (_data_->mrl);
		_g_object_unref0 (_data_->t);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		return FALSE;
	}
	_g_object_unref0 (_data_->file);
	_g_free0 (_data_->mrl);
	_g_object_unref0 (_data_->t);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}
static gboolean rotation_plugin_try_restore_state_co (RotationPluginTryRestoreStateData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	_data_->_tmp0_ = _data_->mrl;
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = g_file_new_for_uri (_data_->_tmp0_);
	_data_->file = _data_->_tmp1_;
	_data_->_tmp3_ = NULL;
	_data_->_tmp3_ = _data_->file;
	_data_->_tmp4_ = FALSE;
	_data_->_tmp4_ = g_file_has_uri_scheme (_data_->_tmp3_, "http");
	if (_data_->_tmp4_) {
		_data_->_tmp2_ = TRUE;
	} else {
		_data_->_tmp5_ = NULL;
		_data_->_tmp5_ = _data_->file;
		_data_->_tmp6_ = FALSE;
		_data_->_tmp6_ = g_file_has_uri_scheme (_data_->_tmp5_, "dvd");
		_data_->_tmp2_ = _data_->_tmp6_;
	}
	if (_data_->_tmp2_) {
		_g_object_unref0 (_data_->file);
		if (_data_->_state_ == 0) {
			g_simple_async_result_complete_in_idle (_data_->_async_result);
		} else {
			g_simple_async_result_complete (_data_->_async_result);
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	{
		_data_->_tmp7_ = NULL;
		_data_->_tmp7_ = _data_->file;
		_data_->_state_ = 1;
		g_file_query_info_async (_data_->_tmp7_, GIO_ROTATION_FILE_ATTRIBUTE, G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, NULL, rotation_plugin_try_restore_state_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp8_ = NULL;
		_data_->_tmp8_ = g_file_query_info_finish (_data_->_tmp7_, _data_->_res_, &_data_->_inner_error_);
		_data_->file_info = _data_->_tmp8_;
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			if (g_error_matches (_data_->_inner_error_, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) {
				goto __catch1_g_io_error_not_supported;
			}
			goto __catch1_g_error;
		}
		_data_->_tmp9_ = NULL;
		_data_->_tmp9_ = _data_->file_info;
		_data_->_tmp10_ = NULL;
		_data_->_tmp10_ = g_file_info_get_attribute_string (_data_->_tmp9_, GIO_ROTATION_FILE_ATTRIBUTE);
		_data_->_tmp11_ = NULL;
		_data_->_tmp11_ = g_strdup (_data_->_tmp10_);
		_data_->state_str = _data_->_tmp11_;
		_data_->_tmp12_ = NULL;
		_data_->_tmp12_ = _data_->state_str;
		if (_data_->_tmp12_ != NULL) {
			_data_->_tmp13_ = NULL;
			_data_->_tmp13_ = _data_->state_str;
			_data_->_tmp14_ = 0ULL;
			_data_->_tmp14_ = uint64_parse (_data_->_tmp13_);
			_data_->state = (gint) ((BvwRotation) _data_->_tmp14_);
			_data_->_tmp15_ = NULL;
			_data_->_tmp15_ = _data_->self->priv->bvw;
			_data_->_tmp16_ = 0;
			_data_->_tmp16_ = _data_->state;
			bacon_video_widget_set_rotation (_data_->_tmp15_, (BvwRotation) _data_->_tmp16_);
		}
		_g_free0 (_data_->state_str);
		_g_object_unref0 (_data_->file_info);
	}
	goto __finally1;
	__catch1_g_io_error_not_supported:
	{
		_data_->e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_g_error_free0 (_data_->e);
	}
	goto __finally1;
	__catch1_g_error:
	{
		_data_->_vala1_e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp17_ = NULL;
		_data_->_tmp17_ = _data_->_vala1_e;
		_data_->_tmp18_ = NULL;
		_data_->_tmp18_ = _data_->_tmp17_->message;
		g_warning ("totem-rotation-plugin.vala:175: Could not query file attribute: %s", _data_->_tmp18_);
		_g_error_free0 (_data_->_vala1_e);
	}
	__finally1:
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
		_g_object_unref0 (_data_->file);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		return FALSE;
	}
	_g_object_unref0 (_data_->file);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}