1
/* Mission Control plugin API - interface to an McdAccountManager for plugins
3
* Copyright © 2010 Nokia Corporation
4
* Copyright © 2010 Collabora Ltd.
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#include <mission-control-plugins/mission-control-plugins.h>
22
#include <mission-control-plugins/implementation.h>
25
mcp_account_manager_get_type (void)
27
static gsize once = 0;
28
static GType type = 0;
30
if (g_once_init_enter (&once))
32
static const GTypeInfo info = {
33
sizeof (McpAccountManagerIface),
35
NULL, /* base_finalize */
36
NULL, /* class_init */
37
NULL, /* class_finalize */
38
NULL, /* class_data */
39
0, /* instance_size */
41
NULL, /* instance_init */
42
NULL /* value_table */
45
type = g_type_register_static (G_TYPE_INTERFACE,
46
"McpAccountManager", &info, 0);
47
g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
48
g_once_init_leave (&once, 1);
55
mcp_account_manager_set_value (const McpAccountManager *mcpa,
60
McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa);
62
g_return_if_fail (iface != NULL);
63
g_return_if_fail (iface->set_value != NULL);
65
iface->set_value (mcpa, acct, key, value);
69
* mcp_account_manager_get_value:
70
* @mcpa: an #McpAccountManager instance
71
* @acct: the unique name of an account
72
* @key: the setting whose value we want to retrieve
74
* Fetch a copy of the current value of an account setting held by
75
* the #McdAccountManager.
77
* Returns: a #gchar* which should be freed when the caller is done with it.
80
mcp_account_manager_get_value (const McpAccountManager *mcpa,
84
McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa);
86
g_return_val_if_fail (iface != NULL, NULL);
87
g_return_val_if_fail (iface->set_value != NULL, NULL);
89
return iface->get_value (mcpa, acct, key);
93
* mcp_account_manager_parameter_is_secret:
94
* @mcpa: an #McpAccountManager instance
95
* @acct: the unique name of an account
96
* @key: the setting whose value we want to retrieve
98
* Determine whether a given account parameter is secret.
99
* generally this is determined by MC and passed down to us,
100
* but any #McpAccountStorage plugin may decide a setting is
101
* secret, in which case the return value for this call will
102
* indicate that fact.
104
* Returns: a #gboolean, %TRUE for secret settings, %FALSE otherwise
107
mcp_account_manager_parameter_is_secret (const McpAccountManager *mcpa,
111
McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa);
113
g_return_val_if_fail (iface != NULL, FALSE);
114
g_return_val_if_fail (iface->is_secret != NULL, FALSE);
116
return iface->is_secret (mcpa, acct, key);
120
* mcp_account_manager_parameter_make_secret:
121
* @mcpa: an #McpAccountManager instance
122
* @acct: the unique name of an account
123
* @key: the setting whose value we want to retrieve
125
* Flag an account setting as secret for the lifetime of this
126
* #McpAccountManager and its corresponding #McdAccountManager
129
mcp_account_manager_parameter_make_secret (const McpAccountManager *mcpa,
133
McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa);
135
g_return_if_fail (iface != NULL);
136
g_return_if_fail (iface->make_secret != NULL);
138
g_debug ("%s.%s should be secret", acct, key);
139
return iface->make_secret (mcpa, acct, key);
143
* mcp_account_manager_get_unique_name:
144
* @mcpa: an #McpAccountManager instance
145
* @manager: the name of the manager
146
* @protocol: the name of the protocol
147
* @params: A gchar * / GValue * hash table of account parameters.
149
* Generate and return the canonical unique name of this [new] account.
150
* Should not be called for accounts which have already had a name
151
* assigned: Intended for use when a plugin encounters an account which
152
* MC has not previously seen before (ie one created by a 3rd party
153
* in the back-end that the plugin in question provides an interface to).
155
* Returns: the newly allocated account name, which should be freed
156
* once the caller is done with it.
159
mcp_account_manager_get_unique_name (McpAccountManager *mcpa,
160
const gchar *manager,
161
const gchar *protocol,
162
const GHashTable *params)
164
McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa);
166
g_return_val_if_fail (iface != NULL, NULL);
167
g_return_val_if_fail (iface->unique_name != NULL, NULL);
169
return iface->unique_name (mcpa, manager, protocol, params);