McpAccountManager

McpAccountManager — Object representing the account manager, implemented by Mission Control

Synopsis

#include <mission-control-plugins/mission-control-plugins.h>

void                mcp_account_manager_set_value       (const McpAccountManager *mcpa,
                                                         const gchar *account,
                                                         const gchar *key,
                                                         const gchar *value);
void                mcp_account_manager_set_attribute   (const McpAccountManager *mcpa,
                                                         const gchar *account,
                                                         const gchar *attribute,
                                                         GVariant *value,
                                                         McpAttributeFlags flags);
void                mcp_account_manager_set_parameter   (const McpAccountManager *mcpa,
                                                         const gchar *account,
                                                         const gchar *parameter,
                                                         GVariant *value,
                                                         McpParameterFlags flags);
gchar *             mcp_account_manager_get_value       (const McpAccountManager *mcpa,
                                                         const gchar *account,
                                                         const gchar *key);
gboolean            mcp_account_manager_parameter_is_secret
                                                        (const McpAccountManager *mcpa,
                                                         const gchar *account,
                                                         const gchar *key);
void                mcp_account_manager_parameter_make_secret
                                                        (const McpAccountManager *mcpa,
                                                         const gchar *account,
                                                         const gchar *key);
gchar *             mcp_account_manager_get_unique_name (McpAccountManager *mcpa,
                                                         const gchar *manager,
                                                         const gchar *protocol,
                                                         const gchar *identification);
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,
                                                         GVariant *parameters,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);
gchar *             mcp_account_manager_identify_account_finish
                                                        (McpAccountManager *mcpa,
                                                         GAsyncResult *res,
                                                         GError **error);
                    McpAccountManagerIface;
                    McpAccountManager;

Object Hierarchy

  GInterface
   +----McpAccountManager

Prerequisites

McpAccountManager requires GObject.

Description

This object represents the Telepathy AccountManager.

Most virtual methods on the McpAccountStorageIface interface receive an object provided by Mission Control that implements this interface. It can be used to manipulate Mission Control's in-memory cache of accounts.

Only Mission Control should implement this interface.

Details

mcp_account_manager_set_value ()

void                mcp_account_manager_set_value       (const McpAccountManager *mcpa,
                                                         const gchar *account,
                                                         const gchar *key,
                                                         const gchar *value);

Inform Mission Control that key has changed its value to value.

This function may either be called from mcp_account_storage_get(), or just before emitting "altered-one".

New plugins should call mcp_account_manager_set_attribute() or mcp_account_manager_set_parameter() instead.

mcpa :

an McpAccountManager instance

account :

the unique name of an account

key :

the setting whose value we wish to change: either an attribute like "DisplayName", or "param-" plus a parameter like "account"

value :

the new value, escaped as if for a GKeyFile, or NULL to delete the setting/parameter

mcp_account_manager_set_attribute ()

void                mcp_account_manager_set_attribute   (const McpAccountManager *mcpa,
                                                         const gchar *account,
                                                         const gchar *attribute,
                                                         GVariant *value,
                                                         McpAttributeFlags flags);

Inform Mission Control that attribute has changed its value to value.

If value is a floating reference, Mission Control will take ownership of it, much like g_variant_builder_add_value().

This function may either be called from mcp_account_storage_get(), or just before emitting "altered-one".

mcpa :

an McpAccountManager instance

account :

the unique name of an account

attribute :

the name of an attribute, such as "DisplayName"

value :

the new value, or NULL to delete the attribute. [allow-none]

flags :

flags for the new value (only used if value is non-NULL)

mcp_account_manager_set_parameter ()

void                mcp_account_manager_set_parameter   (const McpAccountManager *mcpa,
                                                         const gchar *account,
                                                         const gchar *parameter,
                                                         GVariant *value,
                                                         McpParameterFlags flags);

Inform Mission Control that parameter has changed its value to value.

If value is a floating reference, Mission Control will take ownership of it, much like g_variant_builder_add_value().

This function may either be called from mcp_account_storage_get(), or just before emitting "altered-one".

mcpa :

an McpAccountManager instance

account :

the unique name of an account

parameter :

the name of a parameter, such as "account", without the "param-" prefix

value :

the new value, or NULL to delete the parameter. [allow-none]

flags :

flags for the new value (only used if value is non-NULL)

mcp_account_manager_get_value ()

gchar *             mcp_account_manager_get_value       (const McpAccountManager *mcpa,
                                                         const gchar *account,
                                                         const gchar *key);

Fetch a copy of the current value of an account setting held by the account manager.

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"

Returns :

the value of key. [transfer full]

mcp_account_manager_parameter_is_secret ()

gboolean            mcp_account_manager_parameter_is_secret
                                                        (const McpAccountManager *mcpa,
                                                         const gchar *account,
                                                         const gchar *key);

