Re: How to Write a NetworkManager Plugin?



On Mon, 2017-04-24 at 14:43 +0000, Ricardo Feliciano wrote:
Hello Everyone,

I am having trouble finding documentation on how to write a
NetworkManager plugin. Particularly, I'm looking to do something with
certain WiFi networks are connected to.

A.k.a. I would love to have a popup come up on Ubuntu (and everywhere
else NM is used) when I'm at Starbucks, similar to how this happens
on Android and iOS.

Hi Ricardo,

NetworkManager supports various internal plugins (for DHCP, PPP, DNS)
-- that is, their plugin API is not public nor stable. So, these
plugins are merely to split the core package and dependencies.

Then NM supports VPN plugins, there is a public plugin API and the VPN
plugins are maintained outside of NetworkManager.

What you are referring to as "plugin" doesn't exit. First of all,
NetworkManager-core is not concerned with GUI. The GUI clients are
maintained separately from NetworkManager (nm-applet/nm-connection-
editor, gnome-shell/gnome-control-center, plasma-nm, and maybe others).
Those are all regular clients and they communicate with NetworkManager
using its public D-Bus API.
I think those existing GUI components are not (easily) extendable.
Meaning, they don't support plugins (apart from VPN plugins).

The popup you describe could be a separate own GUI client application
(which I wouldn't call a "plugin").

You could either directly use the D-Bus API 
https://wiki.gnome.org/Projects/NetworkManager/Developers#D-Bus_API_Documentation_and_Examples
or use libnm (which is provided by NetworkManager core and basically
wraps the D-Bus API).

nm-applet also provides a libnma library, which provides GTK elements
on top of libnm. nm-applet/nm-connection-editor/gnome-shell/gnome-
control-center is build on libnma. Currently I think that isn't used
much outside of those client applications, but it might help you.
libnma has a stable API.

If you prefer QT, there is a QT client library used by plasma-nm, but I
don't know whether it has stable, public API.


If you use libnm (or libnma), you might also use it python with GObject
introspection, see
https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/examples/python/gi?id=7daf92afb819e8efee7ae3fd496d465dea3fcce7
Have a look at the other examples.


good luck
Thomas

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]