2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
4 <!ENTITY major SYSTEM "version-major.xml">
7 <title>Using libsecret in builds or scripts</title>
10 <title>C: Compiling with libsecret</title>
12 <para>Like other GNOME libraries, <application>libsecret</application> uses
13 <application>pkg-config</application> to provide compiler options. The package
14 name is "<literal>libsecret-&major;</literal>". So in your
15 <literal>configure.ac</literal> script,you might specify something like:</para>
17 <informalexample><programlisting>
18 PKG_CHECK_MODULES(LIBSECRET, [libsecret-&major; >= 1.0])
19 AC_SUBST(LIBSECRET_CFLAGS)
20 AC_SUBST(LIBSECRET_LIBS)
21 </programlisting></informalexample>
24 Code using <application>libsecret</application> should include the header like this:
27 <informalexample><programlisting>
28 #include <libsecret/secret.h>
29 </programlisting></informalexample>
32 Including individual headers besides the main header files is not
33 permitted and will cause an error.
37 Some parts of the <application>libsecret</application> API are not yet stable.
38 To use them you need use the <literal>libsecret-unstable</literal> package.
39 The API contained in this package will change from time to time. Here's how
43 <informalexample><programlisting>
44 PKG_CHECK_MODULES(LIBSECRET, [libsecret-unstable >= 1.0])
45 AC_SUBST(LIBSECRET_CFLAGS)
46 AC_SUBST(LIBSECRET_LIBS)
47 </programlisting></informalexample>
51 <chapter id="using-js">
52 <title>Javascript: Importing libsecret</title>
55 In javascript use the standard introspection import mechanism to get at
56 <application>libsecret</application>:
59 <informalexample><programlisting language="javascript">
60 const Secret = imports.gi.Secret;
62 // ... and here's a sample line of code which uses the import
63 var schema = new Secret.Schema.new("org.mock.Schema",
64 Secret.SchemaFlags.NONE, { "name", Secret.SchemaAttributeType.STRING });
65 </programlisting></informalexample>
69 <chapter id="using-python">
70 <title>Python: Importing libsecret</title>
73 In python use the standard introspection import mechanism to get at
74 <application>libsecret</application>:
77 <informalexample><programlisting language="py">
78 from gi.repository import Secret
80 # ... and a here's sample line of code which uses the import
81 schema = Secret.Schema.new("org.mock.Schema",
82 Secret.SchemaFlags.NONE, { "name", Secret.SchemaAttributeType.STRING })
83 </programlisting></informalexample>
87 <chapter id="using-vala">
88 <title>Vala: Compiling with libsecret</title>
91 The package name is "<literal>libsecret-&major;</literal>". You can use it like
92 this in your <literal>Makefile.am</literal> file:
95 <informalexample><programlisting>
97 --pkg=libsecret-&major;
98 </programlisting></informalexample>
101 Some parts of the <application>libsecret</application> API are not yet stable.
102 To use them you need to define the SECRET_WITH_UNSTABLE C preprocessor
103 macro to use them, or else the build will fail:
106 <informalexample><programlisting>
108 -DSECRET_WITH_UNSTABLE=1
109 </programlisting></informalexample>