Bug 54872

Summary: store account attributes, parameters in-memory as variants
Product: Telepathy Reporter: Simon McVittie <smcv>
Component: mission-controlAssignee: Simon McVittie <smcv>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium CC: jonny.lamb
Version: unspecifiedKeywords: patch
Hardware: Other   
OS: All   
URL: http://cgit.freedesktop.org/~smcv/telepathy-mission-control/log/?h=typed-settings-54872
Whiteboard: r+
i915 platform: i915 features:
Bug Depends on: 54870    
Bug Blocks: 54873    

Description Simon McVittie 2012-09-13 15:05:24 UTC
MC should store account parameters in-memory in a typed format.

This is part 2 of my account storage refactoring megabranch.
Comment 1 Simon McVittie 2012-09-13 15:50:41 UTC
Here's a bit more background on the data model in these branches.

Terminology I've been trying to stick to: each stored account has *attributes* and *parameters*.

Attributes are mostly properties (like DisplayName), except for the ones that aren't (like AvatarMime, avatar_token, AutomaticPresenceType). Mission Control knows the desired type of each attribute, and only Mission Control can define new attributes.

In the old accounts API, attributes were a map { attribute name => value escaped as if for a GKeyFile } per account. In the new API, they are conceptually a map { attribute name => GVariant value }.

In the old API, attributes could (in principle) be "secret", but this was never used and I've abolished it. Attributes do have flags, which could be used to reintroduce that sort of thing later. One thing I've thought about doing is a CONFIG flag that means "this is configuration, store this in XDG_CONFIG_HOME instead of XDG_DATA_HOME".

Parameters are the contents of the Parameters property. In the old API they were effectively part of the attributes map, named "param-" + the parameter name.

In the new API, it gets a little complicated. They are stored in two maps with disjoint keys: one from name to GVariant value ("parameters"), and one from name to keyfile-escaped string value ("untyped parameters"). In either case, the names don't have the "param-" prefix any more; we know which maps to look in from the API call being made.

When existing plugins load parameters from disk, if they know the type, they put them in the typed map; otherwise, they put them in the untyped map by calling older APIs. Entirely new plugins will presumably only store parameters with known types, so they'll never need to interact with the untyped map at all.

Parameters naturally migrate from the untyped map to the typed map whenever they are changed with UpdateParameters(). In principle, we could also have a migration step in which MC looks up connection manager details and uses those to impose a type on previously-untyped parameters.

Parameters can still be "secret", but now it's part of a general-purpose flags word. We could add a CONFIG flag here too, if we wanted to, for instance.
Comment 2 Simon McVittie 2012-09-13 17:14:16 UTC
This branch introduces g_hash_table_add() and g_hash_table_contains() usage, so it will need a GLib 2.32 dependency. Imagine there was a patch here to add that, and I'll insert one when I merge :-)
Comment 3 Will Thompson 2012-11-07 15:27:06 UTC
this all looks reasonable to me, and i enjoyed a number of the comments.
Comment 4 Simon McVittie 2013-02-13 14:18:36 UTC
Fixed in git for 5.15.0

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.