aboutsummaryrefslogtreecommitdiff
path: root/src/mm-auth.c
blob: 939c0af53839fbcd8611faeef8f4e0ab6d15fbff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details:
 *
 * Copyright (C) 2010 - 2012 Red Hat, Inc.
 * Copyright (C) 2012 Google, Inc.
 */

#include <string.h>

#include "config.h"

#include "mm-auth.h"
#include "mm-auth-provider.h"

#ifdef WITH_POLKIT
#include "mm-auth-provider-polkit.h"
#endif

static MMAuthProvider *authp = NULL;

MMAuthProvider *
mm_auth_get_provider (void)
{
    if (!authp) {
#if WITH_POLKIT
        authp = mm_auth_provider_polkit_new ();
#else
        authp = mm_auth_provider_new ();
#endif
    }

    g_assert (authp);

    /* We'll keep the refcount of this object controlled, in order to have
     * clean shutdowns */
    return g_object_ref (authp);
}

void
mm_auth_shutdown (void)
{
    /* Clear the last reference of the auth provider if it was ever set */
    g_clear_object (&authp);
}