McpAccountStorage

McpAccountStorage — Account Storage object, implemented by plugins

Functions

Types and Values

Object Hierarchy


Includes

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

Description

Plugins may implement McpAccountStorage in order to provide account parameter storage backends to the AccountManager object.

To do so, the plugin must implement a GObject subclass that implements McpAccountStorage, then return an instance of that subclass from mcp_plugin_ref_nth_object().

Many methods take "the unique name of an account" as an argument. In this plugin, that means the unique "tail" of the account's object path, for instance "gabble/jabber/chris_40example_2ecom". The account's full object path is obtained by prepending TP_ACCOUNT_OBJECT_PATH_BASE.

A complete implementation of this interface with all methods would look something like this:

Example 1. 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
G_DEFINE_TYPE_WITH_CODE (FooPlugin, foo_plugin,
   G_TYPE_OBJECT,
   G_IMPLEMENT_INTERFACE (...);
   G_IMPLEMENT_INTERFACE (MCP_TYPE_ACCOUNT_STORAGE,
     account_storage_iface_init));
/* ... */
static void
account_storage_iface_init (McpAccountStorageIface *iface)
{
  iface->priority = 0;
  iface->name = "foo";
  iface->desc = "The FOO storage backend";
  iface->provider = "im.telepathy.v1.MissionControl6.FooStorage";

  iface->get_flags = foo_plugin_get_flags;
  iface->delete_async = foo_plugin_delete_async;
  iface->delete_finish = foo_plugin_delete_finish;
  iface->commit = foo_plugin_commit;
  iface->list = foo_plugin_list;
  iface->dup_identifier = foo_plugin_dup_identifier;
  iface->dup_additional_info = foo_plugin_dup_additional_info;
  iface->get_restrictions = foo_plugin_get_restrictions;
  iface->create = foo_plugin_create;
  iface->get_attribute = foo_plugin_get_attribute;
  iface->get_parameter = foo_plugin_get_parameter;
  iface->list_typed_parameters = foo_plugin_list_typed_parameters;
  iface->list_untyped_parameters = foo_plugin_list_untyped_parameters;
  iface->set_attribute = foo_plugin_set_attribute;
  iface->set_parameter = foo_plugin_set_parameter;
}

A single object can implement more than one interface; It is currently unlikely that you would find it useful to implement anything other than an account storage plugin in an account storage object, though.

Functions

mcp_account_storage_priority ()

gint
mcp_account_storage_priority (McpAccountStorage *storage);

Gets the priority for this plugin.

Priorities currently run from MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_DEFAULT (the default storage plugin priority) upwards. More-positive numbers are higher priority.

Plugins at a higher priority then MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_KEYRING used to have the opportunity to "steal" passwords from the gnome keyring. It is no longer significant.

Plugins at a lower priority than the default plugin will never be asked to store any details, although they may still be asked to list them at startup time, and may asynchronously notify MC of accounts via the signals above.

When loading accounts at startup, plugins are consulted in order from lowest to highest, so that higher priority plugins may overrule settings from lower priority plugins.

Loading all the accounts is only done at startup, before the dbus name is claimed, and is therefore the only time plugins are allowed to indulge in blocking calls (indeed, they are expected to carry out this operation, and ONLY this operation, synchronously).

When values are being set, the plugins are invoked from highest priority to lowest, with the first plugin that claims a setting being assigned ownership, and all lower priority plugins being asked to delete the setting in question.

Parameters

storage

an McpAccountStorage instance

 

Returns

the priority of this plugin


mcp_account_storage_create ()

gchar *
mcp_account_storage_create (McpAccountStorage *storage,
                            McpAccountManager *am,
                            const gchar *manager,
                            const gchar *protocol,
                            const gchar *identification,
                            GError **error);

Inform the plugin that a new account is being created. manager , protocol and identification are given to help determining the account's unique name, but does not need to be stored on the account yet, mcp_account_storage_set() and mcp_account_storage_commit() will be called later.

