summaryrefslogtreecommitdiff
path: root/panels/user-accounts/gsd-identity-inquiry.c
blob: fa1646c06a619da64de2fd51e39f5887e3a400ab (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* -*- Mode: C; tab-width: 8; ident-tabs-mode: nil; c-basic-offset: 8 -*-
 *
 * Copyright (C) 2012 Red Hat, Inc.
 *
 * 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, 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * Author: Ray Strode
 */

#include "config.h"

#include "gsd-identity-inquiry.h"
#include "gsd-identity-inquiry-private.h"

#include <string.h>
#include <glib/gi18n.h>
#include <gio/gio.h>

enum {
        COMPLETE,
        NUMBER_OF_SIGNALS,
};

static guint signals[NUMBER_OF_SIGNALS] = { 0 };

G_DEFINE_INTERFACE (GsdIdentityInquiry,
                    gsd_identity_inquiry,
                    G_TYPE_OBJECT);

static void
gsd_identity_inquiry_default_init (GsdIdentityInquiryInterface *interface)
{
        signals[COMPLETE] = g_signal_new ("complete",
                                          G_TYPE_FROM_INTERFACE (interface),
                                          G_SIGNAL_RUN_LAST,
                                          0,
                                          NULL, NULL, NULL,
                                          G_TYPE_NONE, 0);
}

void
_gsd_identity_inquiry_emit_complete (GsdIdentityInquiry *self)
{
        g_signal_emit (G_OBJECT (self), signals[COMPLETE], 0);
}

char *
gsd_identity_inquiry_get_name (GsdIdentityInquiry *self)
{
        g_return_val_if_fail (GSD_IS_IDENTITY_INQUIRY (self), NULL);

        return GSD_IDENTITY_INQUIRY_GET_IFACE (self)->get_name (self);
}

char *
gsd_identity_inquiry_get_banner (GsdIdentityInquiry *self)
{
        g_return_val_if_fail (GSD_IS_IDENTITY_INQUIRY (self), NULL);

        return GSD_IDENTITY_INQUIRY_GET_IFACE (self)->get_banner (self);
}

gboolean
gsd_identity_inquiry_is_complete (GsdIdentityInquiry *self)
{
        g_return_val_if_fail (GSD_IS_IDENTITY_INQUIRY (self), TRUE);

        return GSD_IDENTITY_INQUIRY_GET_IFACE (self)->is_complete (self);
}

void
gsd_identity_inquiry_iter_init (GsdIdentityInquiryIter *iter,
                                GsdIdentityInquiry     *inquiry)
{
        g_return_if_fail (GSD_IS_IDENTITY_INQUIRY (inquiry));

        GSD_IDENTITY_INQUIRY_GET_IFACE (inquiry)->iter_init (iter, inquiry);
}

GsdIdentityQuery *
gsd_identity_inquiry_iter_next (GsdIdentityInquiryIter *iter,
                                GsdIdentityInquiry     *inquiry)
{
        g_return_val_if_fail (GSD_IS_IDENTITY_INQUIRY (inquiry), NULL);

        return GSD_IDENTITY_INQUIRY_GET_IFACE (inquiry)->iter_next (iter, inquiry);
}

GsdIdentity *
gsd_identity_inquiry_get_identity (GsdIdentityInquiry *self)
{
        g_return_val_if_fail (GSD_IS_IDENTITY_INQUIRY (self), NULL);

        return GSD_IDENTITY_INQUIRY_GET_IFACE (self)->get_identity (self);
}

GsdIdentityQueryMode
gsd_identity_query_get_mode (GsdIdentityInquiry *self,
                             GsdIdentityQuery   *query)
{
        g_return_val_if_fail (GSD_IS_IDENTITY_INQUIRY (self),
                              GSD_IDENTITY_QUERY_MODE_INVISIBLE);

        return GSD_IDENTITY_INQUIRY_GET_IFACE (self)->get_mode (self, query);
}

char *
gsd_identity_query_get_prompt (GsdIdentityInquiry *self,
                               GsdIdentityQuery   *query)
{
        g_return_val_if_fail (GSD_IS_IDENTITY_INQUIRY (self), NULL);

        return GSD_IDENTITY_INQUIRY_GET_IFACE (self)->get_prompt (self, query);
}

void
gsd_identity_inquiry_answer_query (GsdIdentityInquiry *self,
                                   GsdIdentityQuery   *query,
                                   const char         *answer)
{
        g_return_if_fail (GSD_IS_IDENTITY_INQUIRY (self));

        GSD_IDENTITY_INQUIRY_GET_IFACE (self)->answer_query (self, query, answer);
}

gboolean
gsd_identity_query_is_answered (GsdIdentityInquiry *self,
                                GsdIdentityQuery   *query)
{
        g_return_val_if_fail (GSD_IS_IDENTITY_INQUIRY (self), FALSE);

        return GSD_IDENTITY_INQUIRY_GET_IFACE (self)->is_answered (self, query);
}