on 38899dd help sign in
102 lines 4.7 kB history raw
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Alberto Ruiz <alberto.ruiz@canonical.com>
18 * Renato Araujo Oliveira Filho <renato@canonical.com>
19 */
21#ifndef __SECRET_AGENT_H__
22#define __SECRET_AGENT_H__
24#include <glib.h>
25#include <glib-object.h>
26#include <nm-secret-agent.h>
28/*
29 * This class is a basic implementation of the NetworkManager SecretAgent base class.
30 *
31 * The purpose of this class is to handle credential requests from the network,
32 * for example, from a WiFi hotspot or a VPN network.
33 *
34 * It queues requests objects (SecretRequest) on a GQueue in the private struct
35 * of the class. And notifies the consumer of the class through the "secret-request"
36 * and the "request-cancelled" signals with the following callback prototypes:
37 *
38 * void (*secret_requested) (UnitySettingsSecretAgent *self,
39 * guint id,
40 * NMConnection *connection,
41 * const char *setting_name,
42 * const char **hints,
43 * NMSecretAgentGetSecretsFlags flags,
44 * gpointer user_data);
45 *
46 * void (*request_cancelled) (UnitySettingsSecretAgent *self,
47 * guint id,
48 * gpointer user_data);
49 *
50 */
53G_BEGIN_DECLS
56#define UNITY_SETTINGS_TYPE_SECRET_AGENT (unity_settings_secret_agent_get_type ())
57#define UNITY_SETTINGS_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_SETTINGS_TYPE_SECRET_AGENT, UnitySettingsSecretAgent))
58#define UNITY_SETTINGS_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_SETTINGS_TYPE_SECRET_AGENT, UnitySettingsSecretAgentClass))
59#define UNITY_SETTINGS_IS_SECRET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_SETTINGS_TYPE_SECRET_AGENT))
60#define UNITY_SETTINGS_IS_SECRET_AGENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_SETTINGS_TYPE_SECRET_AGENT))
61#define UNITY_SETTINGS_SECRET_AGENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_SETTINGS_TYPE_SECRET_AGENT, UnitySettingsSecretAgentClass))
63#define UNITY_SETTINGS_SECRET_AGENT_SECRET_REQUESTED "secret-requested"
64#define UNITY_SETTINGS_SECRET_AGENT_REQUEST_CANCELLED "request-cancelled"
66typedef struct _UnitySettingsSecretAgent UnitySettingsSecretAgent;
67typedef struct _UnitySettingsSecretAgentClass UnitySettingsSecretAgentClass;
68typedef struct _UnitySettingsSecretAgentPrivate UnitySettingsSecretAgentPrivate;
70struct _UnitySettingsSecretAgent {
71 NMSecretAgent parent_instance;
72 UnitySettingsSecretAgentPrivate * priv;
73};
75struct _UnitySettingsSecretAgentClass {
76 NMSecretAgentClass parent_class;
78 void (*secret_requested) (UnitySettingsSecretAgent *self,
79 guint id,
80 NMConnection *connection,
81 const char *setting_name,
82 const char **hints,
83 NMSecretAgentGetSecretsFlags flags);
85 void (*request_cancelled) (UnitySettingsSecretAgent *self,
86 guint id);
87};
90GType unity_settings_secret_agent_get_type (void) G_GNUC_CONST;
91UnitySettingsSecretAgent* unity_settings_secret_agent_new (void);
92UnitySettingsSecretAgent* unity_settings_secret_agent_construct (GType object_type);
94void unity_settings_secret_agent_provide_secret (UnitySettingsSecretAgent *agent,
95 guint request,
96 GHashTable *secrets);
97void unity_settings_secret_agent_cancel_request (UnitySettingsSecretAgent *agent,
98 guint request);
100G_END_DECLS
102#endif