It is recommended to use mcp_account_manager_get_unique_name() to create the unique name, but it's not mandatory. One could base the unique name on an internal storage identifier, prefixed with the provider's name (e.g. goa__1234).

“created” signal should not be emitted for this account, not even when mcp_account_storage_commit() will be called.

The default implementation just returns NULL, and is appropriate for read-only storage.

Since Mission Control 5.17, all storage plugins in which new accounts can be created by Mission Control must implement this method. Previously, it was not mandatory.

Parameters

storage

an McpAccountStorage instance

 

am

an object which can be used to call back into the account manager

 

manager

the name of the manager

 

protocol

the name of the protocol

 

identification

a normalized form of the account name, or "account" if nothing is suitable (e.g. for telepathy-salut)

 

error

a GError to fill

 

Returns

the newly allocated account name, which should be freed once the caller is done with it, or NULL if that couldn't be done.

[transfer full]


mcp_account_storage_delete_async ()

void
mcp_account_storage_delete_async (McpAccountStorage *storage,
                                  McpAccountManager *am,
                                  const gchar *account,
                                  GCancellable *cancellable,
                                  GAsyncReadyCallback callback,
                                  gpointer user_data);

Delete the account account , and commit the change, emitting “deleted” afterwards.

Unlike the 'delete' virtual method in earlier MC versions, this function is expected to commit the change to long-term storage, is expected to emit “deleted”, and is not called for the deletion of individual attributes or parameters.

The default implementation just returns failure (asynchronously), and is appropriate for read-only storage.

Implementations that override delete_async must also override delete_finish.

Parameters

storage

an McpAccountStorage instance

 

am

an McpAccountManager instance

 

account

the unique name of the account

 

cancellable

optionally used to (try to) cancel the operation.

[allow-none]

callback

called on success or failure

 

user_data

data for callback

 

mcp_account_storage_delete_finish ()

gboolean
mcp_account_storage_delete_finish (McpAccountStorage *storage,
                                   GAsyncResult *result,
                                   GError **error);

Process the result of mcp_account_storage_delete_async().

Parameters

storage

an McpAccountStorage instance

 

res

the result of mcp_account_storage_delete_async()

 

error

used to raise an error if FALSE is returned

 

Returns

TRUE on success, FALSE if the account could not be deleted


mcp_account_storage_commit ()

gboolean
mcp_account_storage_commit (McpAccountStorage *storage,
                            McpAccountManager *am,
                            const gchar *account);

The plugin is expected to write its cache to long term storage, deleting, adding or updating entries in said storage as needed.

This call is expected to return promptly, but the plugin is not required to have finished its commit operation when it returns, merely to have started the operation.

The default implementation just returns FALSE, and is appropriate for read-only storage.

Mission Control 5.17+ no longer requires plugins to cope with account == NULL.

Parameters

storage

an McpAccountStorage instance

 

am

an McpAccountManager instance

 

account

the unique suffix of an account's object path

 

Returns

TRUE if the commit process was started (but not necessarily completed) successfully; FALSE if there was a problem that was immediately obvious.


mcp_account_storage_list ()

GList *
mcp_account_storage_list (McpAccountStorage *storage,
                          McpAccountManager *am);

Load details of every account stored by this plugin into an in-memory cache so that it can respond to requests promptly.

This method is called only at initialisation time, before the dbus name has been claimed, and is the only one permitted to block.

There is no default implementation. All implementations of this interface must override this method.

Parameters

storage

an McpAccountStorage instance

 

am

an McpAccountManager instance

 

Returns

a list of account names that the plugin has settings for. The account names should be freed with g_free(), and the list with g_list_free(), when the caller is done with them.

[element-type utf8][transfer full]


mcp_account_storage_dup_identifier ()

GVariant *
mcp_account_storage_dup_identifier (McpAccountStorage *storage,
                                    const gchar *account);

Get the storage-specific identifier for this account.

The default implementation returns account as a string.

This method will only be called for the storage plugin that "owns" the account.

