This file is indexed.

/usr/share/gtk-doc/html/libnm/usage.html is in libnm-dev 1.10.6-2ubuntu1.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Using libnm: libnm Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="libnm Reference Manual">
<link rel="up" href="ref-overview.html" title="Overview">
<link rel="prev" href="ref-overview.html" title="Overview">
<link rel="next" href="ch02.html" title="Client Object API Reference">
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="ref-overview.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="ref-overview.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="ch02.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="usage"></a>Using libnm</h2></div></div></div>
<div class="simplesect">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.2.3.2"></a>When to use libnm</h3></div></div></div>
<p>
          libnm is fairly simple to use from C. It's based on glib and GObject.
          If your project uses these already you'll find integration libnm with your
          project rather convenient. In fact, the <span class="command"><strong>nmcli</strong></span> tool shipped
          with NetworkManager is based on libnm.
        </p>
<p>
          libnm should be also the way to go if your project does something non-trivial
          with NetworkManager, such as manipulating the connection profiles.
          That is, if you're writing a specialized networking control tool or a desktop
          environment, libnm is probably the right choice. The popular desktop
          environments in fact all use libnm directly or with nm-applet and
          nm-connection-editor that are all based on libnm.
        </p>
<p>
          An alternative to use of libnm is the use of the
          <a class="ulink" href="https://developer.gnome.org/NetworkManager/stable/spec.html" target="_top">D-Bus API</a>
          directly.  This gives you larger flexibility and reduces the overhead of linking
          with the libnm library. This makes sense if your task is simple and you have a good
          D-Bus library at your disposal. Activating a particular connection profile
          from a Python script is a good example of a task that is perfectly simple
          without using libnm.
        </p>
</div>
<div class="simplesect">
<div class="titlepage"><div><div><h3 class="title">
<a name="id-1.2.3.3"></a>How to use libnm</h3></div></div></div>
<p>
          You can use the libnm's C API directly. To do so, all libnm programs need to
          include <code class="filename">NetworkManager.h</code> that provides necessary definitions.
          The rest of the API is documented in the reference manual.
        </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="gtkdoc ppc">#include &lt;glib.h&gt;</span>
<span class="gtkdoc ppc">#include &lt;NetworkManager.h&gt;</span>

<span class="gtkdoc kwb">int</span>
<span class="function">main</span> <span class="gtkdoc opt">(</span><span class="gtkdoc kwb">int</span> argc<span class="gtkdoc opt">,</span> <span class="gtkdoc kwb">char</span> <span class="gtkdoc opt">*</span>argv<span class="gtkdoc opt">[])</span>
<span class="gtkdoc opt">{</span>
	NMClient <span class="gtkdoc opt">*</span>client<span class="gtkdoc opt">;</span>

	client <span class="gtkdoc opt">=</span> <span class="function"><a href="NMClient.html#nm-client-new">nm_client_new</a></span> <span class="gtkdoc opt">(</span>NULL<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
	<span class="keyword">if</span> <span class="gtkdoc opt">(</span>client<span class="gtkdoc opt">)</span>
		<span class="function"><a href="../glib/glib-Warnings-and-Assertions.html#g-print">g_print</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;NetworkManager version: %s</span><span class="gtkdoc esc">\n</span><span class="string">&quot;</span><span class="gtkdoc opt">,</span> <span class="function"><a href="NMClient.html#nm-client-get-version">nm_client_get_version</a></span> <span class="gtkdoc opt">(</span>client<span class="gtkdoc opt">));</span>
<span class="gtkdoc opt">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
          Use <span class="command"><strong>pkg-config</strong></span> for <code class="varname">libnm</code> to discover the necessary
          compiler flags.
        </p>
<pre class="screen"><code class="prompt">$ </code><strong class="userinput"><code>cc $(pkg-config --libs --cflags libnm) -o hello-nm hello-nm.c</code></strong>
  <code class="prompt">$ </code><strong class="userinput"><code>./hello-nm</code></strong>
  NetworkManager version: 1.10.6

  <code class="prompt">$ </code></pre>
<p>
          Utilize the <code class="varname">PKG_CHECK_MODULES</code> macro to integrate with an
          autoconf-based build system. It's also recommended to use
          <code class="varname">NM_VERSION_MIN_REQUIRED</code> and <code class="varname">NM_VERSION_MAX_ALLOWED</code>
          macros to tell libnm headers which API version does your application need to work with.
          If you use them, the compiler will warn you when you use functionality that is not
          available in the versions you specified.
        </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function">PKG_CHECK_MODULES</span><span class="gtkdoc opt">(</span>LIBNM<span class="gtkdoc opt">,</span> libnm <span class="gtkdoc opt">&gt;=</span> <span class="number">1.8</span><span class="gtkdoc opt">)</span>
LIBNM_CFLAGS<span class="gtkdoc opt">=</span><span class="string">&quot;$LIBNM_CFLAGS -DNM_VERSION_MIN_REQUIRED=NM_VERSION_1_8&quot;</span>
LIBNM_CFLAGS<span class="gtkdoc opt">=</span><span class="string">&quot;$LIBNM_CFLAGS -DNM_VERSION_MAX_ALLOWED=NM_VERSION_1_8&quot;</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
          You can use libnm from other languages than C with the use of GObject introspection.
          This includes Perl, Python, Javascript, Lua, Ruby and more. The example below shows what the
          typical libnm use in Python would look like.
        </p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6</pre></td>
        <td class="listing_code"><pre class="programlisting">import gi
gi<span class="gtkdoc opt">.</span><span class="function">require_version</span><span class="gtkdoc opt">(</span><span class="string">&apos;NM&apos;</span><span class="gtkdoc opt">,</span> <span class="string">&apos;1.0&apos;</span><span class="gtkdoc opt">)</span>
from gi<span class="gtkdoc opt">.</span>repository import NM

client <span class="gtkdoc opt">=</span> NM<span class="gtkdoc opt">.</span>Client<span class="gtkdoc opt">.</span><span class="keyword">new</span><span class="gtkdoc opt">(</span>None<span class="gtkdoc opt">)</span>
<span class="function">print</span> <span class="gtkdoc opt">(</span><span class="string">&quot;NetworkManager version &quot;</span> <span class="gtkdoc opt">+</span> client<span class="gtkdoc opt">.</span><span class="function">get_version</span><span class="gtkdoc opt">())</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p>
          There's <a class="ulink" href="https://lazka.github.io/pgi-docs/#NM-1.0" target="_top">NM-1.0 Python API Reference</a>
          maintained a third party that is generated from the introspection metadata.
        </p>
<p>
          In general, the C API documentation applies to the use GObject introspection
          from other languages, with the calling convention respecting the language's
          customs. Consult the source tree for
          <a class="ulink" href="https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples" target="_top">some examples</a>.
        </p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.27</div>
</body>
</html>