Top | ![]() |
![]() |
![]() |
![]() |
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 |
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 = "org.freedesktop.Telepathy.MissionControl5.FooStorage"; iface->get = foo_plugin_get; iface->set = foo_plugin_get; iface->delete = foo_plugin_delete; iface->commit = foo_plugin_commit; iface->commit_one = foo_plugin_commit_one; iface->list = foo_plugin_list; iface->ready = foo_plugin_ready; iface->get_identifier = foo_plugin_get_identifier; iface->get_additional_info = foo_plugin_get_additional_info; iface->get_restrictions = foo_plugin_get_restrictions; iface->create = foo_plugin_create; iface->owns = foo_plugin_owns; 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.
gint
mcp_account_storage_priority (const McpAccountStorage *storage
);
mcp_account_storage_priority
is deprecated and should not be used in newly-written code.
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.
gboolean mcp_account_storage_get (const McpAccountStorage *storage
,McpAccountManager *am
,const gchar *account
,const gchar *key
);
Get a value from the plugin's in-memory cache.
Before emitting this signal, the plugin must call
either mcp_account_manager_set_attribute()
,
mcp_account_manager_set_parameter()
,
or mcp_account_manager_set_value()
and (if appropriate)
mcp_account_manager_parameter_make_secret()
before returning from this method call.
Note that mcp_account_manager_set_parameter()
does not use the
"param-" prefix, even if called from this function.
If key
is NULL
the plugin should iterate through all attributes and
parameters, and push each of them into am
, as if this method had
been called once for each attribute or parameter. It must then return
TRUE
if any attributes or parameters were found, or FALSE
if it
was not responsible for account
.
storage |
an McpAccountStorage instance |
|
am |
an McpAccountManager instance |
|
account |
the unique name of the account |
|
key |
the setting whose value we wish to fetch: either an attribute like "DisplayName", or "param-" plus a parameter like "account" |
gboolean mcp_account_storage_set (const McpAccountStorage *storage
,const McpAccountManager *am
,const gchar *account
,const gchar *key
,const gchar *value
);
The plugin is expected to either quickly and synchronously
update its internal cache of values with value
, or to
decline to store the setting.
The plugin is not expected to write to its long term storage
at this point. It can expect Mission Control to call either
mcp_account_storage_commit()
or mcp_account_storage_commit_one()
after a short delay.
Plugins that implement mcp_storage_set_attribute()
and
mcp_account_storage_set_parameter()
can just return FALSE
here.
There is a default implementation, which just returns FALSE
.
storage |
an McpAccountStorage instance |
|
am |
an McpAccountManager instance |
|
account |
the unique name of the account |
|
key |
the non- |
|
value |
a value to associate with |
gchar * mcp_account_storage_create (const McpAccountStorage *storage
,const McpAccountManager *am
,const gchar *manager
,const gchar *protocol
,GHashTable *params
,GError **error
);
Inform the plugin that a new account is being created. manager
, protocol
and params
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.
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 |
|
params |
A gchar * / GValue * hash table of account parameters |
|
error |
a GError to fill |
gboolean mcp_account_storage_delete (const McpAccountStorage *storage
,const McpAccountManager *am
,const gchar *account
,const gchar *key
);
The plugin is expected to remove the setting for key
from its
internal cache and to remember that its state has changed, so
that it can delete said setting from its long term storage if
its long term storage method makes this necessary.
If key
is NULL
, the plugin should forget all its settings for
account
,and remember to delete the entire account from its storage later.
The plugin is not expected to update its long term storage at this point.
storage |
an McpAccountStorage instance |
|
am |
an McpAccountManager instance |
|
account |
the unique name of the account |
|
key |
the setting whose value we wish to store - either an
attribute like "DisplayName", or "param-" plus a parameter like
"account" - or |
[allow-none] |
void mcp_account_storage_ready (const McpAccountStorage *storage
,const McpAccountManager *am
);
Informs the plugin that it is now permitted to create new accounts, ie it can now fire its "created", "altered", "toggled" and "deleted" signals.
gboolean mcp_account_storage_commit (const McpAccountStorage *storage
,const McpAccountManager *am
);
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.
If the commit_one
method is implemented, it will be called preferentially
if only one account is to be committed. If the commit_one
method is
implemented but commit
is not, commit_one
will be called with
account_name
= NULL
to commit all accounts.
gboolean mcp_account_storage_commit_one (const McpAccountStorage *storage
,const McpAccountManager *am
,const gchar *account
);
The same as mcp_account_storage_commit()
, but only commit the given
account. This is optional to implement; the default implementation
is to call commit
.
If both mcp_account_storage_commit_one()
and mcp_account_storage_commit()
are implemented, Mission Control will never pass account
= NULL
to
this method.
storage |
an McpAccountStorage instance |
|
am |
an McpAccountManager instance |
|
account |
the unique suffix of an account's object path,
or |
[allow-none] |
GList * mcp_account_storage_list (const McpAccountStorage *storage
,const 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.
void mcp_account_storage_get_identifier (const McpAccountStorage *storage
,const gchar *account
,GValue *identifier
);
Get the storage-specific identifier for this account. The type is variant, hence the GValue.
This method will only be called for the storage plugin that "owns" the account.
storage |
an McpAccountStorage instance |
|
account |
the unique name of the account |
|
identifier |
a zero-filled GValue whose type can be sent over D-Bus by dbus-glib, to hold the identifier. |
[out caller-allocates] |
GHashTable * mcp_account_storage_get_additional_info (const 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.
guint mcp_account_storage_get_restrictions (const McpAccountStorage *storage
,const gchar *account
);
This method will only be called for the storage plugin that "owns" the account.
const gchar *
mcp_account_storage_name (const McpAccountStorage *storage
);
const gchar *
mcp_account_storage_description (const McpAccountStorage *storage
);
const gchar *
mcp_account_storage_provider (const McpAccountStorage *storage
);
gboolean mcp_account_storage_owns (McpAccountStorage *storage
,McpAccountManager *am
,const gchar *account
);
Check whether account
is stored in storage
. The highest-priority
plugin for which this function returns TRUE
is considered to be
responsible for account
.
There is a default implementation, which calls mcp_account_storage_get()
for the well-known key "manager".
storage |
an McpAccountStorage instance |
|
am |
an McpAccountManager instance |
|
account |
the unique name (object-path tail) of an account |
Since: 5.15.0
gboolean 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
.
Mission Control will call mcp_account_storage_set()
instead,
using a keyfile-escaped version of value
.
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 |
|
flags |
flags influencing how the attribute is to be stored |
Since: 5.15.0
gboolean 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
.
Mission Control will call mcp_account_storage_set()
instead,
using "param-" + parameter
as key and a keyfile-escaped version
of value
as value.
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 |
|
flags |
flags influencing how the parameter is to be stored |
Since: 5.15.0
void mcp_account_storage_emit_created (McpAccountStorage *storage
,const gchar *account
);
void mcp_account_storage_emit_altered (McpAccountStorage *storage
,const gchar *account
);
mcp_account_storage_emit_altered
is deprecated and should not be used in newly-written code.
Emits the “altered” signal
void mcp_account_storage_emit_altered_one (McpAccountStorage *storage
,const gchar *account
,const gchar *key
);
Emits the “altered-one” signal
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" |
void mcp_account_storage_emit_deleted (McpAccountStorage *storage
,const gchar *account
);
Emits the “deleted” signal
void mcp_account_storage_emit_toggled (McpAccountStorage *storage
,const gchar *account
,gboolean enabled
);
Emits ::toggled signal
storage |
an McpAccountStorage instance |
|
account |
the unique name of the account |
|
enabled |
|
void mcp_account_storage_emit_reconnect (McpAccountStorage *storage
,const gchar *account
);
Emits ::reconnect signal
storage |
an McpAccountStorage instance |
|
account |
the unique name of the account to reconnect |
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); /* Virtual method implementation signatures */ typedef gboolean (*McpAccountStorageGetFunc) ( const McpAccountStorage *storage, const McpAccountManager *am, const gchar *account, const gchar *key); typedef gboolean (*McpAccountStorageSetFunc) ( const McpAccountStorage *storage, const McpAccountManager *am, const gchar *account, const gchar *key, const gchar *val); typedef gchar * (*McpAccountStorageCreate) ( const McpAccountStorage *storage, const McpAccountManager *am, const gchar *manager, const gchar *protocol, GHashTable *params, GError **error); typedef gboolean (*McpAccountStorageDeleteFunc) ( const McpAccountStorage *storage, const McpAccountManager *am, const gchar *account, const gchar *key); typedef GList * (*McpAccountStorageListFunc) ( const McpAccountStorage *storage, const McpAccountManager *am); typedef gboolean (*McpAccountStorageCommitFunc) ( const McpAccountStorage *storage, const McpAccountManager *am); typedef gboolean (*McpAccountStorageCommitOneFunc) ( const McpAccountStorage *storage, const McpAccountManager *am, const gchar *account); typedef void (*McpAccountStorageReadyFunc) ( const McpAccountStorage *storage, const McpAccountManager *am); typedef void (*McpAccountStorageGetIdentifierFunc) ( const McpAccountStorage *storage, const gchar *account, GValue *identifier); typedef GHashTable * (*McpAccountStorageGetAdditionalInfoFunc) ( const McpAccountStorage *storage, const gchar *account); /* FIXME: when breaking API, make this return TpStorageRestrictionFlags */ typedef guint (*McpAccountStorageGetRestrictionsFunc) ( const McpAccountStorage *storage, const gchar *account); struct _McpAccountStorageIface { GTypeInterface parent; gint priority; const gchar *name; const gchar *desc; const gchar *provider; McpAccountStorageSetFunc set; McpAccountStorageGetFunc get; McpAccountStorageDeleteFunc delete; McpAccountStorageCommitFunc commit; McpAccountStorageListFunc list; McpAccountStorageReadyFunc ready; McpAccountStorageCommitOneFunc commit_one; McpAccountStorageGetIdentifierFunc get_identifier; McpAccountStorageGetAdditionalInfoFunc get_additional_info; McpAccountStorageGetRestrictionsFunc get_restrictions; McpAccountStorageCreate create; /* Since 5.15.0 */ gboolean (*owns) (McpAccountStorage *storage, McpAccountManager *am, const gchar *account); gboolean (*set_attribute) (McpAccountStorage *storage, McpAccountManager *am, const gchar *account, const gchar *attribute, GVariant *val, McpAttributeFlags flags); gboolean (*set_parameter) (McpAccountStorage *storage, McpAccountManager *am, const gchar *account, const gchar *parameter, GVariant *val, McpParameterFlags flags); };
An object implementing the account storage plugin interface.