If the implementation returns a floating reference, ownership will be taken by mcp_account_storage_dup_identifer(), so that it always returns a "full" reference.

Parameters

storage

an McpAccountStorage instance

 

account

the unique name of the account

 

Returns

the identifier.

[transfer full]


mcp_account_storage_dup_additional_info ()

GVariant *
mcp_account_storage_dup_additional_info
                               (McpAccountStorage *storage,
                                const gchar *account);

Return additional storage-specific information about this account, which is made available on D-Bus but not otherwise interpreted by Mission Control.

This method will only be called for the storage plugin that "owns" the account.

The default implementation returns an empty map.

If the implementation returns a floating reference, ownership will be taken by mcp_account_storage_dup_additional_info(), so that it always returns a "full" reference.

Parameters

storage

an McpAccountStorage instance

 

account

the unique name of the account

 

Returns

a non-NULL G_VARIANT_TYPE_VARDICT of storage-specific information


mcp_account_storage_get_restrictions ()

TpStorageRestrictionFlags
mcp_account_storage_get_restrictions (McpAccountStorage *storage,
                                      const gchar *account);

This method will only be called for the storage plugin that "owns" the account.

The default implementation returns 0, i.e. no restrictions.

Parameters

storage

an McpAccountStorage instance

 

account

the unique name of the account

 

Returns

a bitmask of TpStorageRestrictionFlags with the restrictions to account storage.


mcp_account_storage_name ()

const gchar *
mcp_account_storage_name (McpAccountStorage *storage);

Parameters

storage

an McpAccountStorage instance

 

Returns

the plugin's name (for logging etc)


mcp_account_storage_description ()

const gchar *
mcp_account_storage_description (McpAccountStorage *storage);

Parameters

storage

an McpAccountStorage instance

 

Returns

the plugin's description (for logging etc)


mcp_account_storage_provider ()

const gchar *
mcp_account_storage_provider (McpAccountStorage *storage);

Parameters

storage

an McpAccountStorage instance

 

Returns

a D-Bus namespaced name for this plugin, or "" if none was provided in McpAccountStorageIface.provider.


mcp_account_storage_get_attribute ()

GVariant *
mcp_account_storage_get_attribute (McpAccountStorage *storage,
                                   McpAccountManager *am,
                                   const gchar *account,
                                   const gchar *attribute,
                                   const GVariantType *type,
                                   McpAttributeFlags *flags);

Retrieve an attribute.

There is no default implementation. All account storage plugins must override this method.

The returned variant does not necessarily have to match type : Mission Control will coerce it to an appropriate type if required. In particular, plugins that store strongly-typed attributes may return the stored type, not the expected type, if they differ.

Parameters

storage

an McpAccountStorage instance

 

am

an McpAccountManager instance

 

account

the unique name of the account

 

attribute

the name of an attribute, e.g. "DisplayName"

 

type

the expected type of attribute , as a hint for legacy account storage plugins that do not store attributes' types

 

flags

used to return attribute flags.

[allow-none][out]

Returns

the value of the attribute, or NULL if it is not present.

[transfer full]


mcp_account_storage_get_parameter ()

GVariant *
mcp_account_storage_get_parameter (McpAccountStorage *storage,
                                   McpAccountManager *am,
                                   const gchar *account,
                                   const gchar *parameter,
                                   const GVariantType *type,
                                   McpParameterFlags *flags);

Retrieve a parameter.

There is no default implementation. All account storage plugins must override this method.

The returned variant does not necessarily have to match type : Mission Control will coerce it to an appropriate type if required. In particular, plugins that store strongly-typed parameters may return the stored type, not the expected type, if they differ.

If type is NULL, the plugin must return the parameter with its stored type, or return NULL if the type is not stored.

Parameters

storage

an McpAccountStorage instance

 

am

an McpAccountManager instance

 

account

the unique name of the account

 

parameter

the name of a parameter, e.g. "require-encryption"

 

type

