diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-11-12 15:37:19 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-11-12 15:37:19 +0000 |
commit | ff48fd06ff3984f7324354db78bda7d9818c731d (patch) | |
tree | 6f81bebb7f768ecdc5d1f2404eb6c9bab94d5359 /mission-control-plugins | |
parent | 71490fe5f17e66d8900cb12ce38506745b2bc539 (diff) |
Revert "Remove unused code"
This reverts commit 8171d9e5bc8d4f47a36844afab0a6063b1958004.
Diffstat (limited to 'mission-control-plugins')
-rw-r--r-- | mission-control-plugins/account.c | 109 | ||||
-rw-r--r-- | mission-control-plugins/account.h | 19 | ||||
-rw-r--r-- | mission-control-plugins/implementation.h | 16 |
3 files changed, 144 insertions, 0 deletions
diff --git a/mission-control-plugins/account.c b/mission-control-plugins/account.c index c9859d70..493a34c0 100644 --- a/mission-control-plugins/account.c +++ b/mission-control-plugins/account.c @@ -191,6 +191,31 @@ mcp_account_manager_list_keys (const McpAccountManager *mcpa, } /** + * mcp_account_manager_get_value: + * @mcpa: an #McpAccountManager instance + * @account: the unique name of an account + * @key: the setting whose value we wish to fetch: either an attribute + * like "DisplayName", or "param-" plus a parameter like "account" + * + * Fetch a copy of the current value of an account setting held by + * the account manager. + * + * Returns: (transfer full): the value of @key + */ +gchar * +mcp_account_manager_get_value (const McpAccountManager *mcpa, + const gchar *account, + const gchar *key) +{ + McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa); + + g_return_val_if_fail (iface != NULL, NULL); + g_return_val_if_fail (iface->set_value != NULL, NULL); + + return iface->get_value (mcpa, account, key); +} + +/** * mcp_account_manager_get_unique_name: * @mcpa: an #McpAccountManager instance * @manager: the name of the manager @@ -267,6 +292,34 @@ mcp_account_manager_identify_account_finish (McpAccountManager *mcpa, } /** + * mcp_account_manager_escape_value_from_keyfile: + * @mcpa: a #McpAccountManager + * @value: a value with a supported #GType + * + * Escape @value so it could be passed to g_key_file_set_value(). + * For instance, escaping the boolean value TRUE returns "true", + * and escaping the string value containing one space returns "\s". + * + * It is a programming error to use an unsupported type. + * The supported types are currently %G_TYPE_STRING, %G_TYPE_BOOLEAN, + * %G_TYPE_INT, %G_TYPE_UINT, %G_TYPE_INT64, %G_TYPE_UINT64, %G_TYPE_UCHAR, + * %G_TYPE_STRV, %DBUS_TYPE_G_OBJECT_PATH and %TP_ARRAY_TYPE_OBJECT_PATH_LIST. + * + * Returns: the escaped form of @value + */ +gchar * +mcp_account_manager_escape_value_for_keyfile (const McpAccountManager *mcpa, + const GValue *value) +{ + McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa); + + g_return_val_if_fail (iface != NULL, NULL); + g_return_val_if_fail (iface->escape_value_for_keyfile != NULL, NULL); + + return iface->escape_value_for_keyfile (mcpa, value); +} + +/** * mcp_account_manager_escape_variant_for_keyfile: * @mcpa: a #McpAccountManager * @variant: a #GVariant with a supported #GVariantType @@ -295,3 +348,59 @@ mcp_account_manager_escape_variant_for_keyfile (const McpAccountManager *mcpa, return iface->escape_variant_for_keyfile (mcpa, variant); } + +/** + * mcp_account_manager_unescape_value_from_keyfile: + * @mcpa: a #McpAccountManager + * @escaped: an escaped string as returned by g_key_file_get_value() + * @value: a value to populate, with a supported #GType + * @error: used to raise an error if %FALSE is returned + * + * Attempt to interpret @escaped as a value of @value's type. + * If successful, put it in @value and return %TRUE. + * + * It is a programming error to try to escape an unsupported type. + * The supported types are currently %G_TYPE_STRING, %G_TYPE_BOOLEAN, + * %G_TYPE_INT, %G_TYPE_UINT, %G_TYPE_INT64, %G_TYPE_UINT64, %G_TYPE_UCHAR, + * %G_TYPE_STRV, %DBUS_TYPE_G_OBJECT_PATH and %TP_ARRAY_TYPE_OBJECT_PATH_LIST. + * + * Returns: %TRUE if @value was filled in + */ +gboolean +mcp_account_manager_unescape_value_from_keyfile (const McpAccountManager *mcpa, + const gchar *escaped, + GValue *value, + GError **error) +{ + McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa); + + g_return_val_if_fail (iface != NULL, FALSE); + g_return_val_if_fail (iface->unescape_value_from_keyfile != NULL, FALSE); + + return iface->unescape_value_from_keyfile (mcpa, escaped, value, error); +} + +/** + * mcp_account_manager_init_value_for_attribute: + * @mcpa: a #McpAccountManager + * @value: a zero-filled value to initialize + * @attribute: a supported Mission Control attribute + * + * If @attribute is a known Mission Control attribute, initialize @value + * with an appropriate type for @attribute and return %TRUE. Otherwise, + * return %FALSE. + * + * Returns: %TRUE if @value was initialized + */ +gboolean +mcp_account_manager_init_value_for_attribute (const McpAccountManager *mcpa, + GValue *value, + const gchar *attribute) +{ + McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa); + + g_return_val_if_fail (iface != NULL, FALSE); + g_return_val_if_fail (iface->init_value_for_attribute != NULL, FALSE); + + return iface->init_value_for_attribute (mcpa, value, attribute); +} diff --git a/mission-control-plugins/account.h b/mission-control-plugins/account.h index 4356b3c0..c283ef99 100644 --- a/mission-control-plugins/account.h +++ b/mission-control-plugins/account.h @@ -62,6 +62,10 @@ void mcp_account_manager_set_parameter (const McpAccountManager *mcpa, GVariant *value, McpParameterFlags flags); +gchar * mcp_account_manager_get_value (const McpAccountManager *mcpa, + const gchar *account, + const gchar *key); + gchar * mcp_account_manager_get_unique_name (McpAccountManager *mcpa, const gchar *manager, const gchar *protocol, @@ -70,10 +74,25 @@ gchar * mcp_account_manager_get_unique_name (McpAccountManager *mcpa, GStrv mcp_account_manager_list_keys (const McpAccountManager *mcpa, const gchar *account); +gchar *mcp_account_manager_escape_value_for_keyfile ( + const McpAccountManager *mcpa, + const GValue *value); + gchar *mcp_account_manager_escape_variant_for_keyfile ( const McpAccountManager *mcpa, GVariant *variant); +gboolean mcp_account_manager_unescape_value_from_keyfile ( + const McpAccountManager *mcpa, + const gchar *escaped, + GValue *value, + GError **error); + +gboolean mcp_account_manager_init_value_for_attribute ( + const McpAccountManager *mcpa, + GValue *value, + const gchar *attribute); + void mcp_account_manager_identify_account_async (McpAccountManager *mcpa, const gchar *manager, const gchar *protocol, diff --git a/mission-control-plugins/implementation.h b/mission-control-plugins/implementation.h index 9d44b3bb..9cc04b4e 100644 --- a/mission-control-plugins/implementation.h +++ b/mission-control-plugins/implementation.h @@ -82,6 +82,10 @@ struct _McpAccountManagerIface { const gchar *key, const gchar *value); + gchar * (*get_value) (const McpAccountManager *ma, + const gchar *acct, + const gchar *key); + gchar * (* unique_name) (const McpAccountManager *ma, const gchar *manager, const gchar *protocol, @@ -90,6 +94,18 @@ struct _McpAccountManagerIface { GStrv (* list_keys) (const McpAccountManager *ma, const gchar *acct); + gchar * (* escape_value_for_keyfile) (const McpAccountManager *mcpa, + const GValue *value); + + gboolean (* unescape_value_from_keyfile) (const McpAccountManager *mcpa, + const gchar *escaped, + GValue *value, + GError **error); + + gboolean (* init_value_for_attribute) (const McpAccountManager *mcpa, + GValue *value, + const gchar *attribute); + gchar * (* escape_variant_for_keyfile) (const McpAccountManager *mcpa, GVariant *variant); |