GNOME Bugzilla – Bug 697681
libsecret Vala binding is missing extern constants
Last modified: 2018-03-22 17:47:59 UTC
The binding for libsecret is missing the following two constants: SECRET_SCHEMA_NOTE SECRET_SCHEMA_COMPAT_NETWORK
Evan, do you know how we can make these show up in the vapi? They're in secret-schemas.h here: https://git.gnome.org/browse/libsecret/tree/libsecret/secret-schemas.h ... and look like this: /* * A note or password stored manually by the user. */ extern const SecretSchema * SECRET_SCHEMA_NOTE; /* * This schema is here for compatibility with libgnome-keyring's network * password functions. */ extern const SecretSchema * SECRET_SCHEMA_COMPAT_NETWORK;
It's easy enough to use a *-custom.vala to tell Vala about them, but Vala doesn't see them because they're not in the GIR and, if possible, I would rather get g-ir-scanner to pick them up so all languages can benefit. I'm not sure how to go about that. Colin, do you know if it is possible? FWIW they also have gtk-doc comments in secret-schemas.c.
Looks like a g-ir-scanner bug.
To be fair, as an API, this is pretty grim. This should be a global function, e.g. ``` SecretSchema *secret_get_schema_note (void); SecretSchema *secret_get_schema_compat_network (void); ``` Or an enumeration and a function, e.g.: ``` typedef enum { SECRET_SCHEMA_TYPE_NOTE, SECRET_SCHEMA_TYPE_COMPAT_NETWORK } SecretSchemaType; SecretSchema *secret_get_schema (SecretSchemaType schema_type); ``` Exporting a complex type as an extern variable is typically a recipe for disaster, considering the lack of guarantees of `const` in C. Anyway, I don't think we currently parse this kind of construct outside of simple types; it'll require some surgery in the parser.
Yeah, if this is going to require significant changes to g-ir-scanner, it might be best to punt it back to libsecret and just add new public API there, and use that from the bindings instead.
Created attachment 359868 [details] [review] lib/schemas: Add secret_get_schema() accessor for SECRET_SCHEMA_*s The SECRET_SCHEMA_* extern structs are not introspectable; add a new accessor function which takes an enum and returns a struct, which is introspectable. Mark the old extern structs as (skip), but don’t deprecate them because they’re still useful from C (if unconventional). Signed-off-by: Philip Withnall <withnall@endlessm.com>
Review of attachment 359868 [details] [review]: Looks good, except the indentation.
Pushed with whitespace fixes, thanks. Attachment 359868 [details] pushed as b738c9f - lib/schemas: Add secret_get_schema() accessor for SECRET_SCHEMA_*s