the expected type of parameter , as a hint for legacy account storage plugins that do not store parameters' types.

[allow-none]

flags

used to return parameter flags.

[allow-none][out]

Returns

the value of the parameter, or NULL if it is not present.

[transfer full]


mcp_account_storage_list_typed_parameters ()

gchar **
mcp_account_storage_list_typed_parameters
                               (McpAccountStorage *storage,
                                McpAccountManager *am,
                                const gchar *account);

List the names of all parameters whose corresponding types are known.

Ideally, all parameters are typed parameters, whose types are stored alongside the values. This function produces those as its return value.

However, the Mission Control API has not traditionally required account-storage backends to store parameters' types, so some backends will contain untyped parameters, returned by mcp_account_storage_list_untyped_parameters().

This method is mandatory to implement.

Parameters

storage

an McpAccountStorage instance

 

am

an McpAccountManager instance

 

account

the unique name of the account

 

Returns

a GStrv containing the typed parameters; NULL or empty if there are no typed parameters.

[array zero-terminated=1][transfer full][element-type utf8]


mcp_account_storage_list_untyped_parameters ()

gchar **
mcp_account_storage_list_untyped_parameters
                               (McpAccountStorage *storage,
                                McpAccountManager *am,
                                const gchar *account);

List the names of all parameters whose types are unknown. The values are not listed, because interpreting the value correctly requires a type.

See mcp_account_storage_list_typed_parameters() for more on typed vs. untyped parameters.

The default implementation just returns NULL, and is appropriate for "legacy-free" backends that store a type with every parameter.

Parameters

storage

an McpAccountStorage instance

 

am

an McpAccountManager instance

 

account

the unique name of the account

 

Returns

a GStrv containing the untyped parameters; NULL or empty if there are no untyped parameters.

[array zero-terminated=1][transfer full][element-type utf8]


mcp_account_storage_set_attribute ()

McpAccountStorageSetResult
mcp_account_storage_set_attribute (McpAccountStorage *storage,
                                   McpAccountManager *am,
                                   const gchar *account,
                                   const gchar *attribute,
                                   GVariant *value,
                                   McpAttributeFlags flags);

Store an attribute.

The plugin is expected to either quickly and synchronously update its internal cache of values with value , or to decline to store the attribute.

The plugin is not expected to write to its long term storage at this point.

There is a default implementation, which just returns FALSE for read-only storage plugins.

Parameters

storage

an McpAccountStorage instance

 

am

an McpAccountManager instance

 

account

the unique name of the account

 

attribute

the name of an attribute, e.g. "DisplayName"

 

value

a value to associate with attribute , or NULL to delete.

[allow-none]

flags

flags influencing how the attribute is to be stored

 

Returns

TRUE if the attribute was claimed, FALSE otherwise

Since 5.15.0


mcp_account_storage_set_parameter ()

McpAccountStorageSetResult
mcp_account_storage_set_parameter (McpAccountStorage *storage,
                                   McpAccountManager *am,
                                   const gchar *account,
                                   const gchar *parameter,
                                   GVariant *value,
                                   McpParameterFlags flags);

Store a parameter.

The plugin is expected to either quickly and synchronously update its internal cache of values with value , or to decline to store the parameter.

The plugin is not expected to write to its long term storage at this point.

There is a default implementation, which just returns FALSE for read-only storage plugins.

Parameters

storage

an McpAccountStorage instance

 

am

an McpAccountManager instance

 

account

the unique name of the account

 

parameter

the name of a parameter, e.g. "account" (note that there is no "param-" prefix here)

 

value

a value to associate with parameter , or NULL to delete.

[allow-none]

flags

flags influencing how the parameter is to be stored

 

Returns

TRUE if the parameter was claimed, FALSE otherwise

Since 5.15.0


mcp_account_storage_get_flags ()

McpAccountStorageFlags
mcp_account_storage_get_flags (McpAccountStorage *storage,
                               const gchar *account);

