/*
 * Copyright (C) 2008 Red Hat, Inc.
 *
 * 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 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., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Author: David Zeuthen <davidz@redhat.com>
 */

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif

#include <polkit/polkit.h>
#include <polkitbackend/polkitbackend.h>

int
main (int argc, char **argv)
{
  int ret;
  GError *error;
  GMainLoop *loop;
  PolkitBackendAuthority *authority;

  ret = 1;
  error = NULL;
  authority = NULL;

  g_type_init ();

  loop = g_main_loop_new (NULL, FALSE);

  authority = polkit_backend_authority_get ();

  g_print ("Using authority class %s\n", g_type_name (G_TYPE_FROM_INSTANCE (authority)));

  if (!polkit_backend_register_authority (authority,
                                          "org.freedesktop.PolicyKit1",
                                          "/org/freedesktop/PolicyKit1/Authority",
                                          &error))
    {
      g_printerr ("Error registering authority: %s", error->message);
      g_error_free (error);
      goto out;
    }

  g_main_loop_run (loop);

  ret = 0;

 out:
  if (authority != NULL)
    g_object_unref (authority);
  return ret;
}