Determine whether a given account parameter is secret. Generally this is determined by MC and passed down to plugins, but any McpAccountStorage plugin may decide a parameter is secret, in which case the return value for this call will indicate that fact too.

For historical reasons, this function only operates on parameters, but requires its argument to be prefixed with "param-".

mcpa :

an McpAccountManager instance

account :

the unique name of an account

key :

the constant string "param-", plus a parameter name like "account" or "password"

Returns :

TRUE for secret settings, FALSE otherwise

mcp_account_manager_parameter_make_secret ()

void                mcp_account_manager_parameter_make_secret
                                                        (const McpAccountManager *mcpa,
                                                         const gchar *account,
                                                         const gchar *key);

Flag an account setting as secret for the lifetime of this McpAccountManager. For instance, this should be called if key has been retrieved from gnome-keyring.

For historical reasons, this function only operates on parameters, but requires its argument to be prefixed with "param-".

mcpa :

an McpAccountManager instance

account :

the unique name of an account

key :

the constant string "param-", plus a parameter name like "account" or "password"

mcp_account_manager_get_unique_name ()

gchar *             mcp_account_manager_get_unique_name (McpAccountManager *mcpa,
                                                         const gchar *manager,
                                                         const gchar *protocol,
                                                         const gchar *identification);

Generate and return the canonical unique name of this [new] account. Should not be called for accounts which have already had a name assigned: Intended for use when a plugin encounters an account which MC has not previously seen before (ie one created by a 3rd party in the back-end that the plugin in question provides an interface to).

Changed in 5.17: instead of a map from string to GValue, the last argument is the result of calling IdentifyAccount on the parameters, which normalizes the account's name in a protocol-dependent way. Use mcp_account_manager_identify_account_async() to do that.

mcpa :

an McpAccountManager instance

manager :

the name of the manager

protocol :

the name of the protocol

identification :

the result of calling IdentifyAccount for this account

Returns :

the newly allocated account name, which should be freed once the caller is done with it.

mcp_account_manager_list_keys ()

GStrv               mcp_account_manager_list_keys       (const McpAccountManager *mcpa,
                                                         const gchar *account);

mcp_account_manager_escape_value_for_keyfile ()

gchar *             mcp_account_manager_escape_value_for_keyfile
                                                        (const McpAccountManager *mcpa,
                                                         const GValue *value);

mcp_account_manager_escape_variant_for_keyfile ()

gchar *             mcp_account_manager_escape_variant_for_keyfile
                                                        (const McpAccountManager *mcpa,
                                                         GVariant *variant);

Escape variant 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_VARIANT_TYPE_STRING, G_VARIANT_TYPE_BOOLEAN, G_VARIANT_TYPE_INT32, G_VARIANT_TYPE_UINT32, G_VARIANT_TYPE_INT64, G_VARIANT_TYPE_UINT64, G_VARIANT_TYPE_BYTE, G_VARIANT_TYPE_STRING_ARRAY, G_VARIANT_TYPE_OBJECT_PATH and G_VARIANT_TYPE_OBJECT_PATH_ARRAY.

mcpa :

a McpAccountManager

variant :

a GVariant with a supported GVariantType

Returns :

the escaped form of variant. [transfer full]

mcp_account_manager_unescape_value_from_keyfile ()

gboolean            mcp_account_manager_unescape_value_from_keyfile
                                                        (const McpAccountManager *mcpa,
                                                         const gchar *escaped,
                                                         GValue *value,
                                                         GError **error);

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.

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

Returns :

TRUE if value was filled in

mcp_account_manager_init_value_for_attribute ()

gboolean            mcp_account_manager_init_value_for_attribute
                                                        (const McpAccountManager *mcpa,
                                                         GValue *value,
                                                         const gchar *attribute);

If attribute is a known Mission Control attribute, initialize value with an appropriate type for attribute and return TRUE. Otherwise, return FALSE.

mcpa :

a McpAccountManager

value :

a zero-filled value to initialize

attribute :

a supported Mission Control attribute

Returns :

TRUE if value was initialized

mcp_account_manager_identify_account_async ()

void                mcp_account_manager_identify_account_async
                                                        (McpAccountManager *mcpa,
                                                         const gchar *manager,
                                                         const gchar *protocol,
                                                         GVariant *parameters,
                                                         GCancellable *cancellable,
                                                         GAsyncReadyCallback callback,
                                                         gpointer user_data);

mcp_account_manager_identify_account_finish ()

gchar *             mcp_account_manager_identify_account_finish
                                                        (McpAccountManager *mcpa,
                                                         GAsyncResult *res,
                                                         GError **error);

McpAccountManagerIface

typedef struct _McpAccountManagerIface McpAccountManagerIface;

McpAccountManager

typedef struct _McpAccountManager McpAccountManager;

See Also

McpAccountStorage