Get the backend's features and capabilities. The default implementation returns MCP_ACCOUNT_STORAGE_FLAG_NONE. Additionally providing MCP_ACCOUNT_STORAGE_FLAG_STORES_TYPES is strongly recommended.

Parameters

storage

an McpAccountStorage instance

 

account

the unique name of the account to inspect

 

Returns

a bitmask of API features that apply to account


mcp_account_storage_has_all_flags ()

gboolean
mcp_account_storage_has_all_flags (McpAccountStorage *storage,
                                   const gchar *account,
                                   McpAccountStorageFlags require_all);

Return whether this account has all of the specified flags, according to mcp_account_storage_get_flags().

If require_all is 0, the result will always be TRUE (the account has all of the flags in the empty set).

Parameters

storage

an McpAccountStorage instance

 

account

the unique name of the account to inspect

 

require_all

bitwise "or" of zero or more flags

 

Returns

TRUE if account has every flag in require_all


mcp_account_storage_has_any_flag ()

gboolean
mcp_account_storage_has_any_flag (McpAccountStorage *storage,
                                  const gchar *account,
                                  McpAccountStorageFlags require_one);

Return whether this account has at least one of the required flags, according to mcp_account_storage_get_flags().

If require_one is 0, the result will always be FALSE (it is not true that the account has at least one of the flags in the empty set).

Parameters

storage

an McpAccountStorage instance

 

account

the unique name of the account to inspect

 

require_one

bitwise "or" of one or more flags

 

Returns

TRUE if account has every flag in require_all


mcp_account_storage_emit_created ()

void
mcp_account_storage_emit_created (McpAccountStorage *storage,
                                  const gchar *account);

Emits the “created” signal.

Parameters

storage

an McpAccountStorage instance

 

account

the unique name of the created account

 

mcp_account_storage_emit_altered_one ()

void
mcp_account_storage_emit_altered_one (McpAccountStorage *storage,
                                      const gchar *account,
                                      const gchar *key);

Emits the “altered-one” signal

Parameters

storage

an McpAccountStorage instance

 

account

the unique name of the altered account

 

key

the key of the altered property: either an attribute name like "DisplayName", or "param-" plus a parameter name like "account"

 

mcp_account_storage_emit_deleted ()

void
mcp_account_storage_emit_deleted (McpAccountStorage *storage,
                                  const gchar *account);

Emits the “deleted” signal

Parameters

storage

an McpAccountStorage instance

 

account

the unique name of the deleted account

 

mcp_account_storage_emit_toggled ()

void
mcp_account_storage_emit_toggled (McpAccountStorage *storage,
                                  const gchar *account,
                                  gboolean enabled);

Emits ::toggled signal

Parameters

storage

an McpAccountStorage instance

 

account

the unique name of the account

 

enabled

TRUE if the account is now enabled

 

mcp_account_storage_emit_reconnect ()

void
mcp_account_storage_emit_reconnect (McpAccountStorage *storage,
                                    const gchar *account);

Emits ::reconnect signal

Parameters

storage

an McpAccountStorage instance

 

account

the unique name of the account to reconnect

 

Types and Values

MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_READONLY

#define MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_READONLY -1

MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_DEFAULT

#define MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_DEFAULT   0

MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_NORMAL

#define MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_NORMAL    100

enum McpParameterFlags

Members

MCP_PARAMETER_FLAG_NONE

   

enum McpAttributeFlags

Members

MCP_ATTRIBUTE_FLAG_NONE

   

enum McpAccountStorageSetResult

Members

MCP_ACCOUNT_STORAGE_SET_RESULT_FAILED

   

MCP_ACCOUNT_STORAGE_SET_RESULT_CHANGED

   

MCP_ACCOUNT_STORAGE_SET_RESULT_UNCHANGED

   

enum McpAccountStorageFlags

Flags describing the features and capabilities of a backend.

Members

MCP_ACCOUNT_STORAGE_FLAG_NONE

no particular flags

 

MCP_ACCOUNT_STORAGE_FLAG_STORES_TYPES

this backend can store parameter values' types

 

struct McpAccountStorage

struct McpAccountStorage {
 };
#endif

#define MCP_TYPE_ACCOUNT_STORAGE (mcp_account_storage_get_type ())

#define MCP_ACCOUNT_STORAGE(o) \
  (G_TYPE_CHECK_INSTANCE_CAST ((o), MCP_TYPE_ACCOUNT_STORAGE, \
      McpAccountStorage))

#define MCP_IS_ACCOUNT_STORAGE(o) \
  (G_TYPE_CHECK_INSTANCE_TYPE ((o), MCP_TYPE_ACCOUNT_STORAGE))

#define MCP_ACCOUNT_STORAGE_GET_IFACE(o) \
  (G_TYPE_INSTANCE_GET_INTERFACE ((o), MCP_TYPE_ACCOUNT_STORAGE, \
                                  McpAccountStorageIface))

GType mcp_account_storage_get_type (void);

typedef gchar * (*McpAccountStorageCreate) (
    McpAccountStorage *storage,
    McpAccountManager *am,
    const gchar *manager,
    const gchar *protocol,
    const gchar *identification,
    GError **error);
typedef TpStorageRestrictionFlags (*McpAccountStorageGetRestrictionsFunc) (
    McpAccountStorage *storage,
    const gchar *account);

struct _McpAccountStorageIface
{
  GTypeInterface parent;

  gint priority;
  const gchar *name;
  const gchar *desc;
  const gchar *provider;

  void (*delete_async) (McpAccountStorage *storage,
      McpAccountManager *am,
      const gchar *account,
      GCancellable *cancellable,
      GAsyncReadyCallback callback,
      gpointer user_data);
  gboolean (*delete_finish) (McpAccountStorage *storage,
      GAsyncResult *res,
      GError **error);

  gboolean (*commit) (McpAccountStorage *storage,
    McpAccountManager *am,
    const gchar *account);

  GList * (*list) (McpAccountStorage *storage,
    McpAccountManager *am);

  GVariant *(*dup_identifier) (McpAccountStorage *storage,
    const gchar *account);

  GVariant *(*dup_additional_info) (McpAccountStorage *storage,
    const gchar *account);

  TpStorageRestrictionFlags (*get_restrictions) (McpAccountStorage *storage,
    const gchar *account);

  gchar * (*create) (McpAccountStorage *storage,
    McpAccountManager *am,
    const gchar *manager,
    const gchar *protocol,
    const gchar *identification,
    GError **error);

  GVariant *(*get_attribute) (McpAccountStorage *storage,
      McpAccountManager *am,
      const gchar *account,
      const gchar *attribute,
      const GVariantType *type,
      McpAttributeFlags *flags);
  GVariant *(*get_parameter) (McpAccountStorage *storage,
      McpAccountManager *am,
      const gchar *account,
      const gchar *parameter,
      const GVariantType *type,
      McpParameterFlags *flags);

  McpAccountStorageSetResult (*set_attribute) (McpAccountStorage *storage,
      McpAccountManager *am,
      const gchar *account,
      const gchar *attribute,
      GVariant *val,
      McpAttributeFlags flags);
  McpAccountStorageSetResult (*set_parameter) (McpAccountStorage *storage,
      McpAccountManager *am,
      const gchar *account,
      const gchar *parameter,
      GVariant *val,
      McpParameterFlags flags);

  gchar **(*list_typed_parameters) (McpAccountStorage *storage,
      McpAccountManager *am,
      const gchar *account);
  gchar **(*list_untyped_parameters) (McpAccountStorage *storage,
      McpAccountManager *am,
      const gchar *account);

  McpAccountStorageFlags (*get_flags) (McpAccountStorage *storage,
      const gchar *account);
};

An object implementing the account storage plugin interface.


McpAccountStorageIface

typedef struct _McpAccountStorageIface McpAccountStorageIface;

The interface vtable for an account storage plugin.

Members