/* gcc index-file-for-process-async.c $(pkg-config --cflags --libs
   tracker-control-1.0 gio-2.0 glib-2.0) */

#include <gio/gio.h>
#include <glib.h>
#include <libtracker-control/tracker-control.h>

static void
index_file_for_process_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
  TrackerMinerManager *manager = TRACKER_MINER_MANAGER (source_object);
  GError *error;
  GMainLoop *loop = (GMainLoop *) user_data;

  error = NULL;
  if (!tracker_miner_manager_index_file_for_process_finish (manager, res, &error))
    {
      g_warning ("%s", error->message);
      g_error_free (error);
    }

  g_main_loop_quit (loop);
}

int
main (void)
{
  GError *error;
  GFile *file;
  GMainLoop *loop;
  TrackerMinerManager *manager;

  loop = g_main_loop_new (NULL, FALSE);

  file = g_file_new_for_uri ("file:///home/rishi/devel");
  manager = tracker_miner_manager_new ();

  tracker_miner_manager_index_file_for_process_async (manager,
                                                      file,
                                                      NULL,
                                                      index_file_for_process_cb,
                                                      loop);
  g_main_loop_run (loop);

  g_main_loop_unref (loop);
  g_object_unref (manager);
  g_object_unref (file);

  return 0;
}
