summaryrefslogtreecommitdiff
path: root/src/settings/nm-secret-agent.h
blob: f123d0ac19d1f649b71ab53ff646d3eea95d810e (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
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* NetworkManager -- Network link manager
 *
 * 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.
 *
 * 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.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Copyright (C) 2010 - 2011 Red Hat, Inc.
 */

#ifndef NM_SECRET_AGENT_H
#define NM_SECRET_AGENT_H

#include <glib.h>
#include <glib-object.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>

#include <nm-connection.h>
#include "nm-types.h"
#include "nm-settings-flags.h"

/* NOTE: ensure these capabilities match those in introspection/nm-secret-agent.xml and
 * libnm-glib/nm-secret-agent.h.
 */
typedef enum {
	NM_SECRET_AGENT_CAPABILITY_NONE = 0x0,
	NM_SECRET_AGENT_CAPABILITY_VPN_HINTS = 0x1,
} NMSecretAgentCapabilities;

#define NM_TYPE_SECRET_AGENT            (nm_secret_agent_get_type ())
#define NM_SECRET_AGENT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SECRET_AGENT, NMSecretAgent))
#define NM_SECRET_AGENT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SECRET_AGENT, NMSecretAgentClass))
#define NM_IS_SECRET_AGENT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SECRET_AGENT))
#define NM_IS_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SECRET_AGENT))
#define NM_SECRET_AGENT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SECRET_AGENT, NMSecretAgentClass))

struct _NMSecretAgent {
	GObject parent;
};

typedef struct {
	GObjectClass parent;
} NMSecretAgentClass;

GType nm_secret_agent_get_type (void);

NMSecretAgent *nm_secret_agent_new (DBusGMethodInvocation *context,
                                    NMAuthSubject *subject,
                                    const char *identifier,
                                    NMSecretAgentCapabilities capabilities);

const char *nm_secret_agent_get_description (NMSecretAgent *agent);

const char *nm_secret_agent_get_dbus_owner (NMSecretAgent *agent);

const char *nm_secret_agent_get_identifier (NMSecretAgent *agent);

gulong      nm_secret_agent_get_owner_uid  (NMSecretAgent *agent);

const char *nm_secret_agent_get_owner_username (NMSecretAgent *agent);

gulong      nm_secret_agent_get_pid        (NMSecretAgent *agent);

NMSecretAgentCapabilities nm_secret_agent_get_capabilities (NMSecretAgent *agent);

guint32     nm_secret_agent_get_hash       (NMSecretAgent *agent);

NMAuthSubject *nm_secret_agent_get_subject (NMSecretAgent *agent);

void        nm_secret_agent_add_permission (NMSecretAgent *agent,
                                            const char *permission,
                                            gboolean allowed);

gboolean    nm_secret_agent_has_permission (NMSecretAgent *agent,
                                            const char *permission);

typedef void (*NMSecretAgentCallback) (NMSecretAgent *agent,
                                       gconstpointer call,
                                       GHashTable *new_secrets, /* NULL for save & delete */
                                       GError *error,
                                       gpointer user_data);

gconstpointer nm_secret_agent_get_secrets  (NMSecretAgent *agent,
                                            NMConnection *connection,
                                            const char *setting_name,
                                            const char **hints,
                                            NMSettingsGetSecretsFlags flags,
                                            NMSecretAgentCallback callback,
                                            gpointer callback_data);

void        nm_secret_agent_cancel_secrets (NMSecretAgent *agent,
                                            gconstpointer call_id);

gconstpointer nm_secret_agent_save_secrets (NMSecretAgent *agent,
                                            NMConnection *connection,
                                            NMSecretAgentCallback callback,
                                            gpointer callback_data);

gconstpointer nm_secret_agent_delete_secrets (NMSecretAgent *agent,
                                              NMConnection *connection,
                                              NMSecretAgentCallback callback,
                                              gpointer callback_data);

#endif /* NM_SECRET_AGENT_H */