/*
 * Copyright (C) 2011, Nokia <ivan.frade@nokia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 *
 * Author: Carlos Garnacho <carlos@lanedo.com>
 */

#ifndef __LIBTRACKER_MINER_SPARQL_BUFFER_H__
#define __LIBTRACKER_MINER_SPARQL_BUFFER_H__

#include <glib-object.h>
#include <gio/gio.h>
#include <tinysparql.h>

G_BEGIN_DECLS

typedef enum {
	TRACKER_SPARQL_BUFFER_CLEANUP_AUDIO,
} TrackerSparqlBufferCleanup;

#define TRACKER_TYPE_SPARQL_BUFFER (tracker_sparql_buffer_get_type())
G_DECLARE_FINAL_TYPE (TrackerSparqlBuffer,
                      tracker_sparql_buffer,
                      TRACKER, SPARQL_BUFFER,
                      GObject)

TrackerSparqlBuffer *tracker_sparql_buffer_new   (TrackerSparqlConnection *connection,
                                                  guint                    limit,
                                                  GFile                   *root);

gboolean             tracker_sparql_buffer_flush (TrackerSparqlBuffer *buffer,
                                                  const gchar         *reason,
                                                  GAsyncReadyCallback  cb,
                                                  gpointer             user_data);

gboolean             tracker_sparql_buffer_flush_finish (TrackerSparqlBuffer  *buffer,
                                                         GAsyncResult         *res,
                                                         GError              **error);

void tracker_sparql_buffer_log_delete (TrackerSparqlBuffer *buffer,
                                       GFile               *file);

void tracker_sparql_buffer_log_delete_content (TrackerSparqlBuffer *buffer,
                                               GFile               *file);

void tracker_sparql_buffer_log_move (TrackerSparqlBuffer *buffer,
                                     GFile               *source,
                                     GFile               *dest,
                                     const gchar         *dest_data_source);

void tracker_sparql_buffer_log_move_content (TrackerSparqlBuffer *buffer,
                                             GFile               *source,
                                             GFile               *dest);

void tracker_sparql_buffer_log_clear_content (TrackerSparqlBuffer *buffer,
                                              GFile               *file);

void tracker_sparql_buffer_log_file (TrackerSparqlBuffer *buffer,
                                     GFile               *file,
                                     const gchar         *content_graph,
                                     TrackerResource     *file_resource,
                                     TrackerResource     *graph_resource);

void tracker_sparql_buffer_log_folder (TrackerSparqlBuffer *buffer,
                                       GFile               *file,
                                       gboolean             is_root,
                                       TrackerResource     *file_resource,
                                       TrackerResource     *folder_resource);

void tracker_sparql_buffer_log_attributes_update (TrackerSparqlBuffer *buffer,
                                                  GFile               *file,
                                                  const gchar         *content_graph,
                                                  TrackerResource     *file_resource,
                                                  TrackerResource     *graph_resource);

void tracker_sparql_buffer_log_cleanup (TrackerSparqlBuffer        *buffer,
                                        TrackerSparqlBufferCleanup  cleanup);

gboolean tracker_sparql_buffer_limit_reached (TrackerSparqlBuffer *buffer);

unsigned int tracker_sparql_buffer_get_size (TrackerSparqlBuffer *buffer);

G_END_DECLS

#endif /* __LIBTRACKER_MINER_SPARQL_BUFFER_H__ */
