1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.
8 * This library 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 GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301 USA.
18 * Copyright 2010 - 2011 Red Hat, Inc.
21 #ifndef __NM_SECRET_AGENT_OLD_H__
22 #define __NM_SECRET_AGENT_OLD_H__
28 #define NM_TYPE_SECRET_AGENT_OLD (nm_secret_agent_old_get_type ())
29 #define NM_SECRET_AGENT_OLD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SECRET_AGENT_OLD, NMSecretAgentOld))
30 #define NM_SECRET_AGENT_OLD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SECRET_AGENT_OLD, NMSecretAgentOldClass))
31 #define NM_IS_SECRET_AGENT_OLD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SECRET_AGENT_OLD))
32 #define NM_IS_SECRET_AGENT_OLD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SECRET_AGENT_OLD))
33 #define NM_SECRET_AGENT_OLD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SECRET_AGENT_OLD, NMSecretAgentOldClass))
35 #define NM_SECRET_AGENT_OLD_IDENTIFIER "identifier"
36 #define NM_SECRET_AGENT_OLD_AUTO_REGISTER "auto-register"
37 #define NM_SECRET_AGENT_OLD_REGISTERED "registered"
38 #define NM_SECRET_AGENT_OLD_CAPABILITIES "capabilities"
45 * NMSecretAgentOldGetSecretsFunc:
46 * @agent: the secret agent object
47 * @connection: (transfer none): the connection for which secrets were requested,
48 * note that this object will be unrefed after the callback has returned, use
49 * g_object_ref()/g_object_unref() if you want to use this object after the callback
51 * @secrets: the #GVariant of type %NM_VARIANT_TYPE_CONNECTION containing the requested
52 * secrets (as created by nm_connection_to_dbus() for example). Each key in @secrets
53 * should be the name of a #NMSetting object (like "802-11-wireless-security")
54 * and each value should be an %NM_VARIANT_TYPE_SETTING variant. The sub-dicts
55 * map string:value, where the string is the setting property name (like "psk")
56 * and the value is the secret
57 * @error: if the secrets request failed, give a descriptive error here
58 * @user_data: caller-specific data to be passed to the function
60 * Called as a result of a request by NM to retrieve secrets. When the
61 * #NMSecretAgentOld subclass has finished retrieving secrets and is ready to
62 * return them, or to return an error, this function should be called with
63 * those secrets or the error.
65 * To easily create the dictionary to return the Wi-Fi PSK, you could do
66 * something like this:
68 * <title>Creating a secrets dictionary</title>
70 * NMConnection *secrets;
71 * NMSettingWirelessSecurity *s_wsec;
72 * GVariant *secrets_dict;
74 * secrets = nm_simple_connection_new ();
75 * s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
76 * g_object_set (G_OBJECT (s_wsec),
77 * NM_SETTING_WIRELESS_SECURITY_PSK, "my really cool PSK",
79 * nm_connection_add_setting (secrets, NM_SETTING (s_wsec));
80 * secrets_dict = nm_connection_to_dbus (secrets, NM_CONNECTION_SERIALIZE_ALL);
82 * (call the NMSecretAgentOldGetSecretsFunc with secrets_dict)
84 * g_object_unref (secrets);
85 * g_variant_unref (secrets_dict);
89 typedef void (*NMSecretAgentOldGetSecretsFunc) (NMSecretAgentOld *agent,
90 NMConnection *connection,
96 * NMSecretAgentOldSaveSecretsFunc:
97 * @agent: the secret agent object
98 * @connection: (transfer none): the connection for which secrets were to be saved,
99 * note that this object will be unrefed after the callback has returned, use
100 * g_object_ref()/g_object_unref() if you want to use this object after the callback
102 * @error: if the saving secrets failed, give a descriptive error here
103 * @user_data: caller-specific data to be passed to the function
105 * Called as a result of a request by NM to save secrets. When the
106 * #NMSecretAgentOld subclass has finished saving the secrets, this function
109 typedef void (*NMSecretAgentOldSaveSecretsFunc) (NMSecretAgentOld *agent,
110 NMConnection *connection,
115 * NMSecretAgentOldDeleteSecretsFunc:
116 * @agent: the secret agent object
117 * @connection: (transfer none): the connection for which secrets were to be deleted,
118 * note that this object will be unrefed after the callback has returned, use
119 * g_object_ref()/g_object_unref() if you want to use this object after the callback
121 * @error: if the deleting secrets failed, give a descriptive error here
122 * @user_data: caller-specific data to be passed to the function
124 * Called as a result of a request by NM to delete secrets. When the
125 * #NMSecretAgentOld subclass has finished deleting the secrets, this function
128 typedef void (*NMSecretAgentOldDeleteSecretsFunc) (NMSecretAgentOld *agent,
129 NMConnection *connection,
136 /* Virtual methods for subclasses */
138 /* Called when the subclass should retrieve and return secrets. Subclass
139 * must copy or reference any arguments it may require after returning from
140 * this method, as the arguments will freed (except for 'self', 'callback',
141 * and 'user_data' of course). If the request is canceled, the callback
142 * should still be called, but with the
143 * NM_SECRET_AGENT_OLD_ERROR_AGENT_CANCELED error.
145 void (*get_secrets) (NMSecretAgentOld *self,
146 NMConnection *connection,
147 const char *connection_path,
148 const char *setting_name,
150 NMSecretAgentGetSecretsFlags flags,
151 NMSecretAgentOldGetSecretsFunc callback,
154 /* Called when the subclass should cancel an outstanding request to
155 * get secrets for a given connection. Canceling the request MUST
156 * call the callback that was passed along with the initial get_secrets
157 * call, sending the NM_SECRET_AGENT_OLD_ERROR/
158 * NM_SECRET_AGENT_OLD_ERROR_AGENT_CANCELED error to that callback.
160 void (*cancel_get_secrets) (NMSecretAgentOld *self,
161 const char *connection_path,
162 const char *setting_name);
164 /* Called when the subclass should save the secrets contained in the
165 * connection to backing storage. Subclass must copy or reference any
166 * arguments it may require after returning from this method, as the
167 * arguments will freed (except for 'self', 'callback', and 'user_data'
170 void (*save_secrets) (NMSecretAgentOld *self,
171 NMConnection *connection,
172 const char *connection_path,
173 NMSecretAgentOldSaveSecretsFunc callback,
176 /* Called when the subclass should delete the secrets contained in the
177 * connection from backing storage. Subclass must copy or reference any
178 * arguments it may require after returning from this method, as the
179 * arguments will freed (except for 'self', 'callback', and 'user_data'
182 void (*delete_secrets) (NMSecretAgentOld *self,
183 NMConnection *connection,
184 const char *connection_path,
185 NMSecretAgentOldDeleteSecretsFunc callback,
190 } NMSecretAgentOldClass;
192 GType nm_secret_agent_old_get_type (void);
194 gboolean nm_secret_agent_old_register (NMSecretAgentOld *self,
195 GCancellable *cancellable,
197 void nm_secret_agent_old_register_async (NMSecretAgentOld *self,
198 GCancellable *cancellable,
199 GAsyncReadyCallback callback,
201 gboolean nm_secret_agent_old_register_finish (NMSecretAgentOld *self,
202 GAsyncResult *result,
205 gboolean nm_secret_agent_old_unregister (NMSecretAgentOld *self,
206 GCancellable *cancellable,
208 void nm_secret_agent_old_unregister_async (NMSecretAgentOld *self,
209 GCancellable *cancellable,
210 GAsyncReadyCallback callback,
212 gboolean nm_secret_agent_old_unregister_finish (NMSecretAgentOld *self,
213 GAsyncResult *result,
216 gboolean nm_secret_agent_old_get_registered (NMSecretAgentOld *self);
218 void nm_secret_agent_old_get_secrets (NMSecretAgentOld *self,
219 NMConnection *connection,
220 const char *setting_name,
222 NMSecretAgentGetSecretsFlags flags,
223 NMSecretAgentOldGetSecretsFunc callback,
226 void nm_secret_agent_old_save_secrets (NMSecretAgentOld *self,
227 NMConnection *connection,
228 NMSecretAgentOldSaveSecretsFunc callback,
231 void nm_secret_agent_old_delete_secrets (NMSecretAgentOld *self,
232 NMConnection *connection,
233 NMSecretAgentOldDeleteSecretsFunc callback,
238 #endif /* __NM_SECRET_AGENT_OLD_